mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
implemented server to have a phase shift input
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@341 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
d944ee5372
commit
f6ff1359aa
@ -38,6 +38,7 @@ int ram_size=0;
|
|||||||
int64_t totalTime=1;
|
int64_t totalTime=1;
|
||||||
u_int32_t progressMask=0;
|
u_int32_t progressMask=0;
|
||||||
|
|
||||||
|
int phase_shift=120;
|
||||||
|
|
||||||
|
|
||||||
int ififostart, ififostop, ififostep, ififo;
|
int ififostart, ififostop, ififostep, ififo;
|
||||||
@ -217,31 +218,30 @@ u_int32_t bus_r(u_int32_t offset) {
|
|||||||
|
|
||||||
|
|
||||||
int setPhaseShiftOnce(){
|
int setPhaseShiftOnce(){
|
||||||
u_int32_t addr, reg;
|
u_int32_t addr, reg;
|
||||||
int result=OK, i;
|
int i;
|
||||||
addr=MULTI_PURPOSE_REG;
|
addr=MULTI_PURPOSE_REG;
|
||||||
reg=bus_r(addr);
|
reg=bus_r(addr);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Multipurpose reg:%x\n",reg);
|
printf("Multipurpose reg:%x\n",reg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Checking if it is power on(negative number)
|
//Checking if it is power on(negative number)
|
||||||
if(((reg&0xFFFF0000)>>16)>0){
|
// if(((reg&0xFFFF0000)>>16)>0){
|
||||||
bus_w(addr,0x0); //clear the reg
|
//bus_w(addr,0x0); //clear the reg
|
||||||
//#ifdef VERBOSE
|
|
||||||
printf("Implementing Phase Shift-Reg:%x\n",bus_r(addr));
|
if(reg==0){
|
||||||
//#endif
|
printf("\nImplementing phase shift of %d\n",phase_shift);
|
||||||
//phase shift
|
for (i=1;i<phase_shift;i++) {
|
||||||
for (i=1;i<PHASE_SHIFT;i++) {
|
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
|
||||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
|
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|(SW1_BIT&~PHASE_STEP_BIT)));//0x2820
|
||||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|(SW1_BIT&~PHASE_STEP_BIT)));//0x2820
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
reg=bus_r(addr);
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Multipupose reg now:%x\n",reg);
|
printf("Multipupose reg now:%x\n",bus_r(addr));
|
||||||
#endif
|
#endif
|
||||||
return result;
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
extern int sockfd;
|
extern int sockfd;
|
||||||
|
extern int phase_shift;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void error(char *msg)
|
void error(char *msg)
|
||||||
@ -15,72 +17,81 @@ void error(char *msg)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int portno, b;
|
int portno, b;
|
||||||
char cmd[100];
|
char cmd[100];
|
||||||
int retval=OK;
|
int retval=OK;
|
||||||
int sd, fd;
|
int sd, fd;
|
||||||
|
int iarg;
|
||||||
|
for(iarg=1; iarg<argc; iarg++){
|
||||||
|
if(!strcasecmp(argv[iarg],"-phaseshift")){
|
||||||
|
if ( sscanf(argv[iarg+1],"%d",&phase_shift)==0) {
|
||||||
|
printf("could not decode phase shift\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
argc=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc==1) {
|
||||||
|
portno = DEFAULT_PORTNO;
|
||||||
|
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
|
||||||
|
printf("opening control server on port %d\n",portno );
|
||||||
|
system(cmd);
|
||||||
|
b=1;
|
||||||
|
} else {
|
||||||
|
portno = DEFAULT_PORTNO+1;
|
||||||
|
if ( sscanf(argv[1],"%d",&portno) ==0) {
|
||||||
|
printf("could not open stop server: unknown port\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
b=0;
|
||||||
|
printf("opening stop server on port %d\n",portno);
|
||||||
|
}
|
||||||
|
init_detector(b);
|
||||||
|
|
||||||
|
|
||||||
if (argc==1) {
|
sd=bindSocket(portno);
|
||||||
portno = DEFAULT_PORTNO;
|
|
||||||
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
|
sockfd=sd;
|
||||||
printf("opening control server on port %d\n",portno );
|
|
||||||
system(cmd);
|
|
||||||
b=1;
|
|
||||||
} else {
|
|
||||||
portno = DEFAULT_PORTNO+1;
|
|
||||||
if ( sscanf(argv[1],"%d",&portno) ==0) {
|
|
||||||
printf("could not open stop server: unknown port\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
b=0;
|
|
||||||
printf("opening stop server on port %d\n",portno);
|
|
||||||
}
|
|
||||||
init_detector(b);
|
|
||||||
|
|
||||||
|
|
||||||
sd=bindSocket(portno);
|
if (getServerError(sd)) {
|
||||||
|
printf("server error!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
sockfd=sd;
|
/* assign function table */
|
||||||
|
function_table();
|
||||||
|
|
||||||
if (getServerError(sd)) {
|
|
||||||
printf("server error!\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* assign function table */
|
|
||||||
function_table();
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("function table assigned \n");
|
printf("function table assigned \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* waits for connection */
|
/* waits for connection */
|
||||||
while(retval!=GOODBYE) {
|
while(retval!=GOODBYE) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("Waiting for client call\n");
|
printf("Waiting for client call\n");
|
||||||
#endif
|
#endif
|
||||||
fd=acceptConnection(sockfd);
|
fd=acceptConnection(sockfd);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("Conenction accepted\n");
|
printf("Conenction accepted\n");
|
||||||
#endif
|
#endif
|
||||||
retval=decode_function(fd);
|
retval=decode_function(fd);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("function executed\n");
|
printf("function executed\n");
|
||||||
#endif
|
#endif
|
||||||
closeConnection(fd);
|
closeConnection(fd);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("connection closed\n");
|
printf("connection closed\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
exitServer(sockfd);
|
exitServer(sockfd);
|
||||||
printf("Goodbye!\n");
|
printf("Goodbye!\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
|
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
|
||||||
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
|
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
|
||||||
|
|
||||||
#define PHASE_SHIFT 120
|
|
||||||
|
|
||||||
|
|
||||||
#define ALLMOD 0xffff
|
#define ALLMOD 0xffff
|
||||||
#define ALLFIFO 0xffff
|
#define ALLFIFO 0xffff
|
||||||
|
@ -72,7 +72,7 @@ int init_detector( int b) {
|
|||||||
testFpga();
|
testFpga();
|
||||||
testRAM();
|
testRAM();
|
||||||
//gotthard specific
|
//gotthard specific
|
||||||
//setPhaseShiftOnce();
|
setPhaseShiftOnce();
|
||||||
setDAQRegister(-1);
|
setDAQRegister(-1);
|
||||||
setSettings(GET_SETTINGS,-1);
|
setSettings(GET_SETTINGS,-1);
|
||||||
//Initialization
|
//Initialization
|
||||||
|
Loading…
x
Reference in New Issue
Block a user