From 86fb843021a3072964dae94f16201e7e59d4a76d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 18 Oct 2018 10:58:48 +0200 Subject: [PATCH 1/7] in the process of rewriting detector client interface --- slsDetectorServers/eigerDetectorServer/Feb.c | 335 ------- slsDetectorServers/eigerDetectorServer/Feb.h | 59 -- .../eigerDetectorServer/Makefile | 4 +- .../eigerDetectorServer/Makefile.virtual | 2 +- .../eigerDetectorServer/gitInfo.txt | 8 +- .../eigerDetectorServer/gitInfoEiger.h | 6 +- .../eigerDetectorServer/logger.h | 1 + .../slsDetectorFunctionList.c | 21 +- .../slsDetectorServer_defs.h | 1 - .../slsDetectorServer/communication_funcs.c | 854 +++++++++--------- .../slsDetectorServer/communication_funcs.h | 27 +- slsDetectorServers/slsDetectorServer/logger.h | 63 ++ .../slsDetectorFunctionList.h | 12 +- .../slsDetectorServer/slsDetectorServer.c | 100 +- .../slsDetectorServer_funcs.c | 659 ++++---------- .../slsDetectorServer_funcs.h | 4 +- .../slsDetector/slsDetector.cpp | 490 ++++------ slsDetectorSoftware/slsDetector/slsDetector.h | 42 +- slsReceiverSoftware/include/GeneralData.h | 27 - .../src/slsReceiverImplementation.cpp | 4 - .../src/slsReceiverTCPIPInterface.cpp | 78 +- slsSupportLib/include/ClientInterface.cpp | 43 +- slsSupportLib/include/ClientInterface.h | 40 +- slsSupportLib/include/sls_detector_defs.h | 5 +- 24 files changed, 1012 insertions(+), 1873 deletions(-) delete mode 100644 slsDetectorServers/eigerDetectorServer/Feb.c delete mode 100644 slsDetectorServers/eigerDetectorServer/Feb.h create mode 120000 slsDetectorServers/eigerDetectorServer/logger.h create mode 100644 slsDetectorServers/slsDetectorServer/logger.h diff --git a/slsDetectorServers/eigerDetectorServer/Feb.c b/slsDetectorServers/eigerDetectorServer/Feb.c deleted file mode 100644 index fb9ef7c67..000000000 --- a/slsDetectorServers/eigerDetectorServer/Feb.c +++ /dev/null @@ -1,335 +0,0 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - - -/*#include -#include */ - -#include -#include -#include - - -#include "xparameters.h" -#include "Feb.h" - - - -void Feb_Feb(){ - - Feb_nfebs = 0; - Feb_feb_numb = 0; - - Feb_send_ndata = 0; - Feb_send_buffer_size = 1026; - Feb_send_data_raw = malloc((Feb_send_buffer_size+1)*sizeof(int)); - Feb_send_data = &Feb_send_data_raw[1]; - - Feb_recv_ndata = 0; - Feb_recv_buffer_size = 1026; - Feb_recv_data_raw = malloc((Feb_recv_buffer_size+1)*sizeof(int)); - Feb_recv_data = &Feb_recv_data_raw[1]; - - Local_LocalLinkInterface1(ll,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR); - -} -/* -~Feb(){ - delete ll; - if(feb_numb) delete [] feb_numb; - delete [] send_data_raw; - delete [] recv_data_raw; -} -*/ - -void Feb_SendCompleteFebList(unsigned int n,unsigned int* list){ - unsigned int i; - if(Feb_feb_numb) free(Feb_feb_numb); - Feb_nfebs = n; - Feb_feb_numb = malloc(n*sizeof(unsigned int)); - for(i=0;i0xfff) return 0; - - Feb_send_data_raw[0] = 0x90000000 | (ch<<16); //we - if(Local_Write(ll,4,Feb_send_data_raw)!=4) return 0; - - Feb_send_data_raw[0] = 0xc0000000; //data - return 1;//((Feb_send_ndata+1)*4==Local_Write(ll,(Feb_send_ndata+1)*4,Feb_send_data_raw)); -} - -int Feb_ReadFrom(unsigned int ch, unsigned int ntrys){ - unsigned int t; - if(ch>=0xfff) return 0; - - Feb_recv_data_raw[0] = 0xa0000000 | (ch<<16); //read data - Local_Write(ll,4,Feb_recv_data_raw); - usleep(20); - - Feb_recv_ndata=-1; - for(t=0;t0){ - Feb_recv_ndata--; - break; - } - printf("\t Read try number: %d\n",t); - usleep(1000); - } - - - return (Feb_recv_ndata>=0); -} - -void Feb_PrintData(){ - int i; - printf("Sent data: %d\n",Feb_send_ndata); - for(i=0;i1&&Feb_recv_ndata>1){ - printf("\t\t Tail sent: %d (0x%x) receiver: %d (0x%x)\n",Feb_send_data[Feb_send_ndata-1],Feb_send_data[Feb_send_ndata-1],Feb_recv_data[Feb_recv_ndata-1],Feb_recv_data[Feb_recv_ndata-1]); - }else{ - printf("Error printing tail, too little data nsent = 0x%x, nrecv = 0x%x.\n",Feb_send_ndata, Feb_recv_ndata); - } - Feb_PrintData(); - } - return header_returned_is_ok; -} - - -int Feb_CheckTail(unsigned int valid_bit_mask){ - if(Feb_send_ndata<=1&&Feb_recv_ndata<=1){ - printf("Error checking tail, too little data nsent = %d, nrecv = %d.\n",Feb_send_ndata, Feb_recv_ndata); - return 0; - } - - unsigned int the_tail = Feb_recv_data[Feb_recv_ndata-1]&valid_bit_mask; - if(the_tail!=0){ - printf("Error returned in tail: 0x%x (%d)\n",the_tail,the_tail); - if(the_tail&0x10000000) printf("\t\tBusy flag address error.\n"); - if(the_tail&0x20000000) printf("\t\tRead register address error.\n"); - if(the_tail&0x40000000) printf("\t\tWrite register address error.\n"); - if(the_tail&0x80000000) printf("\t\tBram number error.\n"); - if(the_tail&0x08000000) printf("\t\tFifo to read from error.\n"); - if(the_tail&0x3ff) printf("\t\tNumber of data send error.\n"); - return 0; //error - } - - return 1; -} - - -int Feb_CheckCommunication(){ - Feb_send_data_raw[0] = 0x8fff0000; //rst-all serial coms and lls - if(Local_Write(ll,4,Feb_send_data_raw)!=4) return 0; - - printf("CheckingCommunication ....\n"); - while((Local_Read(ll,Feb_recv_buffer_size*4,Feb_recv_data_raw)/4)>0) printf("\t) Cleanning buffer ...\n"); - - return Feb_SetByteOrder(); -} - - -int Feb_SetByteOrder(){ - - unsigned int i; - Feb_send_ndata = 2; - Feb_send_data[0] = 0; //header - Feb_send_data[1] = 0; //tail - - unsigned int dst = 0xff; - for( i=0;i=nfebs){ - cout<<"Error invalid sub number "<Feb_send_buffer_size-2) return 0; - - Feb_send_ndata = nreads+2; - Feb_send_data[0] = 0x20000000 | nreads << 14; //cmd -> read "00" , nreads - - for(i=0;iFeb_send_buffer_size-2) return 0; - - //cout<<"Write register : "< write nwrites and how many - Feb_send_data[2*nwrites+1] = 0; //tail - - for(i=0;iFeb_send_buffer_size-2) return 0; - - Feb_send_ndata = nwrites+2; - Feb_send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address - Feb_send_data[nwrites+1] = 0; //tail - for(i=0;i #include //to gethostname @@ -17,6 +15,9 @@ #include "versionAPI.h" #endif +// Global variable from slsDetectorServer +extern int debugflag; + int default_tau_from_file= -1; #define BEB_NUM 34 @@ -106,7 +107,7 @@ int getFirmwareCheckResult(char** mess) { return firmware_compatibility; } -void checkFirmwareCompatibility(int flag){ +void checkFirmwareCompatibility(){ firmware_compatibility = OK; firmware_check_done = 0; memset(firmware_message, 0, MAX_STR_LENGTH); @@ -148,8 +149,8 @@ void checkFirmwareCompatibility(int flag){ REQUIRED_FIRMWARE_VERSION, (long long int)client_sw_apiversion); - // return if flag is not zero, debug mode - if (flag) { + // return if debugflag is not zero, debug mode + if (debugflag) { firmware_check_done = 1; return; } @@ -1100,7 +1101,7 @@ int setHighVoltage(int val){ /* parameters - timing, extsig */ -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ +void setTiming( enum externalCommunicationMode arg){ enum externalCommunicationMode ret=GET_EXTERNAL_COMMUNICATION_MODE; if(arg != GET_EXTERNAL_COMMUNICATION_MODE){ switch((int)arg){ @@ -1115,7 +1116,11 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ #endif eiger_triggermode = ret; } +} + +enum externalCommunicationMode getTiming() { + enum externalCommunicationMode ret = GET_EXTERNAL_COMMUNICATION_MODE; ret = eiger_triggermode; switch((int)ret){ case 0: ret = AUTO_TIMING; break; @@ -1131,9 +1136,6 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ - - - /* configure mac */ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival) { @@ -1832,4 +1834,3 @@ int getNumberOfOffsets(){return NOFFSET;} -//#endif diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index 36260b519..ef382ad5f 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -8,7 +8,6 @@ #define GOODBYE (-200) -#define PROGRAMMING_MODE (-200) #define MIN_REQRD_VRSN_T_RD_API 0x171220 #define REQRD_FRMWR_VRSN 0x180615 diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.c b/slsDetectorServers/slsDetectorServer/communication_funcs.c index d9f5b3146..beb439ea2 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.c @@ -1,240 +1,231 @@ #include "communication_funcs.h" -//#include -#include /* for TCP_NODELAY */ +#include "logger.h" + +//#include /* for TCP_NODELAY */ #include #include #include #include - #include -char lastClientIP[INET_ADDRSTRLEN]; -char thisClientIP[INET_ADDRSTRLEN]; -int lockStatus; -int differentClients; -//int socketDescriptor, file_des; -const int send_rec_max_size=SEND_REC_MAX_SIZE; +// Global variables from errno.h extern int errno; +// Variables that will be exported +int lockStatus = 0; +char lastClientIP[INET_ADDRSTRLEN] = ""; +char thisClientIP[INET_ADDRSTRLEN] = ""; +int differentClients = 0; +int isControlServer = 1; +int ret = FAIL; +int fnum = 0; +char mess[MAX_STR_LENGTH]; -char dummyClientIP[INET_ADDRSTRLEN]; - - +// Local variables +char dummyClientIP[INET_ADDRSTRLEN] = ""; +const int send_rec_max_size = SEND_REC_MAX_SIZE; +int myport = -1; +// socket descriptor set fd_set readset, tempset; -int isock=0, maxfd; +// number of socket descrptor listening to +int isock = 0; +// value of socket descriptor, +//becomes max value of socket descriptor (listen) and file descriptor (accept) +int maxfd = 0; -int myport=-1; -//struct sockaddr_in address; -//#define VERBOSE +#define DEFAULT_BACKLOG 5 int bindSocket(unsigned short int port_number) { - int i; + ret = FAIL; + int socketDescriptor = -1; + int i = 0; + struct sockaddr_in addressS; - struct sockaddr_in addressS; - int socketDescriptor; - //int file_des; + // same port + if (myport == port_number) { + sprintf(mess, "Cannot create %s socket with port %d. Already in use before.\n", + (isControlServer ? "control":"stop"), port_number); + FILE_LOG(logERROR, (mess)); + } + // port ok + else { - //file_des= -1; + // create socket + socketDescriptor = socket(AF_INET, SOCK_STREAM,0); + // socket error + if (socketDescriptor < 0) { + sprintf(mess, "Cannot create %s socket with port %d\n", + (isControlServer ? "control":"stop"), port_number); + FILE_LOG(logERROR, (mess)); + } + // socket success + else { + i = 1; + // set port reusable + setsockopt(socketDescriptor, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); + // Set some fields in the serverAddress structure + addressS.sin_family = AF_INET; + addressS.sin_addr.s_addr = htonl(INADDR_ANY); + addressS.sin_port = htons(port_number); + // bind socket error + if(bind(socketDescriptor,(struct sockaddr *) &addressS,sizeof(addressS)) < 0){ + sprintf(mess, "Cannot bind %s socket to port %d.\n", + (isControlServer ? "control":"stop"), port_number); + FILE_LOG(logERROR, (mess)); + } + // bind socket ok + else { + // listen to socket + if (listen(socketDescriptor, DEFAULT_BACKLOG) == 0) { + // clear set of descriptors. set of descriptors needed? + if (isock == 0) { + FD_ZERO(&readset); + } + // add a socket descriptor from listen + FD_SET(socketDescriptor, &readset); + isock++; + maxfd = socketDescriptor; + // success + myport = port_number; + ret = OK; + FILE_LOG(logINFO, (" %s socket bound: isock=%d port=%d fd=%d\n", + (isControlServer ? "Control":"Stop"), isock, port_number, socketDescriptor)); + } + // listen socket error + else { + sprintf(mess, "Cannot bind %s socket to port %d.\n", + (isControlServer ? "control":"stop"), port_number); + FILE_LOG(logERROR, (mess)); + } + } + } + } - - - - - - - if (myport==port_number) - return -10; - - - - - - socketDescriptor = socket(AF_INET, SOCK_STREAM,0); //tcp - - //socketDescriptor = socket(PF_INET, SOCK_STREAM, 0); - - - - if (socketDescriptor < 0) { - printf("Can not create socket\n"); - } else { - - i = 1; - setsockopt(socketDescriptor, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); - // setsockopt(socketDescriptor, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i)); - // TCP_CORK - - // Set some fields in the serverAddress structure. - addressS.sin_family = AF_INET; - addressS.sin_addr.s_addr = htonl(INADDR_ANY); - addressS.sin_port = htons(port_number); - - // memset(&address.sin_addr, 0, sizeof(address.sin_addr)); - - - if(bind(socketDescriptor,(struct sockaddr *) &addressS,sizeof(addressS))<0){ - - printf("Can not create socket\n"); - - socketDescriptor=-1; - } else { - if (listen(socketDescriptor, 5)==0) { - - if (isock==0) { - FD_ZERO(&readset); - } - - - FD_SET(socketDescriptor, &readset); - isock++; - maxfd = socketDescriptor; - printf ("%d port %d fd %d\n",isock, port_number,socketDescriptor); - myport=port_number; - } else - printf("error on listen"); - } - } - - - - //int getrlimit(int resource, struct rlimit *rlim); - - - - return socketDescriptor; - + return socketDescriptor; } - - -int getServerError(int socketDescriptor) -{ - if (socketDescriptor<0) return 1; - else return 0; -}; - - int acceptConnection(int socketDescriptor) { - + int j; + struct sockaddr_in addressC; + int file_des = -1; + struct timeval tv; + socklen_t address_length = sizeof(struct sockaddr_in); - int j; + if (socketDescriptor < 0) + return -1; + // copy file descriptor set temporarily + memcpy(&tempset, &readset, sizeof(tempset)); - struct sockaddr_in addressC; - int file_des=-1; - struct timeval tv; - int result; + // set time out as 2777.77 hours? + tv.tv_sec = 10000000; + tv.tv_usec = 0; + // monitor file descrptors + int result = select(maxfd + 1, &tempset, NULL, NULL, &tv); - //socklen_t address_length; - socklen_t address_length=sizeof(struct sockaddr_in); - - if (socketDescriptor<0) - return -1; + // timeout + if (result == 0) { + FILE_LOG(logDEBUG5, ("%s socket select() timed out!\n", + (isControlServer ? "control":"stop"), myport)); + } - memcpy(&tempset, &readset, sizeof(tempset)); - tv.tv_sec = 10000000; - tv.tv_usec = 0; - result = select(maxfd + 1, &tempset, NULL, NULL, &tv); + // error (not signal caught) + else if (result < 0 && errno != EINTR) { + FILE_LOG(logERROR, ("%s socket select() error: %s\n", + (isControlServer ? "control":"stop"), myport, strerror(errno))); + } - if (result == 0) { - printf("select() timed out!\n"); - } else if (result < 0 && errno != EINTR) { - printf("Error in select(): %s\n", strerror(errno)); - } else if (result > 0) { -#ifdef VERBOSE - printf("select returned!\n"); -#endif - for (j=0; j 0) { + FILE_LOG(logDEBUG5, ("%s select returned!\n", (isControlServer ? "control":"stop"))); + // loop through the file descriptor set + for (j = 0; j < maxfd + 1; ++j) { - if ((file_des = accept(j,(struct sockaddr *) &addressC, &address_length)) < 0) { - printf("Error in accept(): %s\n", strerror(errno)); - printf("Error: with server accept, connection refused %d\n", errno); - - - switch(errno) { - case EWOULDBLOCK: - printf("ewouldblock eagain\n"); - break; - case EBADF: - printf("ebadf\n"); - break; - case ECONNABORTED: - printf("econnaborted\n"); - break; - case EFAULT: - printf("efault\n"); - break; - case EINTR: - printf("eintr\n"); - break; - case EINVAL: - printf("einval\n"); - break; - case EMFILE: - printf("emfile\n"); - break; - case ENFILE: - printf("enfile\n"); - break; - case ENOTSOCK: - printf("enotsock\n"); - break; - case EOPNOTSUPP: - printf("eOPNOTSUPP\n"); - break; - case ENOBUFS: - printf("ENOBUFS\n"); - break; - case ENOMEM: - printf("ENOMEM\n"); - break; - case ENOSR: - printf("ENOSR\n"); - break; - case EPROTO: - printf("EPROTO\n"); - break; - default: - printf("unknown error\n"); - } - - // should remove descriptor + // checks if file descriptor part of set + if (FD_ISSET(j, &tempset)) { + FILE_LOG(logDEBUG5, ("fd %d is set\n",j)); - socketDescriptor=-1; - } else { - - inet_ntop(AF_INET, &(addressC.sin_addr), dummyClientIP, INET_ADDRSTRLEN); -#ifdef VERBOSE - printf("connection accepted %d\n",file_des); -#endif - FD_SET(file_des, &readset); - maxfd = (maxfd < file_des)?file_des:maxfd; - } + // clear the temporary set + FD_CLR(j, &tempset); - } - } - } - - - - return file_des; + // accept connection (if error) + if ((file_des = accept(j,(struct sockaddr *) &addressC, &address_length)) < 0) { + FILE_LOG(logERROR, ("%s socket accept() error. Connection refused.\n", + "Error Number: %d, Message: %s\n", + (isControlServer ? "control":"stop"), + myport, errno, strerror(errno))); + switch(errno) { + case EWOULDBLOCK: + FILE_LOG(logERROR, ("ewouldblock eagain")); + break; + case EBADF: + FILE_LOG(logERROR, ("ebadf\n")); + break; + case ECONNABORTED: + FILE_LOG(logERROR, ("econnaborted\n")); + break; + case EFAULT: + FILE_LOG(logERROR, ("efault\n")); + break; + case EINTR: + FILE_LOG(logERROR, ("eintr\n")); + break; + case EINVAL: + FILE_LOG(logERROR, ("einval\n")); + break; + case EMFILE: + FILE_LOG(logERROR, ("emfile\n")); + break; + case ENFILE: + FILE_LOG(logERROR, ("enfile\n")); + break; + case ENOTSOCK: + FILE_LOG(logERROR, ("enotsock\n")); + break; + case EOPNOTSUPP: + FILE_LOG(logERROR, ("eOPNOTSUPP\n")); + break; + case ENOBUFS: + FILE_LOG(logERROR, ("ENOBUFS\n")); + break; + case ENOMEM: + FILE_LOG(logERROR, ("ENOMEM\n")); + break; + case ENOSR: + FILE_LOG(logERROR, ("ENOSR\n")); + break; + case EPROTO: + FILE_LOG(logERROR, ("EPROTO\n")); + break; + default: + FILE_LOG(logERROR, ("unknown error\n")); + } + } + // accept success + else { + inet_ntop(AF_INET, &(addressC.sin_addr), dummyClientIP, INET_ADDRSTRLEN); + FILE_LOG(logDEBUG5, ("%s socket accepted connection, fd= %d\n", + (isControlServer ? "control":"stop"), file_des)); + // add the file descriptor from accept + FD_SET(file_des, &readset); + maxfd = (maxfd < file_des)?file_des:maxfd; + } + } + } + } + return file_des; } @@ -244,22 +235,18 @@ int acceptConnection(int socketDescriptor) { void closeConnection(int file_des) { -#ifdef VERY_VERBOSE -#endif - if(file_des>=0) - close(file_des); - FD_CLR(file_des, &readset); + if(file_des >= 0) + close(file_des); + // remove file descriptor from set + FD_CLR(file_des, &readset); } void exitServer(int socketDescriptor) { - if (socketDescriptor>=0) - close(socketDescriptor); -#ifdef VERY_VERBOSE - printf("Closing server\n"); -#endif - FD_CLR(socketDescriptor, &readset); - socketDescriptor=-1; - isock--; + if (socketDescriptor >= 0) + close(socketDescriptor); + FILE_LOG(logDEBUG5, ("Closing %s server\n", (isControlServer ? "control":"stop"))); + FD_CLR(socketDescriptor, &readset); + isock--; } @@ -267,18 +254,18 @@ void exitServer(int socketDescriptor) { void swapData(void* val,int length,intType itype){ int i; - int16_t* c= (int16_t*)val; - int32_t* a= (int32_t*)val; - int64_t* b= (int64_t*)val; - for(i=0; length > 0; i++){ + int16_t* c = (int16_t*)val; + int32_t* a = (int32_t*)val; + int64_t* b = (int64_t*)val; + for(i = 0; length > 0; i++){ switch(itype){ case INT16: c[i] = ((c[i] & 0x00FF) << 8) | ((c[i] & 0xFF00) >> 8); length -= sizeof(int16_t); break; case INT32: - a[i]=((a[i] << 8) & 0xFF00FF00) | ((a[i] >> 8) & 0xFF00FF ); - a[i]=(a[i] << 16) | ((a[i] >> 16) & 0xFFFF); + a[i] = ((a[i] << 8) & 0xFF00FF00) | ((a[i] >> 8) & 0xFF00FF ); + a[i] = (a[i] << 16) | ((a[i] >> 16) & 0xFFFF); length -= sizeof(int32_t); break; case INT64: @@ -305,57 +292,59 @@ int sendData(int file_des, void* buf,int length, intType itype){ int receiveData(int file_des, void* buf,int length, intType itype){ - int ret = receiveDataOnly(file_des, buf, length); + int lret = receiveDataOnly(file_des, buf, length); #ifndef PCCOMPILE #ifdef EIGERD - if (ret >= 0) swapData(buf, length, itype); + if (lret >= 0) swapData(buf, length, itype); #endif #endif - return ret; + return lret; } - int sendDataOnly(int file_des, void* buf,int length) { - if (!length) - return 0; - int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored - if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n"); - return ret; +int sendDataOnly(int file_des, void* buf,int length) { + if (!length) + return 0; + int lret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored + if (lret < 0) { + FILE_LOG(logERROR, ("Could not write to %s socket. Possible socket crash\n", + (isControlServer ? "control":"stop"))); + } + return lret; } - int receiveDataOnly(int file_des, void* buf,int length) { +int receiveDataOnly(int file_des, void* buf,int length) { - int total_received=0; - int nreceiving; - int nreceived; - if (file_des<0) return -1; -#ifdef VERY_VERBOSE - printf("want to receive %d Bytes\n", length); -#endif + int total_received = 0; + int nreceiving; + int nreceived; + if (file_des<0) return -1; + FILE_LOG(logDEBUG5, ("want to receive %d Bytes to %s server\n", + length, (isControlServer ? "control":"stop"))); - while(length > 0) { - nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length; // (condition) ? if_true : if_false - nreceived = read(file_des,(char*)buf+total_received,nreceiving); - if(!nreceived){ - if(!total_received) { - return -1; //to handle it - } - break; - } - length-=nreceived; - total_received+=nreceived; - } + while(length > 0) { + nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length; // (condition) ? if_true : if_false + nreceived = read(file_des,(char*)buf+total_received,nreceiving); + if(!nreceived){ + if(!total_received) { + return -1; //to handle it + } + break; + } + length -= nreceived; + total_received += nreceived; + } - if (total_received>0) - strcpy(thisClientIP,dummyClientIP); - - if (strcmp(lastClientIP,thisClientIP)) - differentClients=1; - else - differentClients=0; + if (total_received>0) + strcpy(thisClientIP,dummyClientIP); - return total_received; + if (strcmp(lastClientIP,thisClientIP)) + differentClients = 1; + else + differentClients = 0; + + return total_received; } @@ -367,55 +356,49 @@ int sendModule(int file_des, sls_detector_module *myMod) { int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { - int ts=0; -#ifdef VERBOSE - int idac; -#endif - int nChips=myMod->nchip; - int nChans=myMod->nchan; - int nAdcs=myMod->nadc; - int nDacs=myMod->ndac; - //ts+= sendDataOnly(file_des,myMod,sizeof(sls_detector_module)); - ts+=sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts+=sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts+=sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts+=sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts+=sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts+=sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - ts+=sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + int ts = 0; + int nChips = myMod->nchip; + int nChans = myMod->nchan; + int nAdcs = myMod->nadc; + int nDacs = myMod->ndac; -#ifdef VERBOSE - printf("module of size %d sent\n",ts); -#endif - ts+= sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32); -#ifdef VERBOSE - printf("dacs of size %d sent\n",ts); - int idac; - for (idac=0; idac< nDacs; idac++) - printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]); -#endif - ts+= sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32); -#ifdef VERBOSE - printf("adcs of size %d sent\n", ts); -#endif + // send module structure + ts += sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); + ts += sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); + ts += sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); + ts += sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); + ts += sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); + ts += sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); + ts += sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); + ts += sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + FILE_LOG(logDEBUG5, ("module of size %d sent\n",ts)); - /*some detectors dont require sending all trimbits etc.*/ - if(sendAll){ - ts+=sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); -#ifdef VERBOSE - printf("chips of size %d sent\n", ts); -#endif - ts+=sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); -#ifdef VERBOSE - printf("chans of size %d sent - %d\n", ts, myMod->nchan); -#endif - } + // send dac + ts += sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32); + FILE_LOG(logDEBUG5, ("dacs of size %d sent\n",ts)); + { + int idac; + for (idac = 0; idac < nDacs; idac++) + FILE_LOG(logDEBUG5, ("dac %d is %d\n",idac,(int)myMod->dacs[idac])); + } -#ifdef VERBOSE - printf("module of size %d sent register %x\n", ts, myMod->reg); -#endif - return ts; + // send adc + ts += sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32); + FILE_LOG(logDEBUG5, ("adcs of size %d sent\n", ts)); + + // some detectors dont require sending all trimbits etc. + if(sendAll) { + // chips + ts += sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); + FILE_LOG(logDEBUG5, ("chips of size %d sent\n", ts)); + + // channels + ts += sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); + FILE_LOG(logDEBUG5, ("chans of size %d sent - %d\n", ts, myMod->nchan)); + } + + FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg)); + return ts; } @@ -425,146 +408,163 @@ int receiveModule(int file_des, sls_detector_module* myMod) { } int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) { - int ts=0; - int *dacptr=myMod->dacs; - int *adcptr=myMod->adcs; - int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs; - int nChips, nchipold=myMod->nchip, nchipdiff; - int nChans, nchanold=myMod->nchan, nchandiff; - int nDacs, ndold=myMod->ndac, ndacdiff; - int nAdcs, naold=myMod->nadc, nadcdiff; - ts+=receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts+=receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts+=receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts+=receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts+=receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts+=receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - ts+=receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts+=receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + int ts = 0; + int *dacptr = myMod->dacs; + int *adcptr = myMod->adcs; + int *chipptr = myMod->chipregs, *chanptr = myMod->chanregs; + int nChips, nchipold = myMod->nchip, nchipdiff; + int nChans, nchanold = myMod->nchan, nchandiff; + int nDacs, ndold = myMod->ndac, ndacdiff; + int nAdcs, naold = myMod->nadc, nadcdiff; + ts += receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); + ts += receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); + ts += receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); + ts += receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); + ts += receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); + ts += receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); + ts += receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); + ts += receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); - myMod->dacs=dacptr; - myMod->adcs=adcptr; - myMod->chipregs=chipptr; - myMod->chanregs=chanptr; + myMod->dacs = dacptr; + myMod->adcs = adcptr; + myMod->chipregs = chipptr; + myMod->chanregs = chanptr; #ifdef EIGERD - //feature to exclude sending of trimbtis, nchips=0,nchans=0 in that case - if(myMod->nchip == 0 && myMod->nchan == 0) { - receiveAll=0; - nchipold=0; - nchanold=0; - } +//exclude sending of trimbtis, nchips = 0,nchans = 0 in that case + if(myMod->nchip == 0 && myMod->nchan == 0) { + receiveAll = 0; + nchipold = 0; + nchanold = 0; + } #endif - nChips=myMod->nchip; - nchipdiff=nChips-nchipold; - if (nchipold!=nChips) { - printf("received wrong number of chips\n"); - } -#ifdef VERBOSE - else - printf("received %d chips\n",nChips); -#endif + nChips = myMod->nchip; + nchipdiff = nChips-nchipold; + if (nchipold != nChips) { + FILE_LOG(logERROR, ("received wrong number of chips\n")); + } + else + FILE_LOG(logDEBUG5, ("received %d chips\n",nChips)); - nChans=myMod->nchan; - nchandiff=nChans-nchanold; - if (nchanold!=nChans) { - printf("received wrong number of channels\n"); - } -#ifdef VERBOSE - else - printf("received %d chans\n",nChans); -#endif + nChans = myMod->nchan; + nchandiff = nChans-nchanold; + if (nchanold != nChans) { + FILE_LOG(logERROR, ("received wrong number of channels\n")); + } + else + FILE_LOG(logDEBUG5, ("received %d chans\n",nChans)); - nDacs=myMod->ndac; - ndacdiff=nDacs-ndold; - if (ndold!=nDacs) { - printf("received wrong number of dacs\n"); - } -#ifdef VERBOSE - else - printf("received %d dacs\n",nDacs); -#endif - - nAdcs=myMod->nadc; - nadcdiff=nAdcs-naold; - if (naold!=nAdcs) { - printf("received wrong number of adcs\n"); - } -#ifdef VERBOSE - else - printf("received %d adcs\n",nAdcs); -#endif - if (ndacdiff<=0) { - ts+=receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32); -#ifdef VERBOSE - printf("dacs received\n"); - int id; - for (id=0; iddacs[id]); + nDacs = myMod->ndac; + ndacdiff = nDacs-ndold; + if (ndold != nDacs) { + FILE_LOG(logERROR, ("received wrong number of dacs\n")); + } + else + FILE_LOG(logDEBUG5, ("received %d dacs\n",nDacs)); + + nAdcs = myMod->nadc; + nadcdiff = nAdcs-naold; + if (naold != nAdcs) { + FILE_LOG(logERROR, ("received wrong number of adcs\n")); + } + else + FILE_LOG(logDEBUG5, ("received %d adcs\n",nAdcs)); + if (ndacdiff <= 0) { + ts += receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32); + FILE_LOG(logDEBUG5, ("dacs received\n")); + int id; + for (id = 0; iddacs[id])); + } else { + dacptr = (int*)malloc(ndacdiff*sizeof(int)); + myMod->ndac = ndold; + ts += receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32); + ts += receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32); + free(dacptr); + return FAIL; + } + + if (nadcdiff <= 0) { + ts += receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32); + FILE_LOG(logDEBUG5, ("adcs received\n")); + } else { + adcptr = (int*)malloc(nadcdiff*sizeof(int)); + myMod->nadc = naold; + ts += receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32); + ts += receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32); + free(adcptr); + return FAIL; + } -#endif - } else { - dacptr=(int*)malloc(ndacdiff*sizeof(int)); - myMod->ndac=ndold; - ts+=receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32); - ts+=receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32); - free(dacptr); - return FAIL; - } + // some detectors dont require sending all trimbits etc. + if(receiveAll){ - if (nadcdiff<=0) { - ts+=receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32); -#ifdef VERBOSE - printf("adcs received\n"); -#endif - } else { - adcptr=(int*)malloc(nadcdiff*sizeof(int)); - myMod->nadc=naold; - ts+=receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32); - ts+=receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32); - free(adcptr); - return FAIL; - } + if (nchipdiff <= 0) { + ts += receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); + FILE_LOG(logDEBUG5, ("chips received\n")); + } else { + chipptr = (int*)malloc(nchipdiff*sizeof(int)); + myMod->nchip = nchipold; + ts += receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); + ts += receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); + free(chipptr); + return FAIL; + } - - /*some detectors dont require sending all trimbits etc.*/ - if(receiveAll){ - - if (nchipdiff<=0) { - ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); -#ifdef VERBOSE - printf("chips received\n"); -#endif - } else { - chipptr=(int*)malloc(nchipdiff*sizeof(int)); - myMod->nchip=nchipold; - ts+=receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); - ts+=receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); - free(chipptr); - return FAIL; - } - - if (nchandiff<=0) { - ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); -#ifdef VERBOSE - printf("chans received\n"); -#endif - } else { - chanptr=(int*)malloc(nchandiff*sizeof(int)); - myMod->nchan=nchanold; - ts+=receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); - ts+=receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); - free(chanptr); - return FAIL; - } - } -#ifdef VERBOSE - printf("received module of size %d register %x\n",ts,myMod->reg); -#endif - - return ts; + if (nchandiff <= 0) { + ts += receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); + FILE_LOG(logDEBUG5, ("chans received\n")); + } else { + chanptr = (int*)malloc(nchandiff*sizeof(int)); + myMod->nchan = nchanold; + ts += receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); + ts += receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); + free(chanptr); + return FAIL; + } + } + FILE_LOG(logDEBUG5, ("received module of size %d register %x\n",ts,myMod->reg)); + return ts; +} + + +void Server_LockedError() { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n", lastClientIP); + FILE_LOG(logWARNING, (mess)); +} + + +int Server_VerifyLock() { + if (differentClients && lockStatus) + Server_LockedError(); + return ret; +} + + +void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) { + + // update if different clients + if (update && ret == OK && differentClients) + ret = FORCE_UPDATE; + + // send success of operation + int ret1 = ret; + sendData(fileDes, &ret1,sizeof(ret1), INT32); + if(ret == FAIL) { + // send error message + if (strlen(mess)) + sendData(fileDes, mess, MAX_STR_LENGTH, OTHER); + // debugging feature. should not happen. + else + FILE_LOG(logERROR, ("No error message provided for this failure in %s " + "server. Will mess up TCP.\n", + (isControlServer ? "control":"stop"))); + } + // send return value + sendData(fileDes, retval, retvalSize, itype); } diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.h b/slsDetectorServers/slsDetectorServer/communication_funcs.h index 4d41098cd..6b2068e20 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.h +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.h @@ -37,11 +37,34 @@ int receiveData(int file_des, void* buf,int length, intType itype); int sendDataOnly(int file_des, void* buf,int length); int receiveDataOnly(int file_des, void* buf,int length); - -int getServerError(int socketDescriptor); int sendModule(int file_des, sls_detector_module *myMod); int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll); int receiveModule(int file_des, sls_detector_module* myMod); int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll); +/** + * Servers sets and prints error message for locked server + * @returns success of operaton + */ +void Server_LockedError(); + + +/** + * Server verifies if it is unlocked, + * sets and prints appropriate message if it is locked and different clients + * @returns success of operaton + */ +int Server_VerifyLock(); + + +/** + * Server sends result to client (also set ret to force_update if different clients) + * @param fileDes file descriptor for the socket + * @param itype 32 or 64 or others to determine to swap data from big endian to little endian + * @param update 1 if one must update if different clients, else 0 + * @param retval pointer to result + * @param retvalSize size of result + */ +void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize); + #endif diff --git a/slsDetectorServers/slsDetectorServer/logger.h b/slsDetectorServers/slsDetectorServer/logger.h new file mode 100644 index 000000000..c89aafd30 --- /dev/null +++ b/slsDetectorServers/slsDetectorServer/logger.h @@ -0,0 +1,63 @@ +#pragma once + +#include "ansi.h" + +#include +#include +#include + + +#ifdef FIFODEBUG +#define FILELOG_MAX_LEVEL logDEBUG5 +#elif VERYVERBOSE +#define FILELOG_MAX_LEVEL logDEBUG4 +#elif VERBOSE +#define FILELOG_MAX_LEVEL logDEBUG +#endif + +#ifndef FILELOG_MAX_LEVEL +#define FILELOG_MAX_LEVEL logINFOBLUE +#endif + +typedef enum { +logERROR, logWARNING, logINFO, logINFOBLUE, +logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5 +}TLogLevel; + +#define ERROR_MSG_LENGTH 1000 + +#define FILE_LOG(lvl, fmt, ...) \ + if (lvl > FILELOG_MAX_LEVEL); \ + else {char* temp = FILELOG_BuildLog fmt; FILELOG_PrintLog(lvl, temp);free(temp);} + +static inline void FILELOG_PrintLog(TLogLevel level, char* m) { + switch(level) { + case logERROR: cprintf(RED BOLD, "ERROR: %s", m); break; + case logWARNING: cprintf(YELLOW BOLD, "WARNING: %s", m); break; + case logINFOBLUE: cprintf(BLUE, "INFO: %s", m); break; + case logINFO: cprintf(RESET, "INFO: %s", m); break; + case logDEBUG: cprintf(MAGENTA, "DEBUG: %s", m); break; + case logDEBUG1: cprintf(MAGENTA, "DEBUG1: %s", m); break; + case logDEBUG2: cprintf(MAGENTA, "DEBUG2: %s", m); break; + case logDEBUG3: cprintf(MAGENTA, "DEBUG3: %s", m); break; + case logDEBUG4: cprintf(MAGENTA, "DEBUG4: %s", m); break; + case logDEBUG5: cprintf(MAGENTA, "DEBUG5: %s", m); break; + } +} + +static inline char* FILELOG_BuildLog(const char* fmt, ...) { + char* p; + va_list ap; + p = malloc(ERROR_MSG_LENGTH); + va_start(ap, fmt); + int ret = vsnprintf(p, ERROR_MSG_LENGTH, fmt, ap); + va_end(ap); + if (ret < 0 || ret >= ERROR_MSG_LENGTH) { + FILELOG_PrintLog(logERROR, ("Could not print the " + "complete error message in the next print.\n")); + } + return p; +}; + + + diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index 6b0a7ca03..d100b85f8 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -1,7 +1,3 @@ -#ifdef SLS_DETECTOR_FUNCTION_LIST -#ifndef SLS_DETECTOR_FUNCTION_LIST_H -#define SLS_DETECTOR_FUNCTION_LIST_H - #include "sls_detector_defs.h" #include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h @@ -22,7 +18,7 @@ int isFirmwareCheckDone(); int getFirmwareCheckResult(char** mess); #endif -void checkFirmwareCompatibility(int flag); +void checkFirmwareCompatibility(); #if defined(MYTHEN3D) || defined(JUNGFRAUD) int checkType(); u_int32_t testFpga(void); @@ -166,7 +162,8 @@ int setHighVoltage(int val); // parameters - timing, extsig -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); +void setTiming( enum externalCommunicationMode arg); +enum externalCommunicationMode getTiming(); // configure mac #ifdef JUNGFRAUD @@ -264,6 +261,3 @@ int getNumberOfOffsets(); int getNumberOfChannelsPerChip(); - -#endif -#endif diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c index fd4b0e443..9a4c56df3 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c @@ -3,7 +3,7 @@ #include "sls_detector_defs.h" #include "slsDetectorServer_defs.h" - +#include "logger.h" #include "communication_funcs.h" #include "slsDetectorServer_funcs.h" @@ -12,8 +12,13 @@ #include #include -extern int sockfd; +// Global variables from communication_funcs +extern int isControlServer; +extern int ret; +// Global variables from slsDetectorServer_funcs +extern int sockfd; +extern int debugflag; void error(char *msg){ perror(msg); @@ -22,9 +27,7 @@ void error(char *msg){ int main(int argc, char *argv[]){ int portno = DEFAULT_PORTNO; int retval = OK; - int sd, fd; - int debugflag = 0; - int controlserver = 1; + int fd = 0; // if socket crash, ignores SISPIPE, prevents global signal handler // subsequent read/write to socket gives error - must handle locally @@ -35,21 +38,21 @@ int main(int argc, char *argv[]){ int i; for (i = 1; i < argc; ++i) { if(!strcasecmp(argv[i],"-stopserver")) { - cprintf(BLUE,"Detected stop server\n"); - controlserver = 0; + FILE_LOG(logINFO, ("Detected stop server\n")); + isControlServer = 0; } else if(!strcasecmp(argv[i],"-devel")){ - cprintf(BLUE,"Detected developer mode\n"); + FILE_LOG(logINFO, ("Detected developer mode\n")); debugflag = 1; } #ifdef JUNGFRAUD else if(!strcasecmp(argv[i],"-update")){ - cprintf(BLUE,"Detected update mode\n"); + FILE_LOG(logINFO, ("Detected update mode\n")); debugflag = PROGRAMMING_MODE; } #endif else if(strchr(argv[i],'-') != NULL) { - cprintf(RED,"cannot scan program argument %s\n", argv[1]); + FILE_LOG(logERROR, ("cannot scan program argument %s\n", argv[1])); return -1; } } @@ -59,79 +62,60 @@ int main(int argc, char *argv[]){ char cmd[100]; memset(cmd, 0, 100); #endif - if (controlserver) { + if (isControlServer) { portno = DEFAULT_PORTNO; - cprintf(BLUE, - "********************************************************\n" + FILE_LOG(logINFOBLUE, + ("***************************************************\n" "********* opening control server on port %d **********\n" "********************************************************\n\n" - , portno); + , portno)); #ifdef STOP_SERVER { int i; for (i = 0; i < argc; ++i) sprintf(cmd, "%s %s", cmd, argv[i]); sprintf(cmd,"%s -stopserver&", cmd); - cprintf(BLUE,"cmd:%s\n", cmd); + FILE_LOG(logINFO, ("Command to start stop server:%s\n", cmd)); system(cmd); } #endif } else { - portno = DEFAULT_PORTNO+1; - cprintf(BLUE, - "********************************************************\n" + portno = DEFAULT_PORTNO + 1; + FILE_LOG(logINFOBLUE, + ("***************************************************\n" "*********** opening stop server on port %d ***********\n" "********************************************************\n\n" - , portno); + , portno)); } - setModeFlag(debugflag); //defined in slsDetectorServer_funcs - init_detector(controlserver); //defined in slsDetectorServer_funcs + init_detector(); - sd=bindSocket(portno); //defined in communication_funcs - sockfd=sd; - if (getServerError(sd)) { //defined in communication_funcs - printf("server error!\n"); - return -1; + { // bind socket + sockfd = bindSocket(portno); + if (ret == FAIL) + return -1; } - /* assign function table */ - function_table(); //defined in slsDetectorServer_funcs -#ifdef VERBOSE - printf("function table assigned \n"); -#endif + // assign function table + function_table(); - if (controlserver) - printf("\nControl Server Ready...\n\n"); - else - printf("\nStop Server Ready...\n\n"); + if (isControlServer) { + FILE_LOG(logINFO, ("Control Server Ready...\n\n")); + } else { + FILE_LOG(logINFO, ("Stop Server Ready...\n\n")); + } - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Waiting for client call\n"); -#endif - fd=acceptConnection(sockfd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("Conenction accepted\n"); -#endif - if (fd>0) { - retval=decode_function(fd); //defined in slsDetectorServer_funcs -#ifdef VERY_VERBOSE - printf("function executed\n"); -#endif - closeConnection(fd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("connection closed\n"); -#endif + // waits for connection + while(retval != GOODBYE) { + fd = acceptConnection(sockfd); + if (fd > 0) { + retval = decode_function(fd); + closeConnection(fd); } } - exitServer(sockfd); //defined in communication_funcs - printf("Goodbye!\n"); + exitServer(sockfd); + FILE_LOG(logINFO,("Goodbye!\n")); return 0; } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index e0e0f9d8f..704b56990 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -1,21 +1,12 @@ - -#include "sls_detector_defs.h" #include "slsDetectorServer_funcs.h" #include "slsDetectorFunctionList.h" #include "communication_funcs.h" -#include "slsDetectorServer_defs.h" +#include "logger.h" #include #include #include - -// Global variables -extern int lockStatus; -extern char lastClientIP[INET_ADDRSTRLEN]; -extern char thisClientIP[INET_ADDRSTRLEN]; -extern int differentClients; - //defined in the detector specific Makefile #ifdef GOTTHARDD const enum detectorType myDetectorType=GOTTHARD; @@ -29,53 +20,58 @@ const enum detectorType myDetectorType=MYTHEN3; const enum detectorType myDetectorType=GENERIC; #endif -int sockfd; // (updated in slsDetectorServer) as extern -int (*flist[NUM_DET_FUNCTIONS])(int); -char mess[MAX_STR_LENGTH]; -int dataBytes = 10; -int isControlServer = 0; +// Global variables from communication_funcs +extern int lockStatus; +extern char lastClientIP[INET_ADDRSTRLEN]; +extern char thisClientIP[INET_ADDRSTRLEN]; +extern int differentClients; +extern int isControlServer; +extern int ret; +extern int fnum; +extern char mess[MAX_STR_LENGTH]; + +// Variables that will be exported +int sockfd = 0; int debugflag = 0; + +// Local variables +int (*flist[NUM_DET_FUNCTIONS])(int); +int dataBytes = 10; #ifdef EIGERD uint32_t dhcpipad = 0; #endif + + + /* initialization functions */ int printSocketReadError() { - cprintf(BG_RED, "Error reading from socket. Possible socket crash\n"); + FILE_LOG(logERROR, ("Error reading from socket. Possible socket crash.\n")); return FAIL; } -void setModeFlag(int flag) { - debugflag = flag; -} void basictests() { -#ifdef SLS_DETECTOR_FUNCTION_LIST - checkFirmwareCompatibility(debugflag); -#endif + checkFirmwareCompatibility(); } -void init_detector(int controlserver) { +void init_detector() { #ifdef VIRTUAL - printf("This is a VIRTUAL detector\n"); + FILE_LOG(logINFO, ("This is a VIRTUAL detector\n")); #endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST - if (controlserver) { - isControlServer = 1; + if (isControlServer) { basictests(); #ifdef JUNGFRAUD - if (debugflag != PROGRAMMING_MODE) + if (debugflag == PROGRAMMING_MODE) #endif - initControlServer(); + initControlServer(); #ifdef EIGERD - dhcpipad = getDetectorIP(); + dhcpipad = getDetectorIP(); #endif } else initStopServer(); -#endif strcpy(mess,"dummy message"); strcpy(lastClientIP,"none"); strcpy(thisClientIP,"none1"); @@ -84,48 +80,40 @@ void init_detector(int controlserver) { int decode_function(int file_des) { - int fnum,n; - int ret=FAIL; -#ifdef VERBOSE - printf( "\nreceive data\n"); -#endif - n = receiveData(file_des,&fnum,sizeof(fnum),INT32); - if (n <= 0) { -#ifdef VERBOSE - printf("ERROR reading from socket %d, %d %d (%s)\n", - n, fnum, file_des, getFunctionName((enum detFuncs)fnum)); -#endif - return FAIL; - } -#ifdef VERBOSE - else - printf("size of data received %d\n",n); -#endif + ret = FAIL; + int n = receiveData(file_des,&fnum,sizeof(fnum),INT32); + if (n <= 0) { + FILE_LOG(logDEBUG5, ("ERROR reading from socket n=%d, fnum=%d, file_des=%d, fname=%s\n", + n, fnum, file_des, getFunctionName((enum detFuncs)fnum))); + return FAIL; + } else + FILE_LOG(logDEBUG5, ("Received %d bytes\n", n )); + + // jungfrau in programming mode #ifdef JUNGFRAUD - if ((debugflag == PROGRAMMING_MODE) && ( + if ((debugflag == PROGRAMMING_MODE) && (fnum != F_PROGRAM_FPGA) && (fnum != F_GET_DETECTOR_TYPE) && (fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT) && - (fnum != F_CHECK_VERSION))) { - sprintf(mess,"This Function %s cannot be executed. ", - getFunctionName((enum detFuncs)fnum)); - ret=(M_nofuncMode)(file_des); - } else + (fnum != F_CHECK_VERSION)) { + ret = (M_nofuncMode)(file_des); + } + else #endif - if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) { - cprintf(BG_RED,"Unknown function enum %d\n", fnum); + if (fnum < 0 || fnum >= NUM_DET_FUNCTIONS) { + FILE_LOG(logERROR, ("Unknown function enum %d\n", fnum)); ret=(M_nofunc)(file_des); - }else { -#ifdef VERBOSE - printf(" calling function fnum=%d, (%s) located at 0x%x\n", - fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]); -#endif + } else { + FILE_LOG(logDEBUG5, (" calling function fnum=%d, (%s)\n", + fnum, getFunctionName((enum detFuncs)fnum))); ret=(*flist[fnum])(file_des); - if (ret == FAIL) - cprintf(RED, "Error executing the function = %d (%s)\n", - fnum, getFunctionName((enum detFuncs)fnum)); + + if (ret == FAIL) { + FILE_LOG(logDEBUG5, ("Error executing the function = %d (%s)\n", + fnum, getFunctionName((enum detFuncs)fnum))); + } } return ret; } @@ -253,105 +241,105 @@ void function_table() { flist[F_THRESHOLD_TEMP] = &threshold_temp; flist[F_TEMP_CONTROL] = &temp_control; flist[F_TEMP_EVENT] = &temp_event; - flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable; - flist[F_STORAGE_CELL_START] = &storage_cell_start; - flist[F_CHECK_VERSION] = &check_version; - flist[F_SOFTWARE_TRIGGER] = &software_trigger; + flist[F_AUTO_COMP_DISABLE] = &auto_comp_disable; + flist[F_STORAGE_CELL_START] = &storage_cell_start; + flist[F_CHECK_VERSION] = &check_version; + flist[F_SOFTWARE_TRIGGER] = &software_trigger; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { - cprintf(BG_RED,"The last detector function enum has reached its limit\nGoodbye!\n"); + FILE_LOG(logERROR, ("The last detector function enum has reached its limit\nGoodbye!\n")); exit(EXIT_FAILURE); } -#ifdef VERYVERBOSE - { - int i=0; - for (i = 0; i < NUM_DET_FUNCTIONS ; i++) { - printf("function fnum=%d, (%s) located at 0x%x\n", i, - getFunctionName((enum detFuncs)i), (unsigned int)flist[i]); - } + int iloop = 0; + for (iloop = 0; iloop < NUM_DET_FUNCTIONS ; ++iloop) { + FILE_LOG(logDEBUG5, ("function fnum=%d, (%s) located at 0x%x\n", iloop, + getFunctionName((enum detFuncs)iloop), (unsigned int)flist[iloop])); } -#endif +} + +void functionNotImplemented() { + ret = FAIL; + sprintf(mess, "Function (%s) is not implemented for this detector\n", + getFunctionName((enum detFuncs)fnum)); + FILE_LOG(logERROR, (mess)); } int M_nofunc(int file_des){ - int ret=FAIL,ret1=FAIL; - int n=0; + ret = FAIL; + memset(mess, 0, sizeof(mess)); - //to receive any arguments + // to receive any arguments + int n = 0; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - sprintf(mess,"Unrecognized Function. Please do not proceed.\n"); - cprintf(BG_RED,"Error: %s",mess); - n = sendData(file_des,&ret1,sizeof(ret1),INT32); - n = sendData(file_des,mess,sizeof(mess),OTHER); + strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); + FILE_LOG(logERROR, (mess)); - // return ok / fail + Server_SendResult(file_des, OTHER, 0, NULL, 0); return ret; } // Jungfrau program mode int M_nofuncMode(int file_des){ - int ret=FAIL,ret1=FAIL; - int n=0; - //to receive any arguments + ret = FAIL; + memset(mess, 0, sizeof(mess)); + + // to receive any arguments + int n = 0; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - strcat(mess, "On-board detector server in update mode. Restart detector server in normal mode (without any arguments) to continue.\n"); - cprintf(BG_RED,"Error: %s",mess); - n = sendData(file_des,&ret1,sizeof(ret1),INT32); - n = sendData(file_des,mess,sizeof(mess),OTHER); // mess is defined at function call + sprintf(mess,"This Function %s cannot be executed as the " + "On-board detector server in update mode.\n" + "Restart detector server in normal mode (without any arguments) to continue.\n", + getFunctionName((enum detFuncs)fnum)); + FILE_LOG(logERROR, (mess)); - // return ok / fail + Server_SendResult(file_des, OTHER, 0, NULL, 0); return ret; } -/* functions called by client */ - - int exec_command(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char cmd[MAX_STR_LENGTH]=""; - int sysret=0; + ret = OK; + memset(mess, 0, sizeof(mess)); + char cmd[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; - // receive arguments - n = receiveData(file_des,cmd,MAX_STR_LENGTH,OTHER); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, cmd, MAX_STR_LENGTH, OTHER) < 0) + return printSocketReadError(); - // execute action if the arguments correctly arrived -#ifdef VERBOSE - printf("executing command %s\n", cmd); -#endif - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { - sysret=system(cmd); - //should be replaced by popen - if (sysret==0) { - sprintf(mess,"Succeeded\n"); - } else { - ret = FAIL; - sprintf(mess,"Executing Command failed\n"); - cprintf(RED, "Warning: %s", mess); + if (Server_VerifyLock() != FAIL) { + + FILE_LOG(logINFO, ("Executing command (%s)\n", cmd)); + FILE* sysFile = popen(cmd, "r"); + const size_t tempsize = 256; + char temp[tempsize]; + memset(temp, 0, tempsize); + while(fgets(temp, tempsize, sysFile) != NULL) { + // size left excludes terminating character + size_t sizeleft = MAX_STR_LENGTH - strlen(retval) - 1; + // more than the command + if (tempsize > sizeleft) { + strncat(retval, temp, sizeleft); + break; + } + strncat(retval, temp, tempsize); + memset(temp, 0, tempsize); } + pclose(sysFile); + FILE_LOG(logINFO, ("Result of cmd (%s):\n%s\n", cmd, retval)); } - ret1=ret; - n = sendData(file_des,&ret1,sizeof(ret),INT32); - n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER); + Server_SendResult(file_des, OTHER, 0, retval, sizeof(retval)); - // return ok / fail return ret; } @@ -359,28 +347,13 @@ int exec_command(int file_des) { int get_detector_type(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum detectorType retval=-1; + ret = OK; + enum detectorType retval = myDetectorType; + FILE_LOG(logDEBUG5,("Returning detector type %d\n", retval)); - // execute action - retval=myDetectorType; -#ifdef VERBOSE - printf("Returning detector type %d\n",retval); -#endif + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - if (differentClients) - ret=FORCE_UPDATE; - - // send ok / fail - n += sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail return ret; - - } @@ -388,136 +361,79 @@ int get_detector_type(int file_des) { int set_external_signal_flag(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG; - sprintf(mess,"set external signal flag failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg[2] = {-1,-1}; + enum externalSignalFlag retval= GET_EXTERNAL_SIGNAL_FLAG; + + if (receiveData(file_des, arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); #ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set External Signal Flag) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else + int signalindex = arg[0]; + enum externalSignalFlag flag = arg[1]; - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - int signalindex=arg[0]; - enum externalSignalFlag flag=arg[1]; - - // execute action - if (lockStatus && differentClients && flag!=GET_EXTERNAL_SIGNAL_FLAG) { + // set + if ((flag != GET_EXTERNAL_SIGNAL_FLAG) && (Server_VerifyLock() != FAIL)) { + FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); + setExtSignal(signalindex, flag); + } + // get + retval = getExtSignal(signalindex); + if (flag != GET_EXTERNAL_SIGNAL_FLAG && retval != flag) { ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", + signalindex, flag, retval); + FILE_LOG(logERROR,(mess)); } - -#ifdef SLS_DETECTOR_FUNCTION_LIST - else{ -#ifdef VERBOSE - printf("Setting external signal %d to flag %d\n",signalindex,flag); -#endif - switch (flag) { - case GET_EXTERNAL_SIGNAL_FLAG: - retval=getExtSignal(signalindex); - break; - default: - retval=setExtSignal(signalindex,flag); - if (retval!=flag) { - ret=FAIL; - sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval); - cprintf(RED, "%s", mess); - } - break; - } -#ifdef VERBOSE - printf("Set to flag %d\n",retval); -#endif - } -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; + FILE_LOG(logDEBUG5, ("External Signal Flag: %d\n", retval)); #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; - } + + int set_external_communication_mode(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum externalCommunicationMode arg=GET_EXTERNAL_COMMUNICATION_MODE; - enum externalCommunicationMode retval=GET_EXTERNAL_COMMUNICATION_MODE; - sprintf(mess,"set external communication mode failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum externalCommunicationMode arg = GET_EXTERNAL_COMMUNICATION_MODE; + enum externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE; - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); - // execute action -#ifdef VERBOSE - printf("Setting external communication mode to %d\n", arg); -#endif -#ifdef SLS_DETECTOR_FUNCTION_LIST - switch(arg){ + // set + if ((arg != GET_EXTERNAL_COMMUNICATION_MODE) && (Server_VerifyLock() != FAIL)) { + switch (arg) { + case AUTO_TIMING: + case TRIGGER_EXPOSURE: #ifdef EIGERD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: - case GATE_FIX_NUMBER: - case BURST_TRIGGER: -#elif JUNGFRAUD - case GET_EXTERNAL_COMMUNICATION_MODE: - case AUTO_TIMING: - case TRIGGER_EXPOSURE: + case GATE_FIX_NUMBER: + case BURST_TRIGGER: #endif - retval=setTiming(arg); - break; - default: - ret = FAIL; - sprintf(mess,"Timing mode (%d) is not implemented for this detector\n",(int)arg); - cprintf(RED, "Warning: %s", mess); - break; - } -#ifdef VERBOSE - if(ret==OK) - printf("retval:%d\n",retval); -#endif - if (ret==OK && differentClients==1) - ret=FORCE_UPDATE; - -#endif - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); + FILE_LOG(logDEBUG5,("Setting external communication mode to %d\n", arg)); + setTiming(arg); + break; + default: + ret = FAIL; + sprintf(mess, "Timing mode (%d) is not implemented for this detector\n", (int)arg); + FILE_LOG(logWARNING,(mess)); + break; + } } - // return ok / fail + // get + retval = getTiming(); + FILE_LOG(logDEBUG5, ("Timing Mode: %d\n",retval)); + + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + return ret; } @@ -525,58 +441,34 @@ int set_external_communication_mode(int file_des) { int get_id(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum idMode arg=0; - int64_t retval=-1; - sprintf(mess,"get id failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum idMode arg = 0; + int64_t retval = -1; - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); - // execute action -#ifdef VERBOSE - printf("Getting id %d\n", arg); -#endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST + // get switch (arg) { -#ifdef EIGERD +#if defined(EIGERD) || defined(JUNGFRAUD) case SOFTWARE_FIRMWARE_API_VERSION: #endif case DETECTOR_SERIAL_NUMBER: case DETECTOR_FIRMWARE_VERSION: case DETECTOR_SOFTWARE_VERSION: - retval=getDetectorId(arg); + retval = getDetectorId(arg); + FILE_LOG(logDEBUG5, ("Id(%d): %lld\n", retval)); break; default: ret = FAIL; sprintf(mess,"ID Index (%d) is not implemented for this detector\n", (int) arg); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logWARNING,(mess)); break; } -#endif -#ifdef VERBOSE - printf("ret is %d\n",ret); - printf("Id is %llx\n", retval); -#endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; + Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT64); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail return ret; } @@ -620,7 +512,6 @@ int digital_test(int file_des) { #ifdef VERBOSE printf("Digital test mode %d\n",arg ); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST switch (arg) { #ifdef GOTTHARD @@ -640,7 +531,6 @@ int digital_test(int file_des) { cprintf(RED, "Warning: %s", mess); break; } -#endif } #ifdef VERBOSE printf("digital test result is 0x%x\n", retval); @@ -885,7 +775,6 @@ int set_dac(int file_des) { #ifdef VERBOSE printf("Setting DAC %d to %d \n", idac, val); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST int temp; if (ret==OK) { if (differentClients && lockStatus && val!=-1) { @@ -1010,7 +899,6 @@ int set_dac(int file_des) { } } } -#endif #ifdef VERBOSE printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]); #endif @@ -1106,10 +994,8 @@ int get_adc(int file_des) { #ifdef VERBOSE printf("Getting ADC %d\n", iadc); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST if (ret==OK) retval=getADC(iadc); -#endif #ifdef VERBOSE printf("ADC is %f\n", retval); #endif @@ -1156,7 +1042,6 @@ int write_register(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("writing to register 0x%x data 0x%x\n", addr, val); @@ -1168,7 +1053,6 @@ int write_register(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif #ifdef VERBOSE printf("Data set to 0x%x\n", retval); #endif @@ -1211,9 +1095,7 @@ int read_register(int file_des) { #ifdef VERBOSE printf("reading register 0x%x\n", addr); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=readRegister(addr); -#endif #ifdef VERBOSE printf("Returned value 0x%x\n", retval); #endif @@ -1261,7 +1143,6 @@ int set_module(int file_des) { #else -#ifdef SLS_DETECTOR_FUNCTION_LIST int *myDac=NULL; int *myAdc=NULL; int *myChip = NULL; @@ -1430,7 +1311,6 @@ int set_module(int file_des) { } if (ret==OK && differentClients) ret=FORCE_UPDATE; -#endif #endif // ret could be swapped during sendData @@ -1471,7 +1351,6 @@ int get_module(int file_des) { #else // execute action -#ifdef SLS_DETECTOR_FUNCTION_LIST int *myDac=NULL; int *myAdc=NULL; int *myChip = NULL; @@ -1529,7 +1408,6 @@ int get_module(int file_des) { #endif } } -#endif #endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -1551,12 +1429,10 @@ int get_module(int file_des) { n += sendData(file_des,mess,sizeof(mess),OTHER); } -#ifdef SLS_DETECTOR_FUNCTION_LIST if(myChip != NULL) free(myChip); if(myChan != NULL) free(myChan); if(myDac != NULL) free(myDac); if(myAdc != NULL) free(myAdc); -#endif // return ok / fail return ret; @@ -1596,7 +1472,6 @@ int set_settings(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST switch(isett) { case GET_SETTINGS: @@ -1659,7 +1534,6 @@ int set_settings(int file_des) { } } #endif -#endif #endif if (ret==OK && differentClients) @@ -1702,11 +1576,9 @@ int get_threshold_energy(int file_des) { #ifdef VERBOSE printf("Getting threshold energy \n"); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=getThresholdEnergy(); #ifdef VERBOSE printf("Threshold is %d eV\n", retval); -#endif #endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -1742,14 +1614,12 @@ int start_acquisition(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { printf("Starting acquisition\n"); ret=startStateMachine(); if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -1779,14 +1649,12 @@ int stop_acquisition(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { printf("Stopping acquisition\n"); ret=stopStateMachine(); if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -1827,14 +1695,12 @@ int start_readout(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { printf("Starting readout\n"); ret=startReadOut(); if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -1865,9 +1731,7 @@ int get_run_status(int file_des) { #ifdef VERBOSE printf("Getting status\n"); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST s= getRunStatus(); -#endif if (differentClients) ret=FORCE_UPDATE; @@ -1904,10 +1768,8 @@ int start_and_read_all(int file_des) { // return fail return dataret; } -#ifdef SLS_DETECTOR_FUNCTION_LIST startStateMachine(); read_all(file_des); -#endif return OK; } @@ -1933,9 +1795,7 @@ int read_all(int file_des) { // return fail return dataret; } -#ifdef SLS_DETECTOR_FUNCTION_LIST readFrame(&dataret, mess); -#endif if(dataret == FAIL) cprintf(RED,"%s\n",mess); else @@ -1982,7 +1842,6 @@ int set_timer(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("setting timer %d to %lld ns\n",ind,tns); @@ -2045,7 +1904,6 @@ int set_timer(int file_des) { } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -2086,7 +1944,6 @@ int get_time_left(int file_des) { #ifdef VERBOSE printf("getting time left on timer %d \n",ind); #endif -#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef JUNGFRAUD if (ind == DELAY_AFTER_TRIGGER) { @@ -2137,7 +1994,6 @@ int get_time_left(int file_des) { } // end of if (ind == DELAY_AFTER_TRIGGER) #endif -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -2179,7 +2035,6 @@ int set_dynamic_range(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { switch(dr){ case -1: @@ -2223,7 +2078,6 @@ int set_dynamic_range(int file_des) { #endif if (dr>=0) dataBytes=calculateDataBytes(); } -#endif if ((ret == OK) && dr>=0 && retval!=dr) { ret = FAIL; cprintf(RED,"%s",mess); @@ -2286,7 +2140,6 @@ int set_readout_flags(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("setting readout flags to %d\n",arg); @@ -2310,7 +2163,6 @@ int set_readout_flags(int file_des) { cprintf(RED, "Warning: %s", mess); break; } -#endif if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){ ret = FAIL; sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); @@ -2392,7 +2244,6 @@ int set_roi(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Setting ROI to:"); @@ -2405,7 +2256,6 @@ int set_roi(int file_des) { cprintf(RED, "%s",mess); } } -#endif if(ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -2462,7 +2312,6 @@ int set_speed(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("setting speed variable %d to %d\n",arg,val); @@ -2500,7 +2349,6 @@ int set_speed(int file_des) { break; } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; @@ -2595,16 +2443,13 @@ int get_last_client_ip(int file_des) { int set_port(int file_des) { - int ret=OK,ret1=OK; + ret = OK; + memset(mess, 0, sizeof(mess)); int n=0; - enum portType p_type=0; int p_number=-1; sprintf(mess,"set port failed\n"); - // receive arguments - n = receiveData(file_des,&p_type,sizeof(p_type),INT32); - if (n < 0) return printSocketReadError(); - + // receive argumets n = receiveData(file_des,&p_number,sizeof(p_number),INT32); if (n < 0) return printSocketReadError(); @@ -2616,42 +2461,26 @@ int set_port(int file_des) { cprintf(RED, "Warning: %s", mess); } else { - if (p_number<1024) { + if (p_number < 1024) { ret = FAIL; - sprintf(mess,"Port Number (%d) too low\n", p_number); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"%s port Number (%d) too low\n", + (isControlServer ? "control":"stop"), p_number); + FILE_LOG(logWARNING, (mess)); + } else { + FILE_LOG(logINFO, ("Setting %s port to %d\n", + (isControlServer ? "control":"stop"), p_number)); + sd=bindSocket(p_number); } - printf("set port %d to %d\n",p_type, p_number); - sd=bindSocket(p_number); - if (sd<0) { - ret = FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - cprintf(RED, "Warning: %s", mess); - if (sd==-10) { - ret = FAIL; - sprintf(mess,"Port %d already set\n", p_number); - cprintf(RED, "Warning: %s", mess); - } - } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; } - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n = sendData(file_des,mess,sizeof(mess),OTHER); - } else { - n = sendData(file_des,&p_number,sizeof(p_number),INT32); + Server_SendResult(file_des, INT32, 1, &p_number, sizeof(p_number)); + + if (ret!=FAIL) { closeConnection(file_des); exitServer(sockfd); sockfd=sd; } - // return ok / fail return ret; } @@ -2677,97 +2506,62 @@ int send_update(int file_des) { if (n < 0) return printSocketReadError(); -#ifdef SLS_DETECTOR_FUNCTION_LIST nm=setDynamicRange(GET_FLAG); -#endif n = sendData(file_des,&nm,sizeof(nm),INT32); if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST dataBytes=calculateDataBytes(); -#endif n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST t=setSettings(GET_SETTINGS); -#endif n = sendData(file_des,&t,sizeof(t),INT32); if (n < 0) return printSocketReadError(); - #ifdef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST nm=getThresholdEnergy(GET_FLAG); -#endif n = sendData(file_des,&nm,sizeof(nm),INT32); if (n < 0) return printSocketReadError(); #endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(FRAME_NUMBER,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(ACQUISITION_TIME,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - #ifdef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(SUBFRAME_DEADTIME,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(FRAME_PERIOD,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - #ifndef EIGERD -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif - #if !defined(EIGERD) && !defined(JUNGFRAUD) -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(GATES_NUMBER,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif - -#ifdef SLS_DETECTOR_FUNCTION_LIST retval=setTimer(CYCLES_NUMBER,GET_FLAG); -#endif n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - if (lockStatus==0) { strcpy(lastClientIP,thisClientIP); } @@ -2788,7 +2582,7 @@ int configure_mac(int file_des) { // receive arguments char arg[6][50]; - memset(arg,0,sizeof(arg)); + memset(arg, 0, sizeof(arg)); n = receiveData(file_des,arg,sizeof(arg),OTHER); #if defined(JUNGFRAUD) || defined(EIGERD) int pos[3]={0,0,0}; @@ -2822,7 +2616,6 @@ int configure_mac(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE int i; @@ -2903,7 +2696,6 @@ int configure_mac(int file_des) { } } -#endif if (differentClients) ret=FORCE_UPDATE; @@ -2919,7 +2711,7 @@ int configure_mac(int file_des) { n += sendData(file_des,&retval,sizeof(retval),INT32); #ifdef EIGERD char arg[2][50]; - memset(arg,0,sizeof(arg)); + memset(arg, 0, sizeof(arg)); sprintf(arg[0],"%llx",(long long unsigned int)idetectormacadd); sprintf(arg[1],"%x",detipad); n += sendData(file_des,arg,sizeof(arg),OTHER); @@ -2950,8 +2742,7 @@ int load_image(int file_des) { // receive arguments enum imageType index=0; - char ImageVals[dataBytes]; - memset(ImageVals,0,dataBytes); + char ImageVals[dataBytes] = {0}; n = receiveData(file_des,&index,sizeof(index),INT32); if (n < 0) return printSocketReadError(); @@ -2964,7 +2755,6 @@ int load_image(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { switch (index) { case DARK_IMAGE : @@ -2988,7 +2778,6 @@ int load_image(int file_des) { break; } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3016,7 +2805,7 @@ int read_counter_block(int file_des) { int ret=OK,ret1=OK; int n=0; char CounterVals[dataBytes]; - memset(CounterVals,0,dataBytes); + memset(CounterVals, 0, dataBytes); sprintf(mess,"Read counter block failed\n"); #ifndef GOTTHARDD @@ -3039,7 +2828,6 @@ int read_counter_block(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=readCounterBlock(startACQ,CounterVals); if (ret == FAIL) @@ -3050,7 +2838,6 @@ int read_counter_block(int file_des) { printf("%d:%d\t",i,CounterVals[i]); #endif } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3098,13 +2885,11 @@ int reset_counter_block(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=resetCounterBlock(startACQ); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3155,13 +2940,11 @@ int calibrate_pedestal(int file_des){ sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=calibratePedestal(frames); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if(ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3214,7 +2997,6 @@ int enable_ten_giga(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Enabling/Disabling 10Gbe :%d \n",arg); @@ -3227,7 +3009,6 @@ int enable_ten_giga(int file_des) { else if (differentClients) ret=FORCE_UPDATE; } -#endif #endif // ret could be swapped during sendData @@ -3274,7 +3055,6 @@ int set_all_trimbits(int file_des){ sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("setting all trimbits to %d\n",arg); @@ -3298,7 +3078,6 @@ int set_all_trimbits(int file_des){ } } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3583,7 +3362,6 @@ int set_counter_bit(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Getting/Setting/Resetting counter bit :%d \n",arg); @@ -3596,7 +3374,6 @@ int set_counter_bit(int file_des) { if (ret==OK && differentClients) ret=FORCE_UPDATE; } -#endif #endif // ret could be swapped during sendData @@ -3641,13 +3418,11 @@ int pulse_pixel(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=pulsePixel(arg[0],arg[1],arg[2]); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3693,13 +3468,11 @@ int pulse_pixel_and_move(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=pulsePixelNMove(arg[0],arg[1],arg[2]); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if(ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3747,13 +3520,11 @@ int pulse_chip(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret=pulseChip(arg); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if(ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3800,7 +3571,6 @@ int set_rate_correct(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { printf("Setting rate correction to %lld ns\n",(long long int)tau_ns); //set rate @@ -3827,7 +3597,6 @@ int set_rate_correct(int file_des) { } } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3864,13 +3633,11 @@ int get_rate_correct(int file_des) { cprintf(RED, "Warning: %s", mess); #else -#ifdef SLS_DETECTOR_FUNCTION_LIST // execute action retval = getCurrentTau(); printf("Getting rate correction %lld\n",(long long int)retval); -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -3925,7 +3692,6 @@ int set_network_parameter(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("setting network parameter mode %d to %d\n",(int)mode,value); @@ -3968,7 +3734,6 @@ int set_network_parameter(int file_des) { } } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4037,7 +3802,6 @@ int program_fpga(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { //opening file pointer to flash and telling FPGA to not touch flash if(startWritingFPGAprogram(&fp) != OK) { @@ -4125,7 +3889,6 @@ int program_fpga(int file_des) { initControlServer(); } } -#endif if (ret==OK) ret=FORCE_UPDATE; } @@ -4167,7 +3930,6 @@ int reset_fpga(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { if (isControlServer) { basictests(debugflag); // mapping of control server at lease @@ -4179,7 +3941,6 @@ int reset_fpga(int file_des) { else initStopServer(); //remapping of stop server ret = FORCE_UPDATE; } -#endif #endif // ret could be swapped during sendData @@ -4223,7 +3984,6 @@ int power_chip(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Power chip to %d\n", arg); @@ -4244,7 +4004,6 @@ int power_chip(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4292,7 +4051,6 @@ int set_activate(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Setting activate mode of detector to %d\n",arg); @@ -4304,7 +4062,6 @@ int set_activate(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4346,13 +4103,11 @@ int prepare_acquisition(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { ret = prepareAcquisition(); if (ret == FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if(ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4403,14 +4158,12 @@ int threshold_temp(int file_des) { } -#ifdef SLS_DETECTOR_FUNCTION_LIST if (ret==OK) { #ifdef VERBOSE printf("Setting Threshold Temperature to %d\n", val); #endif retval=setThresholdTemperature(val); } -#endif #ifdef VERBOSE printf("Threshold temperature is %d\n", retval); #endif @@ -4458,14 +4211,12 @@ int temp_control(int file_des) { if (n < 0) return printSocketReadError(); val=arg; -#ifdef SLS_DETECTOR_FUNCTION_LIST if (ret==OK) { #ifdef VERBOSE printf("Setting Temperature control to %d\n", val); #endif retval=setTemperatureControl(val); } -#endif #ifdef VERBOSE printf("Temperature control is %d\n", retval); #endif @@ -4513,14 +4264,12 @@ int temp_event(int file_des) { if (n < 0) return printSocketReadError(); val=arg; -#ifdef SLS_DETECTOR_FUNCTION_LIST if (ret==OK) { #ifdef VERBOSE printf("Setting Temperature Event to %d\n", val); #endif retval=setTemperatureEvent(val); } -#endif #ifdef VERBOSE printf("Temperature Event is %d\n", retval); #endif @@ -4581,7 +4330,6 @@ int auto_comp_disable(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { #ifdef VERBOSE printf("Auto Comp Disable to %d\n", arg); @@ -4599,7 +4347,6 @@ int auto_comp_disable(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4648,7 +4395,6 @@ int storage_cell_start(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else if (arg > MAX_STORAGE_CELL_VAL) { ret=FAIL; strcpy(mess,"Max Storage cell number should not exceed 15\n"); @@ -4669,7 +4415,6 @@ int storage_cell_start(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif @@ -4711,7 +4456,6 @@ int check_version(int file_des) { if (n < 0) return printSocketReadError(); // execute action -#ifdef SLS_DETECTOR_FUNCTION_LIST // check software- firmware compatibility and basic tests if (isControlServer) { @@ -4767,7 +4511,6 @@ int check_version(int file_des) { cprintf(RED, "Warning: %s", mess); } } -#endif #endif // ret could be swapped during sendData @@ -4806,14 +4549,12 @@ int software_trigger(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); } -#ifdef SLS_DETECTOR_FUNCTION_LIST else { printf("Software Trigger\n"); ret=softwareTrigger(); if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } -#endif if (ret==OK && differentClients) ret=FORCE_UPDATE; #endif diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h index 6b3b6057d..adcd6d787 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h @@ -6,12 +6,12 @@ // initialization functions int printSocketReadError(); -void setModeFlag(int); void basictests(); -void init_detector(int); +void init_detector(); int decode_function(int); const char* getFunctionName(enum detFuncs func); void function_table(); +void functionNotImplemented(); int M_nofunc(int); int M_nofuncMode(int); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 07a994a58..66fec09ce 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -27,6 +27,8 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) : detId(id), sharedMemory(0), thisDetector(0), + thisDetectorControl(0), + thisDetectorStop(0), thisReceiver(0), controlSocket(0), stopSocket(0), @@ -55,10 +57,13 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) initializeDetectorStructurePointers(); } + slsDetector::slsDetector(int multiId, int id, bool verify) : detId(id), sharedMemory(0), thisDetector(0), + thisDetectorControl(0), + thisDetectorStop(0), thisReceiver(0), controlSocket(0), stopSocket(0), @@ -85,6 +90,10 @@ slsDetector::~slsDetector() { sharedMemory->UnmapSharedMemory(thisDetector); delete sharedMemory; } + if(thisDetectorControl) + delete thisDetectorControl; + if(thisDetectorStop) + delete thisDetectorStop; if(thisReceiver) delete thisReceiver; if(controlSocket) @@ -107,8 +116,7 @@ int slsDetector::checkVersionCompatibility(portType t) { if (t == DATA_PORT) fnum = F_RECEIVER_CHECK_VERSION; int ret = FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); + char mess[MAX_STR_LENGTH] = {0}; int64_t arg = 0; // detector @@ -205,57 +213,56 @@ int slsDetector::checkVersionCompatibility(portType t) { int64_t slsDetector::getId( idMode mode) { + int fnum = F_GET_ID; + int ret = FAIL; + int arg = (int)mode; + int64_t retval = -1; - int64_t retval=-1; - int fnum=F_GET_ID,fnum2 = F_GET_RECEIVER_ID; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + FILE_LOG(logDEBUG5) << "Getting id type " << mode; -#ifdef VERBOSE - std::cout<< std::endl << "Getting id type "<< mode << std::endl; -#endif - if (mode==THIS_SOFTWARE_VERSION) { - ret=OK; - retval=GITDATE; - } else if (mode==RECEIVER_VERSION) { + // client version + if (mode == THIS_SOFTWARE_VERSION) { + ret = OK; + retval = GITDATE; + } + + // receiver version + else if (mode==RECEIVER_VERSION) { + fnum = F_GET_RECEIVER_ID; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum2, NULL, 0, &retval, sizeof(retval)); + ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); disconnectData(); } - if(ret==FORCE_UPDATE) - ret=updateReceiver(); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if(ret == FORCE_UPDATE) + ret = updateReceiver(); } - } else { + } + + // detector versions + else { if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() != OK) - ret = FAIL; - else{ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + if (connectControl() == OK){ + ret = thisDetectorControl->Client_Send(fnum, + &arg, sizeof(arg), &retval, sizeof(retval)); disconnectControl(); - if (ret==FORCE_UPDATE) + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) updateDetector(); } } } - if (ret==FAIL) { - std::cout<< "Get id failed " << std::endl; - return ret; - } else { -#ifdef VERBOSE - std::cout<< "Id "<< mode <<" is " << hex <chanoff); gain = (int*)(goff + thisDetector->gainoff); offset = (int*)(goff + thisDetector->offsetoff); + if (thisDetectorControl) { + delete thisDetectorControl; + thisDetectorControl = 0; + } + if (thisDetectorStop) { + delete thisDetectorStop; + thisDetectorStop = 0; + } if (thisReceiver) { delete thisReceiver; thisReceiver = 0; } + thisDetectorControl = new ClientInterface(controlSocket, detId, "Detector (Control server)"); + thisDetectorStop = new ClientInterface(stopSocket, detId, "Detector (Stop server)"); thisReceiver = new ClientInterface(dataSocket, detId, "Receiver"); } @@ -853,43 +870,32 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b return type; } - +// static function slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) { - int fnum=F_GET_DETECTOR_TYPE; - int retval = FAIL; - detectorType t = GENERIC; + int fnum = F_GET_DETECTOR_TYPE; + detectorType retval = GENERIC; MySocketTCP* mySocket = 0; try { mySocket = new MySocketTCP(name, cport); } catch(...) { - std::cout << "Cannot create socket to server " << name << " over port " << cport << std::endl; - return t; + FILE_LOG(logERROR) << "Cannot create socket to control server " << name << " over port " << cport; + return retval; } - -#ifdef VERBOSE - std::cout << "Getting detector type " << std::endl; -#endif + FILE_LOG(logINFO) << "Getting detector type "; if (mySocket->Connect() >= 0) { mySocket->SendDataOnly(&fnum,sizeof(fnum)); + int ret = FAIL; // not needed but is in protocol from server + mySocket->ReceiveDataOnly(&ret,sizeof(ret)); mySocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (retval!=FAIL) { - mySocket->ReceiveDataOnly(&t,sizeof(t)); -#ifdef VERBOSE - std::cout << "Detector type is "<< t << std::endl; -#endif - } else { - char mess[MAX_STR_LENGTH]; - mySocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + FILE_LOG(logDEBUG5) << "Detector type is " << retval; mySocket->Disconnect(); } else { - std::cout << "Cannot connect to server " << name << " over port " << cport << std::endl; + FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport; } delete mySocket; - return t; + return retval; } @@ -897,8 +903,6 @@ int slsDetector::setDetectorType(detectorType const type) { int ret=FAIL; int fnum=F_GET_DETECTOR_TYPE,fnum2=F_GET_RECEIVER_TYPE; detectorType retval = type; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); if (type != GET_DETECTOR_TYPE) { #ifdef VERBOSE @@ -1217,7 +1221,8 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (retval!=FAIL) { checkOnline(); - + thisDetectorControl->SetSocket(controlSocket); + thisDetectorStop->SetSocket(stopSocket); // check for version compatibility switch (thisDetector->myDetectorType) { case EIGER: @@ -1352,16 +1357,15 @@ int slsDetector::setPort(portType index, int num) { if(s==dataSocket) fnum = fnum2; s->SendDataOnly(&fnum,sizeof(fnum)); - s->SendDataOnly(&index,sizeof(index)); s->SendDataOnly(&num,sizeof(num)); s->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { char mess[MAX_STR_LENGTH]=""; s->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; - } else { - s->ReceiveDataOnly(&retval,sizeof(retval)); } + s->ReceiveDataOnly(&retval,sizeof(retval)); + s->Disconnect(); }else{ if (index == CONTROL_PORT){ @@ -1539,24 +1543,23 @@ int slsDetector::exitServer() { int slsDetector::execCommand(std::string cmd) { + int fnum = F_EXEC_COMMAND; + int ret = FAIL; + char arg[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; - char arg[MAX_STR_LENGTH]="", retval[MAX_STR_LENGTH]=""; - int fnum=F_EXEC_COMMAND; - int ret=FAIL; strcpy(arg,cmd.c_str()); + FILE_LOG(logDEBUG5) << "Sending command to detector " << arg; -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Sending command " << arg << std::endl; -#endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,MAX_STR_LENGTH); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - controlSocket->ReceiveDataOnly(retval,MAX_STR_LENGTH); - std::cout << "Detector returned:" << retval << std::endl; + ret = thisDetectorControl->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectControl(); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else + FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; } } return ret; @@ -1840,8 +1843,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings isettings) { int fnum = F_SET_SETTINGS; int ret = FAIL; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); + char mess[MAX_STR_LENGTH] = {0}; int retval = -1; int arg = isettings; #ifdef VERBOSE @@ -2417,7 +2419,7 @@ int slsDetector::configureMAC() { int ret=FAIL; int fnum=F_CONFIGURE_MAC; char mess[MAX_STR_LENGTH]=""; - char arg[6][50];memset(arg,0,sizeof(char)*6*50); + char arg[6][50] = {0}; int retval=-1; // to send 3d positions to detector @@ -2572,8 +2574,7 @@ int slsDetector::configureMAC() { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); if (thisDetector->myDetectorType == EIGER) { //rewrite detectormac, detector ip - char arg[2][50]; - memset(arg,0,sizeof(arg)); + char arg[2][50] = {0}; uint64_t idetectormac = 0; uint32_t idetectorip = 0; controlSocket->ReceiveDataOnly(arg,sizeof(arg)); @@ -3058,41 +3059,23 @@ int slsDetector::getADC(dacIndex index) { slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunicationMode( externalCommunicationMode pol) { + int fnum = F_SET_EXTERNAL_COMMUNICATION_MODE; + int ret = FAIL; int arg = pol; externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE;; - int fnum=F_SET_EXTERNAL_COMMUNICATION_MODE; - int ret=FAIL; + FILE_LOG(logDEBUG5) << "Setting communication to mode "<< pol; -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting communication to mode " << pol << std::endl; -#endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - char mess[MAX_STR_LENGTH]=""; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectControl(); - if (ret==FORCE_UPDATE) + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) updateDetector(); } - } else { - retval=GET_EXTERNAL_COMMUNICATION_MODE; - ret=FAIL; - } -#ifdef VERBOSE - std::cout<< "Communication mode "<< " set to" << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Setting communication mode failed" << std::endl; } return retval; } @@ -3101,57 +3084,25 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( externalSignalFlag pol, int signalindex) { + int fnum = F_SET_EXTERNAL_SIGNAL_FLAG; + int ret = FAIL; + int arg[2] = {signalindex, pol}; + externalSignalFlag retval = GET_EXTERNAL_SIGNAL_FLAG; + FILE_LOG(logDEBUG5) << "Setting signal "<< signalindex << " to flag" << pol; - - - int arg[2]; - externalSignalFlag retval; - int ret=FAIL; - int fnum=F_SET_EXTERNAL_SIGNAL_FLAG; - char mess[MAX_STR_LENGTH]=""; - - arg[0]=signalindex; - arg[1]=pol; - - retval=GET_EXTERNAL_SIGNAL_FLAG; - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting signal "<< signalindex << " to flag" << pol << std::endl; -#endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + ret = thisDetectorControl->Client_Send(fnum, arg, sizeof(arg), &retval, sizeof(retval)); disconnectControl(); - if (ret==FORCE_UPDATE) + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) updateDetector(); } - } else { - retval=GET_EXTERNAL_SIGNAL_FLAG; - ret=FAIL; } -#ifdef VERBOSE - std::cout<< "Signal "<< signalindex << " flag set to" << retval << std::endl; - if (ret==FAIL) { - std::cout<< "Set signal flag failed " << std::endl; - } -#endif return retval; - - - - - - } @@ -3833,10 +3784,8 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { int fnum=F_RECEIVER_STREAMING_SRC_IP; int ret = FAIL; - char arg[MAX_STR_LENGTH]; - memset(arg,0,sizeof(arg)); - char retval[MAX_STR_LENGTH]; - memset(retval,0, sizeof(retval)); + char arg[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; // if empty, give rx_hostname if (sourceIP.empty()) { @@ -3861,7 +3810,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { } // on success put IP as std::string into arg else { - dataSocket->ConvertInternetAddresstoIpString(result, arg, MAX_STR_LENGTH); + dataSocket->ConvertInternetAddresstoIpString(result, arg, sizeof(arg)); } } @@ -3881,7 +3830,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); + ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } if(ret==FAIL) { @@ -3901,10 +3850,8 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { int fnum=F_ADDITIONAL_JSON_HEADER; int ret = FAIL; - char arg[MAX_STR_LENGTH]; - memset(arg,0,sizeof(arg)); - char retval[MAX_STR_LENGTH]; - memset(retval,0, sizeof(retval)); + char arg[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; strcpy(arg, jsonheader.c_str()); @@ -3913,7 +3860,7 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { std::cout << "Sending additional json header " << arg << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); + ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } if(ret==FAIL) { @@ -4003,10 +3950,8 @@ int slsDetector::setUDPConnection() { int ret = FAIL; int fnum = F_SETUP_RECEIVER_UDP; - char args[3][MAX_STR_LENGTH]; - memset(args,0,sizeof(args)); - char retval[MAX_STR_LENGTH]; - memset(retval,0,sizeof(retval)); + char args[3][MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; //called before set up if(!strcmp(thisDetector->receiver_hostname,"none")){ @@ -4961,8 +4906,7 @@ int slsDetector::setTemperatureEvent(int val) { int slsDetector::setStoragecellStart(int pos) { int ret=FAIL; int fnum=F_STORAGE_CELL_START; - char mess[MAX_STR_LENGTH]; - memset(mess, 0, MAX_STR_LENGTH); + char mess[MAX_STR_LENGTH] = {0}; int retval=-1; #ifdef VERBOSE @@ -5929,24 +5873,22 @@ int slsDetector::exitReceiver() { } int slsDetector::execReceiverCommand(std::string cmd) { - - int fnum=F_EXEC_RECEIVER_COMMAND; - int ret=FAIL; - char arg[MAX_STR_LENGTH]; - memset(arg,0,sizeof(arg)); - char retval[MAX_STR_LENGTH]; - memset(retval,0, sizeof(retval)); + int fnum = F_EXEC_RECEIVER_COMMAND; + int ret = FAIL; + char arg[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; strcpy(arg,cmd.c_str()); + FILE_LOG(logDEBUG5) << "Sending command to receiver " << arg; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Sending to receiver the command: " << arg << std::endl; -#endif if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); + ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } + if (ret != FAIL) { + FILE_LOG(logINFO) << "Receiver " << detId << " returned:\n" << retval; + } } return ret; } @@ -6157,26 +6099,27 @@ std::string slsDetector::setFilePath(std::string s) { char retval[MAX_STR_LENGTH] = ""; strcpy(arg,s.c_str()); + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Sending file path to receiver " << arg << std::endl; + std::cout << "Sending file path to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); - disconnectData(); + if (connectData() == OK){ + ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); + disconnectData(); + } + if(ret!=FAIL){ + strcpy(thisDetector->receiver_filePath,retval); + } + else { + if(!s.empty()){ + std::cout << "file path does not exist" << std::endl; + setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); + } else + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } + if(ret==FORCE_UPDATE) + updateReceiver(); } - if(ret!=FAIL){ - strcpy(thisDetector->receiver_filePath,retval); - } - else { - if(!s.empty()){ - std::cout << "file path does not exist" << std::endl; - setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); - } else - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - } - if(ret==FORCE_UPDATE) - updateReceiver(); - return getFilePath(); } @@ -6202,7 +6145,7 @@ std::string slsDetector::setFileName(std::string s) { std::cout << "Sending file name to receiver " << arg << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); + ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } if (ret == FAIL) @@ -6309,20 +6252,21 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { int ret = FAIL; int arg = f; int retval = -1; + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ #ifdef VERBOSE - std::cout << "Sending file format to receiver " << arg << std::endl; + std::cout << "Sending file format to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); + if (connectData() == OK){ + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); + else + thisDetector->receiver_fileFormatType = (fileFormat)retval; + if(ret==FORCE_UPDATE) + updateReceiver(); } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); - else - thisDetector->receiver_fileFormatType = (fileFormat)retval; - if(ret==FORCE_UPDATE) - updateReceiver(); - return getFileFormat(); } @@ -6346,21 +6290,21 @@ int slsDetector::setFileIndex(int i) { int retval=-1; int arg = i; - + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending file index to receiver " << arg << std::endl; + std::cout << "Sending file index to receiver " << arg << std::endl; #endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); + if (connectData() == OK){ + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + } + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + else + thisDetector->receiver_fileIndex = retval; + if(ret==FORCE_UPDATE) + updateReceiver(); } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_fileIndex = retval; - if(ret==FORCE_UPDATE) - updateReceiver(); - return getFileIndex(); } @@ -7055,110 +6999,6 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { -int slsDetector::readCalibrationFile(std::string fname, double &gain, double &offset) { - - std::string str; - std::ifstream infile; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - std::istringstream ssstr(str); - ssstr >> offset >> gain; - infile.close(); - std::cout << "Calibration file loaded: " << fname << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; - return FAIL; - } - return OK; -} - - - -int slsDetector::writeCalibrationFile(std::string fname, double gain, double offset) { - - std::ofstream outfile; - outfile.open (fname.c_str()); - - if (outfile.is_open()) { - outfile << offset << " " << gain << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; - - return FAIL; - } - - outfile.close(); - return OK; -} - - -int slsDetector::readCalibrationFile(std::string fname, int *gain, int *offset) { - - std::string str; - std::ifstream infile; - double o,g; - int ig=0; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), std::ios_base::in); - if (infile.is_open()) { - //get gain and offset - for (ig=0; ig<4; ig++) { - //while ( (getline(infile,str)) > -1) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - std::istringstream ssstr(str); - ssstr >> o >> g; - offset[ig]=(int)(o*1000); - gain[ig]=(int)(g*1000); - // ig++; - if (ig>=4) - break; - } - infile.close(); - std::cout << "Calibration file loaded: " << fname << std::endl; - } else { - std::cout << "Could not open calibration file: "<< fname << std::endl; - gain[0]=0; - offset[0]=0; - return FAIL; - } - - return OK; -} - - -int slsDetector::writeCalibrationFile(std::string fname, int *gain, int *offset){ - - std::ofstream outfile; - outfile.open (fname.c_str()); - - if (outfile.is_open()) { - for (int ig=0; ig<4; ig++) - outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; - return FAIL; - } - - outfile.close(); - return OK; -} - - - slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb) { diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 13f7ef752..35c24d620 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1796,42 +1796,6 @@ private: */ int setUDPConnection(); - /** - * reads a calibration file - * @param fname file to be read - * @param gain reference to the gain variable - * @param offset reference to the offset variable - * @returns OK if successful, else FAIL or -1 - */ - static int readCalibrationFile(std::string fname, double &gain, double &offset); - - /** - * writes a calibration file - * @param fname file to be written - * @param gain - * @param offset - * @returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, double gain, double offset); - - /** - * reads a calibration file - * @param fname file to be read - * @param gain reference to the gain variable - * @param offset reference to the offset variable - * @returns OK if successful, else FAIL or -1 - */ - static int readCalibrationFile(std::string fname, int *gain, int *offset); - - /** - * writes a calibration file - * @param fname file to be written - * @param gain reference to the gain variable - * @param offset reference to the offset variable - * @returns OK if successful, else FAIL or -1 - */ - static int writeCalibrationFile(std::string fname, int *gain, int *offset); - /* * Template function to do linear interpolation between two points (Eiger only) */ @@ -1893,6 +1857,12 @@ private: /** Shared memory structure */ sharedSlsDetector *thisDetector; + /** control socket interface */ + ClientInterface *thisDetectorControl; + + /** stop socket interface */ + ClientInterface *thisDetectorStop; + /** receiver interface */ ClientInterface *thisReceiver; diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index 8d70e8602..c5257028b 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -396,33 +396,6 @@ private: }; -class PropixData : public GeneralData { - - private: - - /**bytes per pixel for calculating image size */ - const static uint32_t bytesPerPixel = 2; - - public: - - /** Constructor */ - PropixData(){ - myDetectorType = slsDetectorDefs::PROPIX; - nPixelsX = 22; - nPixelsY = 22; - headerSizeinPacket = 4; - dataSize = 1280; - packetSize = 1286; - packetsPerFrame = 2; //not really - imageSize = nPixelsX*nPixelsY*bytesPerPixel; - frameIndexMask = 0xFFFFFFFE; - frameIndexOffset = 1; - packetIndexMask = 1; - maxFramesPerFile = MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header); - defaultFifoDepth = 50000; - }; -}; class Moench02Data : public GeneralData { diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index 0b428937f..ff317a452 100644 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -897,8 +897,6 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) { myDetectorType = d; switch(myDetectorType) { case GOTTHARD: - case PROPIX: - case MOENCH: case EIGER: case JUNGFRAUCTB: case JUNGFRAU: @@ -913,8 +911,6 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) { //set detector specific variables switch(myDetectorType) { case GOTTHARD: generalData = new GotthardData(); break; - case PROPIX: generalData = new PropixData(); break; - case MOENCH: generalData = new Moench02Data(); break; case EIGER: generalData = new EigerData(); break; case JUNGFRAUCTB: generalData = new JCTBData(); break; case JUNGFRAU: generalData = new JungfrauData(); break; diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 0a395408b..d7af5d8d2 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -20,8 +20,8 @@ #include #include #include - - +#include +#include //unique_ptr slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { stop(); @@ -241,31 +241,28 @@ int slsReceiverTCPIPInterface::function_table(){ int slsReceiverTCPIPInterface::decode_function(){ ret = FAIL; - - FILE_LOG(logDEBUG1) << "waiting to receive data"; int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); if (n <= 0) { - FILE_LOG(logDEBUG1) << "ERROR reading from socket. " + FILE_LOG(logDEBUG5) << "Could not read socket. " "Received " << n << " bytes," << "fnum:" << fnum << " " "(" << getFunctionNameFromEnum((enum detFuncs)fnum) << ")"; return FAIL; } else - FILE_LOG(logDEBUG1) << "Received " << n << " bytes"; - + FILE_LOG(logDEBUG5) << "Received " << n << " bytes"; if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) { FILE_LOG(logERROR) << "Unknown function enum " << fnum; ret = (this->M_nofunc)(); } else{ - FILE_LOG(logDEBUG1) << "calling function fnum: "<< fnum << " " + FILE_LOG(logDEBUG5) << "calling function fnum: "<< fnum << " " "(" << getFunctionNameFromEnum((enum detFuncs)fnum) << ") " "located at " << flist[fnum]; ret = (this->*flist[fnum])(); if (ret == FAIL) { - FILE_LOG(logERROR) << "Failed to execute function = " << fnum << " (" + FILE_LOG(logDEBUG5) << "Failed to execute function = " << fnum << " (" << getFunctionNameFromEnum((enum detFuncs)fnum) << ")"; } } @@ -281,7 +278,7 @@ void slsReceiverTCPIPInterface::functionNotImplemented() { } -int slsReceiverTCPIPInterface::M_nofunc(){printf("111 \n"); +int slsReceiverTCPIPInterface::M_nofunc(){ ret = FAIL; memset(mess, 0, sizeof(mess)); int n = 0; @@ -302,9 +299,10 @@ int slsReceiverTCPIPInterface::M_nofunc(){printf("111 \n"); int slsReceiverTCPIPInterface::exec_command() { + ret = FAIL; memset(mess, 0, sizeof(mess)); - char cmd[MAX_STR_LENGTH]; - memset(cmd,0,sizeof(cmd)); + char cmd[MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, cmd, MAX_STR_LENGTH) == FAIL) @@ -312,14 +310,26 @@ int slsReceiverTCPIPInterface::exec_command() { // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { - ret = (system(cmd) == 0) ? OK : FAIL; - if(ret == FAIL) { + + const size_t tempsize = 256; + std::array temp; + std::string sresult; + std::shared_ptr pipe(popen(cmd, "r"), pclose); + if (!pipe) { + ret = FAIL; strcpy(mess, "Executing Command failed\n"); FILE_LOG(logERROR) << mess; + } else { + while (!feof(pipe.get())) { + if (fgets(temp.data(), tempsize, pipe.get()) != NULL) + sresult += temp.data(); + } + strncpy(retval, sresult.c_str(), MAX_STR_LENGTH); + ret = OK; } } - interface->Server_SendResult(false, ret, NULL, 0, mess); + interface->Server_SendResult(false, ret, retval, MAX_STR_LENGTH, mess); return ret; } @@ -378,17 +388,13 @@ int slsReceiverTCPIPInterface::get_last_client_ip() { int slsReceiverTCPIPInterface::set_port() { ret = OK; memset(mess, 0, sizeof(mess)); - int p_type = 0; int p_number = -1; MySocketTCP* mySocket = 0; - char oldLastClientIP[INET_ADDRSTRLEN]; - memset(oldLastClientIP, 0, sizeof(oldLastClientIP)); + char oldLastClientIP[INET_ADDRSTRLEN] = {0}; - // receive arguments - if (mySock->ReceiveDataOnly(&p_type,sizeof(p_type)) < 0 ) - return interface->Server_SocketCrash(); - if (mySock->ReceiveDataOnly(&p_number,sizeof(p_number)) < 0 ) - return interface->Server_SocketCrash(); + // get args, return if socket crashed + if (interface->Server_ReceiveArg(ret, mess, &p_number, sizeof(p_number)) == FAIL) + return FAIL; // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { @@ -450,8 +456,7 @@ int slsReceiverTCPIPInterface::update_client() { int slsReceiverTCPIPInterface::send_update() { int ind = -1; - char defaultVal[MAX_STR_LENGTH]; - memset(defaultVal, 0, sizeof(defaultVal)); + char defaultVal[MAX_STR_LENGTH] = {0}; char* path = NULL; int n = 0; @@ -581,8 +586,6 @@ int slsReceiverTCPIPInterface::set_detector_type(){ if (ret == OK) { switch(dr) { case GOTTHARD: - case PROPIX: - case MOENCH: case EIGER: case JUNGFRAUCTB: case JUNGFRAU: @@ -628,8 +631,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){ int slsReceiverTCPIPInterface::set_detector_hostname() { memset(mess, 0, sizeof(mess)); - char hostname[MAX_STR_LENGTH]; - memset(hostname, 0, sizeof(hostname)); + char hostname[MAX_STR_LENGTH] = {0}; char* retval = NULL; // get args, return if socket crashed, ret is fail if receiver is not null @@ -706,10 +708,8 @@ int slsReceiverTCPIPInterface::set_roi() { int slsReceiverTCPIPInterface::setup_udp(){ - char args[3][MAX_STR_LENGTH]; - memset(args,0,sizeof(args)); - char retval[MAX_STR_LENGTH]; - memset(retval,0,sizeof(retval)); + char args[3][MAX_STR_LENGTH] = {0}; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, args, sizeof(args), true, receiver) == FAIL) @@ -1062,8 +1062,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){ int slsReceiverTCPIPInterface::set_file_dir() { memset(mess, 0, sizeof(mess)); - char fPath[MAX_STR_LENGTH]; - memset(fPath, 0, sizeof(fPath)); + char fPath[MAX_STR_LENGTH] = {0}; char* retval=NULL; // get args, return if socket crashed, ret is fail if receiver is not null @@ -1100,8 +1099,7 @@ int slsReceiverTCPIPInterface::set_file_dir() { int slsReceiverTCPIPInterface::set_file_name() { memset(mess, 0, sizeof(mess)); - char fName[MAX_STR_LENGTH]; - memset(fName, 0, sizeof(fName)); + char fName[MAX_STR_LENGTH] = {0}; char* retval = NULL; // get args, return if socket crashed, ret is fail if receiver is not null @@ -1672,8 +1670,7 @@ int slsReceiverTCPIPInterface::set_streaming_port() { int slsReceiverTCPIPInterface::set_streaming_source_ip() { memset(mess, 0, sizeof(mess)); - char arg[MAX_STR_LENGTH]; - memset(arg, 0, sizeof(arg)); + char arg[MAX_STR_LENGTH] = {0}; char* retval=NULL; // get args, return if socket crashed, ret is fail if receiver is not null @@ -1813,8 +1810,7 @@ int slsReceiverTCPIPInterface::restream_stop(){ int slsReceiverTCPIPInterface::set_additional_json_header() { memset(mess, 0, sizeof(mess)); - char arg[MAX_STR_LENGTH]; - memset(arg, 0, sizeof(arg)); + char arg[MAX_STR_LENGTH] = {0}; char* retval=NULL; // get args, return if socket crashed, ret is fail if receiver is not null diff --git a/slsSupportLib/include/ClientInterface.cpp b/slsSupportLib/include/ClientInterface.cpp index e18ec5c7b..78bd1bbbd 100644 --- a/slsSupportLib/include/ClientInterface.cpp +++ b/slsSupportLib/include/ClientInterface.cpp @@ -1,16 +1,6 @@ #include "ClientInterface.h" -#include -#include -#include -#include -#include -#include -#include - - - ClientInterface::ClientInterface(MySocketTCP *socket, int n, std::string t): mySocket(socket), index(n), @@ -55,29 +45,7 @@ int ClientInterface::Client_Send(int fnum, mySocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret == FAIL) { if (Client_GetMesage(mess) == FAIL) - return FAIL; - } - mySocket->ReceiveDataOnly(retval, sizeOfRetval); - - return ret; -} - - -int ClientInterface::Client_Send(int fnum, - void* args, int sizeOfArgs, - void* args2, int sizeOfArgs2, - void* retval, int sizeOfRetval, - char* mess) { - - mySocket->SendDataOnly(&fnum,sizeof(fnum)); - mySocket->SendDataOnly(args, sizeOfArgs); - mySocket->SendDataOnly(args2, sizeOfArgs2); - - int ret = FAIL; - mySocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) { - if (Client_GetMesage(mess) == FAIL) - return FAIL; + return FAIL; } mySocket->ReceiveDataOnly(retval, sizeOfRetval); @@ -89,7 +57,7 @@ void ClientInterface::Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess) { // update if different clients - if (update && mySocket->differentClients) + if (update && ret == OK && mySocket->differentClients) ret = FORCE_UPDATE; // send success of operation @@ -143,7 +111,6 @@ int ClientInterface::Server_VerifyLockAndIdle(int& ret, char* mess, int lockstat void ClientInterface::Server_NullObjectError(int& ret, char* mess) { - // only for receiver ret=FAIL; strcpy(mess,"Receiver not set up. Please use rx_hostname first.\n"); FILE_LOG(logERROR) << mess; @@ -158,7 +125,7 @@ int ClientInterface::Server_SocketCrash() { int ClientInterface::Server_LockedError(int& ret, char* mess) { ret = FAIL; - sprintf(mess,"%s locked by %s\n",type.c_str(), mySocket->lastClientIP); + sprintf(mess,"Receiver locked by %s\n", mySocket->lastClientIP); FILE_LOG(logERROR) << mess; return ret; } @@ -166,8 +133,8 @@ int ClientInterface::Server_LockedError(int& ret, char* mess) { int ClientInterface::Server_NotIdleError(int& ret, char* mess, int fnum) { ret = FAIL; - sprintf(mess,"Can not execute %s when %s is not idle\n", - getFunctionNameFromEnum((enum detFuncs)fnum), type.c_str()); + sprintf(mess,"Can not execute %s when receiver is not idle\n", + getFunctionNameFromEnum((enum detFuncs)fnum)); FILE_LOG(logERROR) << mess; return ret; } diff --git a/slsSupportLib/include/ClientInterface.h b/slsSupportLib/include/ClientInterface.h index a53badb92..536c8c984 100644 --- a/slsSupportLib/include/ClientInterface.h +++ b/slsSupportLib/include/ClientInterface.h @@ -57,24 +57,8 @@ public: void* retval, int sizeOfRetval, char* mess = 0); - /** - * Send Arguments (second set) to server and get result back - * @param fnum function enum to determine what parameter - * @param args pointer to arguments - * @param sizeOfArgs argument size - * @param args2 pointer to arguments 2 - * @param sizeOfArgs2 argument size 2 - * @param retval pointer to return value - * @param sizeOfRetval return value size - * @param mess pointer to message if message required externally - */ - int Client_Send(int fnum, - void* args, int sizeOfArgs, - void* args2, int sizeOfArgs2, - void* retval, int sizeOfRetval, - char* mess = 0); - /** + /** only Receiver * Server sends result to client (also set ret to force_update if different clients) * @param update true if one must update if different clients, else false * @param ret success of operation @@ -84,7 +68,7 @@ public: */ void Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess = 0); - /** + /** only Receiver * Server receives arguments and checks if base object is null (if checkbase is true) * checking base object is null (for reciever only when it has not been configured yet) * @param ret pointer to success of operation @@ -97,8 +81,9 @@ public: */ int Server_ReceiveArg(int& ret, char* mess, void* arg, int sizeofArg,bool checkbase=false, void* base=NULL); - /** - * Server verifies if it is locked, sets and prints appropriate message if it is + /** only Receiver + * Server verifies if it is unlocked, + * sets and prints appropriate message if it is locked and different clients * @param ret pointer to sucess * @param mess message * @param lockstatus status of lock @@ -106,8 +91,9 @@ public: */ int Server_VerifyLock(int& ret, char* mess, int lockstatus); - /** - * Server verifies if it is locked and idle, sets and prints appropriate message if it is + /** only Receiver + * Server verifies if it is unlocked and idle, + * sets and prints appropriate message if it is locked and different clients * @param ret pointer to sucess * @param mess message * @param lockstatus status of lock @@ -117,20 +103,20 @@ public: */ int Server_VerifyLockAndIdle(int& ret, char* mess, int lockstatus, slsDetectorDefs::runStatus status, int fnum); - /** + /** only Receiver * Server sets and prints error message for null object error (receiver only) * @param ret pointer to sucess that will be set to FAIL * @param mess message */ void Server_NullObjectError(int& ret, char* mess); - /** + /** only Receiver * Servers prints error message for socket crash when reading * @returns always FAIL */ int Server_SocketCrash(); - /** + /** only Receiver * Servers sets and prints error message for locked server * @param ret pointer to sucess that will be set to FAIL * @param mess message @@ -138,7 +124,7 @@ public: */ int Server_LockedError(int& ret, char* mess); - /** + /** only Receiver * Servers sets and prints error message for server not being idle * @param ret pointer to sucess that will be set to FAIL * @param mess message @@ -154,7 +140,7 @@ private: */ MySocketTCP *mySocket; - /** index for debugging purposes */ + /** index for client debugging purposes */ int index; /** string for type to differentiate between Detector & Receiver in printouts */ diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 1f936c570..07cb8b2ec 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -81,11 +81,10 @@ public: GENERIC, /**< generic sls detector */ EIGER, /**< eiger */ GOTTHARD, /**< gotthard */ - MOENCH, /**< moench */ JUNGFRAU, /**< jungfrau */ JUNGFRAUCTB, /**< jungfrauCTBversion */ - PROPIX, /**< propix */ - MYTHEN3 /**< mythen 3 */ + MYTHEN3, /**< mythen 3 */ + MOENCH /**< moench */ }; From dfad145e1492e961c95063aa5b2f54e5e1b418a0 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 18 Oct 2018 18:08:34 +0200 Subject: [PATCH 2/7] still in the process of interfacing det and client --- .../slsDetectorServer/communication_funcs.c | 6 +- .../slsDetectorServer_funcs.c | 1351 +++++------------ .../slsDetectorServer_funcs.h | 2 + .../slsDetector/slsDetector.cpp | 195 +-- .../slsDetector/slsDetectorCommand.cpp | 19 +- slsSupportLib/include/sls_detector_defs.h | 2 - 6 files changed, 468 insertions(+), 1107 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.c b/slsDetectorServers/slsDetectorServer/communication_funcs.c index beb439ea2..a6ece1276 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.c @@ -548,13 +548,13 @@ int Server_VerifyLock() { void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) { - // update if different clients - if (update && ret == OK && differentClients) + // update if different clients (ret can be ok or acquisition finished), not fail to not overwrite e message + if (update && ret != FAIL && differentClients) ret = FORCE_UPDATE; // send success of operation int ret1 = ret; - sendData(fileDes, &ret1,sizeof(ret1), INT32); + sendData(fileDes, &ret1,sizeof(ret1), INT32);/* if < 0, return , socket crash*/ if(ret == FAIL) { // send error message if (strlen(mess)) diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 704b56990..6e020da88 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -40,7 +40,9 @@ int dataBytes = 10; #ifdef EIGERD uint32_t dhcpipad = 0; #endif - +#ifdef GOTTHARD +int digitalTestBit = 0; +#endif @@ -266,6 +268,25 @@ void functionNotImplemented() { FILE_LOG(logERROR, (mess)); } +void modeNotImplemented(char* modename, int mode) { + ret = FAIL; + sprintf(mess, "%s (%d) is not implemented for this detector\n", modename, mode); + FILE_LOG(logWARNING,(mess)); +} + +void validate(int arg, int retval, char* modename, int hex) { + if (ret == OK && arg != -1 && retval != arg) { + ret = FAIL; + if (hex) + sprintf(mess, "Could not set %s. Set 0x%x, but got 0x%x\n", + modename, arg, retval); + else + sprintf(mess, "Could not set %s. Set %d, but got %d\n", + modename, arg, retval); + FILE_LOG(logERROR,(mess)); + } +} + int M_nofunc(int file_des){ ret = FAIL; @@ -316,9 +337,10 @@ int exec_command(int file_des) { if (receiveData(file_des, cmd, MAX_STR_LENGTH, OTHER) < 0) return printSocketReadError(); - if (Server_VerifyLock() != FAIL) { + FILE_LOG(logINFO, ("Executing command (%s)\n", cmd)); - FILE_LOG(logINFO, ("Executing command (%s)\n", cmd)); + // set + if (Server_VerifyLock() != FAIL) { FILE* sysFile = popen(cmd, "r"); const size_t tempsize = 256; char temp[tempsize]; @@ -363,32 +385,28 @@ int get_detector_type(int file_des) { int set_external_signal_flag(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int arg[2] = {-1,-1}; + int args[2] = {-1,-1}; enum externalSignalFlag retval= GET_EXTERNAL_SIGNAL_FLAG; - if (receiveData(file_des, arg, sizeof(arg), INT32) < 0) + if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); #ifndef GOTTHARDD functionNotImplemented(); #else - int signalindex = arg[0]; - enum externalSignalFlag flag = arg[1]; + int signalindex = args[0]; + enum externalSignalFlag flag = args[1]; + FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); // set if ((flag != GET_EXTERNAL_SIGNAL_FLAG) && (Server_VerifyLock() != FAIL)) { - FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); setExtSignal(signalindex, flag); } // get retval = getExtSignal(signalindex); - if (flag != GET_EXTERNAL_SIGNAL_FLAG && retval != flag) { - ret = FAIL; - sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", - signalindex, flag, retval); - FILE_LOG(logERROR,(mess)); - } + validate((int)flag, (int)retval, "external signal flag", 1); FILE_LOG(logDEBUG5, ("External Signal Flag: %d\n", retval)); +} #endif Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -408,6 +426,8 @@ int set_external_communication_mode(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting external communication mode to %d\n", arg)); + // set if ((arg != GET_EXTERNAL_COMMUNICATION_MODE) && (Server_VerifyLock() != FAIL)) { switch (arg) { @@ -417,19 +437,16 @@ int set_external_communication_mode(int file_des) { case GATE_FIX_NUMBER: case BURST_TRIGGER: #endif - FILE_LOG(logDEBUG5,("Setting external communication mode to %d\n", arg)); setTiming(arg); break; default: - ret = FAIL; - sprintf(mess, "Timing mode (%d) is not implemented for this detector\n", (int)arg); - FILE_LOG(logWARNING,(mess)); + modeNotImplemented("Timing mode", (int)arg); break; } } - // get retval = getTiming(); + validate((int)arg, (int)retval, "timing mode", 0); FILE_LOG(logDEBUG5, ("Timing Mode: %d\n",retval)); Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -449,6 +466,8 @@ int get_id(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Getting Id %d\n", arg)); + // get switch (arg) { #if defined(EIGERD) || defined(JUNGFRAUD) @@ -461,9 +480,7 @@ int get_id(int file_des) { FILE_LOG(logDEBUG5, ("Id(%d): %lld\n", retval)); break; default: - ret = FAIL; - sprintf(mess,"ID Index (%d) is not implemented for this detector\n", (int) arg); - FILE_LOG(logWARNING,(mess)); + modeNotImplemented("ID Index", (int)arg); break; } @@ -477,376 +494,310 @@ int get_id(int file_des) { int digital_test(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"get digital test failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1, -1}; + int retval = -1; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); #ifdef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Digital Test) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else + enum digitalTestMode mode = args[0]; + int ival = args[1]; - enum digitalTestMode arg=0; - int ival=-1; + FILE_LOG(logDEBUG5, ("Digital test, mode = %d\n", mode)); - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - if (arg == DIGITAL_BIT_TEST) { - n = receiveData(file_des,&ival,sizeof(ival),INT32); - if (n < 0) return printSocketReadError(); - } - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef VERBOSE - printf("Digital test mode %d\n",arg ); -#endif - switch (arg) { - -#ifdef GOTTHARD + // set + if (Server_VerifyLock() != FAIL) { + switch (mode) { +#ifdef GOTTHARD: case DIGITAL_BIT_TEST: - retval=0; + FILE_LOG(logDEBUG5, ("Setting digital test bit: %d\n", ival)); + if (ival >= 0) + digitalTestBit = (ival > 0) ? 1 : 0; + retval = digitalTestBit; break; - -#elif JUNGFRAUD +#endif case DETECTOR_FIRMWARE_TEST: case DETECTOR_BUS_TEST: -#endif - retval=detectorTest(arg); + retval = detectorTest(mode); + FILE_LOG(logDEBUG5, ("Digital Test (%d): %d\n", mode, retval)); break; default: - ret = FAIL; - sprintf(mess,"Digital Test Mode (%d) is not implemented for this detector\n",(int)arg); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Digital Test Mode", (int)mode); break; } } -#ifdef VERBOSE - printf("digital test result is 0x%x\n", retval); #endif - if (differentClients) - ret=FORCE_UPDATE; -#endif + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // send ok / fail - // ret could be swapped during sendData - ret1 = ret; - n = sendData(file_des,&ret1,sizeof(ret),INT32); - if (ret!=FAIL) { - // send return argument - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail return ret; - } + + + int set_dac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg[2]={-1,-1}; - int val=-1; - enum dacIndex ind=0; - int retval[2]={-1,-1}; - int mV=0; - sprintf(mess,"set DAC failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[3] = {-1, -1, -1}; + int retval[2] = {-1, -1}; - // receive arguments - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - ind=arg[0]; - mV=arg[1]; + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); - n = receiveData(file_des,&val,sizeof(val),INT32); - if (n < 0) return printSocketReadError(); + enum dacIndex ind = args[0]; + int mV = args[1]; + int val = args[2]; + enum DACINDEX serverDacIndex = 0; // check if dac exists for this detector - enum DACINDEX idac=0; #ifdef JUNGFRAUD if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Dac Index", (int)ind); }else - idac = ind; + serverDacIndex = ind; #else switch (ind) { #ifdef GOTTHARDD case G_VREF_DS : - break; case G_VCASCN_PB: - break; case G_VCASCP_PB: - break; case G_VOUT_CM: - break; case G_VCASC_OUT: - break; case G_VIN_CM: - break; case G_VREF_COMP: - break; case G_IB_TESTC: - break; case HV_POT: - break; + break; #elif EIGERD case TRIMBIT_SIZE: - idac = VTR; + serverDacIndex = VTR; break; case THRESHOLD: - idac = VTHRESHOLD; + serverDacIndex = VTHRESHOLD; break; case E_SvP: - idac = SVP; + serverDacIndex = SVP; break; case E_SvN: - idac = SVN; + serverDacIndex = SVN; break; case E_Vtr: - idac = VTR; + serverDacIndex = VTR; break; case E_Vrf: - idac = VRF; + serverDacIndex = VRF; break; case E_Vrs: - idac = VRS; + serverDacIndex = VRS; break; case E_Vtgstv: - idac = VTGSTV; + serverDacIndex = VTGSTV; break; case E_Vcmp_ll: - idac = VCMP_LL; + serverDacIndex = VCMP_LL; break; case E_Vcmp_lr: - idac = VCMP_LR; + serverDacIndex = VCMP_LR; break; case E_cal: - idac = CAL; + serverDacIndex = CAL; break; case E_Vcmp_rl: - idac = VCMP_RL; + serverDacIndex = VCMP_RL; break; case E_Vcmp_rr: - idac = VCMP_RR; + serverDacIndex = VCMP_RR; break; case E_rxb_rb: - idac = RXB_RB; + serverDacIndex = RXB_RB; break; case E_rxb_lb: - idac = RXB_LB; + serverDacIndex = RXB_LB; break; case E_Vcp: - idac = VCP; + serverDacIndex = VCP; break; case E_Vcn: - idac = VCN; + serverDacIndex = VCN; break; case E_Vis: - idac = VIS; + serverDacIndex = VIS; break; case HV_NEW: - break; case IO_DELAY: break; - /* -#elif JUNGFRAUD - case V_DAC0: - idac = VB_COMP; - break; - case V_DAC1: - idac = VDD_PROT; - break; - case V_DAC2: - idac = VIN_COM; - break; - case V_DAC3: - idac = VREF_PRECH; - break; - case V_DAC4: - idac = VB_PIXBUF; - break; - case V_DAC5: - idac = VB_DS; - break; - case V_DAC6: - idac = VREF_DS; - break; - case V_DAC7: - idac = VREF_COMP; - break; - case HV_POT: - break; - */ #elif MYTHEN3D case M_vIpre: - idac = vIpre; + serverDacIndex = vIpre; break; case M_vIbias: - idac = vIbias; + serverDacIndex = vIbias; break; case PREAMP: - idac = Vrf; + serverDacIndex = Vrf; break; case SHAPER1: - idac = VrfSh; + serverDacIndex = VrfSh; break; case M_vIinSh: - idac = vIinSh; + serverDacIndex = vIinSh; break; case M_VdcSh: - idac = VdcSh; + serverDacIndex = VdcSh; break; case M_Vth2: - idac = Vth2; + serverDacIndex = Vth2; break; case M_VPL: - idac = VPL; + serverDacIndex = VPL; break; case THRESHOLD: - idac = Vth1; + serverDacIndex = Vth1; break; case M_Vth3: - idac = Vth3; + serverDacIndex = Vth3; break; case TRIMBIT_SIZE: - idac = Vtrim; + serverDacIndex = Vtrim; break; case M_casSh: - idac = casSh; + serverDacIndex = casSh; break; case M_cas: - idac = cas; + serverDacIndex = cas; break; case M_vIbiasSh: - idac = vIbiasSh; + serverDacIndex = vIbiasSh; break; case M_vIcin: - idac = vIcin; + serverDacIndex = vIcin; break; case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu - idac = VPH; + serverDacIndex = VPH; break; case M_vIpreOut: - idac = vIpreOut; + serverDacIndex = vIpreOut; break; case V_POWER_A: - idac = V_A; + serverDacIndex = V_A; break; case V_POWER_B: - ipwr = V_B; + serverDacIndex = V_B; break; case V_POWER_IO: - idac = V_IO; + serverDacIndex = V_IO; break; case V_POWER_CHIP: - idac = V_CHIP; + serverDacIndex = V_CHIP; break; case V_LIMIT: - idac = V_LIM; + serverDacIndex = V_LIM; break; #endif default: - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Dac Index", (int)ind); break; } #endif - // execute action -#ifdef VERBOSE - printf("Setting DAC %d to %d \n", idac, val); -#endif - int temp; - if (ret==OK) { - if (differentClients && lockStatus && val!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } else { + // index exists + if (ret == OK) { + + FILE_LOG(logDEBUG5, ("Setting DAC %d to %d %s\n", serverDacIndex, val, + (mV ? "mV" : "dac units"))); + + // set & get + if ((val == -1) || ((val != -1) && (Server_VerifyLock() != FAIL))) { + switch(ind) { + + // io delay #ifdef EIGERD - //iodelay - if(ind == IO_DELAY) - retval[0] = setIODelay(val); - //high voltage - else + case IO_DELAY: + retval[0] = setIODelay(val); + FILE_LOG(logDEBUG5, ("IODelay: %d\n", retval[0])); + break; #endif - if((ind == HV_POT) || (ind == HV_NEW)) { - retval[0] = setHighVoltage(val); + + // high voltage + case HV_POT: + case HV_NEW: + retval[0] = setHighVoltage(val); + FILE_LOG(logDEBUG5, ("High Voltage: %d\n", retval[0])); #ifdef EIGERD - if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { - ret = FAIL; - if(retval[0] == -1) - sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val); - else if(retval[0] == -2) - strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n"); - else if(retval[0] == -3) - strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n"); - cprintf(RED, "Warning: %s", mess); - } + if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { + ret = FAIL; + if(retval[0] == -1) + sprintf(mess, "Setting high voltage failed. Bad value %d. " + "The range is from 0 to 200 V.\n",val); + else if(retval[0] == -2) + strcpy(mess, "Setting high voltage failed. " + "Serial/i2c communication failed.\n"); + else if(retval[0] == -3) + strcpy(mess, "Getting high voltage failed. " + "Serial/i2c communication failed.\n"); + FILE_LOG(logWARNING,(mess)); + } #endif - } + break; + + // power #ifdef MYTHEN3D - else if ((ind >= V_POWER_A && ind <= V_POWER_CHIP) || ind == V_LIMIT) { - printf("Setting a power %d to %d\n",ind, val); - - if (!mV) { - ret = FAIL; - strcpy(mess, "Power of index %d should be set in mV instead of DACu", idac); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - - int lim = getVLimit(); - if (ind != V_LIMIT && lim != -1 && val > lim) { - ret = FAIL; - strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", idac, val, lim); - cprintf(RED, "Warning: %s", mess); - val = -1; - } - - retval[1] = retval[0] = setPower(idac,val); - if (val >= 0 && retval[1] != val) { - ret = FAIL; - sprintf(mess,"Setting power %d failed: wrote %d but read %d\n", idac, val, retval[1]); - cprintf(RED, "Warning: %s", mess); - } + case V_POWER_A: + case V_POWER_B: + case V_POWER_C: + case V_POWER_D: + case V_POWER_IO: + case V_POWER_CHIP: + case V_LIMIT: + FILE_LOG(logDEBUG5, ("Setting a power %d to %d\n",ind, val); + if (!mV) { + ret = FAIL; + strcpy(mess, "Power of index %d should be set in mV instead of DACu", + serverDacIndex); + FILE_LOG(logWARNING,(mess)); + val = -1; } + + int lim = getVLimit(); + if (ind != V_LIMIT && lim != -1 && val > lim) { + ret = FAIL; + strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", + serverDacIndex, val, lim); + FILE_LOG(logWARNING,(mess)); + val = -1; + } + + retval[1] = retval[0] = setPower(serverDacIndex,val); + validate(val, retval[1], "power", 0); + FILE_LOG(logDEBUG5, ("Power (%d): %d\n", serverDacIndex, retval[1])); + break; #endif - //dac - else{ + + // dacs + default: #ifdef MYTHEN3D if( mV && val > MAX_DACVOLTVAL) { ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV\n", idac, val, MAX_DACVOLTVAL); - cprintf(RED, "Warning: %s", mess); + strcpy(mess, "Dac of index %d should be less than %dmV\n", + serverDacIndex, val, MAX_DACVOLTVAL); + FILE_LOG(logWARNING,(mess)); val = -1; } else if( !mV && val >= MAX_DACVAL) { ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", idac, val, MAX_DACVAL); - cprintf(RED, "Warning: %s", mess); + strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", + serverDacIndex, val, MAX_DACVAL); + FILE_LOG(logWARNING,(mess)); val = -1; } - if (val >= 0) { // conver to mV int v = val; @@ -857,17 +808,18 @@ int set_dac(int file_des) { int lim = getVLimit(); if (lim!= -1 && v > lim) { ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", idac, lim, voltageToDac(lim)); - cprintf(RED, "Warning: %s", mess); + strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", + serverDacIndex, lim, voltageToDac(lim)); + FILE_LOG(logWARNING,(mess)); val = -1; } } #endif - setDAC(idac,val,mV,retval); + setDAC(serverDacIndex, val, mV, retval); #ifdef EIGERD if(val != -1) { //changing dac changes settings to undefined - switch(idac){ + switch(serverDacIndex){ case VCMP_LL: case VCMP_LR: case VCMP_RL: @@ -875,7 +827,8 @@ int set_dac(int file_des) { case VRF: case VCP: setSettings(UNDEFINED); - cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n"); + FILE_LOG(logWARNING, ("Settings has been changed " + "to undefined (changed specific dacs)\n")); break; default: break; @@ -884,40 +837,27 @@ int set_dac(int file_des) { #endif //check if (ret == OK) { + int temp = 0; if(mV) temp = retval[1]; else temp = retval[0]; - if ((abs(temp-val)<=5) || val==-1) { + if ((abs(temp-val) <= 5) || val == -1) { ret = OK; } else { ret = FAIL; - sprintf(mess,"Setting dac %d : wrote %d but read %d\n", idac, val, temp); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"Setting dac %d : wrote %d but read %d\n", serverDacIndex, val, temp); + FILE_LOG(logWARNING,(mess)); } } - } - } - } -#ifdef VERBOSE - printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]); -#endif - - if(ret == OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); + FILE_LOG(logDEBUG5, ("Dac (%d): %d dac units and %d mV\n", serverDacIndex, retval[0], retval[1])); + break; + } + } } - // return ok / fail + Server_SendResult(file_des, INT32, 1, retval, sizeof(retval)); + return ret; } @@ -927,95 +867,68 @@ int set_dac(int file_des) { int get_adc(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg=-1; - int retval=-1; - enum dacIndex ind=0; - sprintf(mess,"get ADC failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum dacIndex ind = 0; + int retval = -1; + + if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0) + return printSocketReadError(); #ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get ADC) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - ind=arg; - - enum ADCINDEX iadc=0; + enum ADCINDEX serverAdcIndex = 0; + // get switch (ind) { -#ifdef EIGERD - case TEMPERATURE_FPGAEXT: - iadc = TEMP_FPGAEXT; - break; - case TEMPERATURE_10GE: - iadc = TEMP_10GE; - break; - case TEMPERATURE_DCDC: - iadc = TEMP_DCDC; - break; - case TEMPERATURE_SODL: - iadc = TEMP_SODL; - break; - case TEMPERATURE_SODR: - iadc = TEMP_SODR; - break; - case TEMPERATURE_FPGA: - iadc = TEMP_FPGA; - break; - case TEMPERATURE_FPGA2: - iadc = TEMP_FPGAFEBL; - break; - case TEMPERATURE_FPGA3: - iadc = TEMP_FPGAFEBR; - break; -#endif #if defined(GOTTHARD) || defined(JUNGFRAUD) case TEMPERATURE_FPGA: - iadc = TEMP_FPGA; + serverAdcIndex = TEMP_FPGA; break; case TEMPERATURE_ADC: - iadc = TEMP_ADC; + serverAdcIndex = TEMP_ADC; + break; +#elif EIGERD + case TEMPERATURE_FPGAEXT: + serverAdcIndex = TEMP_FPGAEXT; + break; + case TEMPERATURE_10GE: + serverAdcIndex = TEMP_10GE; + break; + case TEMPERATURE_DCDC: + serverAdcIndex = TEMP_DCDC; + break; + case TEMPERATURE_SODL: + serverAdcIndex = TEMP_SODL; + break; + case TEMPERATURE_SODR: + serverAdcIndex = TEMP_SODR; + break; + case TEMPERATURE_FPGA: + serverAdcIndex = TEMP_FPGA; + break; + case TEMPERATURE_FPGA2: + serverAdcIndex = TEMP_FPGAFEBL; + break; + case TEMPERATURE_FPGA3: + serverAdcIndex = TEMP_FPGAFEBR; break; #endif default: - ret = FAIL; - sprintf(mess,"Dac Index (%d) is not implemented for this detector\n",(int)ind); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Adc Index", (int)ind); break; } -#ifdef VERBOSE - printf("Getting ADC %d\n", iadc); -#endif - if (ret==OK) - retval=getADC(iadc); -#ifdef VERBOSE - printf("ADC is %f\n", retval); -#endif -#endif - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); + // valid index + if (ret == OK) { + FILE_LOG(logDEBUG5, ("Getting ADC %d\n", serverAdcIndex)); + retval = getADC(serverAdcIndex); + FILE_LOG(logDEBUG5, ("ADC(%d): %d\n", retval)); } +#endif + + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1056,23 +969,10 @@ int write_register(int file_des) { #ifdef VERBOSE printf("Data set to 0x%x\n", retval); #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; - } @@ -1099,21 +999,9 @@ int read_register(int file_des) { #ifdef VERBOSE printf("Returned value 0x%x\n", retval); #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1309,22 +1197,10 @@ int set_module(int file_des) { if(myDac != NULL) free(myDac); if(myAdc != NULL) free(myAdc); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1409,34 +1285,19 @@ int get_module(int file_des) { } } #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - ret=sendModuleGeneral(file_des, &myModule, -#ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) -#else - 1 -#endif - ); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); + Server_SendResult(file_des, INT32, 1, NULL, 0); + + // send module, 0 is to receive partially (without trimbits etc) + if (ret != FAIL) { + ret = sendModuleGeneral(file_des, &myModule, (myDetectorType == JUNGFRAU) ? 0 : 1); } - if(myChip != NULL) free(myChip); if(myChan != NULL) free(myChan); if(myDac != NULL) free(myDac); if(myAdc != NULL) free(myAdc); - // return ok / fail return ret; - } @@ -1536,20 +1397,8 @@ int set_settings(int file_des) { #endif #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); - - // return ok / fail return ret; } @@ -1580,21 +1429,10 @@ int get_threshold_energy(int file_des) { #ifdef VERBOSE printf("Threshold is %d eV\n", retval); #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1620,19 +1458,9 @@ int start_acquisition(int file_des) { if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, NULL, 0); - // return ok / fail return ret; } @@ -1655,19 +1483,9 @@ int stop_acquisition(int file_des) { if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, NULL, 0); - // return ok / fail return ret; } @@ -1701,20 +1519,10 @@ int start_readout(int file_des) { if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, NULL, 0); - // return ok / fail return ret; } @@ -1725,22 +1533,16 @@ int start_readout(int file_des) { int get_run_status(int file_des) { int ret=OK,ret1=OK; - enum runStatus s=ERROR; + enum runStatus retval=ERROR; // execute action #ifdef VERBOSE printf("Getting status\n"); #endif - s= getRunStatus(); - if (differentClients) - ret=FORCE_UPDATE; + retval = getRunStatus(); - // send ok / fail - sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - sendData(file_des,&s,sizeof(s),INT32); + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1749,71 +1551,55 @@ int get_run_status(int file_des) { int start_and_read_all(int file_des) { - int dataret1=FAIL, dataret=FAIL; + ret = FAIL; #ifdef VERBOSE printf("Starting and reading all frames\n"); #endif // execute action if (differentClients && lockStatus) { - dataret = FAIL; + ret = FAIL; sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; + + + Server_SendResult(file_des, INT32, 1 , NULL, 0); + + return ret; } startStateMachine(); read_all(file_des); - return OK; + return ret; } int read_all(int file_des) { - int dataret1=FAIL, dataret=FAIL; + ret = FAIL; int n=0; sprintf(mess, "read all frame failed\n"); // execute action if (differentClients && lockStatus) { - dataret = FAIL; + ret = FAIL; sprintf(mess,"Detector locked by %s\n",lastClientIP); cprintf(RED, "Warning: %s", mess); - // ret could be swapped during sendData - dataret1 = dataret; - // send fail - sendData(file_des,&dataret1,sizeof(dataret),INT32); - // send return argument - sendData(file_des,mess,sizeof(mess),OTHER); - // return fail - return dataret; + + Server_SendResult(file_des, INT32, 1 , NULL, 0); + + return ret; } - readFrame(&dataret, mess); - if(dataret == FAIL) + + readFrame(&ret, mess); + if(ret == FAIL) cprintf(RED,"%s\n",mess); else cprintf(GREEN,"%s",mess); - if (differentClients) - dataret=FORCE_UPDATE; + Server_SendResult(file_des, INT32, 1 , NULL, 0); - //dataret could be swapped during sendData - dataret1 = dataret; - // send finished / fail - n=sendData(file_des,&dataret1,sizeof(dataret1),INT32); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // send return argument - n=sendData(file_des,mess,sizeof(mess),OTHER); - if (n<0) return FAIL; // if called from read_all, should fail to stop talking to a closed client socket - // return finished / fail - return dataret; + return ret; } @@ -1904,20 +1690,9 @@ int set_timer(int file_des) { } } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); + Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -1994,21 +1769,8 @@ int get_time_left(int file_des) { } // end of if (ind == DELAY_AFTER_TRIGGER) #endif - if (ret==OK && differentClients) - ret=FORCE_UPDATE; + Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT64); - - // return ok / fail return ret; } @@ -2018,6 +1780,7 @@ int get_time_left(int file_des) { int set_dynamic_range(int file_des) { + int retval[2]; int ret=OK,ret1=OK; int rateret=OK,rateret1=OK; int n=0; @@ -2082,30 +1845,10 @@ int set_dynamic_range(int file_des) { ret = FAIL; cprintf(RED,"%s",mess); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - //rate correction ret - // ret could be swapped during sendData - rateret1 = rateret; - // send ok / fail - n = sendData(file_des,&rateret1,sizeof(rateret1),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); + Server_SendResult(file_des, INT32, 1, retval, sizeof(retval)); - // return ok / fail return ret; } @@ -2168,23 +1911,11 @@ int set_readout_flags(int file_des) { sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); cprintf(RED, "Warning: %s", mess); } - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; } #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -2208,7 +1939,7 @@ int set_roi(int file_des) { #else ROI* retval=0; - int retvalsize=0,retvalsize1=0; + int retvalsize=0; // receive arguments int nroi=-1; @@ -2256,34 +1987,25 @@ int set_roi(int file_des) { cprintf(RED, "%s",mess); } } - if(ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, NULL, 0); + #ifdef GOTTHARDD - else { + if (ret != FAIL) { //retvalsize could be swapped during sendData - retvalsize1=retvalsize; - sendData(file_des,&retvalsize1,sizeof(retvalsize),INT32); - int i=0; - for(i=0;i= 0) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -4220,22 +3662,10 @@ int temp_control(int file_des) { #ifdef VERBOSE printf("Temperature control is %d\n", retval); #endif - if (ret==OK && differentClients && val >= 0) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -4274,22 +3704,10 @@ int temp_event(int file_des) { printf("Temperature Event is %d\n", retval); #endif - if (ret==OK && differentClients && val >= 0) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret!=FAIL) { - n += sendData(file_des,&retval,sizeof(retval),INT32); - } else { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -4347,21 +3765,10 @@ int auto_comp_disable(int file_des) { cprintf(RED, "Warning: %s", mess); } } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -4415,21 +3822,10 @@ int storage_cell_start(int file_des) { cprintf(RED, "Warning: %s", mess); } } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } else - n += sendData(file_des,&retval,sizeof(retval),INT32); + Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - // return ok / fail return ret; } @@ -4513,16 +3909,7 @@ int check_version(int file_des) { } #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - - // return ok / fail + Server_SendResult(file_des, INT32, 1 , NULL, 0); return ret; } @@ -4555,20 +3942,10 @@ int software_trigger(int file_des) { if (ret==FAIL) cprintf(RED, "Warning: %s", mess); } - if (ret==OK && differentClients) - ret=FORCE_UPDATE; #endif - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } + Server_SendResult(file_des, INT32, 1 , NULL, 0); - // return ok / fail return ret; } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h index adcd6d787..0ac890f86 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h @@ -12,6 +12,8 @@ int decode_function(int); const char* getFunctionName(enum detFuncs func); void function_table(); void functionNotImplemented(); +void modeNotImplemented(char* modename, int mode); +void validate(int arg, int retval, char* modename, int hex); int M_nofunc(int); int M_nofuncMode(int); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 66fec09ce..d0a446944 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -870,9 +870,11 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b return type; } + // static function slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) { int fnum = F_GET_DETECTOR_TYPE; + int ret = FAIL; detectorType retval = GENERIC; MySocketTCP* mySocket = 0; @@ -883,17 +885,19 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int return retval; } - FILE_LOG(logINFO) << "Getting detector type "; + FILE_LOG(logDEBUG5) << "Getting detector type "; if (mySocket->Connect() >= 0) { mySocket->SendDataOnly(&fnum,sizeof(fnum)); - int ret = FAIL; // not needed but is in protocol from server mySocket->ReceiveDataOnly(&ret,sizeof(ret)); mySocket->ReceiveDataOnly(&retval,sizeof(retval)); - FILE_LOG(logDEBUG5) << "Detector type is " << retval; mySocket->Disconnect(); } else { FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport; } + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "Detector type is " << retval; + } + delete mySocket; return retval; } @@ -1558,10 +1562,11 @@ int slsDetector::execCommand(std::string cmd) { // handle ret if (ret == FAIL) setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else - FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; } } + if (ret != FAIL) { + FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; + } return ret; } @@ -2953,58 +2958,31 @@ int slsDetector::getDataBytesInclGapPixels() { int slsDetector::setDAC(int val, dacIndex index, int mV) { + if ((index == HV_NEW) && (thisDetector->myDetectorType == GOTTHARD)) + index = HV_POT; - int retval[2]; - retval[0] = -1; - retval[1] = -1; - int fnum=F_SET_DAC; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - int arg[2]; + int fnum = F_SET_DAC; + int ret = FAIL; + int args[3] = {(int)index, mV, val}; + int retval[2] = {-1, -1}; + FILE_LOG(logDEBUG5) << "Setting DAC "<< index << " to " << val << (mV ? "mV" : "dac units"); - if ( (index==HV_NEW) &&(thisDetector->myDetectorType == GOTTHARD)) - index=HV_POT; - - arg[0]=index; - arg[1]=mV; - - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting DAC "<< index << " to " << val << std::endl; -#endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->SendDataOnly(&val,sizeof(val)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(retval,sizeof(retval)); - if (index < thisDetector->nDacs){ - - if (dacs) { - *(dacs+index)=retval[0]; - - } - } - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + ret = thisDetectorControl->Client_Send(fnum, + args, sizeof(args), retval, sizeof(retval)); disconnectControl(); - if (ret==FORCE_UPDATE) + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) updateDetector(); - } } -#ifdef VERBOSE - std::cout<< "Dac set to "<< retval[0] << " dac units (" << retval[1] << "mV)" - << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Set dac " << index << " to " << val << " failed." << std::endl; + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "Dac index " << index << ": " + << retval[0] << " dac units (" << retval[1] << "mV)"; } if(mV) return retval[1]; @@ -3016,42 +2994,30 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { int slsDetector::getADC(dacIndex index) { + int fnum = F_GET_ADC; + int ret = FAIL; + int arg = (int)index; int retval = -1; - int fnum=F_GET_ADC; - int ret=FAIL; - int arg = index; -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Getting ADC "<< index << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Getting ADC "<< index; + if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK){ - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (adcs) { - *(adcs+index)=retval; - } - } else { - char mess[MAX_STR_LENGTH]=""; - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectStop(); - /*commented out to allow adc read during acquire, also not required - if (ret==FORCE_UPDATE) - updateDetector();*/ + if (connectControl() == OK){ + ret = thisDetectorControl->Client_Send(fnum, + &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + /*commented out to allow adc read during acquire + else if (ret == FORCE_UPDATE) + updateDetector();*/ } } -#ifdef VERBOSE - std::cout<< "ADC returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Get ADC failed " << std::endl; + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "ADC (" << index << "): " << retval; } + return retval; } @@ -3077,6 +3043,9 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication updateDetector(); } } + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "Timing Mode: " << retval; + } return retval; } @@ -3102,6 +3071,9 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( updateDetector(); } } + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "Ext Signal (" << signalindex << "): " << retval; + } return retval; } @@ -4029,43 +4001,30 @@ int slsDetector::setUDPConnection() { int slsDetector::digitalTest( digitalTestMode mode, int ival) { - int retval = -1; int fnum = F_DIGITAL_TEST; int ret = FAIL; - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Getting id of "<< mode << std::endl; -#endif + int args[2] = {mode, ival}; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending digital test of mode " << mode << ", ival " << ival; + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(&ival,sizeof(ival)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - char mess[MAX_STR_LENGTH]=""; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } + ret = thisDetectorControl->Client_Send(fnum, + args, sizeof(args), &retval, sizeof(retval)); disconnectControl(); - if (ret==FORCE_UPDATE) + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) updateDetector(); } - } else { - ret=FAIL; } -#ifdef VERBOSE - std::cout<< "Id "<< mode <<" is " << retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Get id failed " << std::endl; - return ret; - } else - return retval; + if (ret != FAIL && mode == DIGITAL_BIT_TEST) { + FILE_LOG(logDEBUG5) << "Digital test bit: " << retval; + } + + return retval; } @@ -4352,19 +4311,29 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { } // update roi in receiver - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ - int fnum=F_RECEIVER_SET_ROI; + if(ret == OK && thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + int fnum = F_RECEIVER_SET_ROI; + ret = FAIL; #ifdef VERBOSE std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl; #endif if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, - &thisDetector->nROI, sizeof(thisDetector->nROI), - thisDetector->roiLimits, thisDetector->nROI * sizeof(ROI)); + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->SendDataOnly(&thisDetector->nROI, sizeof(thisDetector->nROI)); + for(int i = 0; i < thisDetector->nROI; ++i){ + dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmin, sizeof(int)); + dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmax, sizeof(int)); + dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymin, sizeof(int)); + dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymax, sizeof(int)); + } + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret == FAIL) { + dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH); + setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); + cprintf(RED, "Receiver %d returned error: %s", detId, mess); + } disconnectData(); } - if(ret==FAIL) - setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index ffc9de7a3..3c57d5fe8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -143,6 +143,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; ++i; + /*! \page test + - firmwaretest performs the firmware test. Cannot set! Jungfrau only. Only get! + */ + descrToFuncMap[i].m_pFuncName="firmwaretest"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest; + ++i; + /*! \page test - reg [addr] [val] ??? writes to an register \c addr with \c value in hexadecimal format. */ @@ -3706,7 +3713,14 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d if (cmd=="bustest"){ if (action==PUT_ACTION) return string("cannot set ")+cmd; - sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST)); + sprintf(answer,"%d",myDet->digitalTest(DETECTOR_BUS_TEST)); + return string(answer); + } + + else if (cmd=="firmwaretest"){ + if (action==PUT_ACTION) + return string("cannot set ")+cmd; + sprintf(answer,"%d",myDet->digitalTest(DETECTOR_FIRMWARE_TEST)); return string(answer); } @@ -3716,7 +3730,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d int ival=-1; if (sscanf(args[1],"%d",&ival)) { if((ival==0)||(ival==1)){ - sprintf(answer,"0x%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival, detPos)); + sprintf(answer,"%d",myDet->digitalTest(DIGITAL_BIT_TEST,ival, detPos)); return string(answer); } else @@ -3737,6 +3751,7 @@ string slsDetectorCommand::helpDigiTest(int action) { if (action==GET_ACTION || action==HELP_ACTION) { os << "digibittest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask.Gotthard only."<< std::endl; os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Jungfrau only."<< std::endl; + os << "firmwaretest \t performs the firmware test. Jungfrau only." << std::endl; } return os.str(); } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 07cb8b2ec..8649fd686 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -365,8 +365,6 @@ public: detector IDs/versions */ enum idMode{ - MODULE_SERIAL_NUMBER, /** Date: Tue, 23 Oct 2018 16:20:40 +0200 Subject: [PATCH 3/7] eiger server compiles, client side of interface to do --- slsDetectorServers/eigerDetectorServer/Beb.c | 978 +++-- slsDetectorServers/eigerDetectorServer/Beb.h | 159 +- .../eigerDetectorServer/FebControl.c | 1325 +++--- .../eigerDetectorServer/FebControl.h | 279 +- .../eigerDetectorServer/FebInterface.c | 239 +- .../eigerDetectorServer/FebInterface.h | 53 +- .../eigerDetectorServer/HardwareIO.c | 11 - .../eigerDetectorServer/LocalLinkInterface.c | 110 +- .../eigerDetectorServer/LocalLinkInterface.h | 59 +- .../eigerDetectorServer/gitInfo.txt | 8 +- .../eigerDetectorServer/gitInfoEiger.h | 6 +- .../slsDetectorFunctionList.c | 918 +++-- .../slsDetectorServer_defs.h | 2 +- .../slsDetectorFunctionList.c | 11 +- .../mythen3DetectorServer/AD9257.h | 1 - .../mythen3DetectorServer/Makefile | 33 - .../mythen3DetectorServer/Makefile.virtual | 25 - .../mythen3DetectorServer/RegisterDefs.h | 101 - .../mythen3DetectorServer/ansi.h | 1 - .../mythen3DetectorServer/blackfin.h | 1 - .../commonServerFunctions.h | 1 - .../communication_funcs.c | 1 - .../communication_funcs.h | 1 - .../mythen3DetectorServer/gitInfo.txt | 9 - .../mythen3DetectorServer/gitInfoMythen3.h | 6 - .../mythen3DetectorServer/gitInfoMythen3Tmp.h | 6 - .../mythen3DetectorServer/mythen3Server | Bin 92440 -> 0 bytes .../mythen3DetectorServer/mythen3Server.gdb | Bin 435662 -> 0 bytes .../mythen3DetectorServer/programfpga.h | 1 - .../slsDetectorFunctionList.c | 1304 ------ .../slsDetectorFunctionList.h | 1 - .../mythen3DetectorServer/slsDetectorServer.c | 1 - .../slsDetectorServer_defs.h | 167 - .../slsDetectorServer_funcs.c | 1 - .../slsDetectorServer_funcs.h | 1 - .../mythen3DetectorServer/sls_detector_defs.h | 1 - .../sls_detector_funcs.h | 1 - .../mythen3DetectorServer/sls_receiver_defs.h | 1 - .../sls_receiver_funcs.h | 1 - .../mythen3DetectorServer/updateGitVersion.sh | 31 - .../slsDetectorServer/communication_funcs.c | 108 +- .../slsDetectorServer/communication_funcs.h | 3 +- slsDetectorServers/slsDetectorServer/logger.h | 3 +- .../slsDetectorFunctionList.h | 39 +- .../slsDetectorServer/slsDetectorServer.c | 17 +- .../slsDetectorServer_funcs.c | 3626 ++++++----------- .../slsDetectorServer_funcs.h | 6 +- .../slsDetector/slsDetector.cpp | 41 +- .../src/slsReceiverTCPIPInterface.cpp | 174 +- slsSupportLib/include/ClientInterface.cpp | 4 +- slsSupportLib/include/ClientInterface.h | 3 +- slsSupportLib/include/sls_detector_defs.h | 4 +- 52 files changed, 3442 insertions(+), 6441 deletions(-) delete mode 120000 slsDetectorServers/mythen3DetectorServer/AD9257.h delete mode 100644 slsDetectorServers/mythen3DetectorServer/Makefile delete mode 100644 slsDetectorServers/mythen3DetectorServer/Makefile.virtual delete mode 100644 slsDetectorServers/mythen3DetectorServer/RegisterDefs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/ansi.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/blackfin.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/communication_funcs.c delete mode 120000 slsDetectorServers/mythen3DetectorServer/communication_funcs.h delete mode 100644 slsDetectorServers/mythen3DetectorServer/gitInfo.txt delete mode 100644 slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h delete mode 100644 slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h delete mode 100755 slsDetectorServers/mythen3DetectorServer/mythen3Server delete mode 100755 slsDetectorServers/mythen3DetectorServer/mythen3Server.gdb delete mode 120000 slsDetectorServers/mythen3DetectorServer/programfpga.h delete mode 100644 slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c delete mode 120000 slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c delete mode 100644 slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c delete mode 120000 slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h delete mode 120000 slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h delete mode 100755 slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c index dc4e139fa..7c20c2b40 100644 --- a/slsDetectorServers/eigerDetectorServer/Beb.c +++ b/slsDetectorServers/eigerDetectorServer/Beb.c @@ -1,12 +1,8 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - -//return reversed 1 means good, 0 means failed - +#include "xfs_types.h" +#include "xparameters.h" +#include "FebRegisterDefs.h" +#include "logger.h" +#include "Beb.h" #include @@ -14,46 +10,40 @@ #include #include #include - - - -#include "xfs_types.h" -#include "xparameters.h" -#include "FebRegisterDefs.h" - -#include "Beb.h" +#include +#include #define MAX(x, y) (((x) > (y)) ? (x) : (y)) - struct BebInfo beb_infos[10]; - int bebInfoSize = 0; +struct BebInfo beb_infos[10]; +int bebInfoSize = 0; - struct LocalLinkInterface ll_beb_local,* ll_beb; +struct LocalLinkInterface ll_beb_local,* ll_beb; - struct udp_header_type udp_header; +struct udp_header_type udp_header; - int Beb_send_ndata; - unsigned int Beb_send_buffer_size; - unsigned int* Beb_send_data_raw; - unsigned int* Beb_send_data; +int Beb_send_ndata; +unsigned int Beb_send_buffer_size; +unsigned int* Beb_send_data_raw; +unsigned int* Beb_send_data; - int Beb_recv_ndata; - unsigned int Beb_recv_buffer_size; - unsigned int* Beb_recv_data_raw; - unsigned int* Beb_recv_data; +int Beb_recv_ndata; +unsigned int Beb_recv_buffer_size; +unsigned int* Beb_recv_data_raw; +unsigned int* Beb_recv_data; - short Beb_bit_mode; - int BEB_MMAP_SIZE = 0x1000; +short Beb_bit_mode; +int BEB_MMAP_SIZE = 0x1000; - int Beb_activated = 1; +int Beb_activated = 1; - uint32_t Beb_detid = 0; - int Beb_top =0; +uint32_t Beb_detid = 0; +int Beb_top =0; -void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){ +void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num) { bebInfo->beb_number=beb_num; bebInfo->serial_address=0; strcpy(bebInfo->src_mac_1GbE,""); @@ -64,18 +54,18 @@ void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){ } -int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int a){ - //address pre shifted - if(a>0xff) return 0; - bebInfo->serial_address = 0x04000000 | ((a&0xff)<<16); - return 1; +int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int a) { + //address pre shifted + if (a>0xff) return 0; + bebInfo->serial_address = 0x04000000 | ((a&0xff)<<16); + return 1; } -int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port){ - if(ten_gig){ strcpy(bebInfo->src_mac_10GbE,src_mac); strcpy(bebInfo->src_ip_10GbE,src_ip); bebInfo->src_port_10GbE = src_port;} - else { strcpy(bebInfo->src_mac_1GbE,src_mac); strcpy(bebInfo->src_ip_1GbE,src_ip); bebInfo->src_port_1GbE = src_port;} - return 1; +int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port) { + if (ten_gig) { strcpy(bebInfo->src_mac_10GbE,src_mac); strcpy(bebInfo->src_ip_10GbE,src_ip); bebInfo->src_port_10GbE = src_port;} + else { strcpy(bebInfo->src_mac_1GbE,src_mac); strcpy(bebInfo->src_ip_1GbE,src_ip); bebInfo->src_port_1GbE = src_port;} + return 1; } @@ -87,20 +77,29 @@ char* BebInfo_GetSrcIP(struct BebInfo* bebInfo, int ten_gig) {return ten_gig unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig) {return ten_gig ? bebInfo->src_port_10GbE : bebInfo->src_port_1GbE;} -void BebInfo_Print(struct BebInfo* bebInfo){ - printf("\t%d) Beb Info.\n",bebInfo->beb_number); - printf("\t\tSerial Add: 0x%x\n",bebInfo->serial_address); - printf("\t\tMAC 1GbE: %s\n",bebInfo->src_mac_1GbE); - printf("\t\tIP 1GbE: %s\n",bebInfo->src_ip_1GbE); - printf("\t\tport 1GbE: %d\n",bebInfo->src_port_1GbE); - printf("\t\tMAC 10GbE: %s\n",bebInfo->src_mac_10GbE); - printf("\t\tIP 10GbE: %s\n",bebInfo->src_ip_10GbE); - printf("\t\tport 10GbE: %d\n",bebInfo->src_port_10GbE); +void BebInfo_Print(struct BebInfo* bebInfo) { + FILE_LOG(logINFO, ( + "%d) Beb Info:\n" + "\tSerial Add: 0x%x\n" + "\tMAC 1GbE: %s\n" + "\tIP 1GbE: %s\n" + "\tPort 1GbE: %d\n" + "\tMAC 10GbE: %s\n" + "\tIP 10GbE: %s\n" + "\tPort 10GbE: %d\n", + bebInfo->beb_number, + bebInfo->serial_address, + bebInfo->src_mac_1GbE, + bebInfo->src_ip_1GbE, + bebInfo->src_port_1GbE, + bebInfo->src_mac_10GbE, + bebInfo->src_ip_10GbE, + bebInfo->src_port_10GbE)); } -void Beb_Beb(){ - +void Beb_Beb(int id) { + Beb_detid = id; Beb_send_ndata = 0; Beb_send_buffer_size = 1026; Beb_send_data_raw = malloc((Beb_send_buffer_size+1) * sizeof(unsigned int)); @@ -111,76 +110,76 @@ void Beb_Beb(){ Beb_recv_data_raw = malloc((Beb_recv_buffer_size+1) * sizeof(unsigned int)); Beb_recv_data = &Beb_recv_data_raw[1]; - udp_header= (struct udp_header_type){ - {0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC - {0x00, 0x50, 0xc2, 0x46, 0xd9, 0x02}, // SRC MAC - {0x08, 0x00}, - {0x45}, - {0x00}, - {0x00, 0x00}, - {0x00, 0x00}, - {0x40}, - {0x00}, - {0xff}, - {0x11}, - {0x00, 0x00}, - {129, 205, 205, 128}, // Src IP - {129, 205, 205, 122}, // Dst IP - {0x0f, 0xa1}, - {0x13, 0x89}, - {0x00, 0x00}, //{0x00, 0x11}, - {0x00, 0x00} - }; + udp_header= (struct udp_header_type) { + {0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC + {0x00, 0x50, 0xc2, 0x46, 0xd9, 0x02}, // SRC MAC + {0x08, 0x00}, + {0x45}, + {0x00}, + {0x00, 0x00}, + {0x00, 0x00}, + {0x40}, + {0x00}, + {0xff}, + {0x11}, + {0x00, 0x00}, + {129, 205, 205, 128}, // Src IP + {129, 205, 205, 122}, // Dst IP + {0x0f, 0xa1}, + {0x13, 0x89}, + {0x00, 0x00}, //{0x00, 0x11}, + {0x00, 0x00} + }; - if(!Beb_InitBebInfos()) exit(1); + if (!Beb_InitBebInfos()) exit(1); - printf("Printing Beb infos:\n"); - unsigned int i; - for(i=1;i 0) + if (fd > 0) Beb_close(fd,csp0base); return ret; } /* do not work at the moment */ -int Beb_SetSlaveViaSoftware(){ +int Beb_SetSlaveViaSoftware() { - if(!Beb_activated) + if (!Beb_activated) return 0; //mapping new memory @@ -347,66 +343,69 @@ int Beb_SetSlaveViaSoftware(){ //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0) - cprintf(BG_RED,"Set Slave FAIL\n"); - else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Set Slave FAIL\n")); + } else { value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET); value&=~MASTER_BIT; value|=OVERWRITE_HARDWARE_BIT; int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value); - if(newval!=value) - cprintf(BG_RED,"Could not set Slave via Software\n"); - else + if (newval!=value) { + FILE_LOG(logERROR, ("Could not set Slave via Software\n")); + } else { ret = 0; + } } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return ret; } -int Beb_Activate(int enable){ +int Beb_Activate(int enable) { //mapping new memory u_int32_t* csp0base=0; u_int32_t value = 0, ret = -1; //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0) - cprintf(BG_RED,"Deactivate FAIL\n"); - else{ - if(enable > -1){ + if (fd < 0) { + FILE_LOG(logERROR, ("Deactivate FAIL\n")); + } else { + if (enable > -1) { value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET); - printf("Deactivate register value before:%d\n",value); - if(enable) + FILE_LOG(logINFO, ("Deactivate register value before:%d\n",value)); + if (enable) value&=~DEACTIVATE_BIT; else value|=DEACTIVATE_BIT; int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value); - if(newval!=value){ - if(enable) - cprintf(BG_RED,"Could not activate via Software\n"); - else - cprintf(BG_RED,"Could not deactivate via Software\n"); + if (newval!=value) { + if (enable) { + FILE_LOG(logERROR, ("Could not activate via Software\n")); + } else { + FILE_LOG(logERROR, ("Could not deactivate via Software\n")); + } } } value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET); - if(value&DEACTIVATE_BIT) ret = 0; + if (value&DEACTIVATE_BIT) ret = 0; else ret = 1; - if(enable == -1){ - if(ret) - cprintf(BLUE,"Detector is active. Register value:%d\n", value); - else - cprintf(BG_RED,"Detector is deactivated! Register value:%d\n", value); + if (enable == -1) { + if (ret) { + FILE_LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value)); + } else { + FILE_LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value)); + } } } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); Beb_activated = ret; @@ -416,23 +415,23 @@ int Beb_Activate(int enable){ int Beb_Set32bitOverflow(int val) { - if(!Beb_activated) + if (!Beb_activated) return val; //mapping new memory u_int32_t* csp0base=0; u_int32_t valueread = 0; u_int32_t offset = FLOW_REG_OFFSET; - if(val>0) val = 1; + if (val>0) val = 1; //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Could not read register to set overflow flag in 32 bit mode. FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n")); return -1; } - else{ - if(val > -1){ + else { + if (val > -1) { // reset bit valueread = Beb_Read32(csp0base, offset); Beb_Write32(csp0base, offset,valueread & ~FLOW_REG_OVERFLOW_32_BIT_MSK); @@ -446,15 +445,15 @@ int Beb_Set32bitOverflow(int val) { valueread = (Beb_Read32(csp0base, offset) & FLOW_REG_OVERFLOW_32_BIT_MSK) >> FLOW_REG_OVERFLOW_32_BIT_OFST; } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return valueread; } -int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){ +int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val) { - if(!Beb_activated) + if (!Beb_activated) return val; @@ -464,7 +463,7 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){ u_int32_t offset = TXM_DELAY_LEFT_OFFSET; char modename[100] = ""; - switch(mode){ + switch(mode) { case TXN_LEFT: offset = TXM_DELAY_LEFT_OFFSET; strcpy(modename,"Transmission Delay Left"); @@ -480,18 +479,18 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){ case FLOWCTRL_10G: offset = FLOW_REG_OFFSET; strcpy(modename,"Flow Control for 10G"); - if(val>0) val = 1; + if (val>0) val = 1; break; - default: cprintf(BG_RED,"Unrecognized mode in network parameter: %d\n",mode); return -1; + default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1; } //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Could not read register to set network parameter. FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Could not read register to set network parameter. FAIL\n")); return -1; } - else{ - if(val > -1){ + else { + if (val > -1) { if (mode != FLOWCTRL_10G) { valueread = Beb_Read32(csp0base, offset); Beb_Write32(csp0base, offset,val); @@ -517,16 +516,16 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val){ } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return valueread; } -int Beb_ResetToHardwareSettings(){ +int Beb_ResetToHardwareSettings() { - if(!Beb_activated) + if (!Beb_activated) return 1; //mapping new memory @@ -535,18 +534,19 @@ int Beb_ResetToHardwareSettings(){ //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0) - cprintf(BG_RED,"Reset to Hardware Settings FAIL\n"); - else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Reset to Hardware Settings FAIL\n")); + } else { value = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,0); - if(value) - cprintf(BG_RED,"Could not reset to hardware settings\n"); - else + if (value) { + FILE_LOG(logERROR, ("Could not reset to hardware settings\n")); + } else { ret = 0; + } } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return ret; @@ -554,95 +554,97 @@ int Beb_ResetToHardwareSettings(){ -u_int32_t Beb_GetFirmwareRevision(){ +u_int32_t Beb_GetFirmwareRevision() { //mapping new memory u_int32_t* csp0base=0; u_int32_t value = 0; //open file pointer int fd = Beb_open(&csp0base,XPAR_VERSION); - if(fd < 0) - cprintf(BG_RED,"Firmware Revision Read FAIL\n"); - else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Firmware Revision Read FAIL\n")); + } else { value = Beb_Read32(csp0base, FIRMWARE_VERSION_OFFSET); - if(!value) - cprintf(BG_RED,"Firmware Revision Number does not exist in this version\n"); + if (!value) { + FILE_LOG(logERROR, ("Firmware Revision Number does not exist in this version\n")); + } } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return value; } -u_int32_t Beb_GetFirmwareSoftwareAPIVersion(){ +u_int32_t Beb_GetFirmwareSoftwareAPIVersion() { //mapping new memory u_int32_t* csp0base=0; u_int32_t value = 0; //open file pointer int fd = Beb_open(&csp0base,XPAR_VERSION); - if(fd < 0) - cprintf(BG_RED,"Firmware Software API Version Read FAIL\n"); - else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Firmware Software API Version Read FAIL\n")); + } else { value = Beb_Read32(csp0base, FIRMWARESOFTWARE_API_OFFSET); - if(!value) - cprintf(BG_RED,"Firmware Software API Version does not exist in this version\n"); + if (!value) { + FILE_LOG(logERROR, ("Firmware Software API Version does not exist in this version\n")); + } } //close file pointer - if(fd > 0) + if (fd > 0) Beb_close(fd,csp0base); return value; } -void Beb_ResetFrameNumber(){ +void Beb_ResetFrameNumber() { - if(!Beb_activated) + if (!Beb_activated) return; //mapping new memory to read master top module configuration u_int32_t* csp0base=0; //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Reset Frame Number FAIL\n"); - }else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Reset Frame Number FAIL\n")); + } else { //write a 1 Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 1); usleep(100000); //100ms //write a 0 Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 0); - printf("Frame Number Reset OK\n"); + FILE_LOG(logINFO, ("Frame Number Reset OK\n")); //close file pointer Beb_close(fd,csp0base); } } -void Beb_ClearBebInfos(){ +void Beb_ClearBebInfos() { //unsigned int i; - //for(i=0;i=bebInfoSize){ - printf("WriteTo index error.\n"); - return 0; - } + if (index>=bebInfoSize) { + FILE_LOG(logERROR, ("WriteTo index error.\n")); + return 0; + } - Beb_send_data_raw[0] = 0x90000000 | BebInfo_GetSerialAddress(&beb_infos[index]); - if(Local_Write(ll_beb,4,Beb_send_data_raw)!=4) return 0; + Beb_send_data_raw[0] = 0x90000000 | BebInfo_GetSerialAddress(&beb_infos[index]); + if (Local_Write(ll_beb,4,Beb_send_data_raw)!=4) return 0; - Beb_send_data_raw[0] = 0xc0000000; - if((Beb_send_ndata+1)*4!=Local_Write(ll_beb,(Beb_send_ndata+1)*4,Beb_send_data_raw)) return 0; + Beb_send_data_raw[0] = 0xc0000000; + if ((Beb_send_ndata+1)*4!=Local_Write(ll_beb,(Beb_send_ndata+1)*4,Beb_send_data_raw)) return 0; - return 1; + return 1; } -void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d){ +void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d) { unsigned int i; - if(little_endian) for(i=0;i>8) | ((d[i]&0xff000000)>>24)); //little_endian - else for(i=0;i>16)); + if (little_endian) for(i=0;i>8) | ((d[i]&0xff000000)>>24)); //little_endian + else for(i=0;i>16)); } -int Beb_SetByteOrder(){ - return 1; +int Beb_SetByteOrder() { + return 1; } -int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){ +int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port) { - if(!Beb_activated) + if (!Beb_activated) return 1; u_int32_t bram_phy_addr; @@ -757,14 +760,14 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header else bram_phy_addr = 0xC6001000; - if(!Beb_SetHeaderData(beb_number,ten_gig,dst_mac,dst_ip,dst_port)) return 0; + if (!Beb_SetHeaderData(beb_number,ten_gig,dst_mac,dst_ip,dst_port)) return 0; int fd = Beb_open(&csp0base,bram_phy_addr); - if(fd < 0){ - cprintf(BG_RED,"Set up UDP Header FAIL\n"); - }else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Set up UDP Header FAIL\n")); + } else { //read data memcpy(csp0base+header_number*16, &udp_header, sizeof(udp_header)); //close file pointer @@ -774,34 +777,17 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header } -//int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){ -// unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/ -// -// /***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send -// -// Beb_send_ndata = 14; -// Beb_send_data[0] = ten_gig ? 0x00020000 : 0x00010000; //write to fanout numbers 1 or 2 -// Beb_send_data[1] = ((header_number*8)<<16); -// if(!Beb_SetHeaderData(beb_number,ten_gig,dst_mac,dst_ip,dst_port)) return 0; -// -// Beb_SwapDataFun(1,12,&(Beb_send_data[2])); -// -// if(!Beb_WriteTo(i)) return 0; -// printf("beb dst_port:%d\n",dst_port); -// return 1; -//} - -int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port){ - unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/ - /***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send - return Beb_SetHeaderData1(BebInfo_GetSrcMAC(&beb_infos[i],ten_gig),BebInfo_GetSrcIP(&beb_infos[i],ten_gig),BebInfo_GetSrcPort(&beb_infos[i],ten_gig),dst_mac,dst_ip,dst_port); +int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port) { + unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/ + /***********************************if (!i) return 0; *************************************///i must be greater than 0, zero is the global send + return Beb_SetHeaderData1(BebInfo_GetSrcMAC(&beb_infos[i],ten_gig),BebInfo_GetSrcIP(&beb_infos[i],ten_gig),BebInfo_GetSrcPort(&beb_infos[i],ten_gig),dst_mac,dst_ip,dst_port); } -int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port){ - /* example header*/ - //static unsigned int* word_ptr = new unsigned int [16]; - /*static*/ +int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port) { + /* example header*/ + //static unsigned int* word_ptr = new unsigned int [16]; + /*static*/ /* udp_header_type udp_header = { {0x00, 0x50, 0xc5, 0xb2, 0xcb, 0x46}, // DST MAC @@ -823,46 +809,46 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* {0x00, 0x00}, //{0x00, 0x11}, {0x00, 0x00} }; -*/ + */ - if(!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0; - printf("Setting Source MAC to %s\n",src_mac); - if(!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0; - printf("Setting Source IP to %s\n",src_ip); - if(!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0; - printf("Setting Source port to %d\n",src_port); + if (!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0; + FILE_LOG(logINFO, ("Setting Source MAC to %s\n",src_mac)); + if (!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0; + FILE_LOG(logINFO, ("Setting Source IP to %s\n",src_ip)); + if (!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0; + FILE_LOG(logINFO, ("Setting Source port to %d\n",src_port)); - if(!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0; - printf("Setting Destination MAC to %s\n",dst_mac); - if(!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0; - printf("Setting Destination IP to %s\n",dst_ip); - if(!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0; - printf("Setting Destination port to %d\n",dst_port); + if (!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0; + FILE_LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac)); + if (!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0; + FILE_LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip)); + if (!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0; + FILE_LOG(logINFO, ("Setting Destination port to %d\n",dst_port)); - Beb_AdjustIPChecksum(&udp_header); + Beb_AdjustIPChecksum(&udp_header); - unsigned int* base_ptr = (unsigned int *) &udp_header; - unsigned int num_words = ( sizeof(struct udp_header_type) + 3 ) / 4; - // for(unsigned int i=0; i %s\n",macVal); + while (pch != NULL) { + if (strlen(pch)!=2) { + FILE_LOG(logERROR, ("Error: in mac address -> %s\n",macVal)); return 0; } @@ -875,15 +861,15 @@ int Beb_SetMAC(char* mac, uint8_t* dst_ptr){ return 1; } -int Beb_SetIP(char* ip, uint8_t* dst_ptr){ +int Beb_SetIP(char* ip, uint8_t* dst_ptr) { char ipVal[50];strcpy(ipVal,ip); int i = 0; char *pch = strtok (ipVal,"."); - while (pch != NULL){ - if(((i!=3) && ((strlen(pch)>3) || (strlen(pch)<1))) || ((i==3)&&((strlen(pch)<1) || (strlen(pch) > 3)))){ - printf("Error: in ip address -> %s\n",ipVal); - return 0; - } + while (pch != NULL) { + if (((i!=3) && ((strlen(pch)>3) || (strlen(pch)<1))) || ((i==3)&&((strlen(pch)<1) || (strlen(pch) > 3)))) { + FILE_LOG(logERROR, ("Error: in ip address -> %s\n",ipVal)); + return 0; + } int itemp; sscanf(pch,"%d",&itemp); @@ -894,98 +880,94 @@ int Beb_SetIP(char* ip, uint8_t* dst_ptr){ return 1; } -int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr){ - dst_ptr[0] = (port_number >> 8) & 0xff ; - dst_ptr[1] = port_number & 0xff; - return 1; +int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr) { + dst_ptr[0] = (port_number >> 8) & 0xff ; + dst_ptr[1] = port_number & 0xff; + return 1; } -void Beb_AdjustIPChecksum(struct udp_header_type *ip){ - unsigned char *cptr = (unsigned char *) ip->ver_headerlen; +void Beb_AdjustIPChecksum(struct udp_header_type *ip) { + unsigned char *cptr = (unsigned char *) ip->ver_headerlen; - ip->ip_header_checksum[0] = 0; - ip->ip_header_checksum[1] = 0; - ip->total_length[0] = 0; - ip->total_length[1] = 28; // IP + UDP Header Length - - // calc ip checksum - unsigned int ip_checksum = 0; - unsigned int i; - for(i=0; i<10; i++){ - ip_checksum += ( (cptr[2*i] << 8) + (cptr[2*i + 1]) ); - if (ip_checksum & 0x00010000) ip_checksum = (ip_checksum + 1) & 0x0000ffff; - } - - ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff ; - ip->ip_header_checksum[1] = ip_checksum & 0xff ; -} + ip->ip_header_checksum[0] = 0; + ip->ip_header_checksum[1] = 0; + ip->total_length[0] = 0; + ip->total_length[1] = 28; // IP + UDP Header Length - - -int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty){ - -// This is a dead function, will be removed in future -// ================================================== - - unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number); //zero is the global send*/ - - Beb_send_ndata = 3; - if(left_right == 1) Beb_send_data[0] = 0x00040000; - else if(left_right == 2) Beb_send_data[0] = 0x00080000; - else if(left_right == 3) Beb_send_data[0] = 0x000c0000; - else return 0; - - //packet_size/=2; - if(dst_number>0x3f) return 0; - if(packet_size>0x3ff) return 0; - if(npackets==0||npackets>0x100) return 0; - npackets--; - - - Beb_send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets; -#ifdef MARTIN - cprintf(GREEN, "Beb_send_data[1]:%X\n",Beb_send_data[1]); -#endif - Beb_send_data[2] = 0; - - Beb_SwapDataFun(0,2,&(Beb_send_data[1])); -#ifdef MARTIN - cprintf(GREEN, "Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]); -#endif - - if(Beb_activated){ - if(!Beb_WriteTo(i)) return 0; + // calc ip checksum + unsigned int ip_checksum = 0; + unsigned int i; + for(i=0; i<10; i++) { + ip_checksum += ( (cptr[2*i] << 8) + (cptr[2*i + 1]) ); + if (ip_checksum & 0x00010000) ip_checksum = (ip_checksum + 1) & 0x0000ffff; } - return 1; + ip->ip_header_checksum[0] = (ip_checksum >> 8) & 0xff ; + ip->ip_header_checksum[1] = ip_checksum & 0xff ; } -int Beb_SetUpTransferParameters(short the_bit_mode){ - if(the_bit_mode!=4&&the_bit_mode!=8&&the_bit_mode!=16&&the_bit_mode!=32) return 0; - Beb_bit_mode = the_bit_mode; - - //nimages = the_number_of_images; - // on_dst = 0; - return 1; +int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty) { + + // This is a dead function, will be removed in future + // ================================================== + + unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number); //zero is the global send*/ + + Beb_send_ndata = 3; + if (left_right == 1) Beb_send_data[0] = 0x00040000; + else if (left_right == 2) Beb_send_data[0] = 0x00080000; + else if (left_right == 3) Beb_send_data[0] = 0x000c0000; + else return 0; + + //packet_size/=2; + if (dst_number>0x3f) return 0; + if (packet_size>0x3ff) return 0; + if (npackets==0||npackets>0x100) return 0; + npackets--; + + + Beb_send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets; + FILE_LOG(logDEBUG5, ("Beb_send_data[1]:%X\n",Beb_send_data[1])); + Beb_send_data[2] = 0; + + Beb_SwapDataFun(0,2,&(Beb_send_data[1])); + FILE_LOG(logDEBUG5, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1])); + + if (Beb_activated) { + if (!Beb_WriteTo(i)) return 0; + } + + return 1; +} + + +int Beb_SetUpTransferParameters(short the_bit_mode) { + if (the_bit_mode!=4&&the_bit_mode!=8&&the_bit_mode!=16&&the_bit_mode!=32) return 0; + Beb_bit_mode = the_bit_mode; + + //nimages = the_number_of_images; + // on_dst = 0; + + return 1; } int Beb_StopAcquisition() { - if(!Beb_activated) + if (!Beb_activated) return 1; u_int32_t* csp0base=0; volatile u_int32_t valuel,valuer; //open file pointer int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR); - if(fd < 0){ - cprintf(BG_RED,"Beb Stop Acquisition FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Beb Stop Acquisition FAIL\n")); return 0; - }else{ + } else { //find value valuel = Beb_Read32(csp0base, (LEFT_OFFSET+STOP_ACQ_OFFSET)); valuer = Beb_Read32(csp0base, (RIGHT_OFFSET+STOP_ACQ_OFFSET)); @@ -996,19 +978,19 @@ int Beb_StopAcquisition() Beb_Write32(csp0base, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel&(~STOP_ACQ_BIT))); Beb_Write32(csp0base, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer&(~STOP_ACQ_BIT))); - printf("Beb Stop Acquisition OK\n"); + FILE_LOG(logINFO, ("Beb Stop Acquisition OK\n")); //close file pointer Beb_close(fd,csp0base); } return 1; } -int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait){ +int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait) { - if(!Beb_activated) + if (!Beb_activated) return 1; - if(dst_number>64) return 0; + if (dst_number>64) return 0; unsigned int header_size = 4; //4*64 bits unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets @@ -1020,12 +1002,13 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu u_int32_t send_header_command; u_int32_t send_frame_command; - if(in_two_requests) npackets/=2; + if (in_two_requests) npackets/=2; -#ifdef MARTIN - cprintf(RED, "----Beb_RequestNImages Start----\n"); - cprintf(RED, "beb_number:%X, ten_gig:%X,dst_number:%X,npackets:%X,Beb_bit_mode:%X,header_size:%X,nimages:%d,test_just_send_out_packets_no_wait:%X\n",beb_number,ten_gig,dst_number,npackets,Beb_bit_mode,header_size,nimages,test_just_send_out_packets_no_wait); -#endif + FILE_LOG(logDEBUG5, ("----Beb_RequestNImages Start----\n")); + FILE_LOG(logDEBUG5, ("beb_number:%X, ten_gig:%X,dst_number:%X, npackets:%X, " + "Beb_bit_mode:%X, header_size:%X, nimages:%d, test_just_send_out_packets_no_wait:%X\n", + beb_number, ten_gig, dst_number, npackets, Beb_bit_mode, header_size, + nimages, test_just_send_out_packets_no_wait)); // CMD_GEN core registers // @@ -1061,26 +1044,24 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu volatile u_int32_t value; //open file pointer int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR); - if(fd < 0){ - cprintf(BG_RED,"Beb Request N Images FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Beb Request N Images FAIL\n")); return 0; - }else{ - -#ifdef MARTIN - int i; - for (i=0; i < 10; i++) - printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4))); -#endif + } else { + { + int i; + for (i=0; i < 10; i++) + FILE_LOG(logDEBUG5, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); + } // Generating commands send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0; send_frame_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | packet_size << 14 | (npackets-1); - -#ifdef MARTIN - for (i=0; i < 10; i++) - printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4))); - printf("%d\n",in_two_requests); -#endif - + { + int i; + for (i=0; i < 10; i++) + FILE_LOG(logDEBUG5, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); + FILE_LOG(logDEBUG5, ("%d\n",in_two_requests)); + } //"0x20 << 8" is dst_number (0x00 for left, 0x20 for right) //Left Beb_Write32(csp0base, (LEFT_OFFSET + FIRST_CMD_PART1_OFFSET),0); @@ -1088,7 +1069,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu Beb_Write32(csp0base, (LEFT_OFFSET + SECOND_CMD_PART1_OFFSET),0); Beb_Write32(csp0base, (LEFT_OFFSET + SECOND_CMD_PART2_OFFSET),send_frame_command); value = Beb_Read32(csp0base,(LEFT_OFFSET + TWO_REQUESTS_OFFSET)); - if(in_two_requests) Beb_Write32(csp0base, (LEFT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT)); + if (in_two_requests) Beb_Write32(csp0base, (LEFT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT)); else Beb_Write32(csp0base, (LEFT_OFFSET + TWO_REQUESTS_OFFSET),(value &~(TWO_REQUESTS_BIT))); // Right @@ -1097,62 +1078,59 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu Beb_Write32(csp0base, (RIGHT_OFFSET + SECOND_CMD_PART1_OFFSET),0); Beb_Write32(csp0base, (RIGHT_OFFSET + SECOND_CMD_PART2_OFFSET),send_frame_command | right_port_value); value = Beb_Read32(csp0base,(RIGHT_OFFSET + TWO_REQUESTS_OFFSET)); - if(in_two_requests) Beb_Write32(csp0base, (RIGHT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT)); + if (in_two_requests) Beb_Write32(csp0base, (RIGHT_OFFSET + TWO_REQUESTS_OFFSET),(value | TWO_REQUESTS_BIT)); else Beb_Write32(csp0base, (RIGHT_OFFSET + TWO_REQUESTS_OFFSET),(value &~(TWO_REQUESTS_BIT))); // Set number of frames Beb_Write32(csp0base, (LEFT_OFFSET + COMMAND_COUNTER_OFFSET), nimages*(2+in_two_requests)); Beb_Write32(csp0base, (RIGHT_OFFSET + COMMAND_COUNTER_OFFSET), nimages*(2+in_two_requests)); - -#ifdef MARTIN - for (i=0; i < 10; i++) - printf("%X\n",Beb_Read32(baseaddr, (LEFT_OFFSET + i*4))); //*(ptrl+i)); - printf("%d\n",in_two_requests); -#endif - + { + int i; + for (i=0; i < 10; i++) + FILE_LOG(logDEBUG5, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i)); + FILE_LOG(logDEBUG5, ("%d\n",in_two_requests)); + } Beb_close(fd,csp0base); -#ifdef MARTIN - printf("----Beb_RequestNImages----\n"); -#endif + FILE_LOG(logDEBUG5, ("----Beb_RequestNImages----\n")); } return 1; } -int Beb_Test(unsigned int beb_number){ - printf("Testing module number: %d\n",beb_number); - +int Beb_Test(unsigned int beb_number) { + FILE_LOG(logINFO, ("Testing module number: %d\n",beb_number)); - //int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port){ - //SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000); - unsigned int index = Beb_GetBebInfoIndex(beb_number); - if(!index){ - printf("Error beb number (%d)not in list????\n",beb_number); - return 0; - } + //int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port) { + //SetUpUDPHeader(26,0,0,"60:fb:42:f4:e3:d2","129.129.205.186",22000); - unsigned int i; - for(i=0;i<64;i++){ - if(!Beb_SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)){ - printf("Error setting up header table....\n"); - return 0; - } - } + unsigned int index = Beb_GetBebInfoIndex(beb_number); + if (!index) { + FILE_LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number)); + return 0; + } - // SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1); - for(i=0;i<64;i++){ - if(!Beb_SendMultiReadRequest(beb_number,i%3+1,0,i,1,0,1)){ - printf("Error requesting data....\n"); - return 0; - } - } - + unsigned int i; + for(i=0;i<64;i++) { + if (!Beb_SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)) { + FILE_LOG(logERROR, ("Error setting up header table....\n")); + return 0; + } + } - return 1; + // SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1); + for(i=0;i<64;i++) { + if (!Beb_SendMultiReadRequest(beb_number,i%3+1,0,i,1,0,1)) { + FILE_LOG(logERROR, ("Error requesting data....\n")); + return 0; + } + } + + + return 1; } // Returns the FPGA temperature from the xps sysmon ip core @@ -1165,9 +1143,9 @@ int Beb_GetBebFPGATemp() int ret; //open file pointer int fd = Beb_open(&csp0base,XPAR_SYSMON_0_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Module Configuration FAIL\n"); - }else{ + if (fd < 0) { + FILE_LOG(logERROR, ("Module Configuration FAIL\n")); + } else { //read data ret = Beb_Read32(csp0base, FPGA_TEMP_OFFSET); temperature = ((((float)(ret)/65536.0f)/0.00198421639f ) - 273.15f)*1000; // Static conversation, copied from xps sysmon standalone driver @@ -1180,42 +1158,42 @@ int Beb_GetBebFPGATemp() void Beb_SetDetectorNumber(uint32_t detid) { - if(!Beb_activated) + if (!Beb_activated) return; uint32_t swapid = Beb_swap_uint16(detid); - //cprintf(GREEN, "detector id %d swapped %d\n", detid, swapid); + //FILE_LOG(logINFO, "detector id %d swapped %d\n", detid, swapid)); u_int32_t* csp0base=0; int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Set Detector ID FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Set Detector ID FAIL\n")); return; - }else{ + } else { uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); value &= UDP_HEADER_X_MSK; // to keep previous x value Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); - if((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) - cprintf(BG_RED,"Set Detector ID FAIL\n"); - + if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) { + FILE_LOG(logERROR, ("Set Detector ID FAIL\n")); + } value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); value &= UDP_HEADER_X_MSK; // to keep previous x value Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); - if((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) - cprintf(BG_RED,"Set Detector ID FAIL\n"); - + if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) { + FILE_LOG(logERROR, ("Set Detector ID FAIL\n")); + } Beb_close(fd,csp0base); } - printf("detector id %d has been set in udp header\n", detid); + FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid)); } int Beb_SetDetectorPosition(int pos[]) { - if(!Beb_activated) + if (!Beb_activated) return OK; - cprintf(BLUE,"Got Position values %d %d %d...\n", pos[0],pos[1], pos[2]); + FILE_LOG(logINFO, ("Got Position values %d %d %d...\n", pos[0],pos[1], pos[2])); pos[0] = Beb_swap_uint16(pos[0]); //pos[1] = Beb_swap_uint16(pos[1]); @@ -1226,10 +1204,10 @@ int Beb_SetDetectorPosition(int pos[]) { u_int32_t* csp0base=0; //open file pointer int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR); - if(fd < 0){ - cprintf(BG_RED,"Set Detector Position FAIL\n"); + if (fd < 0) { + FILE_LOG(logERROR, ("Set Detector Position FAIL\n")); return FAIL; - }else{ + } else { uint32_t value = 0; ret = OK; // x left @@ -1237,7 +1215,7 @@ int Beb_SetDetectorPosition(int pos[]) { value &= UDP_HEADER_ID_MSK; // to keep previous id value Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); - if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) + if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) ret = FAIL; // x right @@ -1245,7 +1223,7 @@ int Beb_SetDetectorPosition(int pos[]) { value &= UDP_HEADER_ID_MSK; // to keep previous id value Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); - if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) + if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) ret = FAIL; @@ -1255,7 +1233,7 @@ int Beb_SetDetectorPosition(int pos[]) { int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1)); Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST); - if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) + if (value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) ret = FAIL; // y right @@ -1263,7 +1241,7 @@ int Beb_SetDetectorPosition(int pos[]) { posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]); Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST); - if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) + if (value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) ret = FAIL; @@ -1273,7 +1251,7 @@ int Beb_SetDetectorPosition(int pos[]) { value &= UDP_HEADER_Y_MSK; // to keep previous y value Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST); - if((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) + if ((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) ret = FAIL; // z right @@ -1281,7 +1259,7 @@ int Beb_SetDetectorPosition(int pos[]) { value &= UDP_HEADER_Y_MSK; // to keep previous y value Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST); - if((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) + if ((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) ret = FAIL; @@ -1289,11 +1267,11 @@ int Beb_SetDetectorPosition(int pos[]) { Beb_close(fd,csp0base); } if (ret == OK) { - cprintf(BLUE, "Position set to...\n" + FILE_LOG(logINFO, ("Position set to...\n" "Left: [%d, %d, %d]\n" "Right:[%d, %d, %d]\n", - Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]), - Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2])); + Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]), + Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2]))); } return ret; @@ -1301,46 +1279,42 @@ int Beb_SetDetectorPosition(int pos[]) { uint16_t Beb_swap_uint16( uint16_t val) { - return (val << 8) | (val >> 8 ); + return (val << 8) | (val >> 8 ); } -int Beb_open(u_int32_t** csp0base, u_int32_t offset){ +int Beb_open(u_int32_t** csp0base, u_int32_t offset) { int fd = open("/dev/mem", O_RDWR | O_SYNC, 0); - if (fd == -1) - cprintf(BG_RED,"\nCan't find /dev/mem!\n"); - else{ -#ifdef VERBOSE - printf("/dev/mem opened\n"); -#endif + if (fd == -1) { + FILE_LOG(logERROR, ("\nCan't find /dev/mem!\n")); + } else { + FILE_LOG(logDEBUG5, ("/dev/mem opened\n")); *csp0base = (u_int32_t*)mmap(0, BEB_MMAP_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, offset); if (*csp0base == MAP_FAILED) { - cprintf(BG_RED,"\nCan't map memmory area!!\n"); + FILE_LOG(logERROR, ("\nCan't map memmory area!!\n")); fd = -1; } -#ifdef VERBOSE - else printf("CSP0 mapped %p\n",(void*)*csp0base); -#endif + else FILE_LOG(logDEBUG5, ("CSP0 mapped %p\n",(void*)*csp0base)); } return fd; } -u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset){ +u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset) { volatile u_int32_t value; value=* (u_int32_t*)(baseaddr + offset/(sizeof(u_int32_t))); return value; } -u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data){ +u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1=(u_int32_t*)(baseaddr + offset/(sizeof(u_int32_t))); *ptr1 = data; return *ptr1; } -void Beb_close(int fd,u_int32_t* csp0base){ - if(fd >= 0) +void Beb_close(int fd,u_int32_t* csp0base) { + if (fd >= 0) close(fd); munmap(csp0base,BEB_MMAP_SIZE); } diff --git a/slsDetectorServers/eigerDetectorServer/Beb.h b/slsDetectorServers/eigerDetectorServer/Beb.h index 73718db03..6ab1338e8 100644 --- a/slsDetectorServers/eigerDetectorServer/Beb.h +++ b/slsDetectorServers/eigerDetectorServer/Beb.h @@ -1,103 +1,84 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - -#ifndef BEB_H -#define BEB_H - +#pragma once #include "LocalLinkInterface.h" #include "slsDetectorServer_defs.h" - + struct BebInfo{ - unsigned int beb_number; - unsigned int serial_address; - char src_mac_1GbE[50]; - char src_mac_10GbE[50]; - char src_ip_1GbE[50]; - char src_ip_10GbE[50]; - unsigned int src_port_1GbE; - unsigned int src_port_10GbE; + unsigned int beb_number; + unsigned int serial_address; + char src_mac_1GbE[50]; + char src_mac_10GbE[50]; + char src_ip_1GbE[50]; + char src_ip_10GbE[50]; + unsigned int src_port_1GbE; + unsigned int src_port_10GbE; }; - void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num); - void BebInfo_BebDstInfo(struct BebInfo* bebInfo, unsigned int beb_num); - int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int add); - int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number); - unsigned int BebInfo_GetBebNumber(struct BebInfo* bebInfo); - unsigned int BebInfo_GetSerialAddress(struct BebInfo* bebInfo); - char* BebInfo_GetSrcMAC(struct BebInfo* bebInfo, int ten_gig); - char* BebInfo_GetSrcIP(struct BebInfo* bebInfo, int ten_gig); - unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig); - void BebInfo_Print(struct BebInfo* bebInfo); +void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num); +void BebInfo_BebDstInfo(struct BebInfo* bebInfo, unsigned int beb_num); +int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int add); +int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number); +unsigned int BebInfo_GetBebNumber(struct BebInfo* bebInfo); +unsigned int BebInfo_GetSerialAddress(struct BebInfo* bebInfo); +char* BebInfo_GetSrcMAC(struct BebInfo* bebInfo, int ten_gig); +char* BebInfo_GetSrcIP(struct BebInfo* bebInfo, int ten_gig); +unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig); +void BebInfo_Print(struct BebInfo* bebInfo); +void Beb_ClearBebInfos(); +int Beb_InitBebInfos(); +int Beb_CheckSourceStuffBebInfo(); +unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb); +void Beb_GetModuleConfiguration(int* master, int* top, int* normal); +void Beb_EndofDataSend(int tengiga); - void Beb_ClearBebInfos(); - int Beb_InitBebInfos(); - int Beb_CheckSourceStuffBebInfo(); - unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb); +int Beb_SetMasterViaSoftware(); +int Beb_SetSlaveViaSoftware(); +int Beb_Activate(int enable); +int Beb_Set32bitOverflow(int val); +int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val); +int Beb_ResetToHardwareSettings(); +u_int32_t Beb_GetFirmwareRevision(); +u_int32_t Beb_GetFirmwareSoftwareAPIVersion(); +void Beb_ResetFrameNumber(); +int Beb_WriteTo(unsigned int index); +int Beb_SetMAC(char* mac, uint8_t* dst_ptr); +int Beb_SetIP(char* ip, uint8_t* dst_ptr); +int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr); +void Beb_AdjustIPChecksum(struct udp_header_type *ip); + +int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port); +int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port); + +void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d); +int Beb_SetByteOrder(); +void Beb_Beb(); +int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port); +int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port); + +/*int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);*/ +int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty); + +int Beb_StopAcquisition(); +int Beb_SetUpTransferParameters(short the_bit_mode); +/*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait=0); //all images go to the same destination!*/ +int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait); + +int Beb_Test(unsigned int beb_number); + +int Beb_GetBebFPGATemp(); + +void Beb_SetDetectorNumber(uint32_t detid); +int Beb_SetDetectorPosition(int pos[]); + +uint16_t Beb_swap_uint16( uint16_t val); +int Beb_open(u_int32_t** csp0base, u_int32_t offset); +u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset); +u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data); +void Beb_close(int fd,u_int32_t* csp0base); - void Beb_GetModuleConfiguration(int* master, int* top, int* normal); - void Beb_EndofDataSend(int tengiga); - - int Beb_SetMasterViaSoftware(); - int Beb_SetSlaveViaSoftware(); - int Beb_Activate(int enable); - int Beb_Set32bitOverflow(int val); - int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val); - int Beb_ResetToHardwareSettings(); - u_int32_t Beb_GetFirmwareRevision(); - u_int32_t Beb_GetFirmwareSoftwareAPIVersion(); - void Beb_ResetFrameNumber(); - - int Beb_WriteTo(unsigned int index); - - int Beb_SetMAC(char* mac, uint8_t* dst_ptr); - int Beb_SetIP(char* ip, uint8_t* dst_ptr); - int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr); - void Beb_AdjustIPChecksum(struct udp_header_type *ip); - - int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port); - int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port); - - void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d); - int Beb_SetByteOrder(); - - - void Beb_Beb(); - - - int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port); - int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port); - - /*int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);*/ - int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty); - - int Beb_StopAcquisition(); - int Beb_SetUpTransferParameters(short the_bit_mode); - /*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait=0); //all images go to the same destination!*/ - int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait); - - int Beb_Test(unsigned int beb_number); - - int Beb_GetBebFPGATemp(); - - void Beb_SetDetectorNumber(uint32_t detid); - int Beb_SetDetectorPosition(int pos[]); - - uint16_t Beb_swap_uint16( uint16_t val); - int Beb_open(u_int32_t** csp0base, u_int32_t offset); - u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset); - u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data); - void Beb_close(int fd,u_int32_t* csp0base); - -#endif - diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index aa63dbab7..7ee4fb6bc 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -1,10 +1,8 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - +#include "FebRegisterDefs.h" +#include "FebControl.h" +#include "Beb.h" +#include "slsDetectorServer_defs.h" +#include "logger.h" #include #include @@ -14,18 +12,14 @@ #include #include // POSIX terminal control definitions(CS8, CREAD, CLOCAL..) #include - -#include "FebRegisterDefs.h" -#include "FebControl.h" -#include "Beb.h" -#include "slsDetectorServer_defs.h" +#include +#include - -//GetDAQStatusRegister(512,current_mode_bits_from_fpga)){ +//GetDAQStatusRegister(512,current_mode_bits_from_fpga)) { unsigned int Module_ndacs = 16; -char Module_dac_names[16][10]={"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"};; +char Module_dac_names[16][10]={"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"}; @@ -68,7 +62,7 @@ int Feb_Control_activated = 1; int Feb_Control_hv_fd = -1; -void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){ +void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top) { unsigned int i; mod->module_number = number; mod->top_address_valid = 1; @@ -86,7 +80,7 @@ void Module_Module(struct Module* mod,unsigned int number, unsigned int address_ } -void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom){ +void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom) { unsigned int i; mod->module_number = number; mod->top_address_valid = 0; @@ -108,7 +102,7 @@ void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int ad -void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom){ +void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom) { unsigned int i; mod->module_number = number; mod->top_address_valid = 1; @@ -154,23 +148,23 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i) -void Feb_Control_activate(int activate){ +void Feb_Control_activate(int activate) { Feb_Control_activated = activate; } -int Feb_Control_IsBottomModule(){ - if(Module_BottomAddressIsValid(&modules[Feb_Control_current_index])) +int Feb_Control_IsBottomModule() { + if (Module_BottomAddressIsValid(&modules[Feb_Control_current_index])) return 1; return 0; } -int Feb_Control_GetModuleNumber(){ +int Feb_Control_GetModuleNumber() { return Feb_Control_module_number; } -void Feb_Control_FebControl(){ +void Feb_Control_FebControl() { Feb_Control_staticBits=Feb_Control_acquireNReadoutMode=Feb_Control_triggerMode=Feb_Control_externalEnableMode=Feb_Control_subFrameMode=0; Feb_Control_trimbit_size=263680; Feb_Control_last_downloaded_trimbits = malloc(Feb_Control_trimbit_size * sizeof(int)); @@ -180,7 +174,7 @@ void Feb_Control_FebControl(){ -int Feb_Control_Init(int master, int top, int normal, int module_num){ +int Feb_Control_Init(int master, int top, int normal, int module_num) { unsigned int i; Feb_Control_module_number = 0; Feb_Control_current_index = 0; @@ -193,7 +187,7 @@ int Feb_Control_Init(int master, int top, int normal, int module_num){ Feb_Control_module_number = (module_num & 0xFF); int serial = !top; - printf("serial: %d\n",serial); + FILE_LOG(logDEBUG5, ("serial: %d\n",serial)); Feb_Control_current_index = 1; @@ -205,12 +199,12 @@ int Feb_Control_Init(int master, int top, int normal, int module_num){ unsigned int nfebs = 0; unsigned int* feb_list = malloc(moduleSize*4 * sizeof(unsigned int)); - for(i=1;i3){ - cprintf(RED,"Error SetIDelay chip_pos %d doesn't exist.\n",chip_pos);; + if (chip_pos>3) { + FILE_LOG(logERROR, ("SetIDelay chip_pos %d doesn't exist.\n",chip_pos)); return 0; } unsigned int module_index=0; - if(!Feb_Control_GetModuleIndex(module_num,&module_index)){ - cprintf(RED,"Error could not set i delay module number %d invalid.\n",module_num); + if (!Feb_Control_GetModuleIndex(module_num,&module_index)) { + FILE_LOG(logERROR, ("could not set i delay module number %d invalid.\n",module_num)); return 0; } int ok = 1; - if(chip_pos/2==0){ //left fpga - if(Module_TopAddressIsValid(&modules[module_index])){ - if(Feb_Control_SendIDelays(Module_GetTopLeftAddress(&modules[module_index]),chip_pos%2==0,0xffffffff,ndelay_units)){ - if(module_index!=0) Module_SetTopIDelay(&modules[module_index],chip_pos,ndelay_units); - else{ + if (chip_pos/2==0) { //left fpga + if (Module_TopAddressIsValid(&modules[module_index])) { + if (Feb_Control_SendIDelays(Module_GetTopLeftAddress(&modules[module_index]),chip_pos%2==0,0xffffffff,ndelay_units)) { + if (module_index!=0) Module_SetTopIDelay(&modules[module_index],chip_pos,ndelay_units); + else { for(i=0;i0x3ff) ndelay_units=0x3ff; +int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units) { + if (ndelay_units>0x3ff) ndelay_units=0x3ff; // this is global unsigned int delay_data_valid_nclks = 15 - ((ndelay_units&0x3c0)>>6); //data valid delay upto 15 clks ndelay_units &= 0x3f; @@ -520,18 +525,19 @@ int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int chan unsigned int set_left_delay_channels = chip_lr ? channels:0; unsigned int set_right_delay_channels = chip_lr ? 0:channels; - printf("\tSetting delays of "); - if(set_left_delay_channels!=0) printf("left chips of dst_num %d",dst_num); - else if(set_right_delay_channels!=0) printf("right chips of dst_num %d",dst_num); - printf(", tracks 0x%x to: %d, %d clks and %d units.\n",channels,(((15-delay_data_valid_nclks)<<6)|ndelay_units),delay_data_valid_nclks,ndelay_units); + FILE_LOG(logDEBUG5, ("\tSetting delays of %s chips of dst_num %d, " + "tracks 0x%x to %d, %d clks and %d units.\n", + ((set_left_delay_channels != 0) ? "left" : "right"), + dst_num, channels, (((15-delay_data_valid_nclks)<<6)|ndelay_units), + delay_data_valid_nclks, ndelay_units)); - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG2, 1<<31 | delay_data_valid_nclks<<16 | ndelay_units,0,0) || //the 1<<31 time enables the setting of the data valid delays + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG2, 1<<31 | delay_data_valid_nclks<<16 | ndelay_units,0,0) || //the 1<<31 time enables the setting of the data valid delays !Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG3,set_left_delay_channels,0,0) || !Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG4,set_right_delay_channels,0,0) || - !Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG_CTRL,CHIP_DATA_OUT_DELAY_SET,1,1)){ - cprintf(RED,"Warning: could not SetChipDataInputDelays(...).\n"); + !Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG_CTRL,CHIP_DATA_OUT_DELAY_SET,1,1)) { + FILE_LOG(logERROR, ("could not SetChipDataInputDelays(...).\n")); return 0; } } @@ -540,20 +546,20 @@ int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int chan } -int Feb_Control_VoltageToDAC(float value, unsigned int* digital,unsigned int nsteps,float vmin,float vmax){ - if(valuevmax) return 0; +int Feb_Control_VoltageToDAC(float value, unsigned int* digital,unsigned int nsteps,float vmin,float vmax) { + if (valuevmax) return 0; *digital = (int)(((value-vmin)/(vmax-vmin))*(nsteps-1) + 0.5); return 1; } -float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax){ +float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax) { return vmin+(vmax-vmin)*digital/(nsteps-1); } //only master gets to call this function -int Feb_Control_SetHighVoltage(int value){ - printf(" Setting High Voltage:\t"); +int Feb_Control_SetHighVoltage(int value) { + FILE_LOG(logDEBUG5, (" Setting High Voltage:\t")); /* * maximum voltage of the hv dc/dc converter: * 300 for single module power distribution board @@ -562,7 +568,7 @@ int Feb_Control_SetHighVoltage(int value){ */ const float vmin=0; float vmax=200; - if(Feb_control_normal) + if (Feb_control_normal) vmax=300; const float vlimit=200; const unsigned int ntotalsteps = 256; @@ -570,21 +576,22 @@ int Feb_Control_SetHighVoltage(int value){ unsigned int dacval = 0; //calculate dac value - if(!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vlimit)){ - cprintf(RED,"\nWarning: SetHighVoltage bad value, %d. The range is 0 to %d V.\n",value, (int)vlimit); + if (!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vlimit)) { + FILE_LOG(logERROR, ("SetHighVoltage bad value, %d. The range is 0 to %d V.\n",value, (int)vlimit)); return -1; } - printf("(%d dac):\t%dV\n", dacval, value); + FILE_LOG(logINFO, ("High Voltage set to %dV\n", value)); + FILE_LOG(logDEBUG5, ("High Voltage set to (%d dac):\t%dV\n", dacval, value)); return Feb_Control_SendHighVoltage(dacval); } -int Feb_Control_GetHighVoltage(int* value){ - printf(" Getting High Voltage:\t"); +int Feb_Control_GetHighVoltage(int* value) { + FILE_LOG(logDEBUG5, (" Getting High Voltage:\t")); unsigned int dacval = 0; - if(!Feb_Control_ReceiveHighVoltage(&dacval)) + if (!Feb_Control_ReceiveHighVoltage(&dacval)) return 0; //ok, convert dac to v @@ -596,25 +603,25 @@ int Feb_Control_GetHighVoltage(int* value){ */ const float vmin=0; float vmax=200; - if(Feb_control_normal) + if (Feb_control_normal) vmax=300; const float vlimit=200; const unsigned int ntotalsteps = 256; unsigned int nsteps = ntotalsteps*vlimit/vmax; *value = (int)(Feb_Control_DACToVoltage(dacval,nsteps,vmin,vlimit)+0.5); - printf("(%d dac)\t%dV\n", dacval, *value); - + FILE_LOG(logINFO, ("High Voltage read %dV\n", *value)); + FILE_LOG(logDEBUG5, ("High Voltage read (%d dac)\t%dV\n", dacval, *value)); return 1; } -int Feb_Control_SendHighVoltage(int dacvalue){ +int Feb_Control_SendHighVoltage(int dacvalue) { //normal - if(Feb_control_normal){ + if (Feb_control_normal) { //open file FILE* fd=fopen(NORMAL_HIGHVOLTAGE_OUTPUTPORT,"w"); - if(fd==NULL){ - cprintf(RED,"\nWarning: Could not open file for writing to set high voltage\n"); + if (fd==NULL) { + FILE_LOG(logERROR, ("Could not open file for writing to set high voltage\n")); return 0; } //convert to string, add 0 and write to file @@ -623,10 +630,10 @@ int Feb_Control_SendHighVoltage(int dacvalue){ } //9m - else{ + else { /*Feb_Control_OpenSerialCommunication();*/ - if (Feb_Control_hv_fd == -1){ - cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n"); + if (Feb_Control_hv_fd == -1) { + FILE_LOG(logERROR, ("High voltage serial communication not set up for 9m\n")); return 0; } @@ -635,34 +642,34 @@ int Feb_Control_SendHighVoltage(int dacvalue){ buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n'; int n; sprintf(buffer,"p%d",dacvalue); - cprintf(GREEN,"Sending HV: '%s'\n",buffer); + FILE_LOG(logINFO, ("Sending HV: '%s'\n",buffer)); n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); if (n < 0) { - cprintf(RED,"\nWarning: Error writing to i2c bus\n"); + FILE_LOG(logERROR, ("writing to i2c bus\n")); return 0; } #ifdef VERBOSEI - cprintf(GREEN,"Sent %d Bytes\n", n); + FILE_LOG(logINFO, ("Sent %d Bytes\n", n)); #endif //ok/fail memset(buffer,0,SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n'; n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); if (n < 0) { - cprintf(RED,"\nWarning: Error reading from i2c bus\n"); + FILE_LOG(logERROR, ("reading from i2c bus\n")); return 0; } #ifdef VERBOSEI - cprintf(GREEN,"Received %d Bytes\n", n); + FILE_LOG(logINFO, ("Received %d Bytes\n", n)); #endif - cprintf(GREEN,"Received HV: '%s'\n",buffer); + FILE_LOG(logINFO, ("Received HV: '%s'\n",buffer)); fflush(stdout); /*Feb_Control_CloseSerialCommunication();*/ - if(buffer[0] != 's'){ - cprintf(RED,"\nError: Failed to set high voltage\n"); + if (buffer[0] != 's') { + FILE_LOG(logERROR, ("\nError: Failed to set high voltage\n")); return 0; } - cprintf(GREEN,"%s\n",buffer); + FILE_LOG(logINFO, ("%s\n",buffer)); } @@ -675,22 +682,22 @@ int Feb_Control_SendHighVoltage(int dacvalue){ -int Feb_Control_ReceiveHighVoltage(unsigned int* value){ +int Feb_Control_ReceiveHighVoltage(unsigned int* value) { //normal - if(Feb_control_normal){ + if (Feb_control_normal) { //open file FILE* fd=fopen(NORMAL_HIGHVOLTAGE_INPUTPORT,"r"); - if(fd==NULL){ - cprintf(RED,"\nWarning: Could not open file for writing to get high voltage\n"); + if (fd==NULL) { + FILE_LOG(logERROR, ("Could not open file for writing to get high voltage\n")); return 0; } //read, assigning line to null and readbytes to 0 then getline allocates initial buffer size_t readbytes=0; char* line=NULL; - if(getline(&line, &readbytes, fd) == -1){ - cprintf(RED,"\nWarning: could not read file to get high voltage\n"); + if (getline(&line, &readbytes, fd) == -1) { + FILE_LOG(logERROR, ("could not read file to get high voltage\n")); return 0; } //read again to read the updated value @@ -698,8 +705,8 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ free(line); readbytes=0; readbytes = getline(&line, &readbytes, fd); - if(readbytes == -1){ - cprintf(RED,"\nWarning: could not read file to get high voltage\n"); + if (readbytes == -1) { + FILE_LOG(logERROR, ("could not read file to get high voltage\n")); return 0; } // Remove the trailing 0 @@ -710,11 +717,11 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ //9m - else{ + else { /*Feb_Control_OpenSerialCommunication();*/ - if (Feb_Control_hv_fd == -1){ - cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n"); + if (Feb_Control_hv_fd == -1) { + FILE_LOG(logERROR, ("High voltage serial communication not set up for 9m\n")); return 0; } char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE]; @@ -723,14 +730,14 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ //request strcpy(buffer,"g "); - cprintf(GREEN,"\nSending HV: '%s'\n",buffer); + FILE_LOG(logINFO, ("\nSending HV: '%s'\n",buffer)); n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); if (n < 0) { - cprintf(RED,"\nWarning: Error writing to i2c bus\n"); + FILE_LOG(logERROR, ("writing to i2c bus\n")); return 0; } #ifdef VERBOSEI - cprintf(GREEN,"Sent %d Bytes\n", n); + FILE_LOG(logINFO, ("Sent %d Bytes\n", n)); #endif //ok/fail @@ -738,15 +745,15 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n'; n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); if (n < 0) { - cprintf(RED,"\nWarning: Error reading from i2c bus\n"); + FILE_LOG(logERROR, ("reading from i2c bus\n")); return 0; } #ifdef VERBOSEI - cprintf(GREEN,"Received %d Bytes\n", n); + FILE_LOG(logINFO, ("Received %d Bytes\n", n)); #endif - cprintf(GREEN,"Received HV: '%s'\n",buffer); - if(buffer[0] != 's'){ - cprintf(RED,"\nWarning: failed to read high voltage\n"); + FILE_LOG(logINFO, ("Received HV: '%s'\n",buffer)); + if (buffer[0] != 's') { + FILE_LOG(logERROR, ("failed to read high voltage\n")); return 0; } @@ -754,16 +761,16 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1] = '\n'; n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE); if (n < 0) { - cprintf(RED,"\nWarning: Error reading from i2c bus\n"); + FILE_LOG(logERROR, ("reading from i2c bus\n")); return 0; } #ifdef VERBOSEI - cprintf(GREEN,"Received %d Bytes\n", n); + FILE_LOG(logINFO, ("Received %d Bytes\n", n)); #endif - cprintf(GREEN,"Received HV: '%s'\n",buffer); + FILE_LOG(logINFO, ("Received HV: '%s'\n",buffer)); /*Feb_Control_OpenSerialCommunication();*/ - if (!sscanf(buffer,"%d",value)){ - cprintf(RED,"\nWarning: failed to scan high voltage read\n"); + if (!sscanf(buffer,"%d",value)) { + FILE_LOG(logERROR, ("failed to scan high voltage read\n")); return 0; } } @@ -773,87 +780,87 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){ -int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch){ +int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch) { char* local_s = dac_str; *module_index = Feb_Control_current_index; *top = 1;//make them both 1 instead of this *bottom = 1; - if(Module_BottomAddressIsValid(&modules[*module_index])) + if (Module_BottomAddressIsValid(&modules[*module_index])) *top=0; else *bottom=0; *dac_ch = 0; - if(!Feb_Control_GetDACNumber(local_s,dac_ch)){ - cprintf(RED,"Error in dac_name: %s (%s)\n",dac_str,local_s); + if (!Feb_Control_GetDACNumber(local_s,dac_ch)) { + FILE_LOG(logERROR, ("invalid dac_name: %s (%s)\n",dac_str,local_s)); return 0; } return 1; } -int Feb_Control_SetDAC(char* dac_str, int value, int is_a_voltage_mv){ +int Feb_Control_SetDAC(char* dac_str, int value, int is_a_voltage_mv) { unsigned int i; unsigned int module_index, dac_ch; int top, bottom; - if(!Feb_Control_DecodeDACString(dac_str,&module_index,&top,&bottom,&dac_ch)) return 0; + if (!Feb_Control_DecodeDACString(dac_str,&module_index,&top,&bottom,&dac_ch)) return 0; unsigned int v = value; - if(is_a_voltage_mv&&!Feb_Control_VoltageToDAC(value,&v,4096,0,2048)){ - cprintf(RED,"Warning: SetDac bad value, %d. The range is 0 to 2048 mV.\n",value); + if (is_a_voltage_mv&&!Feb_Control_VoltageToDAC(value,&v,4096,0,2048)) { + FILE_LOG(logERROR, ("SetDac bad value, %d. The range is 0 to 2048 mV.\n",value)); return 0; } - if(v<0||v>4095){ - cprintf(RED,"Warning: SetDac bad value, %d. The range is 0 to 4095.\n",v); + if (v<0||v>4095) { + FILE_LOG(logERROR, ("SetDac bad value, %d. The range is 0 to 4095.\n",v)); return 0; } - if(top&&Module_TopAddressIsValid(&modules[module_index])){ + if (top&&Module_TopAddressIsValid(&modules[module_index])) { - if(!Feb_Control_SendDACValue(Module_GetTopRightAddress(&modules[module_index]),dac_ch,&v)) return 0; + if (!Feb_Control_SendDACValue(Module_GetTopRightAddress(&modules[module_index]),dac_ch,&v)) return 0; - if(module_index!=0) Module_SetTopDACValue(&modules[module_index],dac_ch,v); + if (module_index!=0) Module_SetTopDACValue(&modules[module_index],dac_ch,v); else for(i=0;i=Module_ndacs){ - cprintf(RED,"Warning: GetDACName index out of range, %d invalid.\n",dac_num); +int Feb_Control_GetDACName(unsigned int dac_num, char* s) { + if (dac_num>=Module_ndacs) { + FILE_LOG(logERROR, ("GetDACName index out of range, %d invalid.\n",dac_num)); return 0; } strcpy(s,Module_dac_names[dac_num]); return 1; } -int Feb_Control_GetDACNumber(char* s, unsigned int* n){ +int Feb_Control_GetDACNumber(char* s, unsigned int* n) { unsigned int i; - for(i=0;i15){ - cprintf(RED,"Warning invalid ch for SetDAC.\n"); + if (ch<0||ch>15) { + FILE_LOG(logERROR, ("invalid ch for SetDAC.\n")); return 0; } - //if(voltage<0) return PowerDownDAC(socket_num,ch); + //if (voltage<0) return PowerDownDAC(socket_num,ch); *value&=0xfff; unsigned int dac_ic = (ch<8) ? 1:2; @@ -878,73 +885,72 @@ int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int unsigned int r = dac_ic<<30 | 3<<16 | dac_ch<<12 | *value; //3 write and power up - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegister(dst_num,0,r,1,0)){ - cprintf(RED,"Warning: trouble setting dac %d voltage.\n",ch); + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegister(dst_num,0,r,1,0)) { + FILE_LOG(logERROR, ("trouble setting dac %d voltage.\n",ch)); return 0; } } float voltage=Feb_Control_DACToVoltage(*value,4096,0,2048); - printf("\tDac number %d (%s) of dst %d set to %d (%f mV).\n",ch,Module_dac_names[ch],dst_num,*value,voltage); + FILE_LOG(logINFO, ("%s set to %d (%.2fmV)\n", Module_dac_names[ch],*value,voltage)); + FILE_LOG(logDEBUG5, ("Dac number %d (%s) of dst %d set to %d (%f mV)\n",ch,Module_dac_names[ch],dst_num,*value,voltage)); return 1; } -int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){ - printf("Setting Trimbits\n"); +int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits) { + FILE_LOG(logINFO, ("Setting Trimbits\n")); //for (int iy=10000;iy<20020;++iy)//263681 //for (int iy=263670;iy<263680;++iy)//263681 - // printf("%d:%c\t\t",iy,trimbits[iy]); + // FILE_LOG(logINFO, ("%d:%c\t\t",iy,trimbits[iy])); unsigned int trimbits_to_load_l[1024]; unsigned int trimbits_to_load_r[1024]; unsigned int module_index=0; - if(!Feb_Control_GetModuleIndex(module_num,&module_index)){ - cprintf(RED,"Warning could not set trimbits, bad module number.\n"); + if (!Feb_Control_GetModuleIndex(module_num,&module_index)) { + FILE_LOG(logERROR, ("could not set trimbits, bad module number.\n")); return 0; } - if(Feb_Control_Reset() == STATUS_ERROR) cprintf(RED,"Warning could not reset DAQ.\n"); - int l_r; //printf("222\n"); - for(l_r=0;l_r<2;l_r++){ // l_r loop - //printf("\nl_r:%d\t\t",l_r); + if (Feb_Control_Reset() == STATUS_ERROR) { + FILE_LOG(logERROR, ("could not reset DAQ.\n")); + } + int l_r; + for(l_r=0;l_r<2;l_r++) { // l_r loop unsigned int disable_chip_mask = l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT; - if(Feb_Control_activated){ - if(!(Feb_Interface_WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8,0,0) + if (Feb_Control_activated) { + if (!(Feb_Interface_WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8,0,0) &&Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) - &&(Feb_Control_StartDAQOnlyNWaitForFinish(5000) == STATUS_IDLE))){ - printf("Could not select chips\n"); + &&(Feb_Control_StartDAQOnlyNWaitForFinish(5000) == STATUS_IDLE))) { + FILE_LOG(logERROR, ("Could not select chips\n")); return 0; } } int row_set; - for(row_set=0;row_set<16;row_set++){ //16 rows at a time - //printf("row_set:%d\t\t",row_set); - if(row_set==0){ - if(!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY|DAQ_SEND_A_TOKEN_IN|DAQ_LOAD_16ROWS_OF_TRIMBITS)){ - cprintf(RED,"Warning: Could not Feb_Control_SetCommandRegister for loading trim bits.\n"); + for(row_set=0;row_set<16;row_set++) { //16 rows at a time + if (row_set==0) { + if (!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY|DAQ_SEND_A_TOKEN_IN|DAQ_LOAD_16ROWS_OF_TRIMBITS)) { + FILE_LOG(logERROR, ("Could not Feb_Control_SetCommandRegister for loading trim bits.\n")); return 0; } - }else{ - if(!Feb_Control_SetCommandRegister(DAQ_LOAD_16ROWS_OF_TRIMBITS)){ - cprintf(RED,"Warning: Could not Feb_Control_SetCommandRegister for loading trim bits.\n"); + } else { + if (!Feb_Control_SetCommandRegister(DAQ_LOAD_16ROWS_OF_TRIMBITS)) { + FILE_LOG(logERROR, ("Could not Feb_Control_SetCommandRegister for loading trim bits.\n")); return 0; } } int row; - for(row=0;row<16;row++){ //row loop - //printf("row:%d\t\t",row); + for(row=0;row<16;row++) { //row loop int offset = 2*32*row; int sc; - for(sc=0;sc<32;sc++){ //supercolumn loop sc - //printf("sc:%d\t\t",sc); + for(sc=0;sc<32;sc++) { //supercolumn loop sc int super_column_start_position_l = 1030*row + l_r *258 + sc*8; int super_column_start_position_r = 1030*row + 516 + l_r *258 + sc*8; @@ -958,15 +964,14 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){ trimbits_to_load_l[offset+chip_sc+32] = 0; trimbits_to_load_r[offset+chip_sc+32] = 0; int i; - for(i=0;i<8;i++){ // column loop i - //printf("i:%d\t\t",i); + for(i=0;i<8;i++) { // column loop i - if(Module_TopAddressIsValid(&modules[1])){ + if (Module_TopAddressIsValid(&modules[1])) { trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_l+i])<<((7-i)*4);//low trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_l+i])>>3)<<((7-i)*4);//upper trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_r+i])<<((7-i)*4);//low trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_r+i])>>3)<<((7-i)*4);//upper - }else{ + } else { trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])<<((7-i)*4);//low trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])>>3)<<((7-i)*4);//upper trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])<<((7-i)*4);//low @@ -977,25 +982,25 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){ } //end supercolumn loop sc } //end row loop - if(Module_TopAddressIsValid(&modules[1])){ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)|| + if (Module_TopAddressIsValid(&modules[1])) { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)|| !Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)|| - //if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)|| + //if (!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)|| // !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)|| - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - printf(" some errror!\n"); + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, (" some errror!\n")); return 0; } } - }else{ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)|| + } else { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)|| !Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)|| - //if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)|| + //if (!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)|| // !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)|| - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - printf(" some errror!\n"); + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, (" some errror!\n")); return 0; } } @@ -1010,47 +1015,46 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){ } -unsigned int* Feb_Control_GetTrimbits(){ +unsigned int* Feb_Control_GetTrimbits() { return Feb_Control_last_downloaded_trimbits; } -unsigned int Feb_Control_AddressToAll(){printf("in Feb_Control_AddressToAll()\n"); +unsigned int Feb_Control_AddressToAll() { + FILE_LOG(logINFO, ("in Feb_Control_AddressToAll()\n")); -if(moduleSize==0) return 0; + if (moduleSize==0) return 0; -if(Module_BottomAddressIsValid(&modules[1])){ - //printf("************* bottom\n"); - //if(Feb_Control_am_i_master) - return Module_GetBottomLeftAddress(&modules[1])|Module_GetBottomRightAddress(&modules[1]); - // else return 0; -} -// printf("************* top\n"); + if (Module_BottomAddressIsValid(&modules[1])) { + //if (Feb_Control_am_i_master) + return Module_GetBottomLeftAddress(&modules[1])|Module_GetBottomRightAddress(&modules[1]); + // else return 0; + } -return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]); -//return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]); + return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]); + //return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]); } -int Feb_Control_SetCommandRegister(unsigned int cmd){ - if(Feb_Control_activated) +int Feb_Control_SetCommandRegister(unsigned int cmd) { + if (Feb_Control_activated) return Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,cmd,0,0); else return 1; } -int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status){ +int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status) { //if deactivated, should be handled earlier and should not get into this function - if(Feb_Control_activated){ - if(!Feb_Interface_ReadRegister(dst_address,DAQ_REG_STATUS,ret_status)){ - cprintf(RED,"Error: reading status register.\n"); + if (Feb_Control_activated) { + if (!Feb_Interface_ReadRegister(dst_address,DAQ_REG_STATUS,ret_status)) { + FILE_LOG(logERROR, ("Error: reading status register.\n")); return 0; } } @@ -1060,10 +1064,10 @@ int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret } -int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us){ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)||!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_START,0,0)){ - cprintf(RED,"Warning: could not start.\n"); +int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us) { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)||!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_START,0,0)) { + FILE_LOG(logERROR, ("could not start.\n")); return 0; } } @@ -1071,30 +1075,31 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us){ } -int Feb_Control_AcquisitionInProgress(){ +int Feb_Control_AcquisitionInProgress() { unsigned int status_reg_r=0,status_reg_l=0; //deactivated should return end of acquisition - if(!Feb_Control_activated) + if (!Feb_Control_activated) return STATUS_IDLE; int ind = Feb_Control_current_index; - if(Module_BottomAddressIsValid(&modules[ind])){ + if (Module_BottomAddressIsValid(&modules[ind])) { - if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r))) - {cprintf(RED,"Error: Trouble reading Status register. bottom right address\n");return STATUS_ERROR;} - if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l))) - {cprintf(RED,"Error: Trouble reading Status register. bottom left address\n");return STATUS_ERROR;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. bottom right address\n"));return STATUS_ERROR;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. bottom left address\n"));return STATUS_ERROR;} - }else{ - if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r))) - {cprintf(RED,"Error: Trouble reading Status register. top right address\n");return STATUS_ERROR;} - if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l))) - {cprintf(RED,"Error: Trouble reading Status register. top left address\n");return STATUS_ERROR;} + } else { + if (!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. top right address\n"));return STATUS_ERROR;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. top left address\n"));return STATUS_ERROR;} } //running - if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) {/*printf("**runningggg\n");*/ + if ((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) { + FILE_LOG(logDEBUG5, ("**runningggg\n")); return STATUS_RUNNING; } //idle @@ -1102,30 +1107,30 @@ int Feb_Control_AcquisitionInProgress(){ } -int Feb_Control_AcquisitionStartedBit(){ +int Feb_Control_AcquisitionStartedBit() { unsigned int status_reg_r=0,status_reg_l=0; //deactivated should return acquisition started/ready - if(!Feb_Control_activated) + if (!Feb_Control_activated) return 1; int ind = Feb_Control_current_index; - if(Module_BottomAddressIsValid(&modules[ind])){ + if (Module_BottomAddressIsValid(&modules[ind])) { - if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r))) - {cprintf(RED,"Error: Trouble reading Status register. bottom right address\n");return -1;} - if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l))) - {cprintf(RED,"Error: Trouble reading Status register. bottom left address\n");return -1;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. bottom right address\n"));return -1;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. bottom left address\n"));return -1;} - }else{ - if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r))) - {cprintf(RED,"Error: Trouble reading Status register. top right address\n"); return -1;} - if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l))) - {cprintf(RED,"Error: Trouble reading Status register. top left address\n");return -1;} + } else { + if (!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. top right address\n")); return -1;} + if (!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l))) + {FILE_LOG(logERROR, ("Error: Trouble reading Status register. top left address\n"));return -1;} } //doesnt mean it started, just the bit - if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUN_TOGGLE) + if ((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUN_TOGGLE) return 1; return 0; @@ -1133,13 +1138,13 @@ int Feb_Control_AcquisitionStartedBit(){ -int Feb_Control_WaitForFinishedFlag(int sleep_time_us){ +int Feb_Control_WaitForFinishedFlag(int sleep_time_us) { int is_running = Feb_Control_AcquisitionInProgress(); int check_error = 0; // it will break out if it is idle or if check_error is more than 5 times - while(is_running != STATUS_IDLE){ + while(is_running != STATUS_IDLE) { usleep(sleep_time_us); is_running = Feb_Control_AcquisitionInProgress(); @@ -1157,35 +1162,35 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us){ } -int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag){ +int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag) { //deactivated dont wait (otherwise give a toggle value back) - if(!Feb_Control_activated) + if (!Feb_Control_activated) return 1; //did not start - if(prev_flag == -1) + if (prev_flag == -1) return 0; int value = prev_flag; - while(value == prev_flag){ + while(value == prev_flag) { usleep(sleep_time_us); value = Feb_Control_AcquisitionStartedBit(); } //did not start - if(value == -1) + if (value == -1) return 0; return 1; } -int Feb_Control_Reset(){ - printf("Reset daq\n"); - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_RESET,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)){ - cprintf(RED,"Warning: Could not reset daq, no response.\n"); +int Feb_Control_Reset() { + FILE_LOG(logINFO, ("Reset daq\n")); + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_RESET,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)) { + FILE_LOG(logERROR, ("Could not reset daq, no response.\n")); return 0; } } @@ -1196,278 +1201,280 @@ int Feb_Control_Reset(){ -int Feb_Control_SetStaticBits(){ - if(Feb_Control_activated){ +int Feb_Control_SetStaticBits() { + if (Feb_Control_activated) { //program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64 - if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) || + if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) || !Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) || - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(RED,"Warning: Could not set static bits\n"); + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("Could not set static bits\n")); return 0; } } return 1; } -int Feb_Control_SetStaticBits1(unsigned int the_static_bits){ +int Feb_Control_SetStaticBits1(unsigned int the_static_bits) { Feb_Control_staticBits = the_static_bits; return Feb_Control_SetStaticBits(); } -int Feb_Control_SetInTestModeVariable(int on){ - if(on) Feb_Control_staticBits |= DAQ_STATIC_BIT_CHIP_TEST; //setting test bit to high +int Feb_Control_SetInTestModeVariable(int on) { + if (on) Feb_Control_staticBits |= DAQ_STATIC_BIT_CHIP_TEST; //setting test bit to high else Feb_Control_staticBits &= (~DAQ_STATIC_BIT_CHIP_TEST); //setting test bit to low return 1; } -int Feb_Control_GetTestModeVariable(){ +int Feb_Control_GetTestModeVariable() { return Feb_Control_staticBits&DAQ_STATIC_BIT_CHIP_TEST; } -int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo){ +int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo) { static unsigned int everything_but_bit_mode = DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_CHIP_TEST|DAQ_STATIC_BIT_ROTEST; - if(four_eight_sixteen_or_thirtytwo==4){ + if (four_eight_sixteen_or_thirtytwo==4) { Feb_Control_staticBits = DAQ_STATIC_BIT_M4 | (Feb_Control_staticBits&everything_but_bit_mode); //leave test bits in currernt state Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING; - }else if(four_eight_sixteen_or_thirtytwo==8){ + } else if (four_eight_sixteen_or_thirtytwo==8) { Feb_Control_staticBits = DAQ_STATIC_BIT_M8 | (Feb_Control_staticBits&everything_but_bit_mode); Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING; - }else if(four_eight_sixteen_or_thirtytwo==16){ + } else if (four_eight_sixteen_or_thirtytwo==16) { Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits&everything_but_bit_mode); Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING; - }else if(four_eight_sixteen_or_thirtytwo==32){ + } else if (four_eight_sixteen_or_thirtytwo==32) { Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits&everything_but_bit_mode); Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING; - }else{ - cprintf(RED,"Warning: dynamic range (%d) not valid, not setting bit mode.\n",four_eight_sixteen_or_thirtytwo); - printf("Set dynamic range int must equal 4,8 16, or 32.\n"); + } else { + FILE_LOG(logERROR, ("dynamic range (%d) not valid, not setting bit mode.\n",four_eight_sixteen_or_thirtytwo)); + FILE_LOG(logINFO, ("Set dynamic range int must equal 4,8 16, or 32.\n")); return 0; } - printf("Dynamic range set to: %d\n",four_eight_sixteen_or_thirtytwo); + FILE_LOG(logINFO, ("Dynamic range set to %d\n",four_eight_sixteen_or_thirtytwo)); return 1; } -unsigned int Feb_Control_GetDynamicRange(){ - if(Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) return 32; - else if(DAQ_STATIC_BIT_M4&Feb_Control_staticBits) return 4; - else if(DAQ_STATIC_BIT_M8&Feb_Control_staticBits) return 8; +unsigned int Feb_Control_GetDynamicRange() { + if (Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) return 32; + else if (DAQ_STATIC_BIT_M4&Feb_Control_staticBits) return 4; + else if (DAQ_STATIC_BIT_M8&Feb_Control_staticBits) return 8; return 16; } -int Feb_Control_SetReadoutSpeed(unsigned int readout_speed){ //0->full,1->half,2->quarter or 3->super_slow +int Feb_Control_SetReadoutSpeed(unsigned int readout_speed) { //0->full,1->half,2->quarter or 3->super_slow Feb_Control_acquireNReadoutMode &= (~DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED); - if(readout_speed==1){ + if (readout_speed==1) { Feb_Control_acquireNReadoutMode |= DAQ_CHIP_CONTROLLER_HALF_SPEED; - printf("Everything at half speed, ie. reading with 50 MHz main clk (half speed) ....\n"); - }else if(readout_speed==2){ + FILE_LOG(logINFO, ("Speed set to half speed (50 MHz)\n")); + } else if (readout_speed==2) { Feb_Control_acquireNReadoutMode |= DAQ_CHIP_CONTROLLER_QUARTER_SPEED; - printf("Everything at quarter speed, ie. reading with 25 MHz main clk (quarter speed) ....\n"); - }else if(readout_speed==3){ + FILE_LOG(logINFO, ("Speed set to quarter speed (25 MHz)\n")); + } else if (readout_speed==3) { Feb_Control_acquireNReadoutMode |= DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED; - printf("Everything at super slow speed, ie. reading with ~0.200 MHz main clk (super slow speed) ....\n"); - }else{ - if(readout_speed){ - cprintf(RED,"Warning readout speed %d unknown, defaulting to full speed.\n",readout_speed); - printf("Everything at full speed, ie. reading with 100 MHz main clk (full speed) ....\n"); + FILE_LOG(logINFO, ("Speed set to super slow speed (~0.200 MHz)\n")); + } else { + if (readout_speed) { + FILE_LOG(logERROR, ("readout speed %d unknown, defaulting to full speed.\n",readout_speed)); + FILE_LOG(logINFO, ("full speed, (100 MHz)\n")); return 0; } - printf("Everything at full speed, ie. reading with 100 MHz main clk (full speed) ....\n"); + FILE_LOG(logINFO, ("Speed set to full speed (100 MHz)\n")); } return 1; } -int Feb_Control_SetReadoutMode(unsigned int readout_mode){ //0->parallel,1->non-parallel,2-> safe_mode +int Feb_Control_SetReadoutMode(unsigned int readout_mode) { //0->parallel,1->non-parallel,2-> safe_mode Feb_Control_acquireNReadoutMode &= (~DAQ_NEXPOSURERS_PARALLEL_MODE); - if(readout_mode==1){ + if (readout_mode==1) { Feb_Control_acquireNReadoutMode |= DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE; - printf("Readout mode set to normal non-parallel readout mode ... \n");; - }else if(readout_mode==2){ + FILE_LOG(logINFO, ("Readout mode set to Non Parallel\n")); + } else if (readout_mode==2) { Feb_Control_acquireNReadoutMode |= DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE; - printf("Readout mode set to safest mode, row clk before main clk readout sequence .... \n");; - }else{ + FILE_LOG(logINFO, ("Readout mode set to Safe (row clk before main clk readout sequence)\n")); + } else { Feb_Control_acquireNReadoutMode |= DAQ_NEXPOSURERS_PARALLEL_MODE; - if(readout_mode){ - cprintf(RED,"Warning readout mode %d) unknown, defaulting to full speed.\n",readout_mode); - printf("Readout mode set to parrallel acquire/read mode .... \n");; + if (readout_mode) { + FILE_LOG(logERROR, ("readout mode %d) unknown, defaulting to parallel readout.\n",readout_mode)); + FILE_LOG(logINFO, ("Readout mode set to Parallel\n")); return 0; } - printf("Readout mode set to parrallel acquire/read mode .... \n");; + FILE_LOG(logINFO, ("Readout mode set to Parallel\n")); } return 1; } -int Feb_Control_SetTriggerMode(unsigned int trigger_mode,int polarity){ +int Feb_Control_SetTriggerMode(unsigned int trigger_mode,int polarity) { //"00"-> internal exposure time and period, //"01"-> external acquistion start and internal exposure time and period, //"10"-> external start trigger and internal exposure time, //"11"-> external triggered start and stop of exposures Feb_Control_triggerMode = (~DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP); - if(trigger_mode == 1){ + if (trigger_mode == 1) { Feb_Control_triggerMode = DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START; - printf("Trigger mode: external start of acquisition sequence, internal exposure length and period.\n");; - }else if(trigger_mode == 2){ + FILE_LOG(logINFO, ("Trigger mode set to Burst Trigger\n")); + } else if (trigger_mode == 2) { Feb_Control_triggerMode = DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START; - printf("Trigger mode: external image start, internal exposure time.\n");; - }else if(trigger_mode == 3){ + FILE_LOG(logINFO, ("Trigger mode set to Trigger Exposure\n")); + } else if (trigger_mode == 3) { Feb_Control_triggerMode = DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP; - printf("Trigger mode: externally controlled, external image window (start and stop).\n");; - }else{ + FILE_LOG(logINFO, ("Trigger mode set to Gated\n")); + } else { Feb_Control_triggerMode = DAQ_NEXPOSURERS_INTERNAL_ACQUISITION; - if(trigger_mode) cprintf(RED,"Warning trigger %d) unknown, defaulting to internal triggering.\n",trigger_mode);; + if (trigger_mode) { + FILE_LOG(logERROR, ("trigger %d) unknown, defaulting to Auto\n",trigger_mode)); + } - printf("Trigger mode: acquisition internally controlled exposure length and period.\n");; + FILE_LOG(logINFO, ("Trigger mode set to Auto\n")); return trigger_mode==0; } - if(polarity){ + if (polarity) { Feb_Control_triggerMode |= DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY; - printf("External trigger polarity set to positive.\n");; - }else{ + FILE_LOG(logINFO, ("External trigger polarity set to positive\n")); + } else { Feb_Control_triggerMode &= (~DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY); - printf("External trigger polarity set to negitive.\n");; + FILE_LOG(logINFO, ("External trigger polarity set to negitive\n")); } return 1; } -int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity){ - if(use_external_enable){ +int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity) { + if (use_external_enable) { Feb_Control_externalEnableMode |= DAQ_NEXPOSURERS_EXTERNAL_ENABLING; - printf("External enabling enabled, "); - if(polarity){ + if (polarity) { Feb_Control_externalEnableMode |= DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY; - printf(", polarity set to positive.\n");; - }else{ + } else { Feb_Control_externalEnableMode &= (~DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY); - printf(", polarity set to negative.\n");; } - }else{ + FILE_LOG(logINFO, ("External enabling enabled, polarity set to %s\n", + (polarity ? "positive" : "negative"))); + + } else { Feb_Control_externalEnableMode = 0; /* changed by Dhanya according to old code &= (~DAQ_NEXPOSURERS_EXTERNAL_ENABLING);*/ - printf("External enabling disabled.\n");; + FILE_LOG(logINFO, ("External enabling disabled\n")); } return 1; } -int Feb_Control_SetNExposures(unsigned int n_images){ - if(!n_images){ - cprintf(RED,"Warning nimages must be greater than zero.%d\n",n_images); +int Feb_Control_SetNExposures(unsigned int n_images) { + if (!n_images) { + FILE_LOG(logERROR, ("nimages must be greater than zero.%d\n",n_images)); return 0; } Feb_Control_nimages = n_images; - printf("Number of images set to: %d\n",Feb_Control_nimages); + FILE_LOG(logINFO, ("Number of images set to %d\n",Feb_Control_nimages)); return 1; } -unsigned int Feb_Control_GetNExposures(){return Feb_Control_nimages;} +unsigned int Feb_Control_GetNExposures() {return Feb_Control_nimages;} -int Feb_Control_SetExposureTime(double the_exposure_time_in_sec){ +int Feb_Control_SetExposureTime(double the_exposure_time_in_sec) { Feb_Control_exposure_time_in_sec = the_exposure_time_in_sec; - printf("Exposure time set to: %fs\n",Feb_Control_exposure_time_in_sec); + FILE_LOG(logINFO, ("Exposure time set to %fs\n",Feb_Control_exposure_time_in_sec)); return 1; } -double Feb_Control_GetExposureTime(){return Feb_Control_exposure_time_in_sec;} -int64_t Feb_Control_GetExposureTime_in_nsec(){return (int64_t)(Feb_Control_exposure_time_in_sec*(1E9));} +double Feb_Control_GetExposureTime() {return Feb_Control_exposure_time_in_sec;} +int64_t Feb_Control_GetExposureTime_in_nsec() {return (int64_t)(Feb_Control_exposure_time_in_sec*(1E9));} -int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec){ +int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec) { Feb_Control_subframe_exposure_time_in_10nsec = the_subframe_exposure_time_in_10nsec; - printf("Sub Frame Exposure time set to: %lld\n",(long long int)Feb_Control_subframe_exposure_time_in_10nsec); + FILE_LOG(logINFO, ("Sub Frame Exposure time set to %lldns\n",(long long int)Feb_Control_subframe_exposure_time_in_10nsec * 10)); return 1; } -int64_t Feb_Control_GetSubFrameExposureTime(){return Feb_Control_subframe_exposure_time_in_10nsec*10;} +int64_t Feb_Control_GetSubFrameExposureTime() {return Feb_Control_subframe_exposure_time_in_10nsec*10;} -int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec){ +int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec) { Feb_Control_subframe_period_in_10nsec = the_subframe_period_in_10nsec; - printf("Sub Frame Period set to: %lld\n",(long long int)Feb_Control_subframe_period_in_10nsec); + FILE_LOG(logINFO, ("Sub Frame Period set to %lldns\n",(long long int)Feb_Control_subframe_period_in_10nsec * 10)); return 1; } -int64_t Feb_Control_GetSubFramePeriod(){return Feb_Control_subframe_period_in_10nsec*10;} +int64_t Feb_Control_GetSubFramePeriod() {return Feb_Control_subframe_period_in_10nsec*10;} -int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec){ +int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec) { Feb_Control_exposure_period_in_sec = the_exposure_period_in_sec; - printf("Exposure period set to: %f\n",Feb_Control_exposure_period_in_sec); + FILE_LOG(logINFO, ("Exposure period set to %fs\n",Feb_Control_exposure_period_in_sec)); return 1; } -double Feb_Control_GetExposurePeriod(){return Feb_Control_exposure_period_in_sec;} +double Feb_Control_GetExposurePeriod() {return Feb_Control_exposure_period_in_sec;} -unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec){ +unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec) { float n_clk_cycles = round(time_in_sec/10e-9); //200 MHz ctb clk or 100 MHz feb clk unsigned int decoded_time; - if(n_clk_cycles>(pow(2,29)-1)*pow(10,7)){ + if (n_clk_cycles>(pow(2,29)-1)*pow(10,7)) { float max_time = 10e-9*(pow(2,28)-1)*pow(10,7); - cprintf(RED,"Warning: time exceeds (%f) maximum exposure time of %f sec.\n",time_in_sec,max_time); - printf("\t Setting to maximum %f us.\n",max_time); + FILE_LOG(logERROR, ("time exceeds (%f) maximum exposure time of %f sec.\n",time_in_sec,max_time)); + FILE_LOG(logINFO, ("\t Setting to maximum %f us.\n",max_time)); decoded_time = 0xffffffff; - }else{ + } else { int power_of_ten = 0; - while(n_clk_cycles>pow(2,29)-1){ power_of_ten++; n_clk_cycles = round(n_clk_cycles/10.0);} + while(n_clk_cycles>pow(2,29)-1) { power_of_ten++; n_clk_cycles = round(n_clk_cycles/10.0);} decoded_time = (int)(n_clk_cycles)<<3 | (int)(power_of_ten); } return decoded_time; } -int Feb_Control_ResetChipCompletely(){ - if(!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(RED,"Warning: could not ResetChipCompletely() with 0x%x.\n",DAQ_RESET_COMPLETELY); +int Feb_Control_ResetChipCompletely() { + if (!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not ResetChipCompletely() with 0x%x.\n",DAQ_RESET_COMPLETELY)); return 0; } - printf("Chip reset completely\n"); + FILE_LOG(logINFO, ("Chip reset completely\n")); return 1; } -int Feb_Control_ResetChipPartially(){ - if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(RED,"Warning: could not ResetChipPartially with periphery\n"); +int Feb_Control_ResetChipPartially() { + if (!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not ResetChipPartially with periphery\n")); return 0; } - printf("Chip reset periphery 0x%x\n",DAQ_RESET_PERIPHERY); + FILE_LOG(logINFO, ("Chip reset periphery 0x%x\n",DAQ_RESET_PERIPHERY)); - if(!Feb_Control_SetCommandRegister(DAQ_RESET_COLUMN_SELECT) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(RED,"Warning: could not ResetChipPartially with column select\n"); + if (!Feb_Control_SetCommandRegister(DAQ_RESET_COLUMN_SELECT) || (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not ResetChipPartially with column select\n")); return 0; } - printf("Chip reset column select 0x%x\n",DAQ_RESET_COLUMN_SELECT); + FILE_LOG(logINFO, ("Chip reset column select 0x%x\n",DAQ_RESET_COLUMN_SELECT)); return 1; } -void Feb_Control_PrintAcquisitionSetup(){ +void Feb_Control_PrintAcquisitionSetup() { time_t rawtime; time(&rawtime); struct tm *timeinfo = localtime(&rawtime); - printf("\nStarting an exposure: %s",asctime(timeinfo)); - printf("\t Dynamic range nbits: %d\n",Feb_Control_GetDynamicRange()); - printf("\t Trigger mode: 0x%x\n",Feb_Control_triggerMode); - printf("\t Number of exposures: %d\n",Feb_Control_GetNExposures()); - printf("\t Exsposure time (if used): %f seconds.\n",Feb_Control_exposure_time_in_sec); - printf("\t Exsposure period (if used): %f seconds.\n\n\n",Feb_Control_exposure_period_in_sec); + FILE_LOG(logINFO, ("\nStarting an exposure: %s",asctime(timeinfo))); + FILE_LOG(logINFO, ("\t Dynamic range nbits: %d\n",Feb_Control_GetDynamicRange())); + FILE_LOG(logINFO, ("\t Trigger mode: 0x%x\n",Feb_Control_triggerMode)); + FILE_LOG(logINFO, ("\t Number of exposures: %d\n",Feb_Control_GetNExposures())); + FILE_LOG(logINFO, ("\t Exsposure time (if used): %f seconds.\n",Feb_Control_exposure_time_in_sec)); + FILE_LOG(logINFO, ("\t Exsposure period (if used): %f seconds.\n\n\n",Feb_Control_exposure_period_in_sec)); } -int Feb_Control_SendBitModeToBebServer(){ +int Feb_Control_SendBitModeToBebServer() { unsigned int just_bit_mode = (DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8) & Feb_Control_staticBits; unsigned int bit_mode = 16; //default - if(just_bit_mode == DAQ_STATIC_BIT_M4) bit_mode = 4; - else if(just_bit_mode == DAQ_STATIC_BIT_M8) bit_mode = 8; - else if(Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) bit_mode = 32; + if (just_bit_mode == DAQ_STATIC_BIT_M4) bit_mode = 4; + else if (just_bit_mode == DAQ_STATIC_BIT_M8) bit_mode = 8; + else if (Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) bit_mode = 32; - if(!Beb_SetUpTransferParameters(bit_mode)){ - cprintf(RED,"Error: sending bit mode ...\n"); + if (!Beb_SetUpTransferParameters(bit_mode)) { + FILE_LOG(logERROR, ("Error: sending bit mode ...\n")); return 0; } @@ -1475,35 +1482,35 @@ int Feb_Control_SendBitModeToBebServer(){ } -int Feb_Control_PrepareForAcquisition(){//return 1; +int Feb_Control_PrepareForAcquisition() {//return 1; static unsigned int reg_nums[20]; static unsigned int reg_vals[20]; Feb_Control_PrintAcquisitionSetup(); - // if(!Reset()||!ResetDataStream()){ - if(Feb_Control_Reset() == STATUS_ERROR){ - printf("Trouble reseting daq or data stream...\n");; + // if (!Reset()||!ResetDataStream()) { + if (Feb_Control_Reset() == STATUS_ERROR) { + FILE_LOG(logERROR, ("Trouble reseting daq or data stream...\n")); return 0; } - if(!Feb_Control_SetStaticBits1(Feb_Control_staticBits&(DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8))){ - printf("Trouble setting static bits ...\n");; + if (!Feb_Control_SetStaticBits1(Feb_Control_staticBits&(DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8))) { + FILE_LOG(logERROR, ("Trouble setting static bits ...\n")); return 0; } - if(!Feb_Control_SendBitModeToBebServer()){ - printf("Trouble sending static bits to server ...\n");; + if (!Feb_Control_SendBitModeToBebServer()) { + FILE_LOG(logERROR, ("Trouble sending static bits to server ...\n")); return 0; } int ret=0; - if(Feb_Control_counter_bit) + if (Feb_Control_counter_bit) ret = Feb_Control_ResetChipCompletely(); else ret = Feb_Control_ResetChipPartially(); - if(!ret){ - printf("Trouble resetting chips ...\n");; + if (!ret) { + FILE_LOG(logERROR, ("Trouble resetting chips ...\n")); return 0; } @@ -1522,10 +1529,10 @@ int Feb_Control_PrepareForAcquisition(){//return 1; reg_vals[5]= Feb_Control_subframe_exposure_time_in_10nsec; //(1 means 10ns, 100 means 1000ns) reg_nums[6]=DAQ_REG_SUBFRAME_PERIOD; reg_vals[6]= Feb_Control_subframe_period_in_10nsec; //(1 means 10ns, 100 means 1000ns) - // if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)){ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),7,reg_nums,reg_vals,0,0)){ - printf("Trouble starting acquisition....\n");; + // if (!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)) { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),7,reg_nums,reg_vals,0,0)) { + FILE_LOG(logERROR, ("Trouble starting acquisition....\n")); return 0; } } @@ -1535,24 +1542,24 @@ int Feb_Control_PrepareForAcquisition(){//return 1; -int Feb_Control_StartAcquisition(){ - printf("****** starting acquisition********* \n"); +int Feb_Control_StartAcquisition() { + FILE_LOG(logINFO, ("****** starting acquisition********* \n")); static unsigned int reg_nums[20]; static unsigned int reg_vals[20]; int i; - for(i=0;i<14;i++){ + for(i=0;i<14;i++) { reg_nums[i]=DAQ_REG_CTRL; reg_vals[i]=0; } reg_nums[14]=DAQ_REG_CTRL; reg_vals[14]=ACQ_CTRL_START; - if(Feb_Control_activated){ - if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){ - cprintf(RED,"Trouble starting acquisition....\n");; + if (Feb_Control_activated) { + if (!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)) { + FILE_LOG(logERROR, ("Trouble starting acquisition....\n")); return 0; } } @@ -1561,13 +1568,13 @@ int Feb_Control_StartAcquisition(){ return 1; } -int Feb_Control_StopAcquisition(){ +int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); } -int Feb_Control_SaveAllTrimbitsTo(int value){ +int Feb_Control_SaveAllTrimbitsTo(int value) { unsigned int chanregs[Feb_Control_trimbit_size]; int i; for(i=0;i255||y<0||y>255){ - cprintf(RED,"Warning: Pixel out of range.\n"); + if (x<0||x>255||y<0||y>255) { + FILE_LOG(logERROR, ("Pixel out of range.\n")); return 0; } @@ -1609,17 +1616,17 @@ int Feb_Control_Pulse_Pixel(int npulses, int x, int y){ Feb_Control_SetStaticBits(); Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY|DAQ_RESET_COLUMN_SELECT); if (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE) { - cprintf(RED,"Warning: could not pulse pixel as status not idle\n"); + FILE_LOG(logERROR, ("could not pulse pixel as status not idle\n")); return 0; } unsigned int serial_in = 8<<(4*(7-x%8)); - if(!Feb_Control_Shift32InSerialIn(serial_in)){ - cprintf(RED,"Warning ChipController::PulsePixel: could shift in the initail 32.\n"); + if (!Feb_Control_Shift32InSerialIn(serial_in)) { + FILE_LOG(logERROR, ("ChipController::PulsePixel: could shift in the initail 32.\n")); return 0; } - if(!pulse_multiple) + if (!pulse_multiple) serial_in=0; for(i=0;i1023){ - cprintf(RED,"Warning: Clock row clock ntimes (%d) exceeds the maximum value of 1023.\n\t Setting ntimes to 1023.\n",ntimes); +int Feb_Control_ClockRowClock(unsigned int ntimes) { + if (ntimes>1023) { + FILE_LOG(logERROR, ("Clock row clock ntimes (%d) exceeds the maximum value of 1023.\n\t Setting ntimes to 1023.\n",ntimes)); ntimes=1023; } - if(Feb_Control_activated){ - if(!Feb_Control_SetCommandRegister(DAQ_CLK_ROW_CLK_NTIMES) || + if (Feb_Control_activated) { + if (!Feb_Control_SetCommandRegister(DAQ_CLK_ROW_CLK_NTIMES) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CLK_ROW_CLK_NTIMES,ntimes,0,0) || - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(RED,"Warning: could not clock row clock.\n"); + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not clock row clock.\n")); return 0; } } @@ -1691,16 +1698,16 @@ int Feb_Control_ClockRowClock(unsigned int ntimes){ } -int Feb_Control_PulseChip(int npulses){ +int Feb_Control_PulseChip(int npulses) { int i; int on = 1; - if(npulses == -1){ + if (npulses == -1) { on = 0; - printf("\nResetting to normal mode\n"); - }else{ - printf("\n\nPulsing Chip.\n");//really just toggles the enable - printf("Vcmp should be set to 2.0 and Vtrim should be 2.\n"); + FILE_LOG(logINFO, ("\nResetting to normal mode\n")); + } else { + FILE_LOG(logINFO, ("\n\nPulsing Chip.\n"));//really just toggles the enable + FILE_LOG(logINFO, ("Vcmp should be set to 2.0 and Vtrim should be 2.\n")); } @@ -1708,145 +1715,149 @@ int Feb_Control_PulseChip(int npulses){ Feb_Control_SetStaticBits(); //toggle the enable 2x times Feb_Control_ResetChipCompletely(); - for(i=0;i ratemax) ratemax= Feb_Control_rate_meas[i]; + for(i=0;i ratemax) ratemax= Feb_Control_rate_meas[i]; } /* b : index/address of block ram/rate correction table b0 : base in vhdl m : slope in vhdl - + Firmware: data_in(11..2) -> memory address --> memory data_in( 1..0) -> lsb - + mem_data_out(13.. 0) -> base mem_data_out(17..14) -> slope - + delta = slope*lsb corr = base+delta - */ - + */ + int next_i=0; double beforemax; b0[0] = 0; m[0] = 1; - + Feb_Control_rate_correction_table[0] = (((int)(m[0]+0.5)&0xf)<<14) | ((int)(b0[0]+0.5)&0x3fff); int b=0; - for(b=1;b<1024;b++){ - if(m[b-1]<15){ + for(b=1;b<1024;b++) { + if (m[b-1]<15) { double s=0,sx=0,sy=0,sxx=0,sxy=0; - for(;;next_i++){ - if(next_i>=np){ - for(; b<1024; b++){ - if(beforemax>ratemax) b0[b] = beforemax; - else b0[b] = ratemax; - m[b] = 15; - Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff); - } - b=1024; - break; - } - - double x = Feb_Control_rate_meas[next_i] - b*4; - double y = next_i; - /*printf("Start Loop x: %f,\t y: %f,\t s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " + for(;;next_i++) { + if (next_i>=np) { + for(; b<1024; b++) { + if (beforemax>ratemax) b0[b] = beforemax; + else b0[b] = ratemax; + m[b] = 15; + Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff); + } + b=1024; + break; + } + + double x = Feb_Control_rate_meas[next_i] - b*4; + double y = next_i; + /*FILE_LOG(logDEBUG5, ("Start Loop x: %f,\t y: %f,\t s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " "next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n", - x, y, s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/ - - if(x < -0.5) continue; - if(x > 3.5) break; - s += 1; - sx += x; - sy += y; - sxx += x*x; - sxy += x*y; - /*printf("End Loop x: %f,\t y: %f,\t s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " + x, y, s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]));*/ + + if (x < -0.5) continue; + if (x > 3.5) break; + s += 1; + sx += x; + sy += y; + sxx += x*x; + sxy += x*y; + /*FILE_LOG(logDEBUG5, ("End Loop x: %f,\t y: %f,\t s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " "next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n", - x, y, s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/ + x, y, s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]));*/ } double delta = s*sxx - sx*sx; b0[b] = (sxx*sy - sx*sxy)/delta; m[b] = (s*sxy - sx*sy) /delta; beforemax= b0[b]; - if(m[b]<0||m[b]>15){ - m[b]=15; - if(beforemax>ratemax) b0[b] = beforemax; - else b0[b] = ratemax; + if (m[b]<0||m[b]>15) { + m[b]=15; + if (beforemax>ratemax) b0[b] = beforemax; + else b0[b] = ratemax; } - /*printf("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " + /*FILE_LOG(logDEBUG5, ("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " "next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n", - s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]);*/ + s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]));*/ // cout<ratemax) b0[b] = beforemax; - else b0[b] = ratemax; - m[b] = 15; + } else { + if (beforemax>ratemax) b0[b] = beforemax; + else b0[b] = ratemax; + m[b] = 15; } Feb_Control_rate_correction_table[b] = (((int)(m[b]+0.5)&0xf)<<14) | ((int)(b0[b]+0.5)&0x3fff); - /*printf("After Loop 4*b: %d\tbase:%d\tslope:%d\n",4*b, (int)(b0[b]+0.5), (int)(m[b]+0.5) );*/ + /*FILE_LOG(logDEBUG5, ("After Loop 4*b: %d\tbase:%d\tslope:%d\n",4*b, (int)(b0[b]+0.5), (int)(m[b]+0.5) ));*/ } - if(Feb_Control_SetRateCorrectionTable(Feb_Control_rate_correction_table)){ + if (Feb_Control_SetRateCorrectionTable(Feb_Control_rate_correction_table)) { Feb_Control_RateTable_Tau_in_nsec = tau_in_Nsec; Feb_Control_RateTable_Period_in_nsec = period_in_sec*1e9; return 1; - }else{ + } else { Feb_Control_RateTable_Tau_in_nsec = -1; Feb_Control_RateTable_Period_in_nsec = -1; return 0; @@ -1858,75 +1869,75 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){ -int Feb_Control_SetRateCorrectionTable(unsigned int *table){ - if(!table){ - printf("Error: could not set rate correction table, point is zero.\n"); - Feb_Control_SetRateCorrectionVariable(0); - return 0; - } +int Feb_Control_SetRateCorrectionTable(unsigned int *table) { + if (!table) { + FILE_LOG(logERROR, ("Error: could not set rate correction table, point is zero.\n")); + Feb_Control_SetRateCorrectionVariable(0); + return 0; + } - printf("Setting rate correction table. %d %d %d %d ....\n", - table[0],table[1],table[2],table[3]); + FILE_LOG(logINFO, ("Setting rate correction table. %d %d %d %d ....\n", + table[0],table[1],table[2],table[3])); - //was added otherwise after an acquire, startdaqonlywatiforfinish waits forever - if(!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY)){ - cprintf(RED,"Warning: Could not Feb_Control_SetCommandRegister for loading trim bits.\n"); - return 0; - } - printf("daq reset completely\n"); + //was added otherwise after an acquire, startdaqonlywatiforfinish waits forever + if (!Feb_Control_SetCommandRegister(DAQ_RESET_COMPLETELY)) { + FILE_LOG(logERROR, ("Could not Feb_Control_SetCommandRegister for loading trim bits.\n")); + return 0; + } + FILE_LOG(logINFO, ("daq reset completely\n")); - if(Module_TopAddressIsValid(&modules[1])){ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| - !Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(BG_RED,"Error in Top Writing to Memory ::Feb_Control_SetRateCorrectionTable\n"); - return 0; - } - } - }else{ - if(Feb_Control_activated){ - if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| - !Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| - (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)){ - cprintf(BG_RED,"Error in Bottom Writing to Memory ::Feb_Control_SetRateCorrectionTable\n"); - return 0; - } - } - } - return 1; + if (Module_TopAddressIsValid(&modules[1])) { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| + !Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not write to memory (top) ::Feb_Control_SetRateCorrectionTable\n")); + return 0; + } + } + } else { + if (Feb_Control_activated) { + if (!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| + !Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)|| + (Feb_Control_StartDAQOnlyNWaitForFinish(5000) != STATUS_IDLE)) { + FILE_LOG(logERROR, ("could not write to memory (bottom) ::Feb_Control_SetRateCorrectionTable\n")); + return 0; + } + } + } + return 1; } -int Feb_Control_GetRateCorrectionVariable(){ return (Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION);} +int Feb_Control_GetRateCorrectionVariable() { return (Feb_Control_subFrameMode&DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION);} -void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction){ - if(activate_rate_correction){ - Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION; - printf("Rate correction activated.\n"); - }else{ - Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION; - printf("Rate correction deactivated.\n"); - } +void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction) { + if (activate_rate_correction) { + Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION; + FILE_LOG(logINFO, ("Rate correction activated\n")); + } else { + Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION; + FILE_LOG(logINFO, ("Rate correction deactivated\n")); + } } -int Feb_Control_PrintCorrectedValues(){ +int Feb_Control_PrintCorrectedValues() { int i; int delta, slope, base, lsb, corr; - for (i=0; i < 4096; i++){ + for (i=0; i < 4096; i++) { lsb = i&3; base = Feb_Control_rate_correction_table[i>>2] & 0x3fff; slope = ((Feb_Control_rate_correction_table[i>>2] & 0x3c000) >> 14); - + delta = slope*lsb; corr = delta+base; - if(slope==15) corr= 3*slope+base; + if (slope==15) corr= 3*slope+base; - printf("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%lf\n", - i, base, slope, lsb, delta, corr, Feb_Control_rate_meas[i]); + FILE_LOG(logDEBUG5, ("Readout Input: %d,\tBase:%d,\tSlope:%d,\tLSB:%d,\tDelta:%d\tResult:%d\tReal:%lf\n", + i, base, slope, lsb, delta, corr, Feb_Control_rate_meas[i])); } return 1; } @@ -1935,9 +1946,9 @@ int Feb_Control_PrintCorrectedValues(){ //So if software says now 40.00 you neeed to convert to mdegrees 40000(call it A1) and then //A1/65536/0.00198421639-273.15 -int Feb_Control_GetLeftFPGATemp(){ +int Feb_Control_GetLeftFPGATemp() { unsigned int temperature=0; - if(Module_TopAddressIsValid(&modules[1])) + if (Module_TopAddressIsValid(&modules[1])) Feb_Interface_ReadRegister(Module_GetTopLeftAddress (&modules[1]),FEB_REG_STATUS, &temperature); else Feb_Interface_ReadRegister(Module_GetBottomLeftAddress (&modules[1]),FEB_REG_STATUS, &temperature); @@ -1947,9 +1958,9 @@ int Feb_Control_GetLeftFPGATemp(){ return (int)temperature; } -int Feb_Control_GetRightFPGATemp(){ +int Feb_Control_GetRightFPGATemp() { unsigned int temperature=0; - if(Module_TopAddressIsValid(&modules[1])) + if (Module_TopAddressIsValid(&modules[1])) Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),FEB_REG_STATUS, &temperature); else Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),FEB_REG_STATUS, &temperature); @@ -1986,24 +1997,20 @@ int Feb_Control_SoftwareTrigger() { unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER; - if(Feb_Control_activated) { + if (Feb_Control_activated) { // set trigger bit -#ifdef VERBOSE - cprintf(BLUE,"Setting Trigger, Register:0x%x\n",cmd); -#endif + FILE_LOG(logDEBUG5, ("Setting Trigger, Register:0x%x\n",cmd)); if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,cmd,0,0)) { - cprintf(RED,"Warning: Could not give software trigger\n"); + FILE_LOG(logERROR, ("Could not give software trigger\n")); return 0; } // unset trigger bit -#ifdef VERBOSE - cprintf(BLUE,"Unsetting Trigger, Register:0x%x\n",orig_value); -#endif + FILE_LOG(logDEBUG5, ("Unsetting Trigger, Register:0x%x\n",orig_value)); if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,orig_value,0,0)) { - cprintf(RED,"Warning: Could not give software trigger\n"); + FILE_LOG(logERROR, ("Could not give software trigger\n")); return 0; } - cprintf(BLUE,"Software Internal Trigger Sent!\n"); + FILE_LOG(logINFO, ("Software Internal Trigger Sent!\n")); } return 1; @@ -2012,14 +2019,14 @@ int Feb_Control_SoftwareTrigger() { uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) { uint32_t value=0; - if(Module_TopAddressIsValid(&modules[1])){ - if(!Feb_Interface_WriteRegister(Module_GetTopRightAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); + if (Module_TopAddressIsValid(&modules[1])) { + if (!Feb_Interface_WriteRegister(Module_GetTopRightAddress (&modules[1]),offset, data,0, 0)) { + FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value)); value = 0; } } else { - if(!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); + if (!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) { + FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value)); value = 0; } } @@ -2029,14 +2036,14 @@ uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) { uint32_t Feb_Control_ReadRegister(uint32_t offset) { uint32_t value=0; - if(Module_TopAddressIsValid(&modules[1])){ - if(!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); + if (Module_TopAddressIsValid(&modules[1])) { + if (!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) { + FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value)); value = 0; } } else { - if(!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); + if (!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) { + FILE_LOG(logERROR, ("Could not read value. Value read:%d\n", value)); value = 0; } } diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h index b20da4fab..ba3cc4a55 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.h +++ b/slsDetectorServers/eigerDetectorServer/FebControl.h @@ -1,36 +1,24 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - -#ifndef FEBCONTROL_H -#define FEBCONTROL_H - -#include -#include -//#include -//#include - - +#pragma once #include "FebInterface.h" +#include +#include + struct Module{ - unsigned int module_number; - int top_address_valid; - unsigned int top_left_address; - unsigned int top_right_address; - int bottom_address_valid; - unsigned int bottom_left_address; - unsigned int bottom_right_address; + unsigned int module_number; + int top_address_valid; + unsigned int top_left_address; + unsigned int top_right_address; + int bottom_address_valid; + unsigned int bottom_left_address; + unsigned int bottom_right_address; - unsigned int idelay_top[4]; //ll,lr,rl,ll - unsigned int idelay_bottom[4]; //ll,lr,rl,ll - float high_voltage; - int* top_dac; - int* bottom_dac; + unsigned int idelay_top[4]; //ll,lr,rl,ll + unsigned int idelay_bottom[4]; //ll,lr,rl,ll + float high_voltage; + int* top_dac; + int* bottom_dac; }; @@ -38,12 +26,12 @@ void Module_Module(struct Module* mod,unsigned int number, unsigned int address_ void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom); void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom); unsigned int Module_GetModuleNumber(struct Module* mod); -int Module_TopAddressIsValid(struct Module* mod); +int Module_TopAddressIsValid(struct Module* mod); unsigned int Module_GetTopBaseAddress(struct Module* mod); unsigned int Module_GetTopLeftAddress(struct Module* mod) ; unsigned int Module_GetTopRightAddress(struct Module* mod); unsigned int Module_GetBottomBaseAddress(struct Module* mod); -int Module_BottomAddressIsValid(struct Module* mod); +int Module_BottomAddressIsValid(struct Module* mod); unsigned int Module_GetBottomLeftAddress(struct Module* mod); unsigned int Module_GetBottomRightAddress(struct Module* mod); unsigned int Module_SetTopIDelay(struct Module* mod,unsigned int chip,unsigned int value); @@ -51,17 +39,13 @@ unsigned int Module_GetTopIDelay(struct Module* mod,unsigned int chip) ; unsigned int Module_SetBottomIDelay(struct Module* mod,unsigned int chip,unsigned int value); unsigned int Module_GetBottomIDelay(struct Module* mod,unsigned int chip); -float Module_SetHighVoltage(struct Module* mod,float value); -float Module_GetHighVoltage(struct Module* mod); - -int Module_SetTopDACValue(struct Module* mod,unsigned int i, int value); -int Module_GetTopDACValue(struct Module* mod,unsigned int i); -int Module_SetBottomDACValue(struct Module* mod,unsigned int i, int value); -int Module_GetBottomDACValue(struct Module* mod,unsigned int i); - - - +float Module_SetHighVoltage(struct Module* mod,float value); +float Module_GetHighVoltage(struct Module* mod); +int Module_SetTopDACValue(struct Module* mod,unsigned int i, int value); +int Module_GetTopDACValue(struct Module* mod,unsigned int i); +int Module_SetBottomDACValue(struct Module* mod,unsigned int i, int value); +int Module_GetBottomDACValue(struct Module* mod,unsigned int i); void Feb_Control_activate(int activate); @@ -69,142 +53,107 @@ void Feb_Control_activate(int activate); int Feb_Control_IsBottomModule(); int Feb_Control_GetModuleNumber(); +void Feb_Control_PrintModuleList(); +int Feb_Control_GetModuleIndex(unsigned int module_number, unsigned int* module_index); +int Feb_Control_CheckModuleAddresses(struct Module* m); +int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address); +int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned int top_address, unsigned int bottom_address, int half_module); +int Feb_Control_GetDACNumber(char* s, unsigned int* n); +int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value); +int Feb_Control_VoltageToDAC(float value, unsigned int* digital, unsigned int nsteps, float vmin, float vmax); +float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax); +int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units); +int Feb_Control_SetStaticBits(); +int Feb_Control_SetStaticBits1(unsigned int the_static_bits); +int Feb_Control_SendBitModeToBebServer(); +unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec); +unsigned int Feb_Control_AddressToAll(); +int Feb_Control_SetCommandRegister(unsigned int cmd); +int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status); +int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us); +int Feb_Control_ResetChipCompletely(); +int Feb_Control_ResetChipPartially(); +void Feb_Control_FebControl(); +int Feb_Control_Init(int master, int top, int normal, int module_num); +int Feb_Control_OpenSerialCommunication(); +void Feb_Control_CloseSerialCommunication(); +int Feb_Control_CheckSetup(); +unsigned int Feb_Control_GetNModules(); +unsigned int Feb_Control_GetNHalfModules(); +int Feb_Control_SetHighVoltage(int value); +int Feb_Control_GetHighVoltage(int* value); +int Feb_Control_SendHighVoltage(int dacvalue); +int Feb_Control_ReceiveHighVoltage(unsigned int* value); - void Feb_Control_PrintModuleList(); - int Feb_Control_GetModuleIndex(unsigned int module_number, unsigned int* module_index); - int Feb_Control_CheckModuleAddresses(struct Module* m); - int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address); - /*int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module=0);*/ - int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned int top_address, unsigned int bottom_address, int half_module); +int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units); +int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units); - int Feb_Control_GetDACNumber(char* s, unsigned int* n); - int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value); - int Feb_Control_VoltageToDAC(float value, unsigned int* digital, unsigned int nsteps, float vmin, float vmax); - float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax); +int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch); +int Feb_Control_SetDAC(char* s, int value, int is_a_voltage_mv); +int Feb_Control_GetDAC(char* s, int* ret_value, int voltage_mv); +int Feb_Control_GetDACName(unsigned int dac_num,char* s); +int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits); +unsigned int* Feb_Control_GetTrimbits(); +int Feb_Control_SaveAllTrimbitsTo(int value); +int Feb_Control_Reset(); +int Feb_Control_PrepareForAcquisition(); - int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units); +int Feb_Control_StartAcquisition(); +int Feb_Control_StopAcquisition(); +int Feb_Control_AcquisitionInProgress(); +int Feb_Control_AcquisitionStartedBit(); +int Feb_Control_WaitForFinishedFlag(int sleep_time_us); +int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag); +void Feb_Control_PrintAcquisitionSetup(); +int Feb_Control_SetNExposures(unsigned int n_images); +unsigned int Feb_Control_GetNExposures(); +int Feb_Control_SetExposureTime(double the_exposure_time_in_sec); +double Feb_Control_GetExposureTime(); +int64_t Feb_Control_GetExposureTime_in_nsec(); +int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec); +int64_t Feb_Control_GetSubFrameExposureTime(); +int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec); +int64_t Feb_Control_GetSubFramePeriod(); +int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec); +double Feb_Control_GetExposurePeriod(); +int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo); +unsigned int Feb_Control_GetDynamicRange(); +int Feb_Control_SetReadoutSpeed(unsigned int readout_speed); //0 was default, 0->full,1->half,2->quarter or 3->super_slow +int Feb_Control_SetReadoutMode(unsigned int readout_mode); ///0 was default,0->parallel,1->non-parallel,2-> safe_mode +int Feb_Control_SetTriggerMode(unsigned int trigger_mode, int polarity);//0 and 1 was default, +int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity);//0 and 1 was default, - int Feb_Control_SetStaticBits(); - int Feb_Control_SetStaticBits1(unsigned int the_static_bits); +int Feb_Control_SetInTestModeVariable(int on); +int Feb_Control_GetTestModeVariable(); - int Feb_Control_SendBitModeToBebServer(); +void Feb_Control_Set_Counter_Bit(int value); +int Feb_Control_Get_Counter_Bit(); +int Feb_Control_Pulse_Pixel(int npulses,int x, int y); +int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos); +int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in); +int Feb_Control_SendTokenIn(); +int Feb_Control_ClockRowClock(unsigned int ntimes); +int Feb_Control_PulseChip(int npulses); - unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec); +int64_t Feb_Control_Get_RateTable_Tau_in_nsec(); +int64_t Feb_Control_Get_RateTable_Period_in_nsec(); +int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec); +int Feb_Control_SetRateCorrectionTable(unsigned int *table); +int Feb_Control_GetRateCorrectionVariable(); +void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction); +int Feb_Control_PrintCorrectedValues(); - unsigned int Feb_Control_AddressToAll(); - int Feb_Control_SetCommandRegister(unsigned int cmd); - int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status); - /*int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us=5000);*/ - int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us); +int Feb_Control_GetLeftFPGATemp(); +int Feb_Control_GetRightFPGATemp(); - int Feb_Control_ResetChipCompletely(); - int Feb_Control_ResetChipPartially(); +int64_t Feb_Control_GetMeasuredPeriod(); +int64_t Feb_Control_GetSubMeasuredPeriod(); - //struct sockaddr_in Feb_Control_serv_addr; - /* - int Feb_Control_SetupSendToSocket(const char* ip_address_hostname, unsigned short int port); - int Feb_Control_WriteNRead(char* message, int length, int max_length); -*/ +int Feb_Control_SoftwareTrigger(); +uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data); +uint32_t Feb_Control_ReadRegister(uint32_t offset); - void Feb_Control_FebControl(); - int Feb_Control_Init(int master, int top, int normal, int module_num); - int Feb_Control_OpenSerialCommunication(); - void Feb_Control_CloseSerialCommunication(); - int Feb_Control_CheckSetup(); - - unsigned int Feb_Control_GetNModules(); - unsigned int Feb_Control_GetNHalfModules(); - - int Feb_Control_SetHighVoltage(int value); - int Feb_Control_GetHighVoltage(int* value); - - int Feb_Control_SendHighVoltage(int dacvalue); - int Feb_Control_ReceiveHighVoltage(unsigned int* value); - - int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units); - int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units); - - int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch); - /*int Feb_Control_SetDAC(string s, int value, int is_a_voltage_mv=0);*/ - int Feb_Control_SetDAC(char* s, int value, int is_a_voltage_mv); - /* int Feb_Control_GetDAC(string s, int* ret_value, int voltage_mv=0);*/ - int Feb_Control_GetDAC(char* s, int* ret_value, int voltage_mv); - int Feb_Control_GetDACName(unsigned int dac_num,char* s); - - int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits); - unsigned int* Feb_Control_GetTrimbits(); - - - /**Added by Dhanya */ - int Feb_Control_SaveAllTrimbitsTo(int value); - - - - int Feb_Control_Reset(); - int Feb_Control_PrepareForAcquisition(); - - int Feb_Control_StartAcquisition(); - int Feb_Control_StopAcquisition(); - int Feb_Control_AcquisitionInProgress(); - int Feb_Control_AcquisitionStartedBit(); - /*int Feb_Control_WaitForFinishedFlag(int sleep_time_us=5000);*/ - int Feb_Control_WaitForFinishedFlag(int sleep_time_us); - int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag); - - //functions for setting up exposure - void Feb_Control_PrintAcquisitionSetup(); - int Feb_Control_SetNExposures(unsigned int n_images); - unsigned int Feb_Control_GetNExposures(); - int Feb_Control_SetExposureTime(double the_exposure_time_in_sec); - double Feb_Control_GetExposureTime(); - int64_t Feb_Control_GetExposureTime_in_nsec(); - int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec); - int64_t Feb_Control_GetSubFrameExposureTime(); - int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec); - int64_t Feb_Control_GetSubFramePeriod(); - int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec); - double Feb_Control_GetExposurePeriod(); - int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo); - unsigned int Feb_Control_GetDynamicRange(); - int Feb_Control_SetReadoutSpeed(unsigned int readout_speed); //0 was default, 0->full,1->half,2->quarter or 3->super_slow - int Feb_Control_SetReadoutMode(unsigned int readout_mode); ///0 was default,0->parallel,1->non-parallel,2-> safe_mode - int Feb_Control_SetTriggerMode(unsigned int trigger_mode, int polarity);//0 and 1 was default, - int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity);//0 and 1 was default, - - //functions for testing - /*int Feb_Control_SetTestModeVariable(int on=1);*/ - int Feb_Control_SetInTestModeVariable(int on); - int Feb_Control_GetTestModeVariable(); - - void Feb_Control_Set_Counter_Bit(int value); - int Feb_Control_Get_Counter_Bit(); - int Feb_Control_Pulse_Pixel(int npulses,int x, int y); - int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos); - int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in); - int Feb_Control_SendTokenIn(); - int Feb_Control_ClockRowClock(unsigned int ntimes); - int Feb_Control_PulseChip(int npulses); - - int64_t Feb_Control_Get_RateTable_Tau_in_nsec(); - int64_t Feb_Control_Get_RateTable_Period_in_nsec(); - int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec); - int Feb_Control_SetRateCorrectionTable(unsigned int *table); - int Feb_Control_GetRateCorrectionVariable(); - void Feb_Control_SetRateCorrectionVariable(int activate_rate_correction); - int Feb_Control_PrintCorrectedValues(); - - int Feb_Control_GetLeftFPGATemp(); - int Feb_Control_GetRightFPGATemp(); - - int64_t Feb_Control_GetMeasuredPeriod(); - int64_t Feb_Control_GetSubMeasuredPeriod(); - - int Feb_Control_SoftwareTrigger(); - - uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data); - uint32_t Feb_Control_ReadRegister(uint32_t offset); -#endif diff --git a/slsDetectorServers/eigerDetectorServer/FebInterface.c b/slsDetectorServers/eigerDetectorServer/FebInterface.c index a094bda44..5ca087d42 100644 --- a/slsDetectorServers/eigerDetectorServer/FebInterface.c +++ b/slsDetectorServers/eigerDetectorServer/FebInterface.c @@ -1,45 +1,31 @@ - -/** - * @author Ian Johnson - * @version 1.0 - */ - - - -//#include -//#include -//#include -//#include -//#include -//#include +#include "FebInterface.h" +#include "LocalLinkInterface.h" +#include "xparameters.h" +#include "logger.h" #include #include #include -#include "xparameters.h" - -#include "FebInterface.h" +struct LocalLinkInterface ll_local,* ll; - struct LocalLinkInterface ll_local,* ll; +unsigned int Feb_Interface_nfebs; +unsigned int* Feb_Interface_feb_numb; - unsigned int Feb_Interface_nfebs; - unsigned int* Feb_Interface_feb_numb; +int Feb_Interface_send_ndata; +unsigned int Feb_Interface_send_buffer_size; +unsigned int* Feb_Interface_send_data_raw; +unsigned int* Feb_Interface_send_data; - int Feb_Interface_send_ndata; - unsigned int Feb_Interface_send_buffer_size; - unsigned int* Feb_Interface_send_data_raw; - unsigned int* Feb_Interface_send_data; - - int Feb_Interface_recv_ndata; - unsigned int Feb_Interface_recv_buffer_size; - unsigned int* Feb_Interface_recv_data_raw; - unsigned int* Feb_Interface_recv_data; +int Feb_Interface_recv_ndata; +unsigned int Feb_Interface_recv_buffer_size; +unsigned int* Feb_Interface_recv_data_raw; +unsigned int* Feb_Interface_recv_data; -void Feb_Interface_FebInterface(){ +void Feb_Interface_FebInterface() { ll = &ll_local; Feb_Interface_nfebs = 0; Feb_Interface_feb_numb = 0; @@ -54,131 +40,129 @@ void Feb_Interface_FebInterface(){ Feb_Interface_recv_data_raw = malloc((Feb_Interface_recv_buffer_size+1) * sizeof(unsigned int)); Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1]; - Local_LocalLinkInterface1(ll,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR); + Local_LocalLinkInterface1(ll,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR); } -void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list){ +void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list) { unsigned int i; - if(Feb_Interface_feb_numb) free(Feb_Interface_feb_numb); - Feb_Interface_nfebs = n; - Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int)); - for(i=0;i0xfff) return 0; +int Feb_Interface_WriteTo(unsigned int ch) { + if (ch>0xfff) return 0; -#ifdef MARTIN - cprintf(YELLOW, "FIW ch %d\n", ch); -#endif + FILE_LOG(logDEBUG5, ("FIW ch %d\n", ch)); - Feb_Interface_send_data_raw[0] = 0x8fff0000; - if(Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; +Feb_Interface_send_data_raw[0] = 0x8fff0000; +if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; - Feb_Interface_send_data_raw[0] = 0x90000000 | (ch<<16); - if(Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; +Feb_Interface_send_data_raw[0] = 0x90000000 | (ch<<16); +if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; - Feb_Interface_send_data_raw[0] = 0xc0000000; - return ((Feb_Interface_send_ndata+1)*4==Local_Write(ll,(Feb_Interface_send_ndata+1)*4,Feb_Interface_send_data_raw)); +Feb_Interface_send_data_raw[0] = 0xc0000000; +return ((Feb_Interface_send_ndata+1)*4==Local_Write(ll,(Feb_Interface_send_ndata+1)*4,Feb_Interface_send_data_raw)); } -int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys){ +int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) { unsigned int t; - if(ch>=0xfff) return 0; + if (ch>=0xfff) return 0; - Feb_Interface_recv_data_raw[0] = 0xa0000000 | (ch<<16); - Local_Write(ll,4,Feb_Interface_recv_data_raw); - usleep(20); - - Feb_Interface_recv_ndata=-1; - for(t=0;t0){ - Feb_Interface_recv_ndata--; - break; - } - usleep(1000); - } + Feb_Interface_recv_data_raw[0] = 0xa0000000 | (ch<<16); + Local_Write(ll,4,Feb_Interface_recv_data_raw); + usleep(20); - return (Feb_Interface_recv_ndata>=0); + Feb_Interface_recv_ndata=-1; + for(t=0;t0) { + Feb_Interface_recv_ndata--; + break; + } + usleep(1000); + } + + return (Feb_Interface_recv_ndata>=0); } -int Feb_Interface_SetByteOrder(){ +int Feb_Interface_SetByteOrder() { Feb_Interface_send_data_raw[0] = 0x8fff0000; - if(Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; - Feb_Interface_send_ndata = 2; - Feb_Interface_send_data[0] = 0; - Feb_Interface_send_data[1] = 0; - unsigned int i; - unsigned int dst = 0xff; - for(i=0;iFeb_Interface_send_buffer_size-2) return 0; + unsigned int dst = 0xff; + for(i=0;iFeb_Interface_send_buffer_size-2) return 0; + nreads &= 0x3ff; + if (!nreads||nreads>Feb_Interface_send_buffer_size-2) return 0; - //cout<<"Write register : "<Feb_Interface_send_buffer_size-2) return 0; + + //cout<<"Write register : "<0){ + while(ndata_countdown>0) { n_to_send = ndata_countdownFeb_Interface_send_buffer_size-2) {printf("error herer: nwrites:%d\n",nwrites);return 0;}//*d-1026 + mem_num &= 0x3f; + start_address &= 0x3fff; + nwrites &= 0x3ff; + if (!nwrites||nwrites>Feb_Interface_send_buffer_size-2) { + FILE_LOG(logERROR, ("invalid nwrites:%d\n",nwrites)); + return 0; + }//*d-1026 - Feb_Interface_send_ndata = nwrites+2;//*d-1026 - Feb_Interface_send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address - Feb_Interface_send_data[nwrites+1] = 0; - for(i=0;i write to memory, nwrites, mem number, start address + Feb_Interface_send_data[nwrites+1] = 0; + for(i=0;i -//#include -//#include -//#include -//#include - #include "HardwareIO.h" xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress) diff --git a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c index 8d1b9db1f..7679ad432 100644 --- a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c +++ b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c @@ -1,44 +1,36 @@ - -//Class initially from Gerd and was called mmap_test.c -//return reversed 1 means good, 0 means failed - +#include "LocalLinkInterface.h" +#include "HardwareMMappingDefs.h" +#include "logger.h" +#include "ansi.h" #include #include -//#include +#include +#include -#include "HardwareMMappingDefs.h" - -#include "LocalLinkInterface.h" - - - -void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){ - // printf("\n v 1 \n"); - printf("Initialize PLB LL FIFOs\n"); +void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) { + FILE_LOG(logDEBUG5, ("Initialize PLB LL FIFOs\n")); ll->ll_fifo_base=0; ll->ll_fifo_ctrl_reg=0; - if(Local_Init(ll,ll_fifo_badr)){ + if (Local_Init(ll,ll_fifo_badr)) { Local_Reset(ll); - printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll)); - }else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr); - printf("\n\n"); + FILE_LOG(logDEBUG5, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll))); + } else FILE_LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr)); } -/*~LocalLinkInterface(){};*/ -void Local_LocalLinkInterface(struct LocalLinkInterface* ll){ - printf("Initializing new memory\n"); +void Local_LocalLinkInterface(struct LocalLinkInterface* ll) { + FILE_LOG(logDEBUG5, ("Initializing new memory\n")); } -int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){ +int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) { int fd; void *plb_ll_fifo_ptr; - if ((fd=open("/dev/mem", O_RDWR)) < 0){ + if ((fd=open("/dev/mem", O_RDWR)) < 0) { fprintf(stderr, "Could not open /dev/mem\n"); return 0; } @@ -46,7 +38,7 @@ int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){ plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr); close(fd); - if (plb_ll_fifo_ptr == MAP_FAILED){ + if (plb_ll_fifo_ptr == MAP_FAILED) { perror ("mmap"); return 0; } @@ -59,13 +51,13 @@ int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){ -int Local_Reset(struct LocalLinkInterface* ll){ +int Local_Reset(struct LocalLinkInterface* ll) { return Local_Reset1(ll,PLB_LL_FIFO_CTRL_RESET_STD); } -int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask){ +int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) { ll->ll_fifo_ctrl_reg |= rst_mask; - printf("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg); + FILE_LOG(logDEBUG5, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg)); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); @@ -75,17 +67,16 @@ int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask){ ll->ll_fifo_ctrl_reg &= (~rst_mask); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); - // printf("FIFO CTRL Address: 0x%08x\n FIFO CTRL Register: 0x%08x\n",PLB_LL_FIFO_REG_CTRL,plb_ll_fifo[PLB_LL_FIFO_REG_CTRL]); return 1; } -unsigned int Local_StatusVector(struct LocalLinkInterface* ll){ +unsigned int Local_StatusVector(struct LocalLinkInterface* ll) { return HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS); } -int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){ +int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { // note: buffer must be word (4 byte) aligned // frame_len in byte int vacancy=0; @@ -101,22 +92,19 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf last_word = (buffer_len-1)/4; word_ptr = (unsigned int *)buffer; -#ifdef MARTIN - cprintf(BLUE, "LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base); + FILE_LOG(logDEBUG5, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base)); for (i=0; i < buffer_len/4; i++) - cprintf(BLUE, "%.8X ",*(((unsigned *) buffer)+i)); - printf("\n"); -#endif + FILE_LOG(logDEBUG5, ("%.8X ",*(((unsigned *) buffer)+i))); while (words_send <= last_word) { while (!vacancy)//wait for Fifo to be empty again { status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS); - if((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1; -#ifdef MARTIN - if (vacancy == 0) cprintf(RED, "Fifo full!\n"); -#endif + if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1; + if (vacancy == 0) { + FILE_LOG(logERROR, ("Fifo full!\n")); + } } //Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100 @@ -140,7 +128,7 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf } -int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){ +int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { static unsigned int buffer_ptr = 0; // note: buffer must be word (4 byte) aligned // frame_len in byte @@ -150,9 +138,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff volatile unsigned int fifo_val; int sof = 0; -#ifdef MARTIN - cprintf(CYAN, "LL Read - If: %X - Data: ",ll->ll_fifo_base); -#endif + FILE_LOG(logDEBUG5, ("LL Read - If: %X - Data: ",ll->ll_fifo_base)); word_ptr = (unsigned int *)buffer; do @@ -168,7 +154,6 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff buffer_ptr = 0; return -1; // buffer overflow } - // printf(">>>> SOF\n\r"); buffer_ptr = 0; sof = 1; } @@ -179,9 +164,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff { if ( (buffer_len >> 2) > buffer_ptr) { -#ifdef MARTIN - cprintf(CYAN, "%.8X ", fifo_val); -#endif + FILE_LOG(logDEBUG5, ("%.8X ", fifo_val)); word_ptr[buffer_ptr++] = fifo_val; //write to buffer } else @@ -193,10 +176,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff if (status & PLB_LL_FIFO_STATUS_LL_EOF) { len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT ); -#ifdef MARTIN - cprintf(CYAN, "Len: %d\n",len); -#endif - // printf(">>>>status=0x%08x EOF len = %d \n\r\n\r",status, len); + FILE_LOG(logDEBUG5, ("Len: %d\n",len)); buffer_ptr = 0; return len; } @@ -209,19 +189,15 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff return 0; } -int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val){ - // printf("Fifo CTRL Reg(1): 0x%08x\n",plb_ll_fifo_ctrl_reg); +int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val) { ll->ll_fifo_ctrl_reg &= (~mask); - //printf("Fifo CTRL Reg(2): 0x%08x\n",plb_ll_fifo_ctrl_reg); ll->ll_fifo_ctrl_reg |= ( mask & val); - // printf("Fifo CTRL Reg: 0x%08x\n",plb_ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); - // printf("Fifo STAT Reg: 0x%08x\n", plb_ll_fifo[PLB_LL_FIFO_REG_STATUS]); return 1; } -int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){ +int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { int len; unsigned int rec_buff_len = 4096; @@ -233,28 +209,14 @@ int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff do{ len = Local_Read(ll,rec_buff_len,rec_buffer); - printf("receive length: %i\n",len); + FILE_LOG(logDEBUG5, ("receive length: %i\n",len)); - if (len > 0){ + if (len > 0) { rec_buffer[len]=0; - printf((char*) rec_buffer); - printf("\n"); + FILE_LOG(logINFO, ("%s\n", (char*) rec_buffer)); } } while(len > 0); - printf("\n\n\n\n"); return 1; } -void Local_llfifo_print_frame(struct LocalLinkInterface* ll,unsigned char* fbuff, int len){ - int i; - printf("\n\r----Frame of len : %d Byte\n\r",len); - for(i=0;i - -#include "ansi.h" -#include -#include - -/*class LocalLinkInterface: public HardwareIO{ //*/ struct LocalLinkInterface{ - xfs_u32 ll_fifo_base; - unsigned int ll_fifo_ctrl_reg; + xfs_u32 ll_fifo_base; + unsigned int ll_fifo_ctrl_reg; }; +int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); +int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask); +int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val); +void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); +unsigned int Local_StatusVector(struct LocalLinkInterface* ll); +int Local_Reset(struct LocalLinkInterface* ll); +int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); +int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); +int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); +void Local_LocalLinkInterface(struct LocalLinkInterface* ll); - - int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); - int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask); - - int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val); - void Local_llfifo_print_frame(struct LocalLinkInterface* ll,unsigned char* fbuff, int len); - - - void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); - /* virtual ~LocalLinkInterface();*/ - - unsigned int Local_StatusVector(struct LocalLinkInterface* ll); - int Local_Reset(struct LocalLinkInterface* ll); - int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); - int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); - - int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); - - void Local_LocalLinkInterface(struct LocalLinkInterface* ll); - - /* - int FiFoReset(unsigned int numb); - int FifoSend(unsigned int numb, unsigned int frame_len, void *buffer); - int FifoReceive(unsigned int numb, unsigned int frame_len, void *buffer); - int FifoTest(unsigned int numb,unsigned int send_len, char *send_str); - */ - - - - -#endif diff --git a/slsDetectorServers/eigerDetectorServer/gitInfo.txt b/slsDetectorServers/eigerDetectorServer/gitInfo.txt index 8aa8ce29d..136474476 100644 --- a/slsDetectorServers/eigerDetectorServer/gitInfo.txt +++ b/slsDetectorServers/eigerDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: 178b83222380f7b7294cde66e66719c5d1c1363c -Revision: 2 +Repsitory UUID: dfad145e1492e961c95063aa5b2f54e5e1b418a0 +Revision: 3 Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4125 -Last Changed Date: 2018-10-16 09:02:45.000000002 +0200 ./Makefile +Last Changed Rev: 4127 +Last Changed Date: 2018-10-23 12:30:26.000000002 +0200 ./Beb.c diff --git a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h b/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h index 6ae33d32f..2254b38c9 100644 --- a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h +++ b/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "178b83222380f7b7294cde66e66719c5d1c1363c" +#define GITREPUUID "dfad145e1492e961c95063aa5b2f54e5e1b418a0" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4125 -#define GITDATE 0x20181016 +#define GITREV 0x4127 +#define GITDATE 0x20181023 #define GITBRANCH "refactor" diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 2231ae283..0de061582 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1,3 +1,12 @@ +#include "slsDetectorFunctionList.h" +#ifndef VIRTUAL +#include "gitInfoEiger.h" +#include "FebControl.h" +#include "Beb.h" +#include "versionAPI.h" +#endif +#include "logger.h" + #include #include //to gethostname @@ -7,32 +16,39 @@ #include #endif -#include "slsDetectorFunctionList.h" -#ifndef VIRTUAL -#include "gitInfoEiger.h" -#include "FebControl.h" -#include "Beb.h" -#include "versionAPI.h" -#endif - // Global variable from slsDetectorServer extern int debugflag; +extern int isControlServer; -int default_tau_from_file= -1; - -#define BEB_NUM 34 - -enum detectorSettings thisSettings; const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"}; - -enum{E_PARALLEL, E_NON_PARALLEL, E_SAFE}; - +int default_tau_from_file= -1; +enum detectorSettings thisSettings; sls_detector_module *detectorModules=NULL; int *detectorChips=NULL; int *detectorChans=NULL; int *detectorDacs=NULL; int *detectorAdcs=NULL; +int send_to_ten_gig = 0; +int ndsts_in_use=32; +unsigned int nimages_per_request=1; +int on_dst=0; +int dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +enum masterFlags masterMode=IS_SLAVE; +int top = 0; +int master = 0; +int normal = 0; +#ifndef VIRTUAL +uint32_t detid = 0; +#endif + + +int firmware_compatibility = OK; +int firmware_check_done = 0; +char firmware_message[MAX_STR_LENGTH]; + + int eiger_highvoltage = 0; int eiger_theo_highvoltage = 0; int eiger_iodelay = 0; @@ -72,30 +88,6 @@ int eiger_virtual_stop = 0; #endif -int send_to_ten_gig = 0; -int ndsts_in_use=32; -unsigned int nimages_per_request=1; -int on_dst=0; -int dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - -int default_gain_values[3] = {517000,517000,517000}; -int default_offset_values[3] = {3851000,3851000,3851000}; - - -enum masterFlags masterMode=IS_SLAVE; -int top = 0; -int master = 0; -int normal = 0; -#ifndef VIRTUAL -uint32_t detid = 0; -#endif - -/* basic tests */ - -int firmware_compatibility = OK; -int firmware_check_done = 0; -char firmware_message[MAX_STR_LENGTH]; int isFirmwareCheckDone() { @@ -107,15 +99,12 @@ int getFirmwareCheckResult(char** mess) { return firmware_compatibility; } -void checkFirmwareCompatibility(){ +void checkFirmwareCompatibility() { firmware_compatibility = OK; firmware_check_done = 0; memset(firmware_message, 0, MAX_STR_LENGTH); #ifdef VIRTUAL - cprintf(BLUE,"\n\n" - "********************************************************\n" - "***************** EIGER Virtual Server *****************\n" - "********************************************************\n"); + FILE_LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n")); firmware_check_done = 1; return; #endif @@ -126,11 +115,7 @@ void checkFirmwareCompatibility(){ int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); int64_t client_sw_apiversion = getDetectorId(CLIENT_SOFTWARE_API_VERSION); - cprintf(BLUE,"\n\n" - "********************************************************\n" - "**********************EIGER Server**********************\n" - "********************************************************\n"); - cprintf(BLUE,"\n" + FILE_LOG(logINFOBLUE, ("**************** EIGER Server *********************\n\n" "Detector IP Addr:\t\t 0x%x\n" "Detector MAC Addr:\t\t 0x%llx\n" @@ -147,50 +132,47 @@ void checkFirmwareCompatibility(){ (long long int)swversion, (long long int)sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION, - (long long int)client_sw_apiversion); + (long long int)client_sw_apiversion)); // return if debugflag is not zero, debug mode if (debugflag) { firmware_check_done = 1; - return; + return; } //cant read versions - if(!fwversion || !sw_fw_apiversion){ - strcpy(firmware_message, - "FATAL ERROR: Cant read versions from FPGA. Please update firmware.\n"); - cprintf(RED,"%s\n\n", firmware_message); + if (!fwversion || !sw_fw_apiversion) { + strcpy(firmware_message, "Cant read versions from FPGA. Please update firmware.\n"); + FILE_LOG(logERROR, (firmware_message)); firmware_compatibility = FAIL; firmware_check_done = 1; return; } //check for API compatibility - old server - if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ - sprintf(firmware_message, - "FATAL ERROR: This detector software software version (%lld) is incompatible.\n" + if (sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION) { + sprintf(firmware_message, "This detector software software version (%lld) is incompatible.\n" "Please update detector software (min. %lld) to be compatible with this firmware.\n", (long long int)sw_fw_apiversion, (long long int)REQUIRED_FIRMWARE_VERSION); - cprintf(RED,"%s\n\n", firmware_message); + FILE_LOG(logERROR, (firmware_message)); firmware_compatibility = FAIL; firmware_check_done = 1; return; } //check for firmware compatibility - old firmware - if( REQUIRED_FIRMWARE_VERSION > fwversion){ - sprintf(firmware_message, - "FATAL ERROR: This firmware version (%lld) is incompatible.\n" + if ( REQUIRED_FIRMWARE_VERSION > fwversion) { + sprintf(firmware_message, "This firmware version (%lld) is incompatible.\n" "Please update firmware (min. %lld) to be compatible with this server.\n", (long long int)fwversion, (long long int)REQUIRED_FIRMWARE_VERSION); - cprintf(RED,"%s\n\n", firmware_message); + FILE_LOG(logERROR, (firmware_message)); firmware_compatibility = FAIL; firmware_check_done = 1; return; } - printf("Compatibility - success\n"); + FILE_LOG(logINFO, ("Compatibility - success\n")); firmware_check_done = 1; } @@ -200,13 +182,13 @@ void checkFirmwareCompatibility(){ /* Ids */ -int64_t getDetectorId(enum idMode arg){ +int64_t getDetectorId(enum idMode arg) { #ifdef VIRTUAL return 0; #else int64_t retval = -1; - switch(arg){ + switch(arg) { case DETECTOR_SERIAL_NUMBER: retval = getDetectorNumber();/** to be implemented with mac? */ break; @@ -215,7 +197,7 @@ int64_t getDetectorId(enum idMode arg){ case SOFTWARE_FIRMWARE_API_VERSION: return (int64_t)Beb_GetFirmwareSoftwareAPIVersion(); case DETECTOR_SOFTWARE_VERSION: - return (GITDATE & 0xFFFFFF); + return (GITDATE & 0xFFFFFF); case CLIENT_SOFTWARE_API_VERSION: return APIEIGER; default: @@ -236,7 +218,7 @@ u_int64_t getFirmwareVersion() { -u_int32_t getDetectorNumber(){ +u_int32_t getDetectorNumber() { #ifdef VIRTUAL return 0; #else @@ -262,22 +244,22 @@ u_int64_t getDetectorMAC() { //getting rid of ":" char * pch; pch = strtok (output,":"); - while (pch != NULL){ + while (pch != NULL) { strcat(mac,pch); pch = strtok (NULL, ":"); } sscanf(mac,"%llx",&res); //increment by 1 for 10g - if(send_to_ten_gig) + if (send_to_ten_gig) res++; - //printf("mac:%llx\n",res); + //FILE_LOG(logINFO, ("mac:%llx\n",res)); return res; #endif } -u_int32_t getDetectorIP(){ +u_int32_t getDetectorIP() { #ifdef VIRTUAL return 0; #endif @@ -298,7 +280,7 @@ u_int32_t getDetectorIP(){ } strcpy(output,temp); sscanf(output, "%x", &res); - //printf("ip:%x\n",res); + //FILE_LOG(logINFO, ("ip:%x\n",res)); return res; } @@ -309,11 +291,10 @@ u_int32_t getDetectorIP(){ /* initialization */ -void initControlServer(){ +void initControlServer() { #ifdef VIRTUAL getModuleConfiguration(); setupDetector(); - printf("\n"); return; #else //Feb and Beb Initializations @@ -322,38 +303,35 @@ void initControlServer(){ Feb_Control_FebControl(); Feb_Control_Init(master,top,normal, getDetectorNumber()); //master of 9M, check high voltage serial communication to blackfin - if(master && !normal){ - if(Feb_Control_OpenSerialCommunication()) - ;// Feb_Control_CloseSerialCommunication(); + if (master && !normal) { + if (Feb_Control_OpenSerialCommunication()) + ;// Feb_Control_CloseSerialCommunication(); } - printf("FEB Initialization done\n"); - Beb_Beb(); + FILE_LOG(logDEBUG5, ("Control server: FEB Initialization done\n")); + Beb_Beb(detid); Beb_SetDetectorNumber(getDetectorNumber()); - printf("BEB Initialization done\n"); + FILE_LOG(logDEBUG5, ("Control server: BEB Initialization done\n")); setupDetector(); #endif - printf("\n"); } -void initStopServer(){ +void initStopServer() { #ifdef VIRTUAL getModuleConfiguration(); - printf("\n"); return; #else getModuleConfiguration(); Feb_Interface_FebInterface(); Feb_Control_FebControl(); Feb_Control_Init(master,top,normal,getDetectorNumber()); - printf("FEB Initialization done\n"); + FILE_LOG(logDEBUG5, ("Stop server: FEB Initialization done\n")); #endif - printf("\n"); } -void getModuleConfiguration(){ +void getModuleConfiguration() { #ifdef VIRTUAL #ifdef VIRTUAL_MASTER master = 1; @@ -367,24 +345,22 @@ void getModuleConfiguration(){ #else normal = 1; #endif - if(top) printf("*************** TOP ***************\n"); - else printf("*************** BOTTOM ***************\n"); - if(master) printf("*************** MASTER ***************\n"); - else printf("*************** SLAVE ***************\n"); - if(normal) printf("*************** NORMAL ***************\n"); - else printf("*************** SPECIAL ***************\n"); + FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n", + (top ? "TOP" : "BOTTOM"), + (master ? "MASTER" : "SLAVE"), + (normal ? "NORMAL" : "SPECIAL"))); return; #else int *m=&master; int *t=⊤ int *n=&normal; Beb_GetModuleConfiguration(m,t,n); - if(top) printf("*************** TOP ***************\n"); - else printf("*************** BOTTOM ***************\n"); - if(master) printf("*************** MASTER ***************\n"); - else printf("*************** SLAVE ***************\n"); - if(normal) printf("*************** NORMAL ***************\n"); - else printf("*************** SPECIAL ***************\n"); + if (isControlServer) { + FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n", + (top ? "TOP" : "BOTTOM"), + (master ? "MASTER" : "SLAVE"), + (normal ? "NORMAL" : "SPECIAL"))); + } // read detector id char output[255]; @@ -392,7 +368,9 @@ void getModuleConfiguration(){ fgets(output, sizeof(output), sysFile); pclose(sysFile); sscanf(output,"%u",&detid); - printf("detector id: %u\n",detid); + if (isControlServer) { + FILE_LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid)); + } #endif } @@ -400,8 +378,8 @@ void getModuleConfiguration(){ /* set up detector */ -void allocateDetectorStructureMemory(){ - printf("This Server is for 1 Eiger half module (250k)\n"); +void allocateDetectorStructureMemory() { + FILE_LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n")); //Allocation of memory detectorModules=malloc(sizeof(sls_detector_module)); @@ -409,13 +387,11 @@ void allocateDetectorStructureMemory(){ detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); detectorDacs=malloc(NDAC*sizeof(int)); detectorAdcs=malloc(NADC*sizeof(int)); -#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n); - printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP); - printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN); - printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC); - printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC); -#endif + FILE_LOG(logDEBUG5, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); + FILE_LOG(logDEBUG5, ("chips from 0x%x to 0x%x\n",detectorChips, detectorChips)); + FILE_LOG(logDEBUG5, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); + FILE_LOG(logDEBUG5, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); + FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); (detectorModules)->dacs=detectorDacs; (detectorModules)->adcs=detectorAdcs; (detectorModules)->chipregs=detectorChips; @@ -442,18 +418,20 @@ void setupDetector() { allocateDetectorStructureMemory(); //set dacs - printf("Setting Default Dac values\n"); + FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n")); { int i = 0; int retval[2]={-1,-1}; const int defaultvals[NDAC] = DEFAULT_DAC_VALS; for(i = 0; i < NDAC; ++i) { setDAC((enum DACINDEX)i,defaultvals[i],0,retval); - if (retval[0] != defaultvals[i]) - cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]); + if (retval[0] != defaultvals[i]) { + FILE_LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0])); + } } } + FILE_LOG(logINFOBLUE, ("Setting Default Parameters\n")); //setting default measurement parameters setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME); @@ -466,7 +444,7 @@ void setupDetector() { setReadOutFlags(DEFAULT_READOUT_MODE); setReadOutFlags(DEFAULT_READOUT_STOREINRAM_MODE); setReadOutFlags(DEFAULT_READOUT_OVERFLOW32_MODE); - setSpeed(CLOCK_DIVIDER, DEFAULT_CLK_SPEED);//clk_devider,half speed + setSpeed(DEFAULT_CLK_SPEED);//clk_devider,half speed setIODelay(DEFAULT_IO_DELAY); setTiming(DEFAULT_TIMING_MODE); //SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15); @@ -480,6 +458,7 @@ void setupDetector() { #ifndef VIRTUAL Feb_Control_CheckSetup(); #endif + FILE_LOG(logDEBUG5, ("Setup detector done\n\n")); } @@ -506,25 +485,25 @@ uint32_t readRegister(uint32_t offset) { /* set parameters - dr, roi */ -int setDynamicRange(int dr){ +int setDynamicRange(int dr) { #ifdef VIRTUAL - if(dr > 0){ - printf(" Setting dynamic range: %d\n",dr); + if (dr > 0) { + FILE_LOG(logINFO, ("Setting dynamic range: %d\n", dr)); eiger_dynamicrange = dr; } return eiger_dynamicrange; #else - if(dr > 0){ - printf(" Setting dynamic range: %d\n",dr); - if(Feb_Control_SetDynamicRange(dr)){ + if (dr > 0) { + FILE_LOG(logDEBUG5, ("Setting dynamic range: %d\n", dr)); + if (Feb_Control_SetDynamicRange(dr)) { //EigerSetBitMode(dr); on_dst = 0; int i; for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested - if(Beb_SetUpTransferParameters(dr)) + if (Beb_SetUpTransferParameters(dr)) eiger_dynamicrange = dr; - else printf("ERROR:Could not set bit mode in the back end\n"); + else FILE_LOG(logERROR, ("Could not set bit mode in the back end\n")); } } //make sure back end and front end have the same bit mode @@ -539,15 +518,12 @@ int setDynamicRange(int dr){ /* parameters - readout */ -int setSpeed(enum speedVariable arg, int val){ +enum speedVariable setSpeed(int val) { - if (arg != CLOCK_DIVIDER) - return -1; - - if(val != -1){ - printf(" Setting Read out Speed: %d\n",val); + if (val != -1) { + FILE_LOG(logDEBUG5, ("Setting Read out Speed: %d\n", val)); #ifndef VIRTUAL - if(Feb_Control_SetReadoutSpeed(val)) + if (Feb_Control_SetReadoutSpeed(val)) #endif eiger_readoutspeed = val; } @@ -555,25 +531,33 @@ int setSpeed(enum speedVariable arg, int val){ } -enum readOutFlags setReadOutFlags(enum readOutFlags val){ +enum readOutFlags setReadOutFlags(enum readOutFlags val) { enum readOutFlags retval = GET_READOUT_FLAGS; - if(val!=GET_READOUT_FLAGS){ + if (val!=GET_READOUT_FLAGS) { - if(val&0xF0000){ - switch(val){ - case PARALLEL: val=E_PARALLEL; printf(" Setting Read out Flag: Parallel\n"); break; - case NONPARALLEL: val=E_NON_PARALLEL; printf(" Setting Read out Flag: Non Parallel\n"); break; - case SAFE: val=E_SAFE; printf(" Setting Read out Flag: Safe\n"); break; + if (val&0xF0000) { + switch(val) { + case PARALLEL: + val=E_PARALLEL; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Parallel\n")); + break; + case NONPARALLEL: + val=E_NON_PARALLEL; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Non Parallel\n")); + break; + case SAFE: + val=E_SAFE; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Safe\n")); + break; default: - cprintf(RED,"Cannot set unknown readout flag. 0x%x\n", val); + FILE_LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", val)); return -1; } - printf(" Setting Read out Flag: %d\n",val); #ifndef VIRTUAL - if(Feb_Control_SetReadoutMode(val)) + if (Feb_Control_SetReadoutMode(val)) #endif eiger_readoutmode = val; #ifndef VIRTUAL @@ -583,16 +567,21 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){ } else if (val&0xF00000) { - switch(val){ - case SHOW_OVERFLOW: val=1; printf(" Setting Read out Flag: Overflow in 32 bit mode\n"); break; - case NOOVERFLOW: val=0; printf(" Setting Read out Flag: No overflow in 32 bit mode\n"); break; + switch(val) { + case SHOW_OVERFLOW: + val=1; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Overflow in 32 bit mode\n")); + break; + case NOOVERFLOW: + val=0; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: No overflow in 32 bit mode\n")); + break; default: - cprintf(RED,"Cannot set unknown readout flag. 0x%x\n", val); + FILE_LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", val)); return -1; } - printf(" Setting Read out Flag: %d\n",val); #ifndef VIRTUAL - if(Beb_Set32bitOverflow(val) != -1) + if (Beb_Set32bitOverflow(val) != -1) #endif eiger_overflow32 = val; #ifndef VIRTUAL @@ -601,41 +590,58 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){ } - else{ - switch(val){ - case STORE_IN_RAM: val=1; printf(" Setting Read out Flag: Store in Ram\n"); break; - case CONTINOUS_RO: val=0; printf(" Setting Read out Flag: Continuous Readout\n"); break; + else { + switch(val) { + case STORE_IN_RAM: + val=1; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Store in Ram\n")); + break; + case CONTINOUS_RO: + val=0; + FILE_LOG(logDEBUG5, ("Setting Read out Flag: Continuous Readout\n")); + break; default: - cprintf(RED,"Cannot set unknown readout flag. 0x%x\n", val); + FILE_LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", val)); return -1; } - printf(" Setting store in ram variable: %d\n",val); eiger_storeinmem = val; } } - switch(eiger_readoutmode){ - case E_PARALLEL: retval=PARALLEL; break; - case E_NON_PARALLEL: retval=NONPARALLEL; break; - case E_SAFE: retval=SAFE; break; + switch(eiger_readoutmode) { + case E_PARALLEL: + retval=PARALLEL; + break; + case E_NON_PARALLEL: + retval=NONPARALLEL; + break; + case E_SAFE: + retval=SAFE; + break; } - switch(eiger_overflow32){ - case 1: retval|=SHOW_OVERFLOW; break; - case 0: retval|=NOOVERFLOW; break; + switch(eiger_overflow32) { + case 1: + retval|=SHOW_OVERFLOW; + break; + case 0: + retval|=NOOVERFLOW; + break; } - switch(eiger_storeinmem){ - case 0: retval|=CONTINOUS_RO; break; - case 1: retval|=STORE_IN_RAM; break; + switch(eiger_storeinmem) { + case 0: + retval|=CONTINOUS_RO; + break; + case 1: + retval|=STORE_IN_RAM; + break; } - - - printf("Read out Flag: 0x%x\n",retval); + FILE_LOG(logDEBUG5, ("Read out Flag: 0x%x\n", retval)); return retval; } @@ -648,17 +654,17 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){ /* parameters - timer */ -int64_t setTimer(enum timerIndex ind, int64_t val){ +int64_t setTimer(enum timerIndex ind, int64_t val) { #ifndef VIRTUAL int64_t subdeadtime = 0; #endif int64_t subexptime = 0; - switch(ind){ + switch(ind) { case FRAME_NUMBER: - if(val >= 0){ - printf(" Setting number of frames: %d * %d\n",(unsigned int)val,eiger_ncycles); + if (val >= 0) { + FILE_LOG(logDEBUG5, ("Setting number of frames: %d * %d\n", (unsigned int)val, eiger_ncycles)); #ifndef VIRTUAL - if(Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)){ + if (Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)) { eiger_nexposures = val; //SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles()); on_dst = 0; @@ -674,8 +680,8 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ }return eiger_nexposures; case ACQUISITION_TIME: - if(val >= 0){ - printf(" Setting exp time: %fs\n",val/(1E9)); + if (val >= 0) { + FILE_LOG(logDEBUG5, ("Setting exp time: %fs\n", val/(1E9))); #ifndef VIRTUAL Feb_Control_SetExposureTime(val/(1E9)); #else @@ -689,8 +695,8 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ #endif case SUBFRAME_ACQUISITION_TIME: - if(val >= 0){ - printf(" Setting sub exp time: %lldns\n",(long long int)val); + if (val >= 0) { + FILE_LOG(logDEBUG5, ("Setting sub exp time: %lldns\n", (long long int)val)); #ifndef VIRTUAL // calculate subdeadtime before settings subexptime subdeadtime = Feb_Control_GetSubFramePeriod() - @@ -714,16 +720,16 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ case SUBFRAME_DEADTIME: #ifndef VIRTUAL - // get subexptime - subexptime = Feb_Control_GetSubFrameExposureTime(); + // get subexptime + subexptime = Feb_Control_GetSubFrameExposureTime(); #else - subexptime = eiger_virtual_subexptime*10; + subexptime = eiger_virtual_subexptime*10; #endif - if(val >= 0){ - printf(" Setting sub period: %lldns = subexptime(%lld) + subdeadtime(%lld)\n", - (long long int)(val + subexptime), + if (val >= 0) { + FILE_LOG(logINFO, ("Setting sub period (subdeadtime(%lld)): %lldns\n", (long long int)subexptime, - (long long int)val); + (long long int)val), + (long long int)(val + subexptime)); //calculate subperiod val += subexptime; #ifndef VIRTUAL @@ -739,8 +745,8 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ #endif case FRAME_PERIOD: - if(val >= 0){ - printf(" Setting acq period: %fs\n",val/(1E9)); + if (val >= 0) { + FILE_LOG(logDEBUG5, ("Setting acq period: %fs\n", val/(1E9))); #ifndef VIRTUAL Feb_Control_SetExposurePeriod(val/(1E9)); #else @@ -754,10 +760,11 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ #endif case CYCLES_NUMBER: - if(val >= 0){ - printf(" Setting number of triggers: %d * %d\n",(unsigned int)val,eiger_nexposures); + if (val >= 0) { + FILE_LOG(logDEBUG5, ("Setting number of triggers: %d * %d\n", + (unsigned int)val,eiger_nexposures)); #ifndef VIRTUAL - if(Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)){ + if (Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)) { eiger_ncycles = val; //SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles()); on_dst = 0; @@ -772,7 +779,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val){ } return eiger_ncycles; default: - cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind); + FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind)); break; } @@ -784,12 +791,12 @@ int64_t getTimeLeft(enum timerIndex ind) { #ifdef VIRTUAL return 0; #else - switch(ind){ + switch(ind) { case MEASURED_PERIOD: return Feb_Control_GetMeasuredPeriod(); case MEASURED_SUBPERIOD: return Feb_Control_GetSubMeasuredPeriod(); return 0; default: - cprintf(RED,"This timer left index (%d) not defined for Eiger\n",ind); + FILE_LOG(logERROR, ("This timer left index (%d) not defined for Eiger\n", ind)); return -1; } #endif @@ -801,13 +808,11 @@ int64_t getTimeLeft(enum timerIndex ind) { /* parameters - channel, chip, module, settings */ -int setModule(sls_detector_module myMod, int delay){ +int setModule(sls_detector_module myMod, int delay) { int retval[2]; int i; - //#ifdef VERBOSE - printf("Setting module with settings %d\n",myMod.reg); - //#endif + FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg)); //copy module locally (module number, serial number, gain offset, //dacs (pointless), trimbit values(if needed) @@ -819,8 +824,8 @@ int setModule(sls_detector_module myMod, int delay){ setSettings( (enum detectorSettings)myMod.reg); // iodelay - if(setIODelay(delay)!= delay){ - cprintf(RED,"could not set iodelay %d\n",delay); + if (setIODelay(delay)!= delay) { + FILE_LOG(logERROR, ("Could not set iodelay %d\n", delay)); return FAIL; } @@ -830,10 +835,10 @@ int setModule(sls_detector_module myMod, int delay){ // trimbits #ifndef VIRTUAL - if(myMod.nchan==0 && myMod.nchip == 0) - cprintf(BLUE,"Setting module without trimbits\n"); - else{ - printf("Setting module with trimbits\n"); + if (myMod.nchan==0 && myMod.nchip == 0) { + FILE_LOG(logINFO, ("Setting module without trimbits\n")); + } else { + FILE_LOG(logINFO, ("Setting module with trimbits\n")); //includ gap pixels unsigned int tt[263680]; int iy,ichip,ix,ip=0,ich=0; @@ -850,8 +855,8 @@ int setModule(sls_detector_module myMod, int delay){ } //set trimbits - if(!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)){ - cprintf(BG_RED,"Could not set trimbits\n"); + if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)) { + FILE_LOG(logERROR, ("Could not set trimbits\n")); return FAIL; } } @@ -860,7 +865,7 @@ int setModule(sls_detector_module myMod, int delay){ } -int getModule(sls_detector_module *myMod){ +int getModule(sls_detector_module *myMod) { #ifndef VIRTUAL int i; @@ -869,7 +874,7 @@ int getModule(sls_detector_module *myMod){ //dacs for(i=0;idacs)+i)); + //FILE_LOG(logINFO,"dac%d:%d\n",i, *((detectorModules->dacs)+i)); } //trimbits @@ -895,7 +900,7 @@ int getModule(sls_detector_module *myMod){ if (detectorModules) { if (copyModule(myMod, detectorModules) == FAIL) return FAIL; - } + } else return FAIL; return OK; @@ -903,16 +908,16 @@ int getModule(sls_detector_module *myMod){ -enum detectorSettings setSettings(enum detectorSettings sett){ - if(sett == UNINITIALIZED){ +enum detectorSettings setSettings(enum detectorSettings sett) { + if (sett == UNINITIALIZED) { return thisSettings; - }if(sett != GET_SETTINGS) + }if (sett != GET_SETTINGS) thisSettings = sett; - printf(" Settings: %d\n", thisSettings); + FILE_LOG(logINFO, ("Settings: %d\n", thisSettings)); return thisSettings; } -enum detectorSettings getSettings(){ +enum detectorSettings getSettings() { return thisSettings; } @@ -923,15 +928,15 @@ enum detectorSettings getSettings(){ /* parameters - threshold */ -int getThresholdEnergy(){ - printf(" Getting Threshold energy\n"); +int getThresholdEnergy() { + FILE_LOG(logINFO, ("Getting Threshold energy\n")); return eiger_photonenergy; } -int setThresholdEnergy(int ev){ - printf(" Setting threshold energy:%d\n",ev); - if(ev >= 0) +int setThresholdEnergy(int ev) { + FILE_LOG(logINFO, ("Setting threshold energy:%d\n",ev)); + if (ev >= 0) eiger_photonenergy = ev; return getThresholdEnergy(); } @@ -942,61 +947,55 @@ int setThresholdEnergy(int ev){ /* parameters - dac, adc, hv */ -void setDAC(enum DACINDEX ind, int val, int mV, int retval[]){ - printf("Going to set dac %d to %d with mv mode %d \n", (int)ind, val, mV); - if(ind == VTHRESHOLD){ +void setDAC(enum DACINDEX ind, int val, int mV, int retval[]) { + FILE_LOG(logDEBUG5, ("Going to set dac %d to %d with mv mode %d \n", (int)ind, val, mV)); + if (ind == VTHRESHOLD) { int ret[5]; setDAC(VCMP_LL,val,mV,retval); - ret[0] = retval[mV]; + ret[0] = retval[mV]; setDAC(VCMP_LR,val,mV,retval); - ret[1] = retval[mV]; + ret[1] = retval[mV]; setDAC(VCMP_RL,val,mV,retval); - ret[2] = retval[mV]; + ret[2] = retval[mV]; setDAC(VCMP_RR,val,mV,retval); - ret[3] = retval[mV]; + ret[3] = retval[mV]; setDAC(VCP,val,mV,retval); - ret[4] = retval[mV]; + ret[4] = retval[mV]; - if((ret[0]== ret[1])&& + if ((ret[0]== ret[1])&& (ret[1]==ret[2])&& (ret[2]==ret[3]) && - (ret[3]==ret[4])) - cprintf(GREEN,"vthreshold match\n"); - else{ - retval[0] = -1;retval[1] = -1; - cprintf(RED,"vthreshold mismatch 0:%d 1:%d 2:%d 3:%d\n", - ret[0],ret[1],ret[2],ret[3]); + (ret[3]==ret[4])) { + FILE_LOG(logINFO, ("vthreshold match\n")); + } else { + retval[0] = -1;retval[1] = -1; + FILE_LOG(logERROR, ("vthreshold mismatch 0:%d 1:%d 2:%d 3:%d\n", + ret[0],ret[1],ret[2],ret[3])); } return; } char iname[10]; - if(((int)ind>=0)&&((int)ind=0)&&((int)ind= 0) - printf("Setting dac %d: %s to %d ",ind, iname,val); - else - printf("Getting dac %d: %s ",ind, iname); - if(mV) - printf("in mV\n"); - else - printf("in dac units\n"); -#endif + FILE_LOG(logDEBUG5, ("%s dac %d: %s to %d %s\n", + (val >= 0) ? "Setting" : "Getting", + ind, iname, val, + mV ? "mV" : "dac units")); #ifdef VIRTUAL - if (mV){ + if (mV) { retval[0] = (int)(((val-0)/(2048-0))*(4096-1) + 0.5); retval[1] = val; - }else + } else retval[0] = val; #else - if(val >= 0) + if (val >= 0) Feb_Control_SetDAC(iname,val,mV); int k; Feb_Control_GetDAC(iname, &k,0); @@ -1010,7 +1009,7 @@ void setDAC(enum DACINDEX ind, int val, int mV, int retval[]){ -int getADC(enum ADCINDEX ind){ +int getADC(enum ADCINDEX ind) { #ifdef VIRTUAL return 0; #else @@ -1018,43 +1017,43 @@ int getADC(enum ADCINDEX ind){ char tempnames[6][20]={"FPGA EXT", "10GE","DCDC", "SODL", "SODR", "FPGA"}; char cstore[255]; - switch(ind){ - case TEMP_FPGA: - retval=getBebFPGATemp(); - break; - case TEMP_FPGAFEBL: - retval=Feb_Control_GetLeftFPGATemp(); - break; - case TEMP_FPGAFEBR: - retval=Feb_Control_GetRightFPGATemp(); - break; - case TEMP_FPGAEXT: - case TEMP_10GE: - case TEMP_DCDC: - case TEMP_SODL: - case TEMP_SODR: - sprintf(cstore,"more /sys/class/hwmon/hwmon%d/device/temp1_input",ind); - FILE* sysFile = popen(cstore, "r"); - fgets(cstore, sizeof(cstore), sysFile); - pclose(sysFile); - sscanf(cstore,"%d",&retval); - break; - default: - return -1; + switch(ind) { + case TEMP_FPGA: + retval=getBebFPGATemp(); + break; + case TEMP_FPGAFEBL: + retval=Feb_Control_GetLeftFPGATemp(); + break; + case TEMP_FPGAFEBR: + retval=Feb_Control_GetRightFPGATemp(); + break; + case TEMP_FPGAEXT: + case TEMP_10GE: + case TEMP_DCDC: + case TEMP_SODL: + case TEMP_SODR: + sprintf(cstore,"more /sys/class/hwmon/hwmon%d/device/temp1_input",ind); + FILE* sysFile = popen(cstore, "r"); + fgets(cstore, sizeof(cstore), sysFile); + pclose(sysFile); + sscanf(cstore,"%d",&retval); + break; + default: + return -1; } - printf("Temperature %s: %f°C\n",tempnames[ind],(double)retval/1000.00); + FILE_LOG(logINFO, ("Temperature %s: %f°C\n", tempnames[ind], (double)retval/1000.00)); return retval; #endif } -int setHighVoltage(int val){ +int setHighVoltage(int val) { #ifdef VIRTUAL if (master) { // set - if(val!=-1){ + if (val!=-1) { eiger_theo_highvoltage = val; } return eiger_theo_highvoltage; @@ -1066,10 +1065,10 @@ int setHighVoltage(int val){ if (master) { // set - if(val!=-1){ + if (val!=-1) { eiger_theo_highvoltage = val; int ret = Feb_Control_SetHighVoltage(val); - if(!ret) //could not set + if (!ret) //could not set return -2; else if (ret == -1) //outside range return -1; @@ -1077,13 +1076,13 @@ int setHighVoltage(int val){ // get if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) { - cprintf(RED,"Warning: Could not read high voltage\n"); + FILE_LOG(logERROR, ("Could not read high voltage\n")); return -3; } // tolerance of 5 if (abs(eiger_theo_highvoltage-eiger_highvoltage) > HIGH_VOLTAGE_TOLERANCE) { - cprintf(BLUE, "High voltage still ramping: %d\n", eiger_highvoltage); + FILE_LOG(logINFO, ("High voltage still ramping: %d\n", eiger_highvoltage)); return eiger_highvoltage; } return eiger_theo_highvoltage; @@ -1101,18 +1100,18 @@ int setHighVoltage(int val){ /* parameters - timing, extsig */ -void setTiming( enum externalCommunicationMode arg){ +void setTiming( enum externalCommunicationMode arg) { enum externalCommunicationMode ret=GET_EXTERNAL_COMMUNICATION_MODE; - if(arg != GET_EXTERNAL_COMMUNICATION_MODE){ - switch((int)arg){ + if (arg != GET_EXTERNAL_COMMUNICATION_MODE) { + switch((int)arg) { case AUTO_TIMING: ret = 0; break; case TRIGGER_EXPOSURE: ret = 2; break; case BURST_TRIGGER: ret = 1; break; case GATE_FIX_NUMBER: ret = 3; break; } - printf(" Setting Triggering Mode: %d\n",(int)ret); + FILE_LOG(logDEBUG5, ("Setting Triggering Mode: %d\n", (int)ret)); #ifndef VIRTUAL - if(Feb_Control_SetTriggerMode(ret,1)) + if (Feb_Control_SetTriggerMode(ret,1)) #endif eiger_triggermode = ret; } @@ -1122,13 +1121,13 @@ void setTiming( enum externalCommunicationMode arg){ enum externalCommunicationMode getTiming() { enum externalCommunicationMode ret = GET_EXTERNAL_COMMUNICATION_MODE; ret = eiger_triggermode; - switch((int)ret){ + switch((int)ret) { case 0: ret = AUTO_TIMING; break; case 2: ret = TRIGGER_EXPOSURE; break; case 1: ret = BURST_TRIGGER; break; case 3: ret = GATE_FIX_NUMBER; break; default: - printf("Unknown trigger mode found %d\n",ret); + FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", ret)); ret = 0; } return ret; @@ -1138,7 +1137,7 @@ enum externalCommunicationMode getTiming() { /* configure mac */ -int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival) { +int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) { #ifndef VIRTUAL char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; int src_port = 0xE185; @@ -1157,40 +1156,47 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t (unsigned int)((destmac>>8)&0xFF), (unsigned int)((destmac>>0)&0xFF)); - printf("src_port:%d\n",src_port); - printf("src_ip:%s\n",src_ip); - printf("dst_ip:%s\n",dst_ip); - printf("src_mac:%s\n",src_mac); - printf("dst_mac:%s\n",dst_mac); - int beb_num = BEB_NUM;//Feb_Control_GetModuleNumber(); + FILE_LOG(logINFO, ("src_port:%d\n" + "src_ip:%s\n" + "dst_ip:%s\n" + "src_mac:%s\n" + "dst_mac:%s\n", + src_port, src_ip, dst_ip, src_mac, dst_mac)); + + + int beb_num = detid; int header_number = 0; int dst_port = udpport; - if(!top) + if (!top) dst_port = udpport2; - printf("dst_port:%d\n\n",dst_port); + FILE_LOG(logINFO, ("dst_port:%d\n", dst_port)); int i=0; - /* for(i=0;i<32;i++){ modified for Aldo*/ - if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && - Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) - printf("set up left ok\n"); - else return -1; + /* for(i=0;i<32;i++) { modified for Aldo*/ + if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && + Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) { + FILE_LOG(logINFO, ("set up left ok\n")); + } else { + return -1; + } /*}*/ header_number = 32; dst_port = udpport2; - if(!top) + if (!top) dst_port = udpport; - printf("dst_port:%d\n\n",dst_port); + FILE_LOG(logINFO, ("dst_port:%d\n",dst_port)); - /*for(i=0;i<32;i++){*//** modified for Aldo*/ - if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && - Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) - printf("set up right ok\n\n"); - else return -1; + /*for(i=0;i<32;i++) {*//** modified for Aldo*/ + if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && + Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) { + FILE_LOG(logINFO, ("set up right ok\n")); + } else { + return -1; + } /*}*/ on_dst = 0; @@ -1217,11 +1223,11 @@ int setDetectorPosition(int pos[]) { /* eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter */ -int setIODelay(int val){ - if(val!=-1){ - printf(" Setting IO Delay: %d\n",val); +int setIODelay(int val) { + if (val!=-1) { + FILE_LOG(logDEBUG5, ("Setting IO Delay: %d\n",val)); #ifndef VIRTUAL - if(Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val)) + if (Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val)) #endif eiger_iodelay = val; } @@ -1229,30 +1235,26 @@ int setIODelay(int val){ } -int enableTenGigabitEthernet(int val){ - if(val!=-1){ - if(val>0) +int enableTenGigabitEthernet(int val) { + if (val!=-1) { + FILE_LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0)); + if (val>0) send_to_ten_gig = 1; else send_to_ten_gig = 0; //configuremac called from client } -#ifdef VERBOSE - printf("10Gbe:%d\n",send_to_ten_gig); -#endif return send_to_ten_gig; } -int setCounterBit(int val){ - if(val!=-1){ +int setCounterBit(int val) { + if (val!=-1) { + FILE_LOG(logINFO, ("Setting Counter Bit: %d\n",val)); #ifdef VIRTUAL eiger_virtual_counter_bit = val; #else Feb_Control_Set_Counter_Bit(val); -#endif -#ifdef VERBOSE - printf("Counter Bit:%d\n",val); #endif } #ifdef VIRTUAL @@ -1263,45 +1265,45 @@ int setCounterBit(int val){ } -int pulsePixel(int n, int x, int y){ +int pulsePixel(int n, int x, int y) { #ifndef VIRTUAL - if(!Feb_Control_Pulse_Pixel(n,x,y)) + if (!Feb_Control_Pulse_Pixel(n,x,y)) return FAIL; #endif return OK; } -int pulsePixelNMove(int n, int x, int y){ +int pulsePixelNMove(int n, int x, int y) { #ifndef VIRTUAL - if(!Feb_Control_PulsePixelNMove(n,x,y)) + if (!Feb_Control_PulsePixelNMove(n,x,y)) return FAIL; #endif return OK; } -int pulseChip(int n){ +int pulseChip(int n) { #ifndef VIRTUAL - if(!Feb_Control_PulseChip(n)) + if (!Feb_Control_PulseChip(n)) return FAIL; #endif return OK; } -int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never be -1) +int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never be -1) #ifdef VIRTUAL //deactivating rate correction - if(custom_tau_in_nsec==0){ + if (custom_tau_in_nsec==0) { eiger_virtual_ratecorrection_variable = 0; return 0; } //when dynamic range changes, use old tau - else if(custom_tau_in_nsec == -1) + else if (custom_tau_in_nsec == -1) custom_tau_in_nsec = eiger_virtual_ratetable_tau_in_ns; //get period = subexptime if 32bit , else period = exptime if 16 bit int64_t actual_period = eiger_virtual_subexptime*10; //already in nsec - if(eiger_dynamicrange == 16) + if (eiger_dynamicrange == 16) actual_period = eiger_virtual_exptime; int64_t ratetable_period_in_nsec = eiger_virtual_ratetable_period_in_ns; @@ -1310,44 +1312,44 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never b //same setting - if((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)){ - if(eiger_dynamicrange == 32) - printf("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n", - (long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec); + if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) { + if (eiger_dynamicrange == 32) + FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n", + (long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec)); else - printf("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n", - (long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec); + FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n", + (long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec)); } //different setting, calculate table - else{ + else { eiger_virtual_ratetable_tau_in_ns = custom_tau_in_nsec; double period_in_sec = (double)(eiger_virtual_subexptime*10)/(double)1e9; - if(eiger_dynamicrange == 16) + if (eiger_dynamicrange == 16) period_in_sec = eiger_virtual_exptime; eiger_virtual_ratetable_period_in_ns = period_in_sec*1e9; } //activating rate correction eiger_virtual_ratecorrection_variable = 1; - printf("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns); + FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns)); return eiger_virtual_ratetable_tau_in_ns; #else //deactivating rate correction - if(custom_tau_in_nsec==0){ + if (custom_tau_in_nsec==0) { Feb_Control_SetRateCorrectionVariable(0); return 0; } //when dynamic range changes, use old tau - else if(custom_tau_in_nsec == -1) + else if (custom_tau_in_nsec == -1) custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec(); int dr = Feb_Control_GetDynamicRange(); //get period = subexptime if 32bit , else period = exptime if 16 bit int64_t actual_period = Feb_Control_GetSubFrameExposureTime(); //already in nsec - if(dr == 16) + if (dr == 16) actual_period = Feb_Control_GetExposureTime_in_nsec(); int64_t ratetable_period_in_nsec = Feb_Control_Get_RateTable_Period_in_nsec(); @@ -1355,35 +1357,34 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never b //same setting - if((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)){ - if(dr == 32) - printf("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n", - tau_in_nsec,ratetable_period_in_nsec); - else - printf("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n", - tau_in_nsec,ratetable_period_in_nsec); + if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) { + if (dr == 32) { + FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n", + tau_in_nsec,ratetable_period_in_nsec)); + } else { + FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n", + tau_in_nsec,ratetable_period_in_nsec)); + } } //different setting, calculate table - else{ + else { int ret = Feb_Control_SetRateCorrectionTau(custom_tau_in_nsec); - if(ret<=0){ - cprintf(RED,"Rate correction failed. Deactivating rate correction\n"); + if (ret<=0) { + FILE_LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n")); Feb_Control_SetRateCorrectionVariable(0); return ret; } } //activating rate correction Feb_Control_SetRateCorrectionVariable(1); - printf("Rate Correction Value set to %lld ns\n",(long long int)Feb_Control_Get_RateTable_Tau_in_nsec()); -#ifdef VERBOSE + FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec())); Feb_Control_PrintCorrectedValues(); -#endif return Feb_Control_Get_RateTable_Tau_in_nsec(); #endif } -int getRateCorrectionEnable(){ +int getRateCorrectionEnable() { #ifdef VIRTUAL return eiger_virtual_ratecorrection_variable; #else @@ -1391,28 +1392,28 @@ int getRateCorrectionEnable(){ #endif } -int getDefaultSettingsTau_in_nsec(){ +int getDefaultSettingsTau_in_nsec() { return default_tau_from_file; } -void setDefaultSettingsTau_in_nsec(int t){ +void setDefaultSettingsTau_in_nsec(int t) { default_tau_from_file = t; - printf("Default tau set to %d\n",default_tau_from_file); + FILE_LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file)); } -int64_t getCurrentTau(){ - if(!getRateCorrectionEnable()) +int64_t getCurrentTau() { + if (!getRateCorrectionEnable()) return 0; else #ifndef VIRTUAL return Feb_Control_Get_RateTable_Tau_in_nsec(); #else - return eiger_virtual_ratetable_tau_in_ns; + return eiger_virtual_ratetable_tau_in_ns; #endif } -void setExternalGating(int enable[]){ - if(enable>=0){ +void setExternalGating(int enable[]) { + if (enable>=0) { #ifndef VIRTUAL Feb_Control_SetExternalEnableMode(enable[0], enable[1]);//enable = 0 or 1, polarity = 0 or 1 , where 1 is positive #endif @@ -1423,44 +1424,41 @@ void setExternalGating(int enable[]){ enable[1] = eiger_extgatingpolarity; } -int setAllTrimbits(int val){ +int setAllTrimbits(int val) { #ifndef VIRTUAL - if(!Feb_Control_SaveAllTrimbitsTo(val)){ - cprintf(RED,"error in setting all trimbits to value\n"); + if (!Feb_Control_SaveAllTrimbitsTo(val)) { + FILE_LOG(logERROR, ("Could not set all trimbits\n")); return FAIL; } #endif -#ifdef VERBOSE - printf("Copying register %x value %d\n",destMod->reg,val); -#endif - if (detectorModules){ + if (detectorModules) { int ichan; for (ichan=0; ichan<(detectorModules->nchan); ichan++) { *((detectorModules->chanregs)+ichan)=val; } } - cprintf(GREEN, "All trimbits have been set to %d\n", val); + FILE_LOG(logINFO, ("All trimbits have been set to %d\n", val)); return OK; } -int getAllTrimbits(){ +int getAllTrimbits() { int ichan=0; int value = *((detectorModules->chanregs)); - if (detectorModules){ + if (detectorModules) { for (ichan=0; ichan<(detectorModules->nchan); ichan++) { - if(*((detectorModules->chanregs)+ichan) != value) { + if (*((detectorModules->chanregs)+ichan) != value) { value= -1; break; } } } - printf("Value of all Trimbits: %d\n", value); + FILE_LOG(logINFO, ("Value of all Trimbits: %d\n", value)); return value; } -int getBebFPGATemp(){ +int getBebFPGATemp() { #ifdef VIRTUAL return 0; #else @@ -1468,7 +1466,7 @@ int getBebFPGATemp(){ #endif } -int activate(int enable){ +int activate(int enable) { #ifdef VIRTUAL if (enable >=0) eiger_virtual_activate = enable; @@ -1480,12 +1478,12 @@ int activate(int enable){ #endif } -int setNetworkParameter(enum NETWORKINDEX mode, int value){ +int setNetworkParameter(enum NETWORKINDEX mode, int value) { #ifndef VIRTUAL return Beb_SetNetworkParameter(mode, value); #else if (value>-1) { - switch(mode){ + switch(mode) { case TXN_LEFT: eiger_virtual_transmission_delay_left = value; break; @@ -1497,13 +1495,13 @@ int setNetworkParameter(enum NETWORKINDEX mode, int value){ break; case FLOWCTRL_10G: eiger_virtual_transmission_flowcontrol_10g = value; - if(value>0) value = 1; + if (value>0) value = 1; break; - default: cprintf(BG_RED,"Unrecognized mode in network parameter: %d\n",mode); - return -1; + default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); + return -1; } } - switch(mode){ + switch(mode) { case TXN_LEFT: return eiger_virtual_transmission_delay_left; case TXN_RIGHT: @@ -1512,8 +1510,8 @@ int setNetworkParameter(enum NETWORKINDEX mode, int value){ return eiger_virtual_transmission_delay_frame; case FLOWCTRL_10G: return eiger_virtual_transmission_flowcontrol_10g; - default: cprintf(BG_RED,"Unrecognized mode in network parameter: %d\n",mode); - return -1; + default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); + return -1; } #endif } @@ -1527,11 +1525,11 @@ int setNetworkParameter(enum NETWORKINDEX mode, int value){ /* aquisition */ -int prepareAcquisition(){ +int prepareAcquisition() { #ifndef VIRTUAL - printf("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()); + FILE_LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit())); Feb_Control_PrepareForAcquisition(); - printf("Going to reset Frame Number\n"); + FILE_LOG(logINFO, ("Going to reset Frame Number\n")); Beb_ResetFrameNumber(); #endif return OK; @@ -1539,16 +1537,16 @@ int prepareAcquisition(){ } -int startStateMachine(){ +int startStateMachine() { #ifdef VIRTUAL eiger_virtual_status = 1; eiger_virtual_stop = 0; - if(pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) { - cprintf(RED,"Could not start Virtual acquisition thread\n"); + if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) { + FILE_LOG(logERROR, ("Could not start Virtual acquisition thread\n")); eiger_virtual_status = 0; return FAIL; } - cprintf(GREEN,"***Virtual Acquisition started\n"); + FILE_LOG(logINFO ,"***Virtual Acquisition started\n"); return OK; #else @@ -1556,24 +1554,24 @@ int startStateMachine(){ //get the DAQ toggle bit prev_flag = Feb_Control_AcquisitionStartedBit(); - printf("Going to start acquisition\n"); + FILE_LOG(logINFO, ("Going to start acquisition\n")); Feb_Control_StartAcquisition(); - if(!eiger_storeinmem){ - printf("requesting images right after start\n"); + if (!eiger_storeinmem) { + FILE_LOG(logINFO, ("requesting images right after start\n")); ret = startReadOut(); } //wait for acquisition start - if(ret == OK){ - if(!Feb_Control_WaitForStartedFlag(5000, prev_flag)){ - cprintf(RED,"Error: Acquisition did not start or trouble reading register\n"); + if (ret == OK) { + if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) { + FILE_LOG(logERROR, ("Acquisition did not FILE_LOG(logERROR ouble reading register\n")); return FAIL; } - cprintf(GREEN,"***Acquisition started\n"); + FILE_LOG(logINFO, ("***Acquisition started\n")); } - /*while(getRunStatus() == IDLE){printf("waiting for being not idle anymore\n");}*/ + /*while(getRunStatus() == IDLE) {FILE_LOG(logINFO, ("waiting for being not idle anymore\n"));}*/ return ret; #endif @@ -1583,12 +1581,12 @@ int startStateMachine(){ void* start_timer(void* arg) { eiger_virtual_status = 1; int wait_in_s = nimages_per_request * eiger_virtual_period; - cprintf(GREEN,"going to wait for %d s\n", wait_in_s); + FILE_LOG(logINFO, ("going to wait for %d s\n", wait_in_s)); while(!eiger_virtual_stop && (wait_in_s >= 0)) { usleep(1000 * 1000); wait_in_s--; } - cprintf(GREEN,"Virtual Timer Done***\n"); + FILE_LOG(logINFO, ("Virtual Timer Done***\n")); eiger_virtual_status = 0; return NULL; @@ -1597,16 +1595,16 @@ void* start_timer(void* arg) { -int stopStateMachine(){ - cprintf(BG_RED,"Going to stop acquisition\n"); +int stopStateMachine() { + FILE_LOG(logERROR, ("Going to stop acquisition\n")); #ifdef VIRTUAL eiger_virtual_stop = 0; return OK; #else - if((Feb_Control_StopAcquisition() == STATUS_IDLE) & Beb_StopAcquisition()) + if ((Feb_Control_StopAcquisition() == STATUS_IDLE) & Beb_StopAcquisition()) return OK; - cprintf(BG_RED,"failed to stop acquisition\n"); + FILE_LOG(logERROR, ("failed to stop acquisition\n")); return FAIL; #endif } @@ -1622,29 +1620,29 @@ int softwareTrigger() { } -int startReadOut(){ +int startReadOut() { - printf("Requesting images...\n"); + FILE_LOG(logINFO, ("Requesting images...\n")); #ifdef VIRTUAL return OK; #else //RequestImages(); int ret_val = 0; dst_requested[0] = 1; - while(dst_requested[on_dst]){ + while(dst_requested[on_dst]) { //waits on data - int beb_num = BEB_NUM;//Feb_Control_GetModuleNumber(); + int beb_num = detid; if ((ret_val = (!Beb_RequestNImages(beb_num,send_to_ten_gig,on_dst,nimages_per_request,0)))) break; -// for(i=0;iserialnumber>=0){ + if (srcMod->serialnumber>=0) { destMod->serialnumber=srcMod->serialnumber; } //no trimbit feature if (destMod->nchip && ((srcMod->nchip)>(destMod->nchip))) { - printf("Number of chip of source is larger than number of chips of destination\n"); + FILE_LOG(logINFO, ("Number of chip of source is larger than number of chips of destination\n")); return FAIL; } //no trimbit feature if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) { - printf("Number of channels of source is larger than number of channels of destination\n"); + FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n")); return FAIL; } if ((srcMod->ndac)>(destMod->ndac)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); + FILE_LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n")); return FAIL; } if ((srcMod->nadc)>(destMod->nadc)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); + FILE_LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n")); return FAIL; } -#ifdef VERBOSE - printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac); - printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc); - printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip); - printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan); - -#endif + FILE_LOG(logDEBUG5, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac)); + FILE_LOG(logDEBUG5, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc)); + FILE_LOG(logDEBUG5, ("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip)); + FILE_LOG(logDEBUG5, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan)); destMod->ndac=srcMod->ndac; destMod->nadc=srcMod->nadc; destMod->nchip=srcMod->nchip; destMod->nchan=srcMod->nchan; if (srcMod->reg>=0) destMod->reg=srcMod->reg; -#ifdef VERBOSE - printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg ); -#endif + FILE_LOG(logDEBUG5, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg )); if (srcMod->gain>=0) destMod->gain=srcMod->gain; if (srcMod->offset>=0) destMod->offset=srcMod->offset; - if((destMod->nchip!=0) || (destMod->nchan!=0)) { + if ((destMod->nchip!=0) || (destMod->nchan!=0)) { for (ichip=0; ichip<(srcMod->nchip); ichip++) { if (*((srcMod->chipregs)+ichip)>=0) *((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip); @@ -1792,9 +1786,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){ *((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan); } } -#ifdef VERBOSE - else printf("Not Copying trimbits\n"); -#endif + else FILE_LOG(logINFO, ("Not Copying trimbits\n")); for (idac=0; idac<(srcMod->ndac); idac++) { if (*((srcMod->dacs)+idac)>=0) { *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); @@ -1808,8 +1800,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){ } -int calculateDataBytes(){ - if(send_to_ten_gig) +int calculateDataBytes() { + if (send_to_ten_gig) return setDynamicRange(-1) * ONE_GIGA_CONSTANT * TEN_GIGA_BUFFER_SIZE; else return setDynamicRange(-1) * TEN_GIGA_CONSTANT * ONE_GIGA_BUFFER_SIZE; @@ -1818,13 +1810,13 @@ int calculateDataBytes(){ -int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} -int getNumberOfChips(){return NCHIP;} -int getNumberOfDACs(){return NDAC;} -int getNumberOfADCs(){return NADC;} -int getNumberOfChannelsPerChip(){return NCHAN;} -int getNumberOfGains(){return NGAIN;} -int getNumberOfOffsets(){return NOFFSET;} +int getTotalNumberOfChannels() {return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());} +int getNumberOfChips() {return NCHIP;} +int getNumberOfDACs() {return NDAC;} +int getNumberOfADCs() {return NADC;} +int getNumberOfChannelsPerChip() {return NCHAN;} +int getNumberOfGains() {return NGAIN;} +int getNumberOfOffsets() {return NOFFSET;} diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h index fec509799..dfc4d745b 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h @@ -42,7 +42,7 @@ enum DACINDEX {SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RX }; enum ADCINDEX {TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA, TEMP_FPGAFEBL, TEMP_FPGAFEBR}; enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G}; - +enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE}; /* Hardware Definitions */ #define NCHAN (256 * 256) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index c922d0ddc..81a7e4912 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -448,7 +448,7 @@ void setupDetector() { bus_w(DAQ_REG, 0x0); /* Only once at server startup */ - setSpeed(CLOCK_DIVIDER, HALF_SPEED); + setSpeed(HALF_SPEED); cleanFifos(); resetCore(); @@ -465,7 +465,7 @@ void setupDetector() { setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY); setTimer(STORAGE_CELL_NUMBER, DEFAULT_NUM_STRG_CLLS); selectStoragecellStart(DEFAULT_STRG_CLL_STRT); - /*setSpeed(CLOCK_DIVIDER, HALF_SPEED); depends if all the previous stuff works*/ + /*setSpeed(HALF_SPEED); depends if all the previous stuff works*/ setTiming(DEFAULT_TIMING_MODE); setHighVoltage(DEFAULT_HIGH_VOLTAGE); @@ -611,10 +611,7 @@ int setDynamicRange(int dr){ /* parameters - readout */ -int setSpeed(enum speedVariable arg, int val) { - - if (arg != CLOCK_DIVIDER) - return -1; +enum speedVariable setSpeed(int val) { // setting if(val >= 0) { @@ -1620,7 +1617,7 @@ void readFrame(int *ret, char *mess){ } else { *ret = (int)FINISHED; sprintf(mess,"acquisition successfully finished\n"); - printf("%s",mess); + cprintf(GREEN, "%s",mess); } } diff --git a/slsDetectorServers/mythen3DetectorServer/AD9257.h b/slsDetectorServers/mythen3DetectorServer/AD9257.h deleted file mode 120000 index 87b70e097..000000000 --- a/slsDetectorServers/mythen3DetectorServer/AD9257.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/AD9257.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/Makefile b/slsDetectorServers/mythen3DetectorServer/Makefile deleted file mode 100644 index ba8ffe5f1..000000000 --- a/slsDetectorServers/mythen3DetectorServer/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -CROSS = bfin-uclinux- -CC = $(CROSS)gcc -#CC = gcc -CLAGS += -Wall -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE -LDLIBS += -lm -lstdc++ - - -PROGS = mythen3DetectorServer -DESTDIR ?= bin -INSTMODE = 0777 - -SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c -OBJS = $(SRC_CLNT:.c=.o) - - - -all: clean versioning $(PROGS) - -boot: $(OBJS) - -versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` - -$(PROGS): $(OBJS) -# echo $(OBJS) - mkdir -p $(DESTDIR) - $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) - mv $(PROGS) $(DESTDIR) - rm *.gdb - -clean: - rm -rf $(DESTDIR)/$(PROGS) *.o - diff --git a/slsDetectorServers/mythen3DetectorServer/Makefile.virtual b/slsDetectorServers/mythen3DetectorServer/Makefile.virtual deleted file mode 100644 index de7284bcc..000000000 --- a/slsDetectorServers/mythen3DetectorServer/Makefile.virtual +++ /dev/null @@ -1,25 +0,0 @@ -CC = gcc -CFLAGS += -Wall -DVIRTUAL -DMYTHEN3D -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE -LDLIBS += -lm -lstdc++ - -PROGS = virtualMythen3DetectorServer -DESTDIR ?= bin -INSTMODE = 0777 - -SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c -OBJS = $(SRC_CLNT:.c=.o) - -all: clean $(PROGS) - -boot: $(OBJS) - -$(PROGS): $(OBJS) - echo $(OBJS) - mkdir -p $(DESTDIR) - $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) - mv $(PROGS) $(DESTDIR) - rm *.gdb - -clean: - rm -rf $(DESTDIR)/$(PROGS) *.o - diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h deleted file mode 100644 index 1fa922d3b..000000000 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef REGISTERS_G_H -#define REGISTERS_G_H - -/* Definitions for FPGA*/ - -/* FPGA Version register */ -#define FPGA_VERSION_REG (0x00 << 11) - -#define BOARD_REVISION_OFST (0) -#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST) -#define DETECTOR_TYPE_OFST (24) -#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) - -/* Fix pattern register */ -#define FIX_PATT_REG (0x01 << 11) - - -/* Timer 64 bit Regiser */ -#define SET_DELAY_LSB_REG (0x60 << 11) //96<<11 //0x68<<11 -#define SET_DELAY_MSB_REG (0x61 << 11) //97<<11 //0x69<<11 -#define SET_CYCLES_LSB_REG (0x62 << 11) //98<<11//0x6c<<11 -#define SET_CYCLES_MSB_REG (0x63 << 11) //99<<11//0x6d<<11 -#define SET_FRAMES_LSB_REG (0x64 << 11) //(100<<11)/** to hex */ -#define SET_FRAMES_MSB_REG (0x65 << 11) //101<<11//0x71<<11 -#define SET_PERIOD_LSB_REG (0x66 << 11) //102<<11//0x74<<11 -#define SET_PERIOD_MSB_REG (0x67 << 11) //103<<11//0x75<<11 -#define SET_GATES_LSB_REG (0x6A << 11) /*check in firmware*///106<<11//0x7c<<11 -#define SET_GATES_MSB_REG (0x6B << 11) //107<<11//0x7d<<11 -#define SET_EXPTIME_LSB_REG (0x72 << 11) /** check in firmware *///114<<11//0x78<<11 -#define SET_EXPTIME_MSB_REG (0x73 << 11) //115<<11//0x79<<11 - -#define GET_ACTUAL_TIME_LSB_REG (0x10 << 11) //16<<11 -#define GET_ACTUAL_TIME_MSB_REG (0x11 << 11) //17<<11 -#define GET_DELAY_LSB_REG (0x12 << 11) //18<<11//0x6a<<11 -#define GET_DELAY_MSB_REG (0x13 << 11) //19<<11//0x6b<<11 -#define GET_CYCLES_LSB_REG (0x14 << 11) //20<<11//0x6e<<11 -#define GET_CYCLES_MSB_REG (0x15 << 11) //21<<11//0x6f<<11 -#define GET_FRAMES_LSB_REG (0x16 << 11) //22<<11//0x72<<11 -#define GET_FRAMES_MSB_REG (0x17 << 11) //23<<11//0x73<<11 -#define GET_PERIOD_LSB_REG (0x18 << 11) //24<<11//0x76<<11 -#define GET_PERIOD_MSB_REG (0x19 << 11) //25<<11//0x77<<11 -#define GET_EXPTIME_LSB_REG (0x1A << 11) //26<<11//0x7a<<11 -#define GET_EXPTIME_MSB_REG (0x1B << 11) //27<<11//0x7b<<11 -#define GET_GATES_LSB_REG (0x1C << 11) //28<<11//0x7e<<11 -#define GET_GATES_MSB_REG (0x1D << 11) //29<<11//0x7f<<11 - -#define FRAMES_FROM_START_LSB_REG (0x22 << 11) //34<<11 -#define FRAMES_FROM_START_MSB_REG (0x23 << 11) //35<<11 -#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11) //36<<11 -#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11) //37<<11 -#define GET_MEASUREMENT_TIME_LSB_REG (0x26 << 11) //38<<11 -#define GET_MEASUREMENT_TIME_MSB_REG (0x27 << 11) //39<<11 - - -/* SPI (Serial Peripheral Interface) Register */ -#define SPI_REG (0x40 << 11) - -#define DAC_SERIAL_DIGITAL_OUT_OFST (0) -#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST) -#define DAC_SERIAL_CLK_OUT_OFST (1) -#define DAC_SERIAL_CLK_OUT_MSK (0x00000001 << DAC_SERIAL_CLK_OUT_OFST) -#define DAC_SERIAL_CS_OUT_OFST (2) -#define DAC_SERIAL_CS_OUT_MSK (0x00000001 << DAC_SERIAL_CS_OUT_OFST) -#define HV_SERIAL_DIGITAL_OUT_OFST (8) -#define HV_SERIAL_DIGITAL_OUT_MSK (0x00000001 << HV_SERIAL_DIGITAL_OUT_OFST) -#define HV_SERIAL_CLK_OUT_OFST (9) -#define HV_SERIAL_CLK_OUT_MSK (0x00000001 << HV_SERIAL_CLK_OUT_OFST) -#define HV_SERIAL_CS_OUT_OFST (10) -#define HV_SERIAL_CS_OUT_MSK (0x00000001 << HV_SERIAL_CS_OUT_OFST) - -/* Control Register */ -#define CONTROL_REG (0x4F << 11) //(79 << 11) /** to hex */ - - -/* Reconfiguratble PLL Control Regiser */ -#define PLL_CONTROL_REG (0x51 << 11) //(81 << 11)/** to hex */ - -//#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset -//#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset -//#define PLL_CTRL_WR_PARAMETER_OFST (2) -//#define PLL_CTRL_WR_PARAMETER_MSK (0x00000001 << PLL_CTRL_WR_PARAMETER_OFST) -#define PLL_CTRL_RST_OFST (3) -#define PLL_CTRL_RST_MSK (0x00000001 << PLL_CTRL_RST_OFST) -//#define PLL_CTRL_ADDR_OFST (16) -//#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST) - -/* Samples Register */ -#define NSAMPLES_REG (0x5D << 11) //93<<11 - -/* Power On Register */ -#define POWER_ON_REG (0x5e<<11) - -#define POWER_ENABLE_OFST (16) - -/* Dac Registers */ -#define DAC_VAL_REG (0x79 << 11) //121<<11 -#define DAC_NUM_REG (0x80 << 11) //122<<11 -#define DAC_VAL_OUT_REG (0x2A << 11) //42<<11 - -#endif - diff --git a/slsDetectorServers/mythen3DetectorServer/ansi.h b/slsDetectorServers/mythen3DetectorServer/ansi.h deleted file mode 120000 index a122db0ad..000000000 --- a/slsDetectorServers/mythen3DetectorServer/ansi.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/ansi.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/blackfin.h b/slsDetectorServers/mythen3DetectorServer/blackfin.h deleted file mode 120000 index 24f9c08f7..000000000 --- a/slsDetectorServers/mythen3DetectorServer/blackfin.h +++ /dev/null @@ -1 +0,0 @@ -/afs/psi.ch/project/mythen/marie_a/MythenServer/slsDetectorPackage/slsDetectorSoftware/slsDetectorServer/blackfin.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h deleted file mode 120000 index 33bdd8d53..000000000 --- a/slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/commonServerFunctions.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/communication_funcs.c b/slsDetectorServers/mythen3DetectorServer/communication_funcs.c deleted file mode 120000 index 87a4f95d1..000000000 --- a/slsDetectorServers/mythen3DetectorServer/communication_funcs.c +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.c \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/communication_funcs.h b/slsDetectorServers/mythen3DetectorServer/communication_funcs.h deleted file mode 120000 index f220903b2..000000000 --- a/slsDetectorServers/mythen3DetectorServer/communication_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/gitInfo.txt b/slsDetectorServers/mythen3DetectorServer/gitInfo.txt deleted file mode 100644 index 4df512cd8..000000000 --- a/slsDetectorServers/mythen3DetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer -URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git -Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git -Repsitory UUID: 2f3dc8d109de8607f3217cf429619073dc9cc60e -Revision: 103 -Branch: developer -Last Changed Author: Dhanya_Maliakal -Last Changed Rev: 3397 -Last Changed Date: 2017-12-04 18:23:05.000000002 +0100 ./RegisterDefs.h diff --git a/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h b/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h deleted file mode 100644 index 1acd1f071..000000000 --- a/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" -#define GITREPUUID "2f3dc8d109de8607f3217cf429619073dc9cc60e" -#define GITAUTH "Dhanya_Maliakal" -#define GITREV 0x3397 -#define GITDATE 0x20171204 -#define GITBRANCH "developer" diff --git a/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h b/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3Server b/slsDetectorServers/mythen3DetectorServer/mythen3Server deleted file mode 100755 index 2f0fcf0df512e59de0500d8d3c73cc1d73a081d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 92440 zcmd3Pdt6l4wf~vnF=xgB4lv4qqa5&sFF1~<;Bx>UNEAjye8i-KkU$dKkTh*fV%q_Y z+SE2sO`~a=48}G|YtzBnTgFLSG!|{IH^nBswXID#IY_;!NiYusiq7x5&Y8!VVW92( z{r>p*`7AtZ?blj+uf6u#YwvSr+sZXn48z0%mNU#%C!?8vmC@K-48t+A<1B8CxI5nnu!;Nf89wjDiiRx`OW^M>8%Xo ztM}*)T(Z@${r&?7@2+g!#!PSZ=m#>(z<~i!Y>YSC#QiA0KYts;I?UhITwxe*93*3? z9m422ke_J9MuS|YNIWs0%4zWbHfFWRT-5{ER>nBS9LQg6j58MrR7+*BE_J>1+~MwU zG18ifKwHce189S8#?k3z9R1z~hu*Vw~6ZpuwDq9C!+n9c6A8SnT^O}M-ZQ^#6-u@xg zzPP;K)9LM$N23$MWPFQ0)&3AFRMs& z0|NjX0QNdC0I+Mox`6?Jy$9?HFaR(KSZu$B0N5p9JTL&TKLA?}3;^s+V0K^tU}u3j zfB}GY0&4^Y0OkR<8yEoCabSml0f7Ao*im2rU`K(ufdPPh57-%C0ASw%_BJp8u&06b z0s{cs2kaAI0ANkPVy{7lYlJ-x%mfSo?2Ev1fB}GQ2bK>E0PG%MHedi?cLTEn0|46y z%mEAl%nqy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QYxnks-jGaQ2`ZEb!1LbDkVqeyu2SXD5O%VpmIOQmv>N)?KFDe-w7C@czXWtBub%l z%A^?OP#zUf5fxJvJzuki>ZqQ!(++B;UDQS$)Ja{`P5bE}J-6Wq9iv|Aqmwj1gEU0L zbe=BK2#wMhjnfU9peedd({zt!=rKLzTR*$!%s%!!#ZX0DjEV%Cb8JI0WN*iJLdI?$eiqu%$?1S I?CsS3f3U=Yj{pDw diff --git a/slsDetectorServers/mythen3DetectorServer/mythen3Server.gdb b/slsDetectorServers/mythen3DetectorServer/mythen3Server.gdb deleted file mode 100755 index 4d4b23a68f2b4622c59812d318f09c797cf3a8e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 435662 zcmeFadstN0)jxh_7-r540~}zK0Y^FD4X+$WV!(JAKn0D$h=`Y5ItU3Qu?UVH7e*WPEJ?<`%pOry~-%8!=0ouQNtzxntz3-m|TGbk4a>$_#3>3>7rEd4|!d_>_90wN0n!4zokfBztbye%7)Js!|=f4S05Q#^Cd$P9R?SEc+H zk$-!6h0tCPn0LUF13a$_l3d1efAx{P8yHq7hP1VTQ|||T1D<~GoDQv!AfyXuvz&!K zIe7`&!21D|Zz-4RtzLBCfcBm=`8Vll= z5mWEVsdHi~D5rG&gyl^+#fz!G$f+e_>Qy=A6jLYUluJx?$*D#$<&#s}#MB`Zg@)EP0gQ%-#>rkdrH?gH^}znrp&se9y9u9(^^ zr}D+rEpo~srf!x~PBFDkPPxRCQ%*ICspWENo0uw=Q@h2~b#m&Un97$^$HmkvIrWB^ znj)vpi>WL*by-YVbNMP8Eo$I61XMOkL(BEpUpdPvn$KOua9szAmQz zC8u_Zsa`p?TTJ~;PI<)CpXJnHG4)3|bzDpxms78csh8x`c`@~CIW-`rej%sWkBFmZ z<&;%SwackoF||)l6^N-vU|Y)HX5oZ8`OXn7UU^dBs$toH{P1Zj)1Q zh^b9->YSLmK~7y3Q&n=x{4r6zN={7@Q_JL3zL;7pr^>`sftJ?M{Dmzbe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!g_&^xB&{=s;)dE zkXkdsNs}I;nGt^!9dW4GBYrC{fN$U~ zr4WXWo#?Sp%ek;LEeL8JP}uFbV*yvhpMA(dl~H$u2}W(4iqJ~tirY#HH(~So!3YL0 z&z7=_UfyyF*bf<53iMNQ73QNz(TY>qCvK59<6)LZWRiqJt9&YkeBeSkxna5E5(iL? nlNe7{#AvNwXd0xwAigk=cmS9ol$1iXr3K3q1|303D$f4}h3NTT diff --git a/slsDetectorServers/mythen3DetectorServer/programfpga.h b/slsDetectorServers/mythen3DetectorServer/programfpga.h deleted file mode 120000 index 72c54d21d..000000000 --- a/slsDetectorServers/mythen3DetectorServer/programfpga.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/programfpga.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c deleted file mode 100644 index b31416c6a..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ /dev/null @@ -1,1304 +0,0 @@ -//#ifdef SLS_DETECTOR_FUNCTION_LIST - - -#include "slsDetectorFunctionList.h" -#include "gitInfoMythen3.h" - - -#include "AD9257.h" // include "commonServerFunctions.h", which in turn includes "blackfin.h" -#include "programfpga.h" -#include "RegisterDefs.h" - -/* global variables */ -sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; -int *detectorChans=NULL; -dacs_t *detectorDacs=NULL; -dacs_t *detectorAdcs=NULL; - -enum detectorSettings thisSettings; -enum masterFlags masterMode = NO_MASTER; -int32_t clkPhase[2] = {0, 0}; -int vlimit = -1; - - - -/* basic tests */ - -void checkFirmwareCompatibility(int flag) { - - defineGPIOpins(); - resetFPGA(); - if (mapCSP0() == FAIL) { - cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); - exit(EXIT_FAILURE); - } - - // does check only if flag is 0 (by default), set by command line - if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) { - cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); - exit(EXIT_FAILURE); - } - - uint32_t ipadd = getDetectorIP(); - uint64_t macadd = getDetectorMAC(); - int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION); - int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION); - //int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION); - cprintf(BLUE,"\n\n" - "********************************************************\n" - "****************** Mythen3 Server *********************\n" - "********************************************************\n\n" - - "Detector IP Addr:\t\t 0x%x\n" - "Detector MAC Addr:\t\t 0x%llx\n" - - "Firmware Version:\t\t 0x%llx\n" - "Software Version:\t\t 0x%llx\n" - //"F/w-S/w API Version:\t\t 0x%llx\n" - //"Required Firmware Version:\t 0x%x\n" - "\n" - "********************************************************\n", - hversion, hsnumber, - ipadd, macadd, - fwversion, swversion - //, sw_fw_apiversion, REQUIRED_FIRMWARE_VERSION - ); - - -/* - * printf("Testing firmware capability... "); - //cant read versions - if(!fwversion || !sw_fw_apiversion){ - cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n"); - cprintf(RED,"Exiting Server. Goodbye!\n\n"); - exit(-1); - } - - //check for API compatibility - old server - if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){ - cprintf(RED,"FATAL ERROR: This software version is incompatible.\n" - "Please update it to be compatible with this firmware\n\n"); - cprintf(RED,"Exiting Server. Goodbye!\n\n"); - exit(-1); - } - - //check for firmware compatibility - old firmware - if( REQUIRED_FIRMWARE_VERSION > fwversion){ - cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n" - "Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION); - cprintf(RED,"Exiting Server. Goodbye!\n\n"); - exit(-1); - } -*/ -} - - -int checkType() { - volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST); - if (type != JUNGFRAUCTB){ - cprintf(BG_RED,"This is not a Mythen 3 Server (read %d, expected %d)\n",type, JUNGFRAUCTB); - return FAIL; - } - - return OK; -} - - - -u_int32_t testFpga(void) { - printf("\nTesting FPGA...\n"); - - //fixed pattern - int ret = OK; - volatile u_int32_t val = bus_r(FIX_PATT_REG); - if (val == FIX_PATT_VAL) { - printf("Fixed pattern: successful match 0x%08x\n",val); - } else { - cprintf(RED,"Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL); - ret = FAIL; - } - return ret; -} - - -int testBus() { - printf("\nTesting Bus...\n"); - - int ret = OK; - u_int32_t addr = SET_DELAY_LSB_REG; - int times = 1000 * 1000; - int i = 0; - - for (i = 0; i < times; ++i) { - bus_w(addr, i * 100); - if (i * 100 != bus_r(SET_DELAY_LSB_REG)) { - cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(SET_DELAY_LSB_REG)); - ret = FAIL; - } - } - - if (ret == OK) - printf("Successfully tested bus %d times\n", times); - return ret; -} - - - - -int detectorTest( enum digitalTestMode arg){ - switch(arg){ - case DETECTOR_FIRMWARE_TEST: return testFpga(); - case DETECTOR_BUS_TEST: return testBus(); - default: - cprintf(RED,"Warning: Test not implemented for this detector %d\n", (int)arg); - break; - } - return OK; -} - - - - - -/* Ids */ - -int64_t getDetectorId(enum idMode arg){ - int64_t retval = -1; - - switch(arg){ - case DETECTOR_SERIAL_NUMBER: - retval = getDetectorMAC(); - break; - case DETECTOR_FIRMWARE_VERSION: - retval = getFirmwareVersion(); - break; - //case SOFTWARE_FIRMWARE_API_VERSION: - //return GetFirmwareSoftwareAPIVersion(); - case DETECTOR_SOFTWARE_VERSION: - retval= GITREV; - retval= (retval <<32) | GITDATE; - break; - default: - break; - } - - return retval; -} - -u_int64_t getFirmwareVersion() { - return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST); -} - - - -u_int64_t getDetectorMAC() { - char output[255],mac[255]=""; - u_int64_t res=0; - FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - //getting rid of ":" - char * pch; - pch = strtok (output,":"); - while (pch != NULL){ - strcat(mac,pch); - pch = strtok (NULL, ":"); - } - sscanf(mac,"%llx",&res); - return res; -} - -u_int32_t getDetectorIP(){ - char temp[50]=""; - u_int32_t res=0; - //execute and get address - char output[255]; - FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - - //converting IPaddress to hex. - char* pcword = strtok (output,"."); - while (pcword != NULL) { - sprintf(output,"%02x",atoi(pcword)); - strcat(temp,output); - pcword = strtok (NULL, "."); - } - strcpy(output,temp); - sscanf(output, "%x", &res); - //printf("ip:%x\n",res); - - return res; -} - - - - - - - - -/* initialization */ - -void initControlServer(){ - clkPhase[0] = 0; clkPhase[1] = 0; - setupDetector(); - printf("\n"); -} - - - -void initStopServer() { - - usleep(CTRL_SRVR_INIT_TIME_US); - if (mapCSP0() == FAIL) { - cprintf(BG_RED, "Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"); - exit(EXIT_FAILURE); - } -} - - - - - - -/* set up detector */ - -void allocateDetectorStructureMemory(){ - printf("This Server is for 1 Jungfrau module (500k)\n"); - - //Allocation of memory - if (detectorModules!=NULL) free(detectorModules); - if (detectorChans!=NULL) free(detectorChans); - if (detectorChips!=NULL) free(detectorChips); - if (detectorDacs!=NULL) free(detectorDacs); - if (detectorAdcs!=NULL) free(detectorAdcs); - detectorModules=malloc(sizeof(sls_detector_module)); - detectorChips=malloc(NCHIP*sizeof(int)); - detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(NDAC*sizeof(dacs_t)); - detectorAdcs=malloc(NADC*sizeof(dacs_t)); -#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n); - printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC); - printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC); -#endif - (detectorModules)->dacs=detectorDacs; - (detectorModules)->adcs=detectorAdcs; - (detectorModules)->ndac=NDAC; - (detectorModules)->nadc=NADC; - (detectorModules)->nchip=NCHIP; - (detectorModules)->nchan=NCHIP*NCHAN; - (detectorModules)->module=0; - (detectorModules)->gain=0; - (detectorModules)->offset=0; - (detectorModules)->reg=0; - thisSettings = UNINITIALIZED; - - // if trimval requested, should return -1 to acknowledge unknown - int ichan=0; - for (ichan=0; ichan<(detectorModules->nchan); ichan++) { - *((detectorModules->chanregs)+ichan) = -1; - } -} - - - -void setupDetector() { - - allocateDetectorStructureMemory(); - - resetPLL(); - resetCore(); - resetPeripheral(); - cleanFifos(); - - //initialize dac series - initDac(0); - initDac(8); - initDac(16); - - //set dacs - printf("Setting Default Dac values\n"); - { - int i = 0; - int retval[2]={-1,-1}; - const int defaultvals[NDAC] = DEFAULT_DAC_VALS; - for(i = 0; i < NDAC; ++i) { - setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval); - if (retval[0] != defaultvals[i]) - cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]); - } - } - - /*setSamples(1); - bus_w(DAC_REG,0xffff); - setSpeed - cleanFifos(); /* todo might work without - resetCore(); /* todo might work without */ - - //Initialization of acquistion parameters - setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); - setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES); - setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME); - setTimer(FRAME_PERIOD, DEFAULT_PERIOD); - setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY); -} - - - - - - - -/* firmware functions (resets) */ - -int powerChip (int on){ - - /* set all the required voltages */ - return 0; -} - - -void cleanFifos() { printf("\nClearing Acquisition Fifos - Not doing anything\n"); - /* printf("\nClearing Acquisition Fifos\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK);*/ -} - -void resetCore() {printf("\nResetting Core - Not doing anything\n"); - /*printf("\nResetting Core\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK);*/ -} - -void resetPeripheral() {printf("\nResetting Peripheral - Not doing anything\n"); - /* printf("\nResetting Peripheral\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK);*/ -} - -int getPhase(int i) { - if (i>=0 && i<4) - return clkPhase[i]; - else - return -1; -} - - -int configurePhase(int val, int i) { /** compare with old jungfrau software and add in */ - - u_int32_t l=0x0c; - u_int32_t h=0x0d; - u_int32_t vv; - int32_t phase=0, inv=0; - - u_int32_t tot; - u_int32_t odd=1;//0; - - if (i<0 || i>3) - return -1; - - if (val>65535 || val<-65535) - return clkPhase[i]; - - resetPLL(); - - setPllReconfigReg(PLL_MODE_REG, 1, 0); - printf("phase in %d\n",clkPhase[1]); - - if (val>0) { - inv=0; - phase=val&0xffff; - } else { - inv=0; - val=-1*val; - phase=(~val)&0xffff; - } - - - vv=phase | (i<<16);// | (inv<<21); - - setPllReconfigReg(PLL_PHASE_SHIFT_REG,vv,0); - - clkPhase[i]=val; - return clkPhase[i]; -} - - - -int configureFrequency(int val, enum CLKINDEX i) { /** compare with old jungfrau software and add in */ - - - u_int32_t l=0x0c; - u_int32_t h=0x0d; - u_int32_t vv; - int32_t phase=0, inv=0; - - u_int32_t tot; - u_int32_t odd=1;//0; - printf("Want to configure frequency of counter %d to %d\n",i,val); - // printf("PLL reconfig reset\N"); bus_w(PLL_CNTRL_REG,(1<3) { - printf("wrong counter number %d\n",i); - return -1; - } - - if (val<=0) { - - printf("get value %d %d \n",i,clkDivider[i]); - return clkDivider[i]; - } - if (i==adc_clk_c){ - if (val>40) - { - printf("Too high frequency %d MHz for these ADCs!\n", val); - return clkDivider[i]; - } - } - - tot= PLL_VCO_FREQ_MHZ/val; - l=tot/2; - h=l; - if (tot>2*l) { - h=l+1; - odd=1; - } - else - { - odd=0; - } - - printf("Counter %d: Low is %d, High is %d\n",i, l,h); - - - vv= (i<<18)| (odd<<17) | l | (h<<8); - - printf("Counter %d, val: %08x\n", i, vv); - setPllReconfigReg(PLL_C_COUNTER_REG, vv,0); - - - usleep(10000); - - resetPLL(); - - clkDivider[i]=PLL_VCO_FREQ_MHZ/(l+h); - - printf("Frequency of clock %d is %d\n", i, clkDivider[i]); - - return clkDivider[i]; -} - - - - - - - - -/* set parameters - nmod, dr, roi */ - -int setNMod(int nm, enum dimension dim){ - return NMOD; -} - - -int getNModBoard(enum dimension arg){ - return NMAXMOD; -} - - -int setDynamicRange(int dr){ - /* edit functionality */ - return 16; -} - - - - -/* parameters - readout */ - -int setSpeed(enum speedVariable arg, int val) { - int retval = -1; - - switch (arg) { - case DBIT_PHASE: - if (val==-1) - retval=getPhase(DBIT_CLK_C); - else - retval=configurePhase(val,DBIT_CLK_C); - break; - case DBIT_CLOCK: - retval=configureFrequency(val,DBIT_CLK_C); - if (configureFrequency(-1,SYNC_CLK_C)>retval){ - configureFrequency(retval,SYNC_CLK_C); - printf("--Configuring sync clk to %d MHz\n",val); - } else if (configureFrequency(-1,ADC_CLK_C)>retval && configureFrequency(-1,RUN_CLK_C)>retval) { - printf("++Configuring sync clk to %d MHz\n",val); - configureFrequency(retval,SYNC_CLK_C); - } - break; - default: - sprintf(mess,"Unknown speed parameter %d",arg); - break; - } - return retval; -} - - - - - - -/* parameters - timer */ - -int64_t setTimer(enum timerIndex ind, int64_t val) { - - int64_t retval = -1; - switch(ind){ - - case FRAME_NUMBER: - if(val >= 0) - printf("\nSetting #frames: %lld\n",(long long int)val); - retval = set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); - printf("Getting #frames: %lld\n",(long long int)retval); - break; - - case ACQUISITION_TIME: - if(val >= 0){ - printf("\nSetting exptime: %lldns\n", (long long int)val); - val *= (1E-3 * CLK_RUN); /* ?? */ - } - retval = set64BitReg(val, SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG) / (1E-3 * CLK_RUN); - printf("Getting exptime: %lldns\n", (long long int)retval); - break; - - case FRAME_PERIOD: - if(val >= 0){ - printf("\nSetting period to %lldns\n",(long long int)val); - val *= (1E-3 * CLK_SYNC); /* ?? */ - } - retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-3 * CLK_SYNC); - printf("Getting period: %lldns\n", (long long int)retval); - break; - - case DELAY_AFTER_TRIGGER: - if(val >= 0){ - printf("\nSetting delay to %lldns\n", (long long int)val); - val *= (1E-3 * CLK_SYNC); /* ?? */ - } - retval = set64BitReg(val, SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); - printf("Getting delay: %lldns\n", (long long int)retval); - break; - - case CYCLES_NUMBER: - if(val >= 0) - printf("\nSetting #cycles to %lld\n", (long long int)val); - retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); - printf("Getting #cycles: %lld\n", (long long int)retval); - break; - - case GATES_NUMBER: - if(val >= 0) - printf("\nSetting #gates to %lld\n", (long long int)val); - retval = set64BitReg(val, SET_GATES_LSB_REG, SET_GATES_MSB_REG); - printf("Getting #gates: %lld\n", (long long int)retval); - break; - - case PROBES_NUMBER: /* does not exist in firmware_funcs.c*/ - /*if(val >= 0) - printf("\nSetting #probes to %lld\n", (long long int)val); - retval = set64BitReg(val, SET_PROBES_LSB_REG, SET_PROBES_MSB_REG); - printf("Getting #probes: %lld\n", (long long int)retval); - */ - break; - - case SAMPLES_JCTB: - if(val >= 0) - printf("\nSetting #samples to %lld\n", (long long int)val); - retval = bus_w(NSAMPLES_REG, val); - printf("Getting #samples: %lld\n", (long long int)retval); - - break; - - default: - cprintf(RED,"Warning: Timer Index not implemented for this detector: %d\n", ind); - break; - } - - return retval; - -} - - - -int64_t getTimeLeft(enum timerIndex ind){ - int64_t retval = -1; - switch(ind){ - - case FRAME_NUMBER: - retval = get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); - printf("Getting number of frames left: %lld\n",(long long int)retval); - break; - - case FRAME_PERIOD: - retval = get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG) / (1E-3 * CLK_SYNC); - printf("Getting period left: %lldns\n", (long long int)retval); - break; - - case DELAY_AFTER_TRIGGER: - retval = get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-3 * CLK_SYNC); - printf("Getting delay left: %lldns\n", (long long int)retval); - break; - - /** acquisition time and period gives in time left in func.c, pls check with anna */ - - case CYCLES_NUMBER: - retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG); - printf("Getting number of cycles left: %lld\n", (long long int)retval); - break; - - case ACTUAL_TIME: - retval = get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG) / (1E-9 * CLK_SYNC); - printf("Getting actual time (time from start): %lld\n", (long long int)retval); - break; - - case MEASUREMENT_TIME: - retval = get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG) / (1E-9 * CLK_SYNC); - printf("Getting measurement time (timestamp/ start frame time): %lld\n", (long long int)retval); - break; - - case FRAMES_FROM_START: - retval = get64BitReg(FRAMES_FROM_START_LSB_REG, FRAMES_FROM_START_MSB_REG); - printf("Getting frames from start run control %lld\n", (long long int)retval); - break; - - case FRAMES_FROM_START_PG: /** ask anna, seems to be calling previous function (frames_from_start) */ - retval = get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG); - printf("Getting frames from start run control %lld\n", (long long int)retval); - break; - - default: - cprintf(RED, "Warning: Remaining Timer index not implemented for this detector: %d\n", ind); - break; - } - - return retval; -} - - - - - - -/* parameters - channel, chip, module, settings */ - - -int setModule(sls_detector_module myMod){ - return thisSettings; -} - - -int getModule(sls_detector_module *myMod){ - return OK; -} - - - -enum detectorSettings setSettings(enum detectorSettings sett, int imod){ - return getSettings(); - -} - - -enum detectorSettings getSettings(){ - return thisSettings; -} - - - - - -/* parameters - dac, adc, hv */ - - - - - - -void initDac(int dacnum) { - printf("\nInitializing dac for %d to \n",dacnum); - - u_int32_t codata; - int csdx = dacnum / NDAC_PER_SET + DAC_SERIAL_CS_OUT_OFST; //,so can be DAC_SERIAL_CS_OUT_OFST or +1 - int dacchannel = 0xf; // all channels - int dacvalue = 0x6; // can be any random value (just writing to power up) - printf(" Write to Input Register\n" - " Chip select bit:%d\n" - " Dac Channel:0x%x\n" - " Dac Value:0x%x\n", - csdx, dacchannel, dacvalue); - - codata = LTC2620_DAC_CMD_WRITE + // command to write to input register - ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + // all channels - ((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); // any random value - serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); -} - - - - - - - - - -int voltageToDac(int value){ - int vmin = 0; - int vmax = MAX_DACVOLTVAL; - int nsteps = MAX_DACVAL; - if ((value < vmin) || (value > vmax)) { - cprintf(RED,"Voltage value (to convert to dac value) is outside bounds: %d\n", value); - return -1; - } - return (int)(((value - vmin) / (vmax - vmin)) * (nsteps - 1) + 0.5); -} - -int dacToVoltage(unsigned int digital){ - int vmin = 0; - int vmax = MAX_DACVOLTVAL; - int nsteps = MAX_DACVAL; - int v = vmin + (vmax - vmin) * digital / (nsteps - 1); - if((v < 0) || (v > nsteps - 1)) { - cprintf(RED,"Voltage value (converted from dac value) is outside bounds: %d\n", v); - return -1; - } - return v; -} - -int powerToDac(int value, int chip) { - int nsteps = MAX_DACVAL; - int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1); - printf("Current V_Chip: %d mV\n",vchip); - - int vmax = vchip - MIN_VCHIP_OFSTVAL; - int vmin = MIN_VCHIP_VAL; - - // recalculating only for v_chip - if (chip) { - printf("vchip\n"); - vmax = MAX_VCHIPVAL; - vmin = MAX_VCHIPVAL - 1000; - } - else - printf("vpower\n"); - - int v = (int)(((vmax - value) * (nsteps - 1) / (vmax - vmin)) ); /***+0.5 removed is this correct? seems different from voltageToDac maybe get rid of 0.5*/ - - - if (v < 0) v = 0; - if (v > nsteps - 1) v = nsteps - 1; - if (value == -100) v = -100; - - return v; -} - -int dacToPower(int value, int chip) { - int retval1 = -1; - int nsteps = MAX_DACVAL; - int vchip = MAX_VCHIPVAL - (getDacRegister(V_CHIP)*1000)/(nsteps -1); - printf("Vchip id %d mV\n",vmax); - int vmax = vchip - MIN_VCHIP_OFSTVAL; - int vmin = MIN_VCHIP_VAL; - - // recalculating only for v_chip - if (chip) { - printf("vchip\n"); - vmax = MAX_VCHIPVAL; - vmin = MAX_VCHIPVAL - 1000; - } - else - printf("vpower\n"); - - retval1 = vmax - (value * (vmax - vmin)) / (nsteps - 1); - if (retval1 > vmax) retval1 = vmax; - if (retval1 < vmin) retval1 = vmin; - if (value < 0) retval1 = value; - return retval1; -} - - - -void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){ - - int dacval = val; - - // dacs: if set and mv, convert to dac - if (ind < val > 0 && mV) { - val = voltageToDac(val); //gives -1 on error - } - - - if ( (val >= 0) || (val == -100)) { - - - u_int32_t ichip = 2 - ind / NDAC_PER_SET; - u_int32_t valw = 0; - int i; - - // start and chip select bar down ----------------- - SPIChipSelect (&valw, SPI_REG, (0x1 << csdx)); - - - // next dac -------------------------------------- - for (i = 0; i < ichip; ++i) { - printf("%d next DAC\n", i); - sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); - } - - - // this dac ---------------------------------------- - u_int32_t codata; - int csdx = DAC_SERIAL_CS_OUT_OFST; - int dacchannel = ind % NDAC_PER_SET; - - printf("\nSetting of DAC %d : %d dac units (%d mV)\n",ind, dacval, val); - // command - if (val >= 0) { - printf(" Write to Input Register and Update\n"); - codata = LTC2620_DAC_CMD_SET; - - } else if (val == -100) { - printf(" POWER DOWN\n"); - codata = LTC2620_DAC_CMD_POWER_DOWN; - } - // address - printf(" Chip select bit:%d\n" - " Dac Channel:0x%x\n" - " Dac Value:0x%x\n", - csdx, dacchannel, val); - codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + - ((val << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); - // to spi - serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); - - - printf("--------done setting dac set %d \n",i); - - // next dac ----------------------------------------------------------- - for (i = ichip+1; i < (N_DAC / NDAC_PER_SET); ++i) { - printf("%d next DAC\n", i); - sendDataToSPI (&valw, SPI_REG, LTC2620_DAC_CMD_MSK, LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); - } - - - //chip select bar up, clk down and stop -------------------------------- - SPIChipDeselect (&valw, SPI_REG, (0x1 << csdx), DAC_SERIAL_CLK_OUT_MSK); - - // writes to register - setDacRegister(ind, dacval); - } - - // reading dac value from register - printf("Getting DAC %d : ",ind); - retval[0] = getDacRegister(ind); printf("%d dac units ", retval[0]); - retval[1] = dacToVoltage(retval[0]);printf("(%d mV)\n", retval[1]); -} - - -int setPower(enum DACINDEX ind, int val) { - - // not implemented yet - if ((ind == V_D) || (ind == V_C)) - return -1; - - // vlimit software limit - else if (ind == V_LIMIT) { - if (val >= 0) - vlimit = val; - return vlimit; - } - - int pwrindex = -1; - int dacval = val; - int retval=-1, retval1=-1; - u_int32_t preg = 0; - int temp[2] = {-1,-1}; - - // get - if (val == -1) - dacval = -1; - - // vchip - else if (ind == V_CHIP) - dacval = powerToDac(val, 1); - - // power a, b, c , d, io - else { - dacval = powerToDac(val, 0); - - switch (ind) { - case V_IO: pwrindex = 0;break; - case V_A: pwrindex = 1; break; - case V_B: pwrindex = 2; break; - default:break; - } - - // shut down - preg = bus_r(POWER_ON_REG); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - printf("Switching off power %d\n", ind); - bus_w(POWER_ON_REG,preg &(~(1 << (POWER_ENABLE_OFST + pwrindex)))); - setDac(ind,-100, 0, 1, temp); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - retval=0; - } - - // actual setting - if (val != -100) { - printf("Setting power %d to %d mV (%d dac val)\n",ind, val, dacval); - retval = setDac(ind, dacval); - // setting power a, b, c, d, io - if (pwrindex >= 0 && dacval >= 0 ) { - preg = bus_r(POWER_ON_REG); - printf("power reg is %08x\n", bus_r(POWER_ON_REG)); - printf("Switching on power %d\n", pwrindex); - bus_w(POWER_ON_REG, preg | ((1 << (POWER_ENABLE_OFST + pwrindex)))); - printf("power reg is %08x\n",bus_r(POWER_ON_REG)); - } - } - - if (pwrindex >= 0) { - if (bus_r(POWER_ON_REG) & (1 << (POWER_ENABLE_OFST + pwrindex))) { - retval1 = dacToPower(retval, 0); - printf("Vdac id %d mV\n",retval1); - } else - retval1 = 0; - } else { - if (retval >= 0) { - retval1 = dacToPower(retval, 1); - /*printf("Vchip is %d mV\n",vmax); makes no sense.. should be printing retval1??? */ - } else - retval1=-1; - } - - return retval1; -} - -int getVLimit() { - return vlimit; -} - -void setDacRegister(int dacnum,int dacvalue) { - bus_w(DAC_NUM_REG, dacnum); - bus_w(DAC_VAL_REG, dacvalue); - bus_w(DAC_NUM_REG, dacnum | (1<<16));/** super strange writing dac num in weird ways */ - bus_w(DAC_NUM_REG, dacnum); - printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; -} - -int getDacRegister(int dacnum) {/** super strange, reading out in some other register than written */ - bus_w(DAC_NUM_REG, dacnum); - printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ; - return (int16_t)bus_r(DAC_VAL_OUT_REG); -} - - - - - -/* parameters - timing, extsig */ - - -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){ - return AUTO_TIMING; -} - - - - -/* jungfrau specific - pll, flashing fpga */ - - - -void resetPLL() { - // reset PLL Reconfiguration and PLL - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_RECONFIG_RST_MSK | PLL_CTRL_RST_MSK); - usleep(100); - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_RECONFIG_RST_MSK & ~PLL_CTRL_RST_MSK); -} - - -u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) { - - // set parameter - bus_w(PLL_PARAM_REG, val); - - // set address - bus_w(PLL_CONTROL_REG, (reg << PLL_CTRL_ADDR_OFST) & PLL_CTRL_ADDR_MSK); - usleep(10*1000); - - //write parameter - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_WR_PARAMETER_MSK); - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_WR_PARAMETER_MSK); - usleep(10*1000); - - return val; -} - - - - -void configurePll() { - u_int32_t val; - int32_t phase=0, inv=0; - - printf(" phase in %d\n", clkPhase[1]); - if (clkPhase[1]>0) { - inv=0; - phase=clkPhase[1]; - } else { - inv=1; - phase=-1*clkPhase[1]; - } - printf(" phase out %d (0x%08x)\n", phase, phase); - - if (inv) { - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C1_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL; - printf(" phase word 0x%08x\n", val); - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - } else { - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C0_VAL + PLL_SHIFT_UP_DOWN_NEG_VAL; - printf(" phase word 0x%08x\n", val); - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - - printf(" phase word 0x%08x\n", val); - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) + PLL_SHIFT_CNT_SLCT_C2_VAL; - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - } - usleep(10000); -} - - - - -/* aquisition */ - -int startStateMachine(){ - printf("*******Starting State Machine*******\n"); - - cleanFifos(); - - //start state machine - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_START_ACQ_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_START_ACQ_MSK); - - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - return OK; -} - - -int stopStateMachine(){ - cprintf(BG_RED,"*******Stopping State Machine*******\n"); - - //stop state machine - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK); - usleep(100); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STOP_ACQ_MSK); - - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - return OK; -} - - - - - -enum runStatus getRunStatus(){ -#ifdef VERBOSE - printf("Getting status\n"); -#endif - - enum runStatus s; - u_int32_t retval = bus_r(STATUS_REG); - printf("Status Register: %08x\n",retval); - - //running - if(((retval & RUN_BUSY_MSK) >> RUN_BUSY_OFST)) { - if ((retval & WAITING_FOR_TRIGGER_MSK) >> WAITING_FOR_TRIGGER_OFST) { - printf("-----------------------------------WAITING-----------------------------------\n"); - s=WAITING; - } - else{ - printf("-----------------------------------RUNNING-----------------------------------\n"); - s=RUNNING; - } - } - - //not running - else { - if ((retval & STOPPED_MSK) >> STOPPED_OFST) { - printf("-----------------------------------STOPPED--------------------------\n"); - s=STOPPED; - } else if ((retval & RUNMACHINE_BUSY_MSK) >> RUNMACHINE_BUSY_OFST) { - printf("-----------------------------------READ MACHINE BUSY--------------------------\n"); - s=TRANSMITTING; - } else if (!retval) { - printf("-----------------------------------IDLE--------------------------------------\n"); - s=IDLE; - } else { - printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval); - s=ERROR; - } - } - - return s; -} - - - -void readFrame(int *ret, char *mess){ - - // wait for status to be done - while(runBusy()){ - usleep(500); - } - - // frames left to give status - int64_t retval = getTimeLeft(FRAME_NUMBER) + 1; - if ( retval > 0) { - *ret = (int)FAIL; - sprintf(mess,"no data and run stopped: %lld frames left\n",retval); - cprintf(RED,"%s\n",mess); - } else { - *ret = (int)FINISHED; - sprintf(mess,"acquisition successfully finished\n"); - printf("%s",mess); - } -} - - - -u_int32_t runBusy(void) { - u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST); -#ifdef VERBOSE - printf("Status Register: %08x\n", s); -#endif - return s; -} - - - - - - - - -/* common */ - -//jungfrau doesnt require chips and chans (save memory) -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){ - - int idac, iadc; - int ret=OK; - -#ifdef VERBOSE - printf("Copying module %x to module %x\n",srcMod,destMod); -#endif - - if (srcMod->module>=0) { -#ifdef VERBOSE - printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module); -#endif - destMod->module=srcMod->module; - } - if (srcMod->serialnumber>=0){ - - destMod->serialnumber=srcMod->serialnumber; - } - if ((srcMod->nchip)>(destMod->nchip)) { - printf("Number of chip of source is larger than number of chips of destination\n"); - return FAIL; - } - if ((srcMod->nchan)>(destMod->nchan)) { - printf("Number of channels of source is larger than number of channels of destination\n"); - return FAIL; - } - if ((srcMod->ndac)>(destMod->ndac)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - if ((srcMod->nadc)>(destMod->nadc)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - -#ifdef VERBOSE - printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac); - printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc); - printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip); - printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan); - -#endif - destMod->ndac=srcMod->ndac; - destMod->nadc=srcMod->nadc; - destMod->nchip=srcMod->nchip; - destMod->nchan=srcMod->nchan; - if (srcMod->reg>=0) - destMod->reg=srcMod->reg; -#ifdef VERBOSE - printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg ); -#endif - if (srcMod->gain>=0) - destMod->gain=srcMod->gain; - if (srcMod->offset>=0) - destMod->offset=srcMod->offset; - - for (idac=0; idac<(srcMod->ndac); idac++) { - if (*((srcMod->dacs)+idac)>=0) - *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); - } - for (iadc=0; iadc<(srcMod->nadc); iadc++) { - if (*((srcMod->adcs)+iadc)>=0) - *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc); - } - return ret; -} - - -int calculateDataBytes(){ - return DATA_BYTES; -} - -int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerModule() * (int)getTotalNumberOfModules());} -int getTotalNumberOfChips(){return ((int)getNumberOfChipsPerModule() * (int)getTotalNumberOfModules());} -int getTotalNumberOfModules(){return NMOD;} -int getNumberOfChannelsPerModule(){return ((int)getNumberOfChannelsPerChip() * (int)getTotalNumberOfChips());} -int getNumberOfChipsPerModule(){return NCHIP;} -int getNumberOfDACsPerModule(){return NDAC;} -int getNumberOfADCsPerModule(){return NADC;} -int getNumberOfChannelsPerChip(){return NCHAN;} - - - -/* sync */ - -enum masterFlags setMaster(enum masterFlags arg){ - return NO_MASTER; -} - -enum synchronizationMode setSynchronization(enum synchronizationMode arg){ - return NO_SYNCHRONIZATION; -} - - - - - - -//#endif diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h deleted file mode 120000 index 345b8c029..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/slsDetectorFunctionList.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c deleted file mode 120000 index a7eb59acb..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/slsDetectorServer.c \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h deleted file mode 100644 index e638f840e..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * mythen3Server_defs.h - * - * Created on: Jan 24, 2013 - * Author: l_maliakal_d, changed my Marie A. - */ - -#ifndef SLSDETECTORSERVER_DEFS_H_ -#define SLSDETECTORSERVER_DEFS_H_ - -#include "sls_detector_defs.h" -#include - -/** This is only an example file!!! */ - - - -#define GOODBYE (-200) -enum DACINDEX {vIpre, vIbias, Vrf, VrfSh, vIinSh, VdcSh, Vth2, VPL, Vth1, Vth3, Vtrim, casSh, cas, vIbiasSh, vIcin, VPH, NC, vIpreOut, V_D, V_CHIP, V_C, V_B, V_A, V_IO, V_LIM}; // Mythen 3.01 -enum PWRINDEX {PWR_IO, PWR_A, PWR_B, PWR_C, PWR_D, PWR_CHIP=-1, PWR_LIMIT=-1}; -enum CLKINDEX {RUN_CLK_C, ADC_CLK_C, SYNC_CLK_C, DBIT_CLK_C}; - -#define DEFAULT_DAC_VALS { 2150, /* vIpre */ \ - 1200, /* vIbias */ \ - 900, /* Vrf */ \ - 1050, /* VrfSh */ \ - 1400, /* vIinSh */ \ - 655, /* VdcSh */ \ - 850, /* Vth2 */ \ - 1400, /* VPL */ \ - 850, /* Vth1 */ \ - 850, /* Vth3 */ \ - 2294, /* Vtrim */ \ - 983, /* casSh */ \ - 1474, /* cas */ \ - 1200, /* vIbiasSh */ \ - 1600, /* vIcin */ \ - 1520, /* VPH */ \ - 0, /* NC */ \ - 1000 /* vIpreOut */ \ - 0 /* V_D */ \ - 0 /* V_CHIP */ \ - 0 /* V_C */ \ - 1335 /* V_B */ \ - 1335 /* V_A */ \ - 1350 /* V_IO */ \ - }; - -#define DEFAULT_DAC_NAMES { "vIpre", \ - "vIbias", \ - "Vrf", \ - "VrfSh", \ - "vIinSh", \ - "VdcSh", \ - "Vth2", \ - "VPL", \ - "Vth1", \ - "Vth3", \ - "Vtrim", \ - "casSh", \ - "cas", \ - "vIbiasSh", \ - "vIcin", \ - "VPH", \ - "NC", \ - "vIpreOut" \ - "v_d" \ - "v_chip" \ - "v_c" \ - "v_b" \ - "v_a" \ - "v_io" \ - }; - -/*Hardware Definitions */ -#define NMAXMOD (1) -#define NMOD (1) -#define NCHAN (32) -#define NCHIP (1) -#define NADC (0) -#define NDAC (24) -#define NDAC_PER_SET (8) - - -#define NPWR (5) -#define MAX_DACVOLTVAL (2500) //mV -#define MAX_DACVAL (4096) // dac val -#define MAX_VCHIPVAL (2700) //mV /** name ???? */ -#define MIN_VCHIP_OFSTVAL (200) //mV /** name ???? */ -#define MIN_VCHIP_VAL (600) //mV /** name ???? */ - - -/** Default Parameters */ -#define DEFAULT_NUM_FRAMES (1) -#define DEFAULT_NUM_CYCLES (1) -#define DEFAULT_EXPTIME (200*1000) //ns -#define DEFAULT_PERIOD (1*1000*1000) //ns -#define DEFAULT_DELAY (0) -#define DEFAULT_HIGH_VOLTAGE (0) -#define DEFAULT_TIMING_MODE (AUTO_TIMING) - - -/* Defines in the Firmware */ -#define FIX_PATT_VAL (0xACDC1980) - -/* LTC2620 DAC DEFINES */ -#define LTC2620_DAC_CMD_OFST (20) -#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_ADDR_OFST (16) -#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST) -#define LTC2620_DAC_DATA_OFST (4) -#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST) - -#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_NUMBITS (24) - -/** PLL Reconfiguration Registers */ -//https://www.altera.com/documentation/mcn1424769382940.html -#define PLL_MODE_REG (0x00) -#define PLL_STATUS_REG (0x01) -#define PLL_START_REG (0x02) -#define PLL_N_COUNTER_REG (0x03) -#define PLL_M_COUNTER_REG (0x04) -#define PLL_C_COUNTER_REG (0x05) -#define PLL_PHASE_SHIFT_REG (0x06) - -#define PLL_SHIFT_NUM_SHIFTS_OFST (0) -#define PLL_SHIFT_NUM_SHIFTS_MSK (0x0000FFFF << PLL_SHIFT_NUM_SHIFTS_OFST) - -#define PLL_SHIFT_CNT_SELECT_OFST (16) -#define PLL_SHIFT_CNT_SELECT_MSK (0x0000001F << PLL_SHIFT_CNT_SELECT_OFST) -#define PLL_SHIFT_CNT_SLCT_C0_VAL ((0x0 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C1_VAL ((0x1 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C2_VAL ((0x2 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C3_VAL ((0x3 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C4_VAL ((0x4 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C5_VAL ((0x5 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C6_VAL ((0x6 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C7_VAL ((0x7 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C8_VAL ((0x8 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C9_VAL ((0x9 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C10_VAL ((0x10 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C11_VAL ((0x11 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C12_VAL ((0x12 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C13_VAL ((0x13 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C14_VAL ((0x14 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C15_VAL ((0x15 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C16_VAL ((0x16 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) -#define PLL_SHIFT_CNT_SLCT_C17_VAL ((0x17 << PLL_SHIFT_CNT_SELECT_OFST) & PLL_SHIFT_CNT_SELECT_MSK) - -#define PLL_SHIFT_UP_DOWN_OFST (21) -#define PLL_SHIFT_UP_DOWN_MSK (0x00000001 << PLL_SHIFT_UP_DOWN_OFST) -#define PLL_SHIFT_UP_DOWN_NEG_VAL ((0x0 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK) -#define PLL_SHIFT_UP_DOWN_POS_VAL ((0x1 << PLL_SHIFT_UP_DOWN_OFST) & PLL_SHIFT_UP_DOWN_MSK) - -#define PLL_K_COUNTER_REG (0x07) -#define PLL_BANDWIDTH_REG (0x08) -#define PLL_CHARGEPUMP_REG (0x09) -#define PLL_VCO_DIV_REG (0x1c) -#define PLL_MIF_REG (0x1f) - -#define PLL_VCO_FREQ_MHZ 400 - - -#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c deleted file mode 120000 index a7532ccd4..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/slsDetectorServer_funcs.c \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h deleted file mode 120000 index 7569daf47..000000000 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorServer/slsDetectorServer_funcs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h b/slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h deleted file mode 120000 index c5062e03f..000000000 --- a/slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h b/slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h deleted file mode 120000 index 844b67129..000000000 --- a/slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h b/slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h deleted file mode 120000 index 1de31caf5..000000000 --- a/slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h b/slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h deleted file mode 120000 index c2ea4ded9..000000000 --- a/slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh b/slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh deleted file mode 100755 index 0c25e7f1e..000000000 --- a/slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,31 +0,0 @@ -SERVER=jungfrauDetectorServer -MAINDIR=slsDetectorsPackage -SPECDIR=slsDetectorSoftware/$SERVER -TMPFILE=gitInfoJungfrauTmp.h -INCLFILE=gitInfoJungfrau.h - - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|bin|.git|updateGitVersion|.o' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.c b/slsDetectorServers/slsDetectorServer/communication_funcs.c index a6ece1276..a82f9bd82 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.c @@ -95,7 +95,7 @@ int bindSocket(unsigned short int port_number) { // success myport = port_number; ret = OK; - FILE_LOG(logINFO, (" %s socket bound: isock=%d port=%d fd=%d\n", + FILE_LOG(logDEBUG5, ("%s socket bound: isock=%d, port=%d, fd=%d\n", (isControlServer ? "Control":"Stop"), isock, port_number, socketDescriptor)); } @@ -356,25 +356,34 @@ int sendModule(int file_des, sls_detector_module *myMod) { int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { - int ts = 0; + int ts = 0, n = 0; int nChips = myMod->nchip; int nChans = myMod->nchan; int nAdcs = myMod->nadc; int nDacs = myMod->ndac; // send module structure - ts += sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts += sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts += sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts += sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts += sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts += sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - ts += sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts += sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + n = sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); + if (!n) return -1; ts += n; + n = sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("module of size %d sent\n",ts)); // send dac - ts += sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32); + n = sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("dacs of size %d sent\n",ts)); { int idac; @@ -383,18 +392,21 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { } // send adc - ts += sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32); + n = sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("adcs of size %d sent\n", ts)); // some detectors dont require sending all trimbits etc. if(sendAll) { // chips - ts += sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); + n = sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("chips of size %d sent\n", ts)); // channels - ts += sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); + n = sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); FILE_LOG(logDEBUG5, ("chans of size %d sent - %d\n", ts, myMod->nchan)); + if (!n) return -1; ts += n; } FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg)); @@ -408,7 +420,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) { } int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) { - int ts = 0; + int ts = 0, n = 0; int *dacptr = myMod->dacs; int *adcptr = myMod->adcs; int *chipptr = myMod->chipregs, *chanptr = myMod->chanregs; @@ -416,14 +428,22 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA int nChans, nchanold = myMod->nchan, nchandiff; int nDacs, ndold = myMod->ndac, ndacdiff; int nAdcs, naold = myMod->nadc, nadcdiff; - ts += receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - ts += receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - ts += receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - ts += receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - ts += receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - ts += receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - ts += receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - ts += receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + n = receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + if (!n) return -1; ts += n; myMod->dacs = dacptr; myMod->adcs = adcptr; @@ -473,7 +493,8 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA else FILE_LOG(logDEBUG5, ("received %d adcs\n",nAdcs)); if (ndacdiff <= 0) { - ts += receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32); + n = receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("dacs received\n")); int id; for (id = 0; idndac = ndold; - ts += receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32); - ts += receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32); + n = receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32); + if (!n) return -1; ts += n; free(dacptr); return FAIL; } if (nadcdiff <= 0) { - ts += receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32); + n = receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("adcs received\n")); } else { adcptr = (int*)malloc(nadcdiff*sizeof(int)); myMod->nadc = naold; - ts += receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32); - ts += receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32); + n = receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32); + if (!n) return -1; ts += n; free(adcptr); return FAIL; } @@ -504,25 +530,31 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA if(receiveAll){ if (nchipdiff <= 0) { - ts += receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); + n = receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("chips received\n")); } else { chipptr = (int*)malloc(nchipdiff*sizeof(int)); myMod->nchip = nchipold; - ts += receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); - ts += receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); + n = receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); + if (!n) return -1; ts += n; free(chipptr); return FAIL; } if (nchandiff <= 0) { - ts += receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); + n = receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); + if (!n) return -1; ts += n; FILE_LOG(logDEBUG5, ("chans received\n")); } else { chanptr = (int*)malloc(nchandiff*sizeof(int)); myMod->nchan = nchanold; - ts += receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); - ts += receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); + n = receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); + if (!n) return -1; ts += n; free(chanptr); return FAIL; } @@ -546,7 +578,7 @@ int Server_VerifyLock() { } -void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) { +int Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) { // update if different clients (ret can be ok or acquisition finished), not fail to not overwrite e message if (update && ret != FAIL && differentClients) @@ -554,7 +586,7 @@ void Server_SendResult(int fileDes, intType itype, int update, void* retval, int // send success of operation int ret1 = ret; - sendData(fileDes, &ret1,sizeof(ret1), INT32);/* if < 0, return , socket crash*/ + sendData(fileDes, &ret1,sizeof(ret1), INT32); if(ret == FAIL) { // send error message if (strlen(mess)) @@ -567,4 +599,6 @@ void Server_SendResult(int fileDes, intType itype, int update, void* retval, int } // send return value sendData(fileDes, retval, retvalSize, itype); + + return ret; } diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.h b/slsDetectorServers/slsDetectorServer/communication_funcs.h index 6b2068e20..0089fc16e 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.h +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.h @@ -64,7 +64,8 @@ int Server_VerifyLock(); * @param update 1 if one must update if different clients, else 0 * @param retval pointer to result * @param retvalSize size of result + * @returns result of operation */ -void Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize); +int Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize); #endif diff --git a/slsDetectorServers/slsDetectorServer/logger.h b/slsDetectorServers/slsDetectorServer/logger.h index c89aafd30..85d0661e4 100644 --- a/slsDetectorServers/slsDetectorServer/logger.h +++ b/slsDetectorServers/slsDetectorServer/logger.h @@ -20,7 +20,7 @@ #endif typedef enum { -logERROR, logWARNING, logINFO, logINFOBLUE, +logERROR, logWARNING, logINFO, logINFOBLUE, logGREEN, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5 }TLogLevel; @@ -35,6 +35,7 @@ static inline void FILELOG_PrintLog(TLogLevel level, char* m) { case logERROR: cprintf(RED BOLD, "ERROR: %s", m); break; case logWARNING: cprintf(YELLOW BOLD, "WARNING: %s", m); break; case logINFOBLUE: cprintf(BLUE, "INFO: %s", m); break; + case logGREEN: cprintf(GREEN, "INFO: %s", m); break; case logINFO: cprintf(RESET, "INFO: %s", m); break; case logDEBUG: cprintf(MAGENTA, "DEBUG: %s", m); break; case logDEBUG1: cprintf(MAGENTA, "DEBUG1: %s", m); break; diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index d100b85f8..05861f3e0 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -19,15 +19,12 @@ int getFirmwareCheckResult(char** mess); #endif void checkFirmwareCompatibility(); -#if defined(MYTHEN3D) || defined(JUNGFRAUD) +#ifdef JUNGFRAUD int checkType(); u_int32_t testFpga(void); int testBus(void); #endif -#ifdef MYTHEN3D -int moduleTest( enum digitalTestMode arg); -#endif #ifdef JUNGFRAUD int detectorTest( enum digitalTestMode arg); #endif @@ -40,7 +37,7 @@ u_int64_t getFirmwareAPIVersion(); u_int16_t getHardwareVersionNumber(); u_int16_t getHardwareSerialNumber(); #endif -#if !defined(MYTHEN3D) || !defined(EIGERD) +#ifdef EIGERD u_int32_t getDetectorNumber(); #endif u_int64_t getDetectorMAC(); @@ -73,17 +70,11 @@ uint32_t readRegister(uint32_t offset); // firmware functions (resets) -#if defined(MYTHEN3D) || defined(JUNGFRAUD) +#ifdef JUNGFRAUD int powerChip (int on); void cleanFifos(); void resetCore(); void resetPeripheral(); -#endif -#ifdef MYTHEN3D -int getPhase(int i); -int configurePhase(int val, enum CLKINDEX i); -int configureFrequency(int val, int i); -#elif JUNGFRAUD int autoCompDisable(int on); int adcPhase(int st); int getPhase(); @@ -97,7 +88,7 @@ int setROI(int n, ROI arg[], int *retvalsize, int *ret); #endif // parameters - readout -int setSpeed(enum speedVariable arg, int val); +enum speedVariable setSpeed(int val); #ifdef EIGERD enum readOutFlags setReadOutFlags(enum readOutFlags val); #endif @@ -129,35 +120,21 @@ int setThresholdEnergy(int ev); #endif // parameters - dac, adc, hv -#if defined(MYTHEN3D) || defined(JUNGFRAUD) +#ifdef JUNGFRAUD void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset); void initDac(int dacnum); int voltageToDac(int value); int dacToVoltage(unsigned int digital); #endif -#ifdef MYTHEN3D -int setPower(enum DACINDEX ind, int val); -int powerToDac(int value, int chip); -int dacToPower(int value, int chip); -#endif #ifdef JUNGFRAUD extern void setAdc(int addr, int val); // AD9257.h #endif void setDAC(enum DACINDEX ind, int val, int mV, int retval[]); -#ifdef MYTHEN3D -int getVLimit(); -void setDacRegister(int dacnum,int dacvalue); -int getDacRegister(int dacnum); -#endif -#ifndef MYTHEN3D int getADC(enum ADCINDEX ind); -#endif -#ifndef MYTHEN3D int setHighVoltage(int val); -#endif @@ -169,8 +146,10 @@ enum externalCommunicationMode getTiming(); #ifdef JUNGFRAUD long int calcChecksum(int sourceip, int destip); #endif -#ifndef MYTHEN3D +#ifdef GOTTHARDD int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival); +#else +int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2); #endif #if defined(JUNGFRAUD) || defined(EIGERD) int setDetectorPosition(int pos[]); @@ -187,7 +166,7 @@ int resetCounterBlock(int startACQ); int calibratePedestal(int frames); // jungfrau specific - pll, flashing firmware -#elif defined(JUNGFRAUD) || defined(MYTHEN3D) +#elif JUNGFRAUD void resetPLL(); u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); void configurePll(); diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c index 9a4c56df3..ef85d11b5 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c @@ -33,6 +33,7 @@ int main(int argc, char *argv[]){ // subsequent read/write to socket gives error - must handle locally signal(SIGPIPE, SIG_IGN); + // circumvent the basic tests { int i; @@ -64,28 +65,20 @@ int main(int argc, char *argv[]){ #endif if (isControlServer) { portno = DEFAULT_PORTNO; - FILE_LOG(logINFOBLUE, - ("***************************************************\n" - "********* opening control server on port %d **********\n" - "********************************************************\n\n" - , portno)); + FILE_LOG(logINFO, ("Opening control server on port %d \n", portno)); #ifdef STOP_SERVER { int i; for (i = 0; i < argc; ++i) sprintf(cmd, "%s %s", cmd, argv[i]); sprintf(cmd,"%s -stopserver&", cmd); - FILE_LOG(logINFO, ("Command to start stop server:%s\n", cmd)); + FILE_LOG(logDEBUG5, ("Command to start stop server:%s\n", cmd)); system(cmd); } #endif } else { portno = DEFAULT_PORTNO + 1; - FILE_LOG(logINFOBLUE, - ("***************************************************\n" - "*********** opening stop server on port %d ***********\n" - "********************************************************\n\n" - , portno)); + FILE_LOG(logINFO,("Opening stop server on port %d \n", portno)); } init_detector(); @@ -100,7 +93,7 @@ int main(int argc, char *argv[]){ function_table(); if (isControlServer) { - FILE_LOG(logINFO, ("Control Server Ready...\n\n")); + FILE_LOG(logINFOBLUE, ("Control Server Ready...\n\n")); } else { FILE_LOG(logINFO, ("Stop Server Ready...\n\n")); } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 6e020da88..c202dceac 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -14,8 +14,6 @@ const enum detectorType myDetectorType=GOTTHARD; const enum detectorType myDetectorType=EIGER; #elif JUNGFRAUD const enum detectorType myDetectorType=JUNGFRAU; -#elif MYTHEN3D -const enum detectorType myDetectorType=MYTHEN3; #else const enum detectorType myDetectorType=GENERIC; #endif @@ -40,7 +38,7 @@ int dataBytes = 10; #ifdef EIGERD uint32_t dhcpipad = 0; #endif -#ifdef GOTTHARD +#ifdef GOTTHARDD int digitalTestBit = 0; #endif @@ -110,7 +108,7 @@ int decode_function(int file_des) { } else { FILE_LOG(logDEBUG5, (" calling function fnum=%d, (%s)\n", fnum, getFunctionName((enum detFuncs)fnum))); - ret=(*flist[fnum])(file_des); + ret = (*flist[fnum])(file_des); if (ret == FAIL) { FILE_LOG(logDEBUG5, ("Error executing the function = %d (%s)\n", @@ -271,24 +269,37 @@ void functionNotImplemented() { void modeNotImplemented(char* modename, int mode) { ret = FAIL; sprintf(mess, "%s (%d) is not implemented for this detector\n", modename, mode); - FILE_LOG(logWARNING,(mess)); + FILE_LOG(logERROR,(mess)); } void validate(int arg, int retval, char* modename, int hex) { if (ret == OK && arg != -1 && retval != arg) { ret = FAIL; if (hex) - sprintf(mess, "Could not set %s. Set 0x%x, but got 0x%x\n", + sprintf(mess, "Could not %s. Set 0x%x, but read 0x%x\n", modename, arg, retval); else - sprintf(mess, "Could not set %s. Set %d, but got %d\n", + sprintf(mess, "Could not %s. Set %d, but read %d\n", + modename, arg, retval); + FILE_LOG(logERROR,(mess)); + } +} + +void validate64(int64_t arg, int64_t retval, char* modename, int hex) { + if (ret == OK && arg != -1 && retval != arg) { + ret = FAIL; + if (hex) + sprintf(mess, "Could not %s. Set 0x%llx, but read 0x%llx\n", + modename, arg, retval); + else + sprintf(mess, "Could not %s. Set %lld, but read %lld\n", modename, arg, retval); FILE_LOG(logERROR,(mess)); } } -int M_nofunc(int file_des){ +int M_nofunc(int file_des) { ret = FAIL; memset(mess, 0, sizeof(mess)); @@ -299,14 +310,12 @@ int M_nofunc(int file_des){ strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); FILE_LOG(logERROR, (mess)); - - Server_SendResult(file_des, OTHER, 0, NULL, 0); - return ret; + return Server_SendResult(file_des, OTHER, 0, NULL, 0); } // Jungfrau program mode -int M_nofuncMode(int file_des){ +int M_nofuncMode(int file_des) { ret = FAIL; memset(mess, 0, sizeof(mess)); @@ -320,9 +329,7 @@ int M_nofuncMode(int file_des){ "Restart detector server in normal mode (without any arguments) to continue.\n", getFunctionName((enum detFuncs)fnum)); FILE_LOG(logERROR, (mess)); - - Server_SendResult(file_des, OTHER, 0, NULL, 0); - return ret; + return Server_SendResult(file_des, OTHER, 0, NULL, 0); } @@ -336,7 +343,6 @@ int exec_command(int file_des) { if (receiveData(file_des, cmd, MAX_STR_LENGTH, OTHER) < 0) return printSocketReadError(); - FILE_LOG(logINFO, ("Executing command (%s)\n", cmd)); // set @@ -359,10 +365,7 @@ int exec_command(int file_des) { pclose(sysFile); FILE_LOG(logINFO, ("Result of cmd (%s):\n%s\n", cmd, retval)); } - - Server_SendResult(file_des, OTHER, 0, retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, OTHER, 0, retval, sizeof(retval)); } @@ -372,10 +375,7 @@ int get_detector_type(int file_des) { ret = OK; enum detectorType retval = myDetectorType; FILE_LOG(logDEBUG5,("Returning detector type %d\n", retval)); - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -391,27 +391,24 @@ int set_external_signal_flag(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); + int signalindex = args[0]; + enum externalSignalFlag flag = args[1]; + FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); + #ifndef GOTTHARDD functionNotImplemented(); #else - int signalindex = args[0]; - enum externalSignalFlag flag = args[1]; - - FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); // set if ((flag != GET_EXTERNAL_SIGNAL_FLAG) && (Server_VerifyLock() != FAIL)) { setExtSignal(signalindex, flag); } // get retval = getExtSignal(signalindex); - validate((int)flag, (int)retval, "external signal flag", 1); + validate((int)flag, (int)retval, "set external signal flag", 1); FILE_LOG(logDEBUG5, ("External Signal Flag: %d\n", retval)); } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -425,7 +422,6 @@ int set_external_communication_mode(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting external communication mode to %d\n", arg)); // set @@ -446,12 +442,9 @@ int set_external_communication_mode(int file_des) { } // get retval = getTiming(); - validate((int)arg, (int)retval, "timing mode", 0); + validate((int)arg, (int)retval, "set timing mode", 0); FILE_LOG(logDEBUG5, ("Timing Mode: %d\n",retval)); - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -465,7 +458,6 @@ int get_id(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Getting Id %d\n", arg)); // get @@ -483,10 +475,7 @@ int get_id(int file_des) { modeNotImplemented("ID Index", (int)arg); break; } - - Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -501,19 +490,21 @@ int digital_test(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); + enum digitalTestMode mode = args[0]; +#ifdef GOTTHARDD + int ival = args[1]; + FILE_LOG(logDEBUG5, ("Digital test, mode = %d, ival:%d\n", mode, ival)); +#else + FILE_LOG(logDEBUG5, ("Digital test, mode = %d\n", mode)); +#endif #ifdef EIGERD functionNotImplemented(); #else - enum digitalTestMode mode = args[0]; - int ival = args[1]; - - FILE_LOG(logDEBUG5, ("Digital test, mode = %d\n", mode)); - - // set + // only set if (Server_VerifyLock() != FAIL) { switch (mode) { -#ifdef GOTTHARD: +#ifdef GOTTHARDD case DIGITAL_BIT_TEST: FILE_LOG(logDEBUG5, ("Setting digital test bit: %d\n", ival)); if (ival >= 0) @@ -532,10 +523,7 @@ int digital_test(int file_des) { } } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -551,7 +539,6 @@ int set_dac(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); - enum dacIndex ind = args[0]; int mV = args[1]; int val = args[2]; @@ -561,7 +548,7 @@ int set_dac(int file_des) { #ifdef JUNGFRAUD if ((ind != HV_NEW) && (ind >= NDAC_OLDBOARD)) { //for compatibility with old board modeNotImplemented("Dac Index", (int)ind); - }else + } else serverDacIndex = ind; #else switch (ind) { @@ -634,73 +621,6 @@ int set_dac(int file_des) { case HV_NEW: case IO_DELAY: break; -#elif MYTHEN3D - case M_vIpre: - serverDacIndex = vIpre; - break; - case M_vIbias: - serverDacIndex = vIbias; - break; - case PREAMP: - serverDacIndex = Vrf; - break; - case SHAPER1: - serverDacIndex = VrfSh; - break; - case M_vIinSh: - serverDacIndex = vIinSh; - break; - case M_VdcSh: - serverDacIndex = VdcSh; - break; - case M_Vth2: - serverDacIndex = Vth2; - break; - case M_VPL: - serverDacIndex = VPL; - break; - case THRESHOLD: - serverDacIndex = Vth1; - break; - case M_Vth3: - serverDacIndex = Vth3; - break; - case TRIMBIT_SIZE: - serverDacIndex = Vtrim; - break; - case M_casSh: - serverDacIndex = casSh; - break; - case M_cas: - serverDacIndex = cas; - break; - case M_vIbiasSh: - serverDacIndex = vIbiasSh; - break; - case M_vIcin: - serverDacIndex = vIcin; - break; - case CALIBRATION_PULSE: // !!! pulse height + 1400 DACu - serverDacIndex = VPH; - break; - case M_vIpreOut: - serverDacIndex = vIpreOut; - break; - case V_POWER_A: - serverDacIndex = V_A; - break; - case V_POWER_B: - serverDacIndex = V_B; - break; - case V_POWER_IO: - serverDacIndex = V_IO; - break; - case V_POWER_CHIP: - serverDacIndex = V_CHIP; - break; - case V_LIMIT: - serverDacIndex = V_LIM; - break; #endif default: modeNotImplemented("Dac Index", (int)ind); @@ -734,92 +654,27 @@ int set_dac(int file_des) { #ifdef EIGERD if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { ret = FAIL; - if(retval[0] == -1) + if (retval[0] == -1) sprintf(mess, "Setting high voltage failed. Bad value %d. " "The range is from 0 to 200 V.\n",val); - else if(retval[0] == -2) + else if (retval[0] == -2) strcpy(mess, "Setting high voltage failed. " "Serial/i2c communication failed.\n"); - else if(retval[0] == -3) + else if (retval[0] == -3) strcpy(mess, "Getting high voltage failed. " "Serial/i2c communication failed.\n"); - FILE_LOG(logWARNING,(mess)); + FILE_LOG(logERROR,(mess)); } #endif break; - // power -#ifdef MYTHEN3D - case V_POWER_A: - case V_POWER_B: - case V_POWER_C: - case V_POWER_D: - case V_POWER_IO: - case V_POWER_CHIP: - case V_LIMIT: - FILE_LOG(logDEBUG5, ("Setting a power %d to %d\n",ind, val); - if (!mV) { - ret = FAIL; - strcpy(mess, "Power of index %d should be set in mV instead of DACu", - serverDacIndex); - FILE_LOG(logWARNING,(mess)); - val = -1; - } - - int lim = getVLimit(); - if (ind != V_LIMIT && lim != -1 && val > lim) { - ret = FAIL; - strcpy(mess, "Power of index %d is %d, should be less than %dmV\n", - serverDacIndex, val, lim); - FILE_LOG(logWARNING,(mess)); - val = -1; - } - - retval[1] = retval[0] = setPower(serverDacIndex,val); - validate(val, retval[1], "power", 0); - FILE_LOG(logDEBUG5, ("Power (%d): %d\n", serverDacIndex, retval[1])); - break; -#endif - // dacs default: -#ifdef MYTHEN3D - if( mV && val > MAX_DACVOLTVAL) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV\n", - serverDacIndex, val, MAX_DACVOLTVAL); - FILE_LOG(logWARNING,(mess)); - val = -1; - } - else if( !mV && val >= MAX_DACVAL) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %d (dac value)\n", - serverDacIndex, val, MAX_DACVAL); - FILE_LOG(logWARNING,(mess)); - val = -1; - } - if (val >= 0) { - // conver to mV - int v = val; - if (!mV) - v = dacToVoltage(val); - - //checkvlimit compliant - int lim = getVLimit(); - if (lim!= -1 && v > lim) { - ret = FAIL; - strcpy(mess, "Dac of index %d should be less than %dmV (%d dac value)\n", - serverDacIndex, lim, voltageToDac(lim)); - FILE_LOG(logWARNING,(mess)); - val = -1; - } - } -#endif setDAC(serverDacIndex, val, mV, retval); #ifdef EIGERD - if(val != -1) { + if (val != -1) { //changing dac changes settings to undefined - switch(serverDacIndex){ + switch(serverDacIndex) { case VCMP_LL: case VCMP_LR: case VCMP_RL: @@ -827,7 +682,7 @@ int set_dac(int file_des) { case VRF: case VCP: setSettings(UNDEFINED); - FILE_LOG(logWARNING, ("Settings has been changed " + FILE_LOG(logERROR, ("Settings has been changed " "to undefined (changed specific dacs)\n")); break; default: @@ -838,7 +693,7 @@ int set_dac(int file_des) { //check if (ret == OK) { int temp = 0; - if(mV) + if (mV) temp = retval[1]; else temp = retval[0]; @@ -847,7 +702,7 @@ int set_dac(int file_des) { } else { ret = FAIL; sprintf(mess,"Setting dac %d : wrote %d but read %d\n", serverDacIndex, val, temp); - FILE_LOG(logWARNING,(mess)); + FILE_LOG(logERROR,(mess)); } } FILE_LOG(logDEBUG5, ("Dac (%d): %d dac units and %d mV\n", serverDacIndex, retval[0], retval[1])); @@ -855,10 +710,7 @@ int set_dac(int file_des) { } } } - - Server_SendResult(file_des, INT32, 1, retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, retval, sizeof(retval)); } @@ -874,14 +726,11 @@ int get_adc(int file_des) { if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0) return printSocketReadError(); - -#ifdef MYTHEN3D - functionNotImplemented(); -#else enum ADCINDEX serverAdcIndex = 0; + // get switch (ind) { -#if defined(GOTTHARD) || defined(JUNGFRAUD) +#if defined(GOTTHARDD) || defined(JUNGFRAUD) case TEMPERATURE_FPGA: serverAdcIndex = TEMP_FPGA; break; @@ -925,11 +774,7 @@ int get_adc(int file_des) { retval = getADC(serverAdcIndex); FILE_LOG(logDEBUG5, ("ADC(%d): %d\n", retval)); } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -937,42 +782,29 @@ int get_adc(int file_des) { int write_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - uint32_t retval=-1; - sprintf(mess,"write to register failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1, -1}; + uint32_t retval = -1; - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - uint32_t val=arg[1]; + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + uint32_t addr = args[0]; + uint32_t val = args[1]; + FILE_LOG(logDEBUG5, ("Writing to register 0x%x, data 0x%x\n", addr, val)); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - retval=writeRegister(addr,val); - if (retval!=val) { + // only set + if (Server_VerifyLock() != FAIL) { + retval = writeRegister(addr, val); + // validate + if (retval != val) { ret = FAIL; - sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"Could not write to register 0x%x. Wrote 0x%x but read 0x%x\n", addr, val, retval); + FILE_LOG(logERROR,(mess)); } + FILE_LOG(logDEBUG5, ("Write register (0x%x): 0x%x\n", retval)); } -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -980,148 +812,139 @@ int write_register(int file_des) { int read_register(int file_des) { - int ret=OK,ret1=OK; - int n=0; - uint32_t retval=-1; - sprintf(mess,"read register failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + uint32_t addr = -1; + uint32_t retval = -1; - // receive arguments - int arg=0; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg; + if (receiveData(file_des, &addr, sizeof(addr), INT32) < 0) + return printSocketReadError(); - // execute action -#ifdef VERBOSE - printf("reading register 0x%x\n", addr); -#endif - retval=readRegister(addr); -#ifdef VERBOSE - printf("Returned value 0x%x\n", retval); -#endif + FILE_LOG(logDEBUG5, ("Reading from register 0x%x\n", addr)); - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + // get + retval = readRegister(addr); + FILE_LOG(logDEBUG5, ("Read register (0x%x): 0x%x\n", retval)); - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int set_module(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_module myModule; - int retval=-1; -#ifdef EIGERD - int myIODelay=-1; - int myTau=-1; - int myEV=-1; -#endif - sprintf(mess,"set module failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Module) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - - int *myDac=NULL; - int *myAdc=NULL; + sls_detector_module module; + int *myDac = NULL; + int *myAdc = NULL; int *myChip = NULL; int *myChan = NULL; +#ifdef EIGERD + int ioDelay = -1; + int tau = -1; + int eV = -1; +#endif - myDac=(int*)malloc(getNumberOfDACs()*sizeof(int)); - if (getNumberOfDACs() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCs()*sizeof(int)); + // allocate to receive arguments + // infinite loop to break out when FAIL or a final OK + while(1) { + // allocate dacs + myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); + // error + if (getNumberOfDACs() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess, "Could not allocate dacs\n"); + FILE_LOG(logERROR,(mess)); + break; + } + module.dacs = myDac; + + // allocate adcs + myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); + // error if (getNumberOfADCs() > 0 && myAdc == NULL) { ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"Could not allocate adcs\n"); + FILE_LOG(logERROR,(mess)); + break; } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory -#ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; -#else - myChip=(int*)malloc(getNumberOfChips()*sizeof(int)); - if (getNumberOfChips() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getTotalNumberOfChannels()*sizeof(int)); - if (getTotalNumberOfChannels() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChips(); - myModule.nchan=getTotalNumberOfChannels(); - myModule.ndac=getNumberOfDACs(); - myModule.nadc=getNumberOfADCs(); + module.adcs=myAdc; - - // receive arguments -#ifdef VERBOSE - printf("Setting module\n"); -#endif - n=receiveModuleGeneral(file_des, &myModule, + // no need to allocate chips and chans for jungfrau, too much memory #ifdef JUNGFRAUD - 0 //0 is to receive partially (without trimbits etc.) + module.chipregs = NULL; + module.chanregs = NULL; #else - 1 -#endif - ); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("module number register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n", - myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); + // allocate chips + myChip = (int*)malloc(getNumberOfChips() * sizeof(int)); + if (getNumberOfChips() > 0 && myChip == NULL) { + ret = FAIL; + sprintf(mess,"Could not allocate chips\n"); + FILE_LOG(logERROR,(mess)); + break; + } + module.chipregs = myChip; + + // allocate chans + myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); + if (getTotalNumberOfChannels() > 0 && myChan == NULL) { + ret = FAIL; + sprintf(mess,"Could not allocate chans\n"); + FILE_LOG(logERROR,(mess)); + break; + } + module.chanregs=myChan; #endif + module.nchip = getNumberOfChips(); + module.nchan = getTotalNumberOfChannels(); + module.ndac = getNumberOfDACs(); + module.nadc = getNumberOfADCs(); + + // receive arguments (0 to partially receive module without trimbits + if (receiveModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1) < 0) { + if (myChip != NULL) free(myChip); + if (myChan != NULL) free(myChan); + if (myDac != NULL) free(myDac); + if (myAdc != NULL) free(myAdc); + return printSocketReadError(); + } + FILE_LOG(logDEBUG5, ("module register is %d, nchan %d, nchip %d, " + "ndac %d, nadc %d, gain %f, offset %f\n", + module.reg, module.nchan, module.nchip, + module.ndac, module.nadc, module.gain,module.offset)); + #ifdef EIGERD - n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myTau,sizeof(myTau),INT32); - if (n<0) return FAIL; - n = receiveData(file_des,&myEV,sizeof(myEV),INT32); - if (n<0) return FAIL; -#ifdef VERBOSE - printf("IO Delay:%d\n",myIODelay); - printf("Tau:%d\n",myTau); - printf("eV:%d\n",myEV); -#endif -#endif -#ifndef JUNGFRAUD - } + int args[3] = {-1, -1}; + if (receiveData(file_des, args, sizeof(args), INT32) < 0) { + if (myChip != NULL) free(myChip); + if (myChan != NULL) free(myChan); + if (myDac != NULL) free(myDac); + if (myAdc != NULL) free(myAdc); + return printSocketReadError(); } + ioDelay = args[0]; + tau = args[1]; + eV = args[2]; + FILE_LOG(logDEBUG5, ("ioDelay: %d, tau: d, ev:%d\n", ioDelay, tau, eV)); #endif - } } - //check settings index - if (ret==OK) { -#if defined(JUNGFRAUD) || defined(EIGERD) - switch(myModule.reg){ - case GET_SETTINGS: - case UNINITIALIZED: + + // receive all arguments + if (ret == FAIL) { + int n = 0; + while (n > 0) + n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER); + } + + + // only set + else if (Server_VerifyLock() != FAIL) { + // check index + switch (module.reg) { #ifdef EIGERD case STANDARD: case HIGHGAIN: @@ -1135,73 +958,68 @@ int set_module(int file_des) { case FIXGAIN2: case FORCESWITCHG1: case FORCESWITCHG2: +#elif GOTTHARDD + case DYNAMICGAIN: + case HIGHGAIN: + case LOWGAIN: + case MEDIUMGAIN: + case VERYHIGHGAIN: #endif break; default: - ret = FAIL; - sprintf(mess,"Setting (%d) is not implemented for this detector\n", myModule.reg); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Settings", (int)module.reg); break; } - } -#endif - - // execute action - if (ret==OK) { - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } -#ifdef EIGERD - //set dacs, trimbits and iodelay - ret=setModule(myModule, myIODelay); - //set threshhold - if (myEV >= 0) - setThresholdEnergy(myEV); - else { - //changes settings to undefined (loading a random trim file) - setSettings(UNDEFINED); - cprintf(RED,"Settings has been changed to undefined (random trim file)\n"); - } - //rate correction - //switch off rate correction: no value read from load calib/load settings) - if(myTau == -1){ - if(getRateCorrectionEnable()){ - setRateCorrection(0); - ret = FAIL; - strcat(mess,"Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n"); - cprintf(RED, "Warning: %s", mess); - } - } - //normal tau value (only if enabled) - else{ - setDefaultSettingsTau_in_nsec(myTau); - if (getRateCorrectionEnable()){ - int64_t retvalTau = setRateCorrection(myTau); - if(myTau != retvalTau){ - cprintf(RED,"%s",mess); - ret=FAIL; - } - } - } - retval = getSettings(); + // set +#ifndef EIGERD + retval = setModule(module); + validate(module.reg, retval, "set module (settings)", 0); + // eiger #else - retval=setModule(myModule); - if (retval != myModule.reg) + //set dacs, trimbits and iodelay + ret = setModule(module, ioDelay); + //set threshhold + if (eV >= 0) + setThresholdEnergy(eV); + else { + //changes settings to undefined (loading a random trim file) + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined " + "(random trim file)\n")); + } + //rate correction + //switch off rate correction: no value read from load calib/load settings) + if (tau == -1) { + if (getRateCorrectionEnable()) { + setRateCorrection(0); ret = FAIL; + sprintf(mess,"Cannot set module. Cannot set Rate correction. " + "No default tau provided. Deactivating Rate Correction\n"); + FILE_LOG(logERROR, (mess)); + } + } + //normal tau value (only if enabled) + else { + setDefaultSettingsTau_in_nsec(tau); + if (getRateCorrectionEnable()) { + int64_t retvalTau = setRateCorrection(tau); + if (tau != retvalTau) { + ret = FAIL; + sprintf(mess, "Cannot set module. Could not set rate correction\n"); + FILE_LOG(logERROR, (mess)); + } + } + } + retval = getSettings(); #endif - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); + FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + if (myChip != NULL) free(myChip); + if (myChan != NULL) free(myChan); + if (myDac != NULL) free(myDac); + if (myAdc != NULL) free(myAdc); + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1212,91 +1030,86 @@ int set_module(int file_des) { int get_module(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sls_detector_module myModule; - sprintf(mess,"get module failed\n"); - -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Module) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // execute action - int *myDac=NULL; - int *myAdc=NULL; + ret = OK; + memset(mess, 0, sizeof(mess)); + sls_detector_module module; + int *myDac = NULL; + int *myAdc = NULL; int *myChip = NULL; int *myChan = NULL; - myDac=(int*)malloc(getNumberOfDACs()*sizeof(int)); - if (getNumberOfDACs() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate dacs\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.dacs=myDac; - myAdc=(int*)malloc(getNumberOfADCs()*sizeof(int)); + // allocate to send arguments + // infinite loop to break out when FAIL or a final OK + while(1) { + + // allocate dacs + myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); + // error + if (getNumberOfDACs() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess, "Could not allocate dacs\n"); + FILE_LOG(logERROR,(mess)); + break; + } + module.dacs = myDac; + + // allocate adcs + myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); + // error if (getNumberOfADCs() > 0 && myAdc == NULL) { ret = FAIL; - sprintf(mess,"could not allocate adcs\n"); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"Could not allocate adcs\n"); + FILE_LOG(logERROR,(mess)); + break; } - else { - myModule.adcs=myAdc; - //no chips and chans allocated for jungfrau, too much memory + module.adcs=myAdc; + + // no need to allocate chips and chans for jungfrau, too much memory #ifdef JUNGFRAUD - myModule.chipregs=NULL; - myModule.chanregs=NULL; + module.chipregs = NULL; + module.chanregs = NULL; #else - myChip=(int*)malloc(getNumberOfChips()*sizeof(int)); - if (getNumberOfChips() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chips\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chipregs=myChip; - myChan=(int*)malloc(getTotalNumberOfChannels()*sizeof(int)); - if (getTotalNumberOfChannels() > 0 && myChan == NULL) { - ret = FAIL; - sprintf(mess,"could not allocate chans\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - myModule.chanregs=myChan; -#endif - myModule.nchip=getNumberOfChips(); - myModule.nchan=getTotalNumberOfChannels(); - myModule.ndac=getNumberOfDACs(); - myModule.nadc=getNumberOfADCs(); - getModule(&myModule); -#ifdef VERBOSE - printf("Returning module of register %x\n", myModule.reg); -#endif -#ifndef JUNGFRAUD - } - } -#endif + // allocate chips + myChip = (int*)malloc(getNumberOfChips() * sizeof(int)); + if (getNumberOfChips() > 0 && myChip == NULL) { + ret = FAIL; + sprintf(mess,"Could not allocate chips\n"); + FILE_LOG(logERROR,(mess)); + break; } - } + module.chipregs = myChip; + + // allocate chans + myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); + if (getTotalNumberOfChannels() > 0 && myChan == NULL) { + ret = FAIL; + sprintf(mess,"Could not allocate chans\n"); + FILE_LOG(logERROR,(mess)); + break; + } + module.chanregs=myChan; #endif + module.nchip = getNumberOfChips(); + module.nchan = getTotalNumberOfChannels(); + module.ndac = getNumberOfDACs(); + module.nadc = getNumberOfADCs(); + + // only get + FILE_LOG(logDEBUG5, ("Getting module\n")); + getModule(&module); + FILE_LOG(logDEBUG5, ("Getting module. Settings:%d\n", module.reg)); + } Server_SendResult(file_des, INT32, 1, NULL, 0); // send module, 0 is to receive partially (without trimbits etc) if (ret != FAIL) { - ret = sendModuleGeneral(file_des, &myModule, (myDetectorType == JUNGFRAU) ? 0 : 1); + ret = sendModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1); } - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - if(myDac != NULL) free(myDac); - if(myAdc != NULL) free(myAdc); - + if (myChip != NULL) free(myChip); + if (myChan != NULL) free(myChan); + if (myDac != NULL) free(myDac); + if (myAdc != NULL) free(myAdc); return ret; } @@ -1306,100 +1119,63 @@ int get_module(int file_des) { int set_settings(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int arg=-1; - int retval=-1; - enum detectorSettings isett=-1; - sprintf(mess,"set settings failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum detectorSettings isett = GET_SETTINGS; + enum detectorSettings retval = GET_SETTINGS; -#ifdef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set Settings) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else + if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting settings %d\n", isett)); - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - isett=arg; + //set & get + if ((isett == GET_SETTINGS) || ((isett != GET_SETTINGS) && (Server_VerifyLock() != FAIL))) { - // execute action - if (differentClients && lockStatus && isett!=GET_SETTINGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - - switch(isett) { - case GET_SETTINGS: - case UNINITIALIZED: + // check index + switch(isett) { + case GET_SETTINGS: #ifdef JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: - case FIXGAIN1: - case FIXGAIN2: - case FORCESWITCHG1: - case FORCESWITCHG2: - break; - default: - ret = FAIL; - sprintf(mess,"Setting (%d) is not implemented for this detector.\n" - "Options are dynamicgain, dynamichg0, fixgain1, fixgain2, " - "forceswitchg1 and forceswitchg2.\n", isett); - cprintf(RED, "Warning: %s", mess); - break; -// other detectors -// #elif GOTTHARDD, MOENCHD, PROPIXD -#else - break; - default: - ret = FAIL; -#ifdef EIGERD - sprintf(mess,"Cannot set settings via SET_SETTINGS, use SET_MODULE\n"); -#else - sprintf(mess,"Setting (%d) is not implemented for this detector\n", isett); + case DYNAMICGAIN: + case DYNAMICHG0: + case FIXGAIN1: + case FIXGAIN2: + case FORCESWITCHG1: + case FORCESWITCHG2: +#elif GOTTHARDD + case DYNAMICGAIN: + case HIGHGAIN: + case LOWGAIN: + case MEDIUMGAIN: + case VERYHIGHGAIN: #endif - cprintf(RED, "Warning: %s", mess); - break; -#endif - } - - if (ret != FAIL) { -#ifdef VERBOSE - printf("Changing settings to %d\n", isett); -#endif - retval=setSettings(isett); -#ifdef VERBOSE - printf("Settings changed to %d\n", isett); -#endif - if (retval == isett || isett < 0) { - ret=OK; - } else { - ret = FAIL; - sprintf(mess,"Changing settings : wrote %d but read %d\n", isett, retval); - cprintf(RED, "Warning: %s", mess); + break; + default: + if (myDetectorType == EIGER) { + ret = FAIL; + sprintf(mess, "Cannot set settings via SET_SETTINGS, use SET_MODULE\n"); + FILE_LOG(logERROR,(mess)); + } else + modeNotImplemented("Settings Index", (int)isett); + break; } - } - // set to default dacs, -//# also for #elif GOTTHARDD, MOENCHD, PROPIXD -#ifdef JUNGFRAUD - if (ret == OK && isett >= 0) { - ret = setDefaultDacs(); - if (ret == FAIL) { - strcpy(mess,"Could change settings, but could not set to default dacs\n"); - cprintf(RED, "Warning: %s", mess); + + // if index is okay, set & get + if (ret == OK) { + retval = setSettings(isett); + FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); + validate((int)isett, (int)retval, "set settings", 0); +#if defined(JUNGFRAUD) || defined (GOTTHARDD) + if (ret == OK && isett >= 0) { + ret = setDefaultDacs(); + if (ret == FAIL) { + strcpy(mess,"Could change settings, but could not set to default dacs\n"); + FILE_LOG(logERROR,(mess)); + } } +#endif } -#endif -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + } + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1407,33 +1183,19 @@ int set_settings(int file_des) { int get_threshold_energy(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"get threshold energy failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + FILE_LOG(logDEBUG5, ("Getting Threshold energy\n")); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // execute action -#ifdef VERBOSE - printf("Getting threshold energy \n"); + // only get + retval = getThresholdEnergy(); + FILE_LOG(logDEBUG5, ("Threshold energy: %d eV\n", retval)); #endif - retval=getThresholdEnergy(); -#ifdef VERBOSE - printf("Threshold is %d eV\n", retval); -#endif -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1442,51 +1204,39 @@ int get_threshold_energy(int file_des) { int start_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start acquisition failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logDEBUG5, ("Starting Acquisition\n")); + // only set + if (Server_VerifyLock() != FAIL) { + ret = startStateMachine(); + if (ret == FAIL) { + sprintf(mess, "Could not start acquisition\n"); + FILE_LOG(logERROR,(mess)); + } + FILE_LOG(logDEBUG5, ("Starting Acquisition ret: %d\n", ret)); } - else { - printf("Starting acquisition\n"); - ret=startStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } int stop_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"stop acquisition failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); + // only set + if (Server_VerifyLock() != FAIL) { + ret = stopStateMachine(); + if (ret == FAIL) { + sprintf(mess, "Could not stop acquisition\n"); + FILE_LOG(logERROR,(mess)); + } + FILE_LOG(logDEBUG5, ("Stopping Acquisition ret: %d\n", ret)); } - else { - printf("Stopping acquisition\n"); - ret=stopStateMachine(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); - } - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -1494,36 +1244,24 @@ int stop_acquisition(int file_des) { int start_readout(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"start readout failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + FILE_LOG(logDEBUG5, ("Starting readout\n")); #ifdef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Start Readout) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Starting readout\n"); - ret=startReadOut(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = startReadOut(); + if (ret == FAIL) { + sprintf(mess, "Could not start readout\n"); + FILE_LOG(logERROR,(mess)); + } + FILE_LOG(logDEBUG5, ("Starting readout ret: %d\n", ret)); } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -1532,18 +1270,15 @@ int start_readout(int file_des) { int get_run_status(int file_des) { - int ret=OK,ret1=OK; - enum runStatus retval=ERROR; + ret = OK; + memset(mess, 0, sizeof(mess)); + enum runStatus retval = ERROR; - // execute action -#ifdef VERBOSE - printf("Getting status\n"); -#endif + FILE_LOG(logDEBUG5, ("Getting status\n")); + // only get retval = getRunStatus(); - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + FILE_LOG(logDEBUG5, ("Status: %d\n", retval)); + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1551,55 +1286,44 @@ int get_run_status(int file_des) { int start_and_read_all(int file_des) { - ret = FAIL; -#ifdef VERBOSE - printf("Starting and reading all frames\n"); -#endif + ret = OK; + memset(mess, 0, sizeof(mess)); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logDEBUG5, ("Starting Acquisition and read all frames\n")); + // start state machine + FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); + // only set + if (Server_VerifyLock() != FAIL) { + ret = startStateMachine(); + if (ret == FAIL) { + sprintf(mess, "Could not start acquisition\n"); + FILE_LOG(logERROR,(mess)); + } + FILE_LOG(logDEBUG5, ("Starting Acquisition ret: %d\n", ret)); - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - - return ret; } - startStateMachine(); - read_all(file_des); - return ret; + + // lock or acquisition start error + if (ret == FAIL) + return Server_SendResult(file_des, INT32, 1 , NULL, 0); + + // read all (again validate lock, but should pass and not fail) + return read_all(file_des); } int read_all(int file_des) { - ret = FAIL; - int n=0; - sprintf(mess, "read all frame failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - - return ret; + FILE_LOG(logDEBUG5, ("Reading all frames\n")); + // only set + if (Server_VerifyLock() != FAIL) { + readFrame(&ret, mess); } - - readFrame(&ret, mess); - if(ret == FAIL) - cprintf(RED,"%s\n",mess); - else - cprintf(GREEN,"%s",mess); - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1 , NULL, 0); } @@ -1608,92 +1332,81 @@ int read_all(int file_des) { int set_timer(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum timerIndex ind=0; - int64_t tns=-1; - int64_t retval=-1; - sprintf(mess,"set timer failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t args[2] = {-1,-1}; + int64_t retval = -1; - // receive arguments - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&tns,sizeof(tns),INT64); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && tns!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("setting timer %d to %lld ns\n",ind,tns); -#endif + if (receiveData(file_des, args, sizeof(args), INT64) < 0) + return printSocketReadError(); + enum timerIndex ind = (int)args[0]; + int64_t tns = args[1]; #ifdef EIGERD - int64_t subexptime = 0; + int64_t subexptime = 0; #endif - switch(ind) { + FILE_LOG(logDEBUG5, ("Setting timer index %d to %lld ns\n", ind, tns)); + + // set & get + if ((tns == -1) || ((tns != -1) && (Server_VerifyLock() != FAIL))) { + + // check index + switch (ind) { + case FRAME_NUMBER: + case ACQUISITION_TIME: + case FRAME_PERIOD: + case CYCLES_NUMBER: +#ifdef JUNGFRAUD + case DELAY_AFTER_TRIGGER: +#endif + retval = setTimer(ind, tns); + break; #ifdef JUNGFRAUD case STORAGE_CELL_NUMBER: if (tns > MAX_STORAGE_CELL_VAL) { - ret=FAIL; + ret = FAIL; strcpy(mess,"Max Storage cell number should not exceed 15\n"); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); break; } + retval = setTimer(ind,tns); + break; #endif #ifdef EIGERD case SUBFRAME_ACQUISITION_TIME: - if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ - ret=FAIL; + if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) { + ret = FAIL; strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n"); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); break; } retval = setTimer(ind,tns); break; case SUBFRAME_DEADTIME: subexptime = setTimer(SUBFRAME_ACQUISITION_TIME, -1); - if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ){ - ret=FAIL; + if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) { + ret = FAIL; sprintf(mess,"Sub Frame Period should not exceed 5.368 seconds. " - "So sub frame dead time should not exceed %lfu seconds (subexptime = %lf seconds)\n", - ((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9), (subexptime/1E9)); - cprintf(RED, "Warning: %s", mess); + "So sub frame dead time should not exceed %lfu seconds " + "(subexptime = %lf seconds)\n", + ((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9), + (subexptime/1E9)); + FILE_LOG(logERROR,(mess)); break; } retval = setTimer(ind,tns); break; #endif -#ifdef JUNGFRAUD - case DELAY_AFTER_TRIGGER: -#elif MYTHEN3D - case DELAY_AFTER_TRIGGER: - case GATES_NUMBER: - case PROBES_NUMBER: - case SAMPLES_JCTB: -#endif - case FRAME_NUMBER: - case ACQUISITION_TIME: - case FRAME_PERIOD: - case CYCLES_NUMBER: - retval = setTimer(ind,tns); - break; default: - ret = FAIL; - sprintf(mess,"Timer Index (%d) is not implemented for this detector\n", (int) ind); - cprintf(RED, "%s", mess); + modeNotImplemented("Timer index", (int)ind); break; } - + // validate + validate64(tns, retval, "set timer", 0); } - - Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - - return ret; + if (ret != FAIL) { + FILE_LOG(logDEBUG5, ("Timer index %d: %lld\n", ind, retval)); + } + return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -1702,48 +1415,29 @@ int set_timer(int file_des) { - - int get_time_left(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"get timer left failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum timerIndex ind = -1; + int64_t retval = -1; + if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Getting timer left index %d\n", ind)); - // receive arguments - enum timerIndex ind=0; - n = receiveData(file_des,&ind,sizeof(ind),INT32); - if (n < 0) return printSocketReadError(); - -#ifdef VERBOSE - printf("getting time left on timer %d \n",ind); -#endif - -#ifdef JUNGFRAUD - if (ind == DELAY_AFTER_TRIGGER) { - ret = FAIL; - sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind); - cprintf(RED, "%s", mess); - } else { -#endif - - switch(ind) { + // only get + // check index + switch(ind) { #ifdef EIGERD case MEASURED_PERIOD: case MEASURED_SUBPERIOD: #elif JUNGFRAUD case FRAMES_FROM_START: case FRAMES_FROM_START_PG: -#elif MYTHEN3D - case GATES_NUMBER: - case PROBES_NUMBER: - case SAMPLES_JCTB: -#endif -#ifndef EIGERD -#ifndef JUNGFRAUD +#elif GOTTHARDD case GATES_NUMBER: #endif +#if defined(GOTTHARDD) || defined(JUNGFRAUD) case FRAME_NUMBER: case ACQUISITION_TIME: case FRAME_PERIOD: @@ -1753,25 +1447,22 @@ int get_time_left(int file_des) { case ACTUAL_TIME: case MEASUREMENT_TIME: #endif - retval=getTimeLeft(ind); + retval = getTimeLeft(ind); + FILE_LOG(logDEBUG5, ("Timer left index %d: %lld\n", ind, retval)); break; - default: - ret = FAIL; - sprintf(mess,"Timer Left Index (%d) is not implemented for this detector\n", (int)ind); - cprintf(RED, "%s", mess); - break; - } -#ifdef VERBOSE - printf("Time left on timer %d is %lld\n",ind, retval); -#endif - #ifdef JUNGFRAUD - } // end of if (ind == DELAY_AFTER_TRIGGER) + case DELAY_AFTER_TRIGGER: + ret = FAIL; + sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind); + FILE_LOG(logERROR,(mess)); + break; #endif - Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - - return ret; + default: + modeNotImplemented("Timer left index", (int)ind); + break; + } + return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -1780,76 +1471,63 @@ int get_time_left(int file_des) { int set_dynamic_range(int file_des) { - int retval[2]; - int ret=OK,ret1=OK; - int rateret=OK,rateret1=OK; - int n=0; - int dr=-1; - int retval=-1; - sprintf(mess,"set dynamic range failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int dr = -1; + int retval = -1; - // receive arguments - n = receiveData(file_des,&dr,sizeof(dr),INT32); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, &dr, sizeof(dr), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting dr to %d\n", dr)); - // execute action - if (differentClients && lockStatus && dr>=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - switch(dr){ + // set & get + if ((dr == -1) || ((dr != -1) && (Server_VerifyLock() != FAIL))) { + +#ifdef EIGERD + int old_dr = setDynamicRange(-1); +#endif + // check dr + switch(dr) { case -1: case 16: #ifdef EIGERD case 4: case 8: case 32: #endif - break; + retval = setDynamicRange(dr); + FILE_LOG(logDEBUG5, ("Dynamic range: %d\n", retval)); + validate(dr, retval, "set dynamic range", 0); + if (dr >= 0) + dataBytes=calculateDataBytes(); + break; default: - ret = FAIL; - sprintf(mess,"Dynamic Range (%d) is not implemented for this detector\n", dr); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Dynamic range", dr); + break; } - } - if(ret == OK){ + #ifdef EIGERD - int old_dr = setDynamicRange(-1); - retval=setDynamicRange(dr); - if (dr>=0 && retval!=dr) - ret=FAIL; - //look at rate correction only if dr change worked - if((ret==OK) && (dr!=32) && (dr!=16) && (dr!=-1) && (getRateCorrectionEnable())){ - setRateCorrection(0); - rateret = FAIL; - strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n"); - cprintf(RED,"%s",mess); - }else{ - //setting it if dr changed from 16 to 32 or vice versa with tau value as in rate table - if((dr!=-1) && (old_dr != dr) && getRateCorrectionEnable() && (dr == 16 || dr == 32)){ + if (dr != -1 && getRateCorrectionEnable()) { + // 4 or 8 bit, switch off rate corr (only if dr worked) + if ((dr != 32) && (dr != 16) && (ret == OK)) { + setRateCorrection(0); + ret = FAIL; + strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n"); + FILE_LOG(logERROR,(mess)); + } + + // 16, 32 (diff from old value), set new tau in rate table(-1), if it didnt work, give error + else if ((dr == 16 || dr == 32) && (old_dr != dr)) { setRateCorrection(-1); //tau_ns will not be -1 here - if(!getRateCorrectionEnable()){ + // it didnt work + if (!getRateCorrectionEnable()) { ret = FAIL; strcpy(mess,"Deactivating Rate Correction. Could not set it.\n"); - cprintf(RED,"%s",mess); + FILE_LOG(logERROR,(mess)); } } } - -#else - retval = setDynamicRange(dr); #endif - if (dr>=0) dataBytes=calculateDataBytes(); } - if ((ret == OK) && dr>=0 && retval!=dr) { - ret = FAIL; - cprintf(RED,"%s",mess); - } - - - Server_SendResult(file_des, INT32, 1, retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1858,38 +1536,22 @@ int set_dynamic_range(int file_des) { int set_readout_flags(int file_des) { - int ret=OK,ret1=OK; - int n=0; - enum readOutFlags retval=-1; - sprintf(mess,"set readout flags failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + enum readOutFlags arg = GET_READOUT_FLAGS; + enum readOutFlags retval = GET_READOUT_FLAGS; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting readout flags to %d\n", arg)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Read Out Flags) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); + functionNotImplemented(); #else + // set & get + if ((arg == GET_READOUT_FLAGS) || ((arg != GET_READOUT_FLAGS) && (Server_VerifyLock() != FAIL))) { - // receive arguments - enum readOutFlags arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=GET_READOUT_FLAGS) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("setting readout flags to %d\n",arg); -#endif switch(arg) { - case GET_READOUT_FLAGS: -#ifdef EIGERD case STORE_IN_RAM: case CONTINOUS_RO: case PARALLEL: @@ -1897,26 +1559,17 @@ int set_readout_flags(int file_des) { case SAFE: case SHOW_OVERFLOW: case NOOVERFLOW: -#endif - retval=setReadOutFlags(arg); + retval = setReadOutFlags(arg); + FILE_LOG(logDEBUG5, ("Read out flags: %d\n", retval)); + validate((int)arg, (int)retval, "set readout flag", 0); break; default: - ret = FAIL; - sprintf(mess,"Readout Flag Index (%d) is not implemented for this detector\n", (int)arg); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Read out flag index", (int)arg); break; } - if (ret==OK && ((retval == -1) || ((arg!=-1) && ((retval&arg)!=arg)))){ - ret = FAIL; - sprintf(mess,"Could not change readout flag: should be 0x%x but is 0x%x\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1925,87 +1578,68 @@ int set_readout_flags(int file_des) { int set_roi(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"set nroi failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int narg = -1; + ROI arg[MAX_ROIS]; + int nretval = -1; + ROI* retval = NULL; + + // receive number of ROIs + if (receiveData(file_des, &narg, sizeof(narg), INT32) < 0) + return printSocketReadError(); + // receive ROIs + { + int iloop = 0; + for (iloop = 0; iloop < narg; ++iloop) { + if (receiveData(file_des, &arg[iloop].xmin, sizeof(int), INT32) < 0) + return printSocketReadError(); + if (receiveData(file_des, &arg[iloop].xmax, sizeof(int), INT32) < 0) + return printSocketReadError(); + if (receiveData(file_des, &arg[iloop].ymin, sizeof(int), INT32) < 0) + return printSocketReadError(); + if (receiveData(file_des, &arg[iloop].ymax, sizeof(int), INT32) < 0) + return printSocketReadError(); + } + } + FILE_LOG(logDEBUG5, ("Set ROI (nroi:%d)\n", narg)); + { + int iloop = 0; + for (iloop = 0; iloop < narg; ++iloop) { + FILE_LOG(logDEBUG5, ("%d: %d\t%d\t%d\t%d\n", + arg[iloop].xmin, arg[iloop].xmax, arg[iloop].ymin, arg[iloop].ymax)); + } + } #ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set ROI) is not implemented for this detector\n"); - cprintf(RED, "%s",mess); + functionNotImplemented(); #else - - ROI* retval=0; - int retvalsize=0; - - // receive arguments - int nroi=-1; - ROI arg[MAX_ROIS]; - n = receiveData(file_des,&nroi,sizeof(nroi),INT32); - if (n < 0) return printSocketReadError(); - - { - int i; - if(nroi!=-1){ - for(i=0;i=0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("setting speed variable %d to %d\n",arg,val); -#endif - switch (arg) { + // set & get + if ((val == -1) || ((val != -1) && (Server_VerifyLock() != FAIL))) { + // check index + switch(ind) { #ifdef JUNGFRAUD case ADC_PHASE: retval = adcPhase(val); - if ((val != 100000) && (retval!=val) && (val>=0)) { - ret=FAIL; - sprintf(mess,"could not change set adc phase: should be %d but is %d \n", val, retval); - cprintf(RED, "Warning: %s", mess); - } - break; -#endif -#ifdef EIGERD - case CLOCK_DIVIDER: -#elif JUNGFRAUD - case CLOCK_DIVIDER: -#elif MYTHEN3D - case DBIT_CLOCK: - case DBIT_PHASE: -#endif - retval=setSpeed(arg, val); - if ((retval!=val) && (val>=0)) { - ret=FAIL; - sprintf(mess,"could not change speed variable %d: should be %d but is %d \n",arg, val, retval); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logDEBUG5, ("ADc Phase: %d\n", retval)); + if (val != 100000) { + validate(val, retval, "set adc phase ", 0); } break; +#endif + case CLOCK_DIVIDER: + retval = setSpeed(val); + FILE_LOG(logDEBUG5, ("Clock: %d\n", retval)); + validate(val, retval, "set clock ", 0); + break; default: - ret = FAIL; - sprintf(mess,"Speed Index (%d) is not implemented for this detector\n",(int) arg); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Speed index", (int)ind); break; } } - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -2083,9 +1691,9 @@ int set_speed(int file_des) { int exit_server(int file_des) { - ret = OK; cprintf(BG_RED,"Closing Server\n"); - Server_SendResult(file_des, INT32, 1, NULL, 0); + ret = OK; + Server_SendResult(file_des, INT32, 0, NULL, 0); return GOODBYE; } @@ -2093,41 +1701,34 @@ int exit_server(int file_des) { int lock_server(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int lock=0; - sprintf(mess,"lock server failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int lock = 0; - // receive arguments - n = receiveData(file_des,&lock,sizeof(lock),INT32); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, &lock, sizeof(lock), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Locking Server to %d\n", lock)); - // execute action - if (lock>=0) { - if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) { - lockStatus=lock; - strcpy(lastClientIP,thisClientIP); + // set + if (lock >= 0) { + if (!lockStatus || // if it was unlocked, anyone can lock + (!strcmp(lastClientIP, thisClientIP)) || // if it was locked, need same ip + (!strcmp(lastClientIP,"none"))) { // if it was locked, must be by "none" + lockStatus = lock; + strcpy(lastClientIP, thisClientIP); } else { - ret = FAIL; - sprintf(mess,"Server already locked by %s\n", lastClientIP); - cprintf(RED, "Warning: %s", mess); + Server_LockedError(); } } - Server_SendResult(file_des, INT32, 1, &lockStatus, sizeof(lockStatus)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &lockStatus, sizeof(lockStatus)); } - int get_last_client_ip(int file_des) { - int ret=OK,ret1=OK; - - Server_SendResult(file_des, INT32, 1, lastClientIP, sizeof(lastClientIP)); - - return ret; + ret = OK; + return Server_SendResult(file_des, INT32, 1, lastClientIP, sizeof(lastClientIP)); } @@ -2136,42 +1737,34 @@ int get_last_client_ip(int file_des) { int set_port(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int n=0; - int p_number=-1; - sprintf(mess,"set port failed\n"); + int p_number = -1; - // receive argumets - n = receiveData(file_des,&p_number,sizeof(p_number),INT32); - if (n < 0) return printSocketReadError(); + if (receiveData(file_des, &p_number, sizeof(p_number), INT32) < 0) + return printSocketReadError(); - // execute action - int sd=-1; - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { + // set only + int sd = -1; + if ((Server_VerifyLock() != FAIL)) { + // port number too low if (p_number < 1024) { ret = FAIL; sprintf(mess,"%s port Number (%d) too low\n", (isControlServer ? "control":"stop"), p_number); - FILE_LOG(logWARNING, (mess)); + FILE_LOG(logERROR,(mess)); } else { FILE_LOG(logINFO, ("Setting %s port to %d\n", (isControlServer ? "control":"stop"), p_number)); - sd=bindSocket(p_number); + sd = bindSocket(p_number); } } Server_SendResult(file_des, INT32, 1, &p_number, sizeof(p_number)); - - if (ret!=FAIL) { + // delete old socket + if (ret != FAIL) { closeConnection(file_des); exitServer(sockfd); - sockfd=sd; + sockfd = sd; } - return ret; } @@ -2180,6 +1773,7 @@ int set_port(int file_des) { int update_client(int file_des) { ret = OK; + memset(mess, 0, sizeof(mess)); Server_SendResult(file_des, INT32, 0, NULL, 0); return send_update(file_des); } @@ -2188,72 +1782,71 @@ int update_client(int file_des) { int send_update(int file_des) { - int n=0; // if (n<0) should fail to stop talking to a closed client socket - int nm=0; + int n = 0; // if (n<0) should fail to stop talking to a closed client socket + int nm = 0; int64_t retval = 0; - enum detectorSettings t; n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); if (n < 0) return printSocketReadError(); - nm=setDynamicRange(GET_FLAG); + nm = setDynamicRange(GET_FLAG); n = sendData(file_des,&nm,sizeof(nm),INT32); if (n < 0) return printSocketReadError(); - dataBytes=calculateDataBytes(); + dataBytes = calculateDataBytes(); n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); if (n < 0) return printSocketReadError(); - t=setSettings(GET_SETTINGS); - n = sendData(file_des,&t,sizeof(t),INT32); + nm = (int)setSettings(GET_SETTINGS); + n = sendData(file_des,&nm,sizeof(nm),INT32); if (n < 0) return printSocketReadError(); #ifdef EIGERD - nm=getThresholdEnergy(GET_FLAG); + nm = getThresholdEnergy(GET_FLAG); n = sendData(file_des,&nm,sizeof(nm),INT32); if (n < 0) return printSocketReadError(); #endif - retval=setTimer(FRAME_NUMBER,GET_FLAG); + retval = setTimer(FRAME_NUMBER,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - retval=setTimer(ACQUISITION_TIME,GET_FLAG); + retval = setTimer(ACQUISITION_TIME,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #ifdef EIGERD - retval=setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); + retval = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - retval=setTimer(SUBFRAME_DEADTIME,GET_FLAG); + retval = setTimer(SUBFRAME_DEADTIME,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif - retval=setTimer(FRAME_PERIOD,GET_FLAG); + retval = setTimer(FRAME_PERIOD,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #ifndef EIGERD - retval=setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); + retval = setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif #if !defined(EIGERD) && !defined(JUNGFRAUD) - retval=setTimer(GATES_NUMBER,GET_FLAG); + retval = setTimer(GATES_NUMBER,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); #endif - retval=setTimer(CYCLES_NUMBER,GET_FLAG); + retval = setTimer(CYCLES_NUMBER,GET_FLAG); n = sendData(file_des,&retval,sizeof(int64_t),INT64); if (n < 0) return printSocketReadError(); - if (lockStatus==0) { + if (lockStatus == 0) { strcpy(lastClientIP,thisClientIP); } @@ -2266,141 +1859,145 @@ int send_update(int file_des) { int configure_mac(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-100; - sprintf(mess,"configure mac failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + char args[9][50]; + memset(args, 0, sizeof(args)); + char retvals[3][50]; + memset(retvals, 0, sizeof(retvals)); + int iretval = -1; - // receive arguments - char arg[6][50]; - memset(arg, 0, sizeof(arg)); - n = receiveData(file_des,arg,sizeof(arg),OTHER); -#if defined(JUNGFRAUD) || defined(EIGERD) - int pos[3]={0,0,0}; - n = receiveData(file_des,pos,sizeof(pos),INT32); + if (receiveData(file_des, args, sizeof(args), OTHER) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("\n Configuring UDP Destination\n")); +#ifdef GOTTHARDD + FILE_LOG(logDEBUG5, ("Digital Test Bit %d\t", digitalTestBit); #endif - if (n < 0) return printSocketReadError(); - - uint32_t ipad; - uint64_t imacadd; - uint64_t idetectormacadd; - uint32_t udpport; - uint32_t udpport2; - uint32_t detipad; - sscanf(arg[0], "%x", &ipad); + uint32_t dstIp = 0; + sscanf(args[0], "%x", &dstIp); + FILE_LOG(logDEBUG5, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n", + (dstIp >> 24) & 0xff, (dstIp >> 16) & 0xff, (dstIp >> 8) & 0xff, (dstIp) & 0xff, + dstIp)); + uint64_t dstMac = 0; #ifdef VIRTUAL - sscanf(arg[1], "%lx", &imacadd); + sscanf(args[1], "%lx", &dstMac); #else - sscanf(arg[1], "%llx", &imacadd); + sscanf(args[1], "%llx", &dstMac); #endif - sscanf(arg[2], "%x", &udpport); -#ifdef VIRTUAL - sscanf(arg[3], "%lx", &idetectormacadd); -#else - sscanf(arg[3], "%llx", &idetectormacadd); -#endif - sscanf(arg[4], "%x", &detipad); - sscanf(arg[5], "%x", &udpport2); - - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - int i; - //#ifdef GOTTHARD - //printf("\ndigital_test_bit in server %d\t",digitalTestBit); - //#endif - printf("\nipadd %x\t",ipad); - printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad); - printf("macad:%llx\n",imacadd); - for (i=0;i<6;i++) - printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF))); - printf("udp port:0x%x\n",udpport); - printf("detector macad:%llx\n",idetectormacadd); - for (i=0;i<6;i++) - printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF))); - printf("detipad %x\n",detipad); - printf("udp port2:0x%x\n",udpport2); - printf("\n"); - printf("Configuring MAC at port %x\n", udpport); - -#if defined(JUNGFRAUD) || defined(EIGERD) - printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]); -#endif -#endif - if(getRunStatus() == RUNNING){ - ret = stopStateMachine(); + FILE_LOG(logDEBUG5, ("Dst Mac Addr: (0x) ")); + { + int iloop = 5; + for (iloop = 5; iloop >= 0; --iloop) { + FILE_LOG(logDEBUG5, ("%x", (unsigned int)(((dstMac >> (8 * iloop)) & 0xFF)))); + if (iloop > 0) { + FILE_LOG(logDEBUG5, (":")); + } } - if(ret==FAIL) { - sprintf(mess,"Could not stop detector acquisition to configure mac\n"); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef EIGERD - // change mac to hardware mac, (for 1 gbe) change ip to hardware ip - if (idetectormacadd != getDetectorMAC()){ - printf("*************************************************\n"); - printf("WARNING: actual detector mac address %llx does not match " - "the one from client %llx\n", - (long long unsigned int)getDetectorMAC(), - (long long unsigned int)idetectormacadd); - idetectormacadd = getDetectorMAC(); - printf("WARNING: Matched detectormac to the hardware mac now\n"); - printf("*************************************************\n"); - } - - // always remember the ip sent from the client (could be for 10g(if not dhcp)) - if (detipad != getDetectorIP()) - dhcpipad = detipad; - - //only for 1Gbe - if(!enableTenGigabitEthernet(-1)){ - printf("*************************************************\n"); - printf("WARNING: Using DHCP IP for Configuring MAC\n"); - printf("*************************************************\n"); - detipad = getDetectorIP(); - } else - detipad = dhcpipad; + } + FILE_LOG(logDEBUG5, (" = %llx\n", dstMac)); + uint32_t dstPort = 0; + sscanf(args[2], "%x", &dstPort); + FILE_LOG(logDEBUG5, ("Dst Port: %x\n", dstPort)); + uint32_t dstPort2 = 0; + sscanf(args[5], "%x", &dstPort2); + FILE_LOG(logDEBUG5, ("Dst Port2: %x\n", dstPort2)); + uint64_t srcMac = 0; +#ifdef VIRTUAL + sscanf(args[3], "%lx", &srcMac); +#else + sscanf(args[3], "%llx", &srcMac); #endif - retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); //digitalTestBit); - if(retval==-1) { - ret = FAIL; - sprintf(mess,"Configure Mac failed\n"); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Configure MAC successful\n"); + FILE_LOG(logDEBUG5, ("Src Mac Addr: (0x) ")); + { + int iloop = 5; + for (iloop = 5; iloop >= 0; --iloop) { + FILE_LOG(logDEBUG5, ("%x", (unsigned int)(((srcMac >> (8 * iloop)) & 0xFF)))); + if (iloop > 0) { + FILE_LOG(logDEBUG5, (":")); + } + } + } + FILE_LOG(logDEBUG5, (" = %llx\n", srcMac)); + uint32_t srcIp = 0; + sscanf(args[4], "%x", &srcIp); + FILE_LOG(logDEBUG5, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n", + (srcIp >> 24) & 0xff, (srcIp >> 16) & 0xff, (srcIp >> 8) & 0xff, (srcIp) & 0xff, + srcIp)); #if defined(JUNGFRAUD) || defined(EIGERD) - ret = setDetectorPosition(pos); - if (ret == FAIL) { - sprintf(mess,"could not set detector position\n"); - cprintf(RED, "Warning: %s", mess); - } -#endif - } -#ifdef VERBOSE - printf("Configured MAC with retval %d\n", retval); + int pos[3] = {0, 0, 0}; + sscanf(args[6], "%x", &pos[0]); + sscanf(args[7], "%x", &pos[1]); + sscanf(args[8], "%x", &pos[2]); + FILE_LOG(logDEBUG5, ("Position: [%d, %d, %d]\n", pos[0], pos[1], pos[2])); #endif + + // set only + if ((Server_VerifyLock() != FAIL)) { + + // stop detector if it was running + if (getRunStatus() != IDLE) { + ret = FAIL; + sprintf(mess, "Cannot configure mac when detector is not idle\n"); + FILE_LOG(logERROR,(mess)); + } + + else { +#ifdef EIGERD + // change mac to hardware mac + if (srcMac != getDetectorMAC()) { + FILE_LOG(logERROR, ("actual detector mac address %llx does not match " + "the one from client %llx\n", + (long long unsigned int)getDetectorMAC(), + (long long unsigned int)srcMac)); + srcMac = getDetectorMAC(); + FILE_LOG(logERROR,("matched detectormac to the hardware mac now\n")); } - } + // always remember the ip sent from the client (could be for 10g(if not dhcp)) + if (srcIp != getDetectorIP()) + dhcpipad = srcIp; - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + //only for 1Gbe, change ip to hardware ip + if (!enableTenGigabitEthernet(-1)) { + FILE_LOG(logERROR, ("using DHCP IP for Configuring MAC\n")); + srcIp = getDetectorIP(); + } + // 10 gbe (use ip given from client) + else + srcIp = dhcpipad; -#ifdef EIGERD - if (ret != FAIL) { - char arg[2][50]; - memset(arg, 0, sizeof(arg)); - sprintf(arg[0],"%llx",(long long unsigned int)idetectormacadd); - sprintf(arg[1],"%x",detipad); - n += sendData(file_des,arg,sizeof(arg),OTHER); - } #endif +#ifdef GOTTHARDD + iretval = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2, digitalTestBit); + FILE_LOG(logDEBUG5, ("Configure mac retval: %d\n", iretval)); + FILE_LOG(logINFO, ("Configure MAC successful: %d\n", iretval)); +#else + iretval = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2); + FILE_LOG(logDEBUG5, ("Configure mac retval: %d\n", iretval)); - return ret; + if (iretval == -1) { + ret = FAIL; + sprintf(mess,"Configure Mac failed\n"); + FILE_LOG(logERROR,(mess)); + } else { + FILE_LOG(logINFO, ("Configure MAC successful\n")); + ret = setDetectorPosition(pos); + if (ret == FAIL) { + sprintf(mess, "Could not set detector position\n"); + FILE_LOG(logERROR,(mess)); + } + } +#endif + // set retval vals + if (ret != FAIL) { + sprintf(retvals[0],"%x", iretval); + sprintf(retvals[1],"%llx", (long long unsigned int)srcMac); + sprintf(retvals[2],"%x", srcIp); + } + } + } + + return Server_SendResult(file_des, OTHER, 1, retvals, sizeof(retvals)); } @@ -2408,63 +2005,49 @@ int configure_mac(int file_des) { int load_image(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Loading image failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1, -1}; + int retval = -1; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + enum imageType index = args[0]; + char* ImageVals = NULL; + if (args[1] > 0) { + ImageVals = (char*)malloc(args[1]); + if (receiveData(file_des, ImageVals, args[1], OTHER) < 0) { + free(ImageVals); + return printSocketReadError(); + } + } + FILE_LOG(logDEBUG5, ("Loading %s image (ind:%d)\n", (index == DARK_IMAGE) ? "dark" : + ((index == GAIN_IMAGE) ? "gain" : "unknown"), index)); #ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Load Image) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - // receive arguments - enum imageType index=0; - char ImageVals[dataBytes] = {0}; - n = receiveData(file_des,&index,sizeof(index),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,ImageVals,dataBytes,OTHER); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { + // set only + if (Server_VerifyLock() != FAIL) { switch (index) { case DARK_IMAGE : -#ifdef VERBOSE - printf("Loading Dark image\n"); -#endif case GAIN_IMAGE : -#ifdef VERBOSE - printf("Loading Gain image\n"); -#endif - retval=loadImage(index,ImageVals); - if (retval==-1) { + retval = loadImage(index, ImageVals); + FILE_LOG(logDEBUG5, ("Loading image retval: %d\n", retval)); + if (retval == -1) { ret = FAIL; - cprintf(RED, "Warning: %s", mess); + sprintf(mess, "Could not load image\n"); + FILE_LOG(logERROR,(mess)); } break; default: - ret = FAIL; - sprintf(mess,"Load Image Index (%d) is not implemented for this detector\n", (int)index); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Image index", (int)index); break; } } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -2473,47 +2056,30 @@ int load_image(int file_des) { int read_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - char CounterVals[dataBytes]; - memset(CounterVals, 0, dataBytes); - sprintf(mess,"Read counter block failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int startACQ = -1; + char retval[dataBytes]; + memset(retval, 0, dataBytes); + + if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Read counter block with start acq bit: %d\n", startACQ)); #ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Read Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=readCounterBlock(startACQ,CounterVals); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); -#ifdef VERBOSE - int i; - for(i=0;i<6;i++) - printf("%d:%d\t",i,CounterVals[i]); -#endif + // only set + if (Server_VerifyLock() != FAIL) { + ret = readCounterBlock(startACQ, retval); + if (ret == FAIL) { + strcpy(mess, "Could not read counter block\n"); + FILE_LOG(logERROR,(mess)); + } } #endif - - Server_SendResult(file_des, OTHER, 1, CounterVals, dataBytes); - - return ret; + return Server_SendResult(file_des, OTHER, 1, retval, dataBytes); } @@ -2521,84 +2087,48 @@ int read_counter_block(int file_des) { int reset_counter_block(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset counter block failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int startACQ = -1; + char retval[dataBytes]; + memset(retval, 0, dataBytes); + + if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Reset counter block with start acq bit: %d\n", startACQ)); #ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Reset Counter Block) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - // receive arguments - int startACQ=-1; - n = receiveData(file_des,&startACQ,sizeof(startACQ),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=resetCounterBlock(startACQ); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = resetCounterBlock(startACQ, retval); + if (ret == FAIL) { + strcpy(mess, "Could not reset counter block\n"); + FILE_LOG(logERROR, (mess)); + } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } -int calibrate_pedestal(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"calibrate pedestal failed\n"); +int calibrate_pedestal(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int frames = -1; + int retval = -1; + if (receiveData(file_des, &frames, sizeof(frames), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Calibrate pedestal, frames: %d\n", frames)); -#ifndef GOTTHARDD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Calibrate Pedestal) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int frames=-1; - n = receiveData(file_des,&frames,sizeof(frames),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=calibratePedestal(frames); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); - } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + functionNotImplemented(); + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -2609,432 +2139,177 @@ int calibrate_pedestal(int file_des){ int enable_ten_giga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Enabling/disabling 10GbE failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Enable/ Disable 10GbE : %d\n", arg)); - // execute action #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Enable 10 GbE) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("Enabling/Disabling 10Gbe :%d \n",arg); -#endif - retval=enableTenGigabitEthernet(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = enableTenGigabitEthernet(arg); + FILE_LOG(logDEBUG5, ("10GbE: %d\n", retval)); + validate(arg, retval, "enable/disable 10GbE", 0); } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } -int set_all_trimbits(int file_des){ - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"setting all trimbits failed\n"); +int set_all_trimbits(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Set all trmbits to %d\n", arg)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Set All Trimbits) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + // set + if (arg >= 0 && Server_VerifyLock() != FAIL) { + ret = setAllTrimbits(arg); + //changes settings to undefined + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined (change all trimbits)\n")); } - else { -#ifdef VERBOSE - printf("setting all trimbits to %d\n",arg); + // get + retval = getAllTrimbits(); + FILE_LOG(logDEBUG5, ("All trimbits: %d\n", retval)); + validate(arg, retval, "set all trimbits", 0); #endif - if(arg < -1){ - ret = FAIL; - strcpy(mess,"Cant set trimbits to this value\n"); - cprintf(RED, "Warning: %s", mess); - }else { - if(arg >= 0){ - ret = setAllTrimbits(arg); - //changes settings to undefined - setSettings(UNDEFINED); - cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n"); - } - retval = getAllTrimbits(); - if (arg!=-1 && arg!=retval) { - ret=FAIL; - sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } - } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } + + int set_ctb_pattern(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Could not set pattern\n"); - -#ifndef MYTHEN3D - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - - ret = FAIL; - sprintf(mess,"Function (Set CTB Pattern) is not implemented for this detector\n"); - cprintf(RED, "Error: %s", mess); - - Server_SendResult(file_des, INT32, 0, NULL, 0);// make sure client doesnt expect a retval if not jctb - - return ret; - -#else - - int retval=-1; - int mode = -1; - int addr = -1, level = -1, nl = -1, start = -1, stop = -1; - uint64_t word = -1,retval64 = -1, t = -1; - - n = receiveDataOnly(file_des, &mode, sizeof(mode)); - printf("pattern mode is %d\n",mode); - - switch (mode) { - - case 0: //sets word - n = receiveDataOnly(file_des,&addr,sizeof(addr)); - n = receiveDataOnly(file_des,&word,sizeof(word)); - ret=OK; - - printf("pattern addr is %d %llx\n",addr, word); - switch (addr) { - case -1: - retval64=writePatternIOControl(word); - break; - case -2: - retval64=writePatternClkControl(word); - break; - default: - retval64=writePatternWord(addr,word); - }; - - - //write word; - //@param addr address of the word, -1 is I/O control register, -2 is clk control register - //@param word 64bit word to be written, -1 gets - - Server_SendResult(file_des, INT32, 0, &retval64, sizeof(retval64)); - - break; - - case 1: //pattern loop - // printf("loop\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&start,sizeof(start)); - n = receiveDataOnly(file_des,&stop,sizeof(stop)); - n = receiveDataOnly(file_des,&nl,sizeof(nl)); - - - - // printf("level %d start %x stop %x nl %d\n",level, start, stop, nl); - /** Sets the pattern or loop limits in the CTB - @param level -1 complete pattern, 0,1,2, loop level - @param start start address if >=0 - @param stop stop address if >=0 - @param n number of loops (if level >=0) - @returns OK/FAIL - */ - ret=setPatternLoop(level, &start, &stop, &nl); - - Server_SendResult(file_des, INT32, 0, retval, sizeof(retval)); -/* n += sendDataOnly(file_des,&start,sizeof(start)); - n += sendDataOnly(file_des,&stop,sizeof(stop)); - n += sendDataOnly(file_des,&nl,sizeof(nl)); - */ - break; - - - - case 2: //wait address - printf("wait\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&addr,sizeof(addr)); - - - - /** Sets the wait address in the CTB - @param level 0,1,2, wait level - @param addr wait address, -1 gets - @returns actual value - */ - printf("wait addr %d %x\n",level, addr); - retval=setPatternWaitAddress(level,addr); - printf("ret: wait addr %d %x\n",level, retval); - ret=OK; - - Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval)); - - break; - - - case 3: //wait time - printf("wait time\n"); - n = receiveDataOnly(file_des,&level,sizeof(level)); - n = receiveDataOnly(file_des,&t,sizeof(t)); - - - /** Sets the wait time in the CTB - @param level 0,1,2, wait level - @param t wait time, -1 gets - @returns actual value - */ - - ret=OK; - - retval64=setPatternWaitTime(level,t); - - Server_SendResult(file_des, INT32, 0, &retval64, sizeof(retval64)); - break; - - - - case 4: - n = receiveDataOnly(file_des,pat,sizeof(pat)); - for (addr=0; addr<1024; addr++) - writePatternWord(addr,word); - ret=OK; - retval=0; - - Server_SendResult(file_des, INT32, 0, &retval64, sizeof(retval64)); - - break; - - - - default: - ret=FAIL; - printf(mess); - sprintf(mess,"%s - wrong mode %d\n",mess, mode); - - Server_SendResult(file_des, INT32, 0, NULL, 0); - } - - - return ret; -#endif + ret = OK; + memset(mess, 0, sizeof(mess)); + functionNotImplemented(); + return Server_SendResult(file_des, INT32, 1, NULL, 0); } + int write_adc_register(int file_des) { - int ret=OK, ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"write to adc register failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1, -1}; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + int addr = args[0]; + int val = args[1]; + FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Write ADC Register) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg[2]={-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - int addr=arg[0]; - int val=arg[1]; - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); + // only set + if (Server_VerifyLock() != FAIL) + setAdc(addr, val); #endif - setAdc(addr,val); -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } int set_counter_bit(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set counter bit failed \n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Set counter bit with value: %d\n", arg)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Set Counter Bit) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + // set + if (arg >= 0 && Server_VerifyLock() != FAIL) { + setCounterBit(arg); } - else { -#ifdef VERBOSE - printf("Getting/Setting/Resetting counter bit :%d \n",arg); + // get + retval = setCounterBit(-1); + FILE_LOG(logDEBUG5, ("Set counter bit retval: %d\n", retval)); + validate(arg, retval, "set counter bit", 0); #endif - retval=setCounterBit(arg); - if((arg != -1) && (retval != arg)) { - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } - } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } + int pulse_pixel(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[3] = {-1,-1,-1}; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Pulse pixel, n: %d, x: %d, y: %d\n", args[0], args[1], args[2])); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=pulsePixel(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = pulsePixel(args[0], args[1], args[2]); + if (ret == FAIL) { + strcpy(mess, "Could not pulse pixel\n"); + FILE_LOG(logERROR,(mess)); + } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } int pulse_pixel_and_move(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse pixel and move failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[3] = {-1,-1,-1}; + + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Pulse pixel and move, n: %d, x: %d, y: %d\n", + args[0], args[1], args[2])); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Pixel and Move) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg[3]={-1,-1,-1}; - n = receiveData(file_des,arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=pulsePixelNMove(arg[0],arg[1],arg[2]); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = pulsePixelNMove(args[0], args[1], args[2]); + if (ret == FAIL) { + strcpy(mess, "Could not pulse pixel and move\n"); + FILE_LOG(logERROR,(mess)); + } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -3043,40 +2318,27 @@ int pulse_pixel_and_move(int file_des) { int pulse_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"pulse chip failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Pulse chip: %d\n", arg)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - strcpy(mess,"Function (Pulse Chip) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg = -1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - ret=pulseChip(arg); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = pulseChip(arg); + if (ret == FAIL) { + strcpy(mess, "Could not pulse chip\n"); + FILE_LOG(logERROR,(mess)); + } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -3084,61 +2346,44 @@ int pulse_chip(int file_des) { int set_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Set rate correct failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t tau_ns = -1; + + if (receiveData(file_des, &tau_ns, sizeof(tau_ns), INT64) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Set rate correct with tau %lld\n", (long long int)tau_ns)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else + // only set + if (Server_VerifyLock() != FAIL) { - // receive arguments - int64_t tau_ns=-1; - n = receiveData(file_des,&tau_ns,sizeof(tau_ns),INT64); - if (n < 0) return printSocketReadError(); + int dr = setDynamicRange(-1); - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Setting rate correction to %lld ns\n",(long long int)tau_ns); - //set rate - //wrong bit mode - if((setDynamicRange(-1)!=32) && (setDynamicRange(-1)!=16) && (tau_ns!=0)){ - ret=FAIL; + // switching on in wrong bit mode + if ((tau_ns != 0) && (dr != 32) && (dr != 16)) { + ret = FAIL; strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n"); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); } - //16 or 32 bit mode - else{ - if(tau_ns < 0) + + // switching on in right mode + else { + if (tau_ns < 0) tau_ns = getDefaultSettingsTau_in_nsec(); - else if(tau_ns > 0){ + else if (tau_ns > 0) { //changing tau to a user defined value changes settings to undefined setSettings(UNDEFINED); - cprintf(RED,"Settings has been changed to undefined (tau changed)\n"); + FILE_LOG(logERROR, ("Settings has been changed to undefined (tau changed)\n")); } - int64_t retval = setRateCorrection(tau_ns); - if(tau_ns != retval){ - ret=FAIL; - cprintf(RED, "Warning: %s", mess); - } + validate64(tau_ns, retval, "set rate correction", 0); } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -3146,30 +2391,18 @@ int set_rate_correct(int file_des) { int get_rate_correct(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int64_t retval=-1; - sprintf(mess,"Get Rate correct failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t retval = -1; + FILE_LOG(logDEBUG5, ("Getting rate correction\n")); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Get Rate Correction) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - - // execute action retval = getCurrentTau(); - printf("Getting rate correction %lld\n",(long long int)retval); - + FILE_LOG(logDEBUG5, ("Tau: %lld\n", (long long int)retval)); #endif - - Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -3177,84 +2410,60 @@ int get_rate_correct(int file_des) { int set_network_parameter(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"set network parameter failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int args[2] = {-1,-1}; + int retval = -1; -#if !defined(EIGERD) && !defined(JUNGFRAUD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function(Set Network Parmaeter) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + if (receiveData(file_des, args, sizeof(args), INT32) < 0) + return printSocketReadError(); + enum networkParameter mode = args[0]; + int value = args[1]; + enum NETWORKINDEX serverIndex = 0; + FILE_LOG(logDEBUG5, ("Set network parameter index %d to %d\n", mode, value)); + +#ifdef GOTTHARDD + functionNotImplemented(); #else - - enum NETWORKINDEX index; - - // receive arguments - enum networkParameter mode=0; - int value=-1; - n = receiveData(file_des,&mode,sizeof(mode),INT32); - if (n < 0) return printSocketReadError(); - - n = receiveData(file_des,&value,sizeof(value),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && value >= 0) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("setting network parameter mode %d to %d\n",(int)mode,value); -#endif + // set & get + if ((value == -1) || ((value != -1) && (Server_VerifyLock() != FAIL))) { + // check index switch (mode) { - #ifdef EIGERD case FLOW_CONTROL_10G: - index = FLOWCTRL_10G; + serverIndex = FLOWCTRL_10G; break; case DETECTOR_TXN_DELAY_LEFT: - index = TXN_LEFT; + serverIndex = TXN_LEFT; break; case DETECTOR_TXN_DELAY_RIGHT: - index = TXN_RIGHT; + serverIndex = TXN_RIGHT; break; #endif case DETECTOR_TXN_DELAY_FRAME: - index = TXN_FRAME; + serverIndex = TXN_FRAME; #ifdef JUNGFRAUD if (value > MAX_TIMESLOT_VAL) { - ret=FAIL; - sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", value, MAX_TIMESLOT_VAL); - cprintf(RED, "Warning: %s", mess); + ret = FAIL; + sprintf(mess,"Transmission delay %d should be in range: 0 - %d\n", + value, MAX_TIMESLOT_VAL); + FILE_LOG(logERROR, (mess)); } #endif break; default: - ret=FAIL; - sprintf(mess,"Network Parameter Index (%d) is not implemented for this detector\n",(int) mode); - cprintf(RED, "Warning: %s", mess); + modeNotImplemented("Image index", (int)serverIndex); break; } - if (ret==OK) { - retval=setNetworkParameter(index, value); - if ((retval!=value) && (value>=0)) { - ret=FAIL; - sprintf(mess,"could not change network parameter mode %d: should be %d but is %d \n",index, value, retval); - cprintf(RED, "Warning: %s", mess); - } + // valid index + if (ret == OK) { + retval = setNetworkParameter(serverIndex, value); + FILE_LOG(logDEBUG5, ("Network Parameter index %d: %d\n", serverIndex, retval)); + validate(value, retval, "set network parameter", 0); } } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -3263,131 +2472,115 @@ int set_network_parameter(int file_des) { int program_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"program FPGA failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + FILE_LOG(logDEBUG5, ("Programming FPGA\n")); #ifndef JUNGFRAUD //to receive any arguments + int n = 0; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Program FPGA) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - if (!debugflag) { - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"FPGA cannot be programmed in this mode. " - "Restart on-board detector server with -update for update mode to continue.\n"); - cprintf(RED, "Warning: %s", mess); - } + // only set + if (Server_VerifyLock() != FAIL) { - else { - printf("Programming FPGA..."); - size_t filesize = 0; - size_t totalsize = 0; - size_t unitprogramsize = 0; - char* fpgasrc = NULL; - FILE* fp = NULL; - - // receive arguments - filesize - n = receiveData(file_des,&filesize,sizeof(filesize),INT32); - if (n < 0) return printSocketReadError(); - totalsize = filesize; -#ifdef VERY_VERBOSE - printf("\n\n Total size is:%d\n",totalsize); -#endif - - // execute action - if (differentClients && lockStatus) { + // not in programming mode + if (debugflag != PROGRAMMING_MODE) { + //to receive any arguments + int n = 1; + while (n > 0) + n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER); ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); + sprintf(mess,"FPGA cannot be programmed in this mode. " + "Restart on-board detector server with -update for programming mode.\n"); + FILE_LOG(logERROR,(mess)); } + else { - //opening file pointer to flash and telling FPGA to not touch flash - if(startWritingFPGAprogram(&fp) != OK) { - ret=FAIL; + FILE_LOG(logINFOBLUE, ("Programming FPGA...\n")); + + size_t filesize = 0; + size_t totalsize = 0; + size_t unitprogramsize = 0; + char* fpgasrc = NULL; + FILE* fp = NULL; + + // filesize + if (receiveData(file_des,&filesize,sizeof(filesize),INT32) < 0) + return printSocketReadError(); + totalsize = filesize; + FILE_LOG(logDEBUG5, ("Total program size is: %d\n", totalsize); + + // opening file pointer to flash and telling FPGA to not touch flash + if (startWritingFPGAprogram(&fp) != OK) { + ret = FAIL; sprintf(mess,"Could not write to flash. Error at startup.\n"); - cprintf(RED,"%s",mess); + FILE_LOG(logERROR,(mess)); } //---------------- first ret ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); - } - //---------------- first ret ---------------- + Server_SendResult(file_des, INT32, 0, NULL, 0); - if(ret!=FAIL) { + if (ret != FAIL) { //erasing flash eraseFlash(); fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); } //writing to flash part by part - while(ret != FAIL && filesize){ + while(ret != FAIL && filesize) { unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb - if(unitprogramsize > filesize) //less than 2mb + if (unitprogramsize > filesize) //less than 2mb unitprogramsize = filesize; -#ifdef VERY_VERBOSE - printf("unit size to receive is:%d\n",unitprogramsize); - printf("filesize:%d currentpointer:%d\n",filesize,currentPointer); -#endif + FILE_LOG(logDEBUG5, ("unit size to receive is:%d\n" + "filesize:%d currentpointer:%d\n", + unitprogramsize, filesize, currentPointer)); - //receive - n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER); - if (n < 0) return printSocketReadError(); - if(!(unitprogramsize - filesize)){ - fpgasrc[unitprogramsize]='\0'; - filesize-=unitprogramsize; + //receive part of program + if (receiveData(file_des,fpgasrc,unitprogramsize,OTHER) < 0) + return printSocketReadError(); + + if (!(unitprogramsize - filesize)) { + fpgasrc[unitprogramsize] = '\0'; + filesize -= unitprogramsize; unitprogramsize++; - }else - filesize-=unitprogramsize; + } else + filesize -= unitprogramsize; - ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp); + // write part to flash + ret = writeFPGAProgram(fpgasrc, unitprogramsize, fp); //---------------- middle rets ---------------- - // ret could be swapped during sendData - ret1 = ret; - // send ok / fail - n = sendData(file_des,&ret1,sizeof(ret),INT32); - // send return argument - if (ret==FAIL) { - n += sendData(file_des,mess,sizeof(mess),OTHER); + Server_SendResult(file_des, INT32, 0, NULL, 0); + + + + if (ret == FAIL) { cprintf(RED,"Failure: Breaking out of program receiving\n"); - } - //---------------- middle rets ---------------- - - if(ret != FAIL){ + } else { //print progress - printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) ); + FILE_LOG(logINFO, ("Writing to Flash:%d%%\r", + (int) (((double)(totalsize-filesize)/totalsize)*100) )); fflush(stdout); } } - printf("\n"); + FILE_LOG(logINFO("\nDone copying program\n")); - //closing file pointer to flash and informing FPGA + // closing file pointer to flash and informing FPGA stopWritingFPGAprogram(fp); //free resources - if(fpgasrc != NULL) + if (fpgasrc != NULL) free(fpgasrc); - if(fp!=NULL) + if (fp != NULL) fclose(fp); -#ifdef VERY_VERBOSE - printf("Done with program receiving command\n"); -#endif + + FILE_LOG(logDEBUG5, ("Done with program receiving command\n")); if (isControlServer) { basictests(debugflag); @@ -3396,10 +2589,7 @@ int program_fpga(int file_des) { } } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -3407,177 +2597,106 @@ int program_fpga(int file_des) { int reset_fpga(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"Reset FPGA unsuccessful\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + FILE_LOG(logDEBUG5, ("Reset FPGA\n")); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Reset FPGA) is not implemented for this detector\n"); cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - if (isControlServer) { - basictests(debugflag); // mapping of control server at lease -#ifdef JUNGFRAUD - if (debugflag != PROGRAMMING_MODE) -#endif - initControlServer(); - } - else initStopServer(); //remapping of stop server + // only set + if (Server_VerifyLock() != FAIL) { + if (isControlServer) { + basictests(debugflag); // mapping of control server at least + if (debugflag != PROGRAMMING_MODE) + initControlServer(); + } + else initStopServer(); //remapping of stop server ret = FORCE_UPDATE; } #endif - - Server_SendResult(file_des, INT32, 1, NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1, NULL, 0); } int power_chip(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"power chip failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Powering chip to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Power Chip) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("Power chip to %d\n", arg); -#endif - retval=powerChip(arg); - -#ifdef VERBOSE - printf("Chip powered: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - if(setTemperatureEvent(-1) == 1) - sprintf(mess,"Powering chip failed due to over-temperature event. Clear event & power chip again. Wrote %d, read %d \n", arg, retval); - else - sprintf(mess,"Powering chip failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = powerChip(arg); + FILE_LOG(logDEBUG5, ("Power chip: %d\n", retval)); + validate(arg, retval, "power on/off chip", 0); + // narrow down error when powering on + if (ret == FAIL && arg > 0) { + if (setTemperatureEvent(-1) == 1) + sprintf(mess,"Powering chip failed due to over-temperature event. " + "Clear event & power chip again. Set %d, read %d \n", arg, retval); + FILE_LOG(logERROR, (mess)); } } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int set_activate(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"Activate/Deactivate failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting activate mode to %d\n", arg)); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Set Activate) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("Setting activate mode of detector to %d\n",arg); -#endif - retval=activate(arg); - if ((retval!=arg) && (arg!=-1)) { - ret=FAIL; - sprintf(mess,"Could not set activate mode to %d, is set to %d\n",arg, retval); - cprintf(RED, "Warning: %s", mess); - } + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = activate(arg); + FILE_LOG(logDEBUG5, ("Activate: %d\n", retval)); + validate(arg, retval, "set activate", 0); } #endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int prepare_acquisition(int file_des) { - int ret=OK,ret1=OK; - int n=0; - strcpy(mess,"prepare acquisition failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); -#if !defined(GOTTHARDD) && !defined(EIGERD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Prepare Acquisition) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logDEBUG5, ("Preparing Acquisition\n")); +#ifndef EIGERD + functionNotImplemented(); #else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { + // only set + if (Server_VerifyLock() != FAIL) { ret = prepareAcquisition(); - if (ret == FAIL) - cprintf(RED, "Warning: %s", mess); + if (ret == FAIL) { + strcpy(mess, "Could not prepare acquisition\n"); + FILE_LOG(logERROR, (mess)); + } } #endif - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1 , NULL, 0); } @@ -3585,130 +2704,86 @@ int prepare_acquisition(int file_des) { int threshold_temp(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get threshold temperature\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting threshold temperature to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - int arg=-1; - int val=-1; - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - val=arg; - if (val > MAX_THRESHOLD_TEMP_VAL) { - ret=FAIL; - sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL); - cprintf(RED, "Warning: %s", mess); - } - - - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Threshold Temperature to %d\n", val); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if (arg > MAX_THRESHOLD_TEMP_VAL) { + ret = FAIL; + sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", + arg, MAX_THRESHOLD_TEMP_VAL); + FILE_LOG(logERROR, (mess)); + } + // valid temp + else { + retval = setThresholdTemperature(arg); + FILE_LOG(logDEBUG5, ("Threshold temperature: %d\n", retval)); + validate(arg, retval, "set threshold temperature", 0); + } + } #endif - retval=setThresholdTemperature(val); - } -#ifdef VERBOSE - printf("Threshold temperature is %d\n", retval); -#endif -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int temp_control(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get temperature control\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting temperature control to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Temperature control) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - int arg=-1; - int val=-1; - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - val=arg; - - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Temperature control to %d\n", val); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = setTemperatureControl(arg); + FILE_LOG(logDEBUG5, ("Temperature control: %d\n", retval)); + validate(arg, retval, "set temperature control", 0); + } #endif - retval=setTemperatureControl(val); - } -#ifdef VERBOSE - printf("Temperature control is %d\n", retval); -#endif -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int temp_event(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"could not set/get temperature event\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting temperature event to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - int arg=-1; - int val=-1; - - // receive arguments - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - val=arg; - - if (ret==OK) { -#ifdef VERBOSE - printf("Setting Temperature Event to %d\n", val); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = setTemperatureEvent(arg); + FILE_LOG(logDEBUG5, ("Temperature event: %d\n", retval)); + validate(arg, retval, "set temperature event", 0); + } #endif - retval=setTemperatureEvent(val); - } -#ifdef VERBOSE - printf("Temperature Event is %d\n", retval); -#endif - -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -3716,60 +2791,26 @@ int temp_event(int file_des) { int auto_comp_disable(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"auto comp disable failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting Auto comp disable to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Auto Comp Disable) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Auto Comp Disable) is not yet implemented for this detector\n"); - cprintf(RED, "%s", mess); - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { -#ifdef VERBOSE - printf("Auto Comp Disable to %d\n", arg); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + retval = autoCompDisable(arg); + FILE_LOG(logDEBUG5, ("Auto comp disable: %d\n", retval)); + validate(arg, retval, "set auto comp disable", 0); + } #endif - retval=autoCompDisable(arg); - -#ifdef VERBOSE - printf("Auto comp disable set to: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - sprintf(mess,"Atuo Comp Disable failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -3777,87 +2818,48 @@ int auto_comp_disable(int file_des) { int storage_cell_start(int file_des) { - int ret=OK,ret1=OK; - int n=0; - int retval=-1; - sprintf(mess,"storage cell start failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + int retval = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + FILE_LOG(logDEBUG5, ("Setting Storage cell start to %d\n", arg)); #ifndef JUNGFRAUD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Storage cell start) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - // receive arguments - int arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT32); - if (n < 0) return printSocketReadError(); - - // execute action - if (differentClients && lockStatus && arg!=-1) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else if (arg > MAX_STORAGE_CELL_VAL) { - ret=FAIL; - strcpy(mess,"Max Storage cell number should not exceed 15\n"); - cprintf(RED, "Warning: %s", mess); - } else { -#ifdef VERBOSE - printf("Storage cell start to %d\n", arg); + // set & get + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if (arg > MAX_STORAGE_CELL_VAL) { + ret = FAIL; + strcpy(mess,"Max Storage cell number should not exceed 15\n"); + FILE_LOG(logERROR, (mess)); + } else { + retval = selectStoragecellStart(arg); + FILE_LOG(logDEBUG5, ("Storage cell start: %d\n", retval)); + validate(arg, retval, "set storage cell start", 0); + } #endif - retval=selectStoragecellStart(arg); - -#ifdef VERBOSE - printf("Storage cell start: %d\n",retval); -#endif - if (retval==arg || arg<0) { - ret=OK; - } else { - sprintf(mess,"Storage cell start select failed, wrote %d but read %d\n", arg, retval); - cprintf(RED, "Warning: %s", mess); - } - } -#endif - - Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); - - return ret; + return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } int check_version(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"check version failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t arg = -1; -#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(GOTTHARD) - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret=FAIL; - sprintf(mess,"Function (Check Version Compatibility) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - - // receive arguments - int64_t arg=-1; - n = receiveData(file_des,&arg,sizeof(arg),INT64); - if (n < 0) return printSocketReadError(); - - // execute action + if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0) + return printSocketReadError(); // check software- firmware compatibility and basic tests if (isControlServer) { -#ifdef VERBOSE - printf("Checking software-firmware compatibility and basic test result\n"); -#endif + FILE_LOG(logDEBUG5, ("Checking software-firmware compatibility and basic test result\n")); + // check if firmware check is done if (!isFirmwareCheckDone()) { usleep(3 * 1000 * 1000); @@ -3865,7 +2867,7 @@ int check_version(int file_des) { ret = FAIL; strcpy(mess,"Firmware Software Compatibility Check (Server Initialization) " "still not done done in server. Unexpected.\n"); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); } } // check firmware check result @@ -3874,15 +2876,14 @@ int check_version(int file_des) { if (getFirmwareCheckResult(&firmware_message) == FAIL) { ret = FAIL; strcpy(mess, firmware_message); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); } } } if (ret == OK) { -#ifdef VERBOSE - printf("Checking versioning compatibility with value %d\n",arg); -#endif + FILE_LOG(logDEBUG5, ("Checking versioning compatibility with value %d\n",arg)); + int64_t client_requiredVersion = arg; int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION); int64_t det_version = getDetectorId(DETECTOR_SOFTWARE_VERSION); @@ -3894,7 +2895,7 @@ int check_version(int file_des) { "Detector's SW API Version: (0x%llx). " "Incompatible, update client!\n", (long long int)client_requiredVersion, (long long int)det_apiVersion); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); } // old software @@ -3904,48 +2905,33 @@ int check_version(int file_des) { "Client's detector SW API Version: (0x%llx). " "Incompatible, update detector software!\n", (long long int)det_version, (long long int)client_requiredVersion); - cprintf(RED, "Warning: %s", mess); + FILE_LOG(logERROR,(mess)); } } -#endif - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - return ret; + return Server_SendResult(file_des, INT32, 1 , NULL, 0); } int software_trigger(int file_des) { - int ret=OK,ret1=OK; - int n=0; - sprintf(mess,"software trigger failed\n"); + ret = OK; + memset(mess, 0, sizeof(mess)); + FILE_LOG(logDEBUG5, ("Software Trigger\n")); #ifndef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Software Trigger) is not implemented for this detector\n"); - cprintf(RED, "%s", mess); + functionNotImplemented(); #else - - // execute action - if (differentClients && lockStatus) { - ret = FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - cprintf(RED, "Warning: %s", mess); - } - else { - printf("Software Trigger\n"); - ret=softwareTrigger(); - if (ret==FAIL) - cprintf(RED, "Warning: %s", mess); + // only set + if (Server_VerifyLock() != FAIL) { + ret = softwareTrigger(); + if (ret == FAIL) { + sprintf(mess, "Could not send software trigger\n"); + FILE_LOG(logERROR,(mess)); + } + FILE_LOG(logDEBUG5, ("Software trigger ret: %d\n", ret)); } #endif - - Server_SendResult(file_des, INT32, 1 , NULL, 0); - - return ret; + return Server_SendResult(file_des, INT32, 1 , NULL, 0); } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h index 0ac890f86..72829ec43 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h @@ -1,6 +1,4 @@ -#ifndef SERVER_FUNCS_H -#define SERVER_FUNCS_H - +#pragma once #include "sls_detector_defs.h" #include @@ -14,6 +12,7 @@ void function_table(); void functionNotImplemented(); void modeNotImplemented(char* modename, int mode); void validate(int arg, int retval, char* modename, int hex); +void validate64(int64_t arg, int64_t retval, char* modename, int hex); int M_nofunc(int); int M_nofuncMode(int); @@ -79,4 +78,3 @@ int storage_cell_start(int); int check_version(int); int software_trigger(int); -#endif diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index d0a446944..bf92c04a2 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -2867,27 +2867,21 @@ int slsDetector::setDynamicRange(int n) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&n,sizeof(n)); - //rate correction is switched off if not 32 bit mode - if(thisDetector->myDetectorType == EIGER){ - controlSocket->ReceiveDataOnly(&rateret,sizeof(rateret)); - if (rateret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - if(strstr(mess,"Rate Correction")!=NULL){ - if(strstr(mess,"32")!=NULL) - setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); - else - setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); - } - } - } controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + if(strstr(mess,"Rate Correction")!=NULL){ + // rate correction is switched off if not 32 bit mode + if(strstr(mess,"32")!=NULL) + setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); + else + setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); + } + else ret = OK; } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + disconnectControl(); if (ret==FORCE_UPDATE) updateDetector(); @@ -4268,13 +4262,24 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { #ifdef VERBOSE std::cout << "Sending ROI of size " << arg << " to detector" << std::endl; #endif - controlSocket->SendDataOnly(roiLimits,arg*sizeof(ROI)); + for(int i = 0; i < n; ++i){ + controlSocket->SendDataOnly(&roiLimits[i].xmin, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].xmax, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].ymin, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].ymax, sizeof(int)); + } + //controlSocket->SendDataOnly(roiLimits,arg*sizeof(ROI)); } controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL){ controlSocket->ReceiveDataOnly(&retvalsize,sizeof(retvalsize)); - nrec = controlSocket->ReceiveDataOnly(retval,retvalsize*sizeof(ROI)); + nrec = 0; + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmax, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); + //nrec = controlSocket->ReceiveDataOnly(retval,retvalsize*sizeof(ROI)); if(nrec!=(retvalsize*(int)sizeof(ROI))){ ret=FAIL; std::cout << " wrong size received: received " << nrec << diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index d7af5d8d2..d1ad6bace 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -290,9 +290,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){ strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); FILE_LOG(logERROR) << mess; - interface->Server_SendResult(false, ret, NULL, 0, mess); - - return ret; + return interface->Server_SendResult(false, ret, NULL, 0, mess); } @@ -329,21 +327,17 @@ int slsReceiverTCPIPInterface::exec_command() { } } - interface->Server_SendResult(false, ret, retval, MAX_STR_LENGTH, mess); - - return ret; + return interface->Server_SendResult(false, ret, retval, MAX_STR_LENGTH, mess); } int slsReceiverTCPIPInterface::exit_server() { - cprintf(RED,"Closing receiver server\n"); + cprintf(RED,"Closing server\n"); ret = OK; interface->Server_SendResult(false, ret, NULL, 0); - - ret = GOODBYE; - return ret; + return GOODBYE; } @@ -361,7 +355,7 @@ int slsReceiverTCPIPInterface::lock_receiver() { if (lock >= 0) { if (!lockStatus || // if it was unlocked, anyone can lock (!strcmp(mySock->lastClientIP,mySock->thisClientIP)) || // if it was locked, need same ip - (!strcmp(mySock->lastClientIP,"none"))) //if it was locked, must be by "none" + (!strcmp(mySock->lastClientIP,"none"))) // if it was locked, must be by "none" { lockStatus = lock; strcpy(mySock->lastClientIP,mySock->thisClientIP); @@ -369,18 +363,14 @@ int slsReceiverTCPIPInterface::lock_receiver() { interface->Server_LockedError(ret, mess); } - interface->Server_SendResult(true, ret, &lockStatus,sizeof(lockStatus), mess); - - return ret; + return interface->Server_SendResult(true, ret, &lockStatus,sizeof(lockStatus), mess); } int slsReceiverTCPIPInterface::get_last_client_ip() { ret = OK; - interface->Server_SendResult(true, ret,mySock->lastClientIP, sizeof(mySock->lastClientIP)); - - return ret; + return interface->Server_SendResult(true, ret,mySock->lastClientIP, sizeof(mySock->lastClientIP)); } @@ -560,9 +550,7 @@ int slsReceiverTCPIPInterface::get_id(){ ret = OK; int64_t retval = getReceiverVersion(); - interface->Server_SendResult(true, ret, &retval, sizeof(retval)); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval)); } @@ -622,9 +610,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){ //get retval = myDetectorType; - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -679,7 +665,13 @@ int slsReceiverTCPIPInterface::set_roi() { int iloop = 0; for (iloop = 0; iloop < nroi; iloop++) { ROI temp; - if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 ) + if ( mySock->ReceiveDataOnly(&temp.xmin,sizeof(int)) < 0 ) + return interface->Server_SocketCrash(); + if ( mySock->ReceiveDataOnly(&temp.xmax,sizeof(int)) < 0 ) + return interface->Server_SocketCrash(); + if ( mySock->ReceiveDataOnly(&temp.ymin,sizeof(int)) < 0 ) + return interface->Server_SocketCrash(); + if ( mySock->ReceiveDataOnly(&temp.ymax,sizeof(int)) < 0 ) return interface->Server_SocketCrash(); roiLimits.push_back(temp); } @@ -766,9 +758,7 @@ int slsReceiverTCPIPInterface::setup_udp(){ } } - interface->Server_SendResult(true, ret, retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, retval, sizeof(retval), mess); } @@ -865,9 +855,7 @@ int slsReceiverTCPIPInterface::set_timer() { FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -927,9 +915,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { FILE_LOG(logDEBUG1) << "dynamic range: " << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -966,9 +952,7 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ } } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -984,9 +968,7 @@ int slsReceiverTCPIPInterface::get_status(){ if (ret == OK) retval = receiver->getStatus(); - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1017,11 +999,7 @@ int slsReceiverTCPIPInterface::start_receiver(){ } } - interface->Server_SendResult(true, ret, NULL, 0, mess); - - return ret; - - + return interface->Server_SendResult(true, ret, NULL, 0, mess); } @@ -1050,9 +1028,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){ } } - interface->Server_SendResult(true, ret, NULL, 0, mess); - - return ret; + return interface->Server_SendResult(true, ret, NULL, 0, mess); } @@ -1162,9 +1138,7 @@ int slsReceiverTCPIPInterface::set_file_index() { FILE_LOG(logDEBUG1) << "file index:" << retval; } - interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1182,9 +1156,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){ if (ret == OK) retval=receiver->getAcquisitionIndex(); - interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1199,9 +1171,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){ if (ret == OK) retval=receiver->getTotalFramesCaught(); - interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1221,9 +1191,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){ } } - interface->Server_SendResult(true, ret, NULL, 0, mess); - - return ret; + return interface->Server_SendResult(true, ret, NULL, 0, mess); } @@ -1256,9 +1224,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){ FILE_LOG(logDEBUG1) << "file write enable:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1293,9 +1259,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() { FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1331,9 +1295,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() { FILE_LOG(logDEBUG1) << "10Gbe:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1371,9 +1333,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { FILE_LOG(logDEBUG1) << "fifo depth:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1409,9 +1369,7 @@ int slsReceiverTCPIPInterface::set_activate() { FILE_LOG(logDEBUG1) << "Activate: " << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1444,9 +1402,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){ FILE_LOG(logDEBUG1) << "data streaming enable:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1479,9 +1435,7 @@ int slsReceiverTCPIPInterface::set_streaming_timer(){ FILE_LOG(logDEBUG1) << "Streaming timer:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1517,9 +1471,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(){ FILE_LOG(logDEBUG1) << "Flipped Data:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1554,9 +1506,7 @@ int slsReceiverTCPIPInterface::set_file_format() { FILE_LOG(logDEBUG1) << "File Format: " << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1589,9 +1539,7 @@ int slsReceiverTCPIPInterface::set_detector_posid() { FILE_LOG(logDEBUG1) << "Position Id:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1628,9 +1576,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1659,9 +1605,7 @@ int slsReceiverTCPIPInterface::set_streaming_port() { FILE_LOG(logDEBUG1) << "streaming port:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1727,9 +1671,7 @@ int slsReceiverTCPIPInterface::set_silent_mode() { FILE_LOG(logDEBUG1) << "silent mode:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1768,9 +1710,7 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() { FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1801,9 +1741,7 @@ int slsReceiverTCPIPInterface::restream_stop(){ } } - interface->Server_SendResult(true, ret, NULL, 0, mess); - - return ret; + return interface->Server_SendResult(true, ret, NULL, 0, mess); } @@ -1871,9 +1809,7 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1888,9 +1824,7 @@ int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){ if (ret == OK) retval = receiver->getActualUDPSocketBufferSize(); - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1924,9 +1858,7 @@ int slsReceiverTCPIPInterface::set_frames_per_file() { FILE_LOG(logDEBUG1) << "frames per file:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1971,9 +1903,7 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { } else FILE_LOG(logINFO) << "Compatibility with Client: Successful"; - interface->Server_SendResult(true, ret, NULL, 0, mess); - - return ret; + return interface->Server_SendResult(true, ret, NULL, 0, mess); } @@ -2007,9 +1937,7 @@ int slsReceiverTCPIPInterface::set_discard_policy() { FILE_LOG(logDEBUG1) << "frame discard policy:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -2045,9 +1973,7 @@ int slsReceiverTCPIPInterface::set_padding_enable() { FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -2084,7 +2010,5 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; } - interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); - - return ret; + return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } diff --git a/slsSupportLib/include/ClientInterface.cpp b/slsSupportLib/include/ClientInterface.cpp index 78bd1bbbd..4d387da76 100644 --- a/slsSupportLib/include/ClientInterface.cpp +++ b/slsSupportLib/include/ClientInterface.cpp @@ -53,7 +53,7 @@ int ClientInterface::Client_Send(int fnum, } -void ClientInterface::Server_SendResult(bool update, int ret, +int ClientInterface::Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess) { // update if different clients @@ -72,6 +72,8 @@ void ClientInterface::Server_SendResult(bool update, int ret, } // send return value mySocket->SendDataOnly(retval, retvalSize); + + return ret; } diff --git a/slsSupportLib/include/ClientInterface.h b/slsSupportLib/include/ClientInterface.h index 536c8c984..049de62aa 100644 --- a/slsSupportLib/include/ClientInterface.h +++ b/slsSupportLib/include/ClientInterface.h @@ -65,8 +65,9 @@ public: * @param retval pointer to result * @param retvalSize size of result * @param mess message + * @returns success of operation */ - void Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess = 0); + int Server_SendResult(bool update, int ret, void* retval, int retvalSize, char* mess = 0); /** only Receiver * Server receives arguments and checks if base object is null (if checkbase is true) diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 8649fd686..3d5bc07e4 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -82,9 +82,7 @@ public: EIGER, /**< eiger */ GOTTHARD, /**< gotthard */ JUNGFRAU, /**< jungfrau */ - JUNGFRAUCTB, /**< jungfrauCTBversion */ - MYTHEN3, /**< mythen 3 */ - MOENCH /**< moench */ + JUNGFRAUCTB /**< jungfrauCTBversion */ }; From cf87b6ca83418744d2e7d1a13309e7e5a201fe22 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 25 Oct 2018 16:24:05 +0200 Subject: [PATCH 4/7] still updating slsdetector.cpp --- .../slsDetectorFunctionList.c | 8 +- .../slsDetectorFunctionList.c | 7 +- .../slsDetectorServer_funcs.c | 8 +- .../slsDetector/slsDetector.cpp | 4125 +++++++---------- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- slsReceiverSoftware/include/GeneralData.h | 58 - .../src/slsReceiverTCPIPInterface.cpp | 26 +- slsSupportLib/include/sls_detector_defs.h | 1 - 8 files changed, 1803 insertions(+), 2432 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 0de061582..d1cfcf860 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1686,9 +1686,7 @@ void readFrame(int *ret, char *mess) { //FILE_LOG(logERROR ,"Waiting for finished flag\n")); usleep(5000); } - *ret = (int)FINISHED; - strcpy(mess,"acquisition successfully finished\n")); - FILE_LOG(logGREEN, "%s", mess)); + FILE_LOG(logGREEN, ("acquisition successfully finished\n")); return; #else @@ -1714,9 +1712,7 @@ void readFrame(int *ret, char *mess) { FILE_LOG(logINFO, ("*****Done Waiting...\n")); - *ret = (int)FINISHED; - strcpy(mess,"acquisition successfully finished\n"); - FILE_LOG(logGREEN, (mess)); + FILE_LOG(logGREEN, ("acquisition successfully finished\n")); #endif } diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 81a7e4912..29093a549 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1599,8 +1599,6 @@ void readFrame(int *ret, char *mess){ //cprintf(RED,"Waiting for finished flag\n"); usleep(5000); } - *ret = (int)FINISHED; - strcpy(mess,"acquisition successfully finished\n"); return; #endif // wait for status to be done @@ -1615,9 +1613,8 @@ void readFrame(int *ret, char *mess){ sprintf(mess,"no data and run stopped: %lld frames left\n",(long long int)retval); cprintf(RED,"%s\n",mess); } else { - *ret = (int)FINISHED; - sprintf(mess,"acquisition successfully finished\n"); - cprintf(GREEN, "%s",mess); + *ret = (int)OK; + cprintf(GREEN, "acquisition successfully finished\n"); } } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index c202dceac..ab06fb6e4 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -373,6 +373,7 @@ int exec_command(int file_des) { int get_detector_type(int file_des) { ret = OK; + memset(mess, 0, sizeof(mess)); enum detectorType retval = myDetectorType; FILE_LOG(logDEBUG5,("Returning detector type %d\n", retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -784,7 +785,7 @@ int get_adc(int file_des) { int write_register(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int args[2] = {-1, -1}; + uint32_t args[2] = {-1, -1}; uint32_t retval = -1; if (receiveData(file_des, args, sizeof(args), INT32) < 0) @@ -1693,6 +1694,7 @@ int set_speed(int file_des) { int exit_server(int file_des) { cprintf(BG_RED,"Closing Server\n"); ret = OK; + memset(mess, 0, sizeof(mess)); Server_SendResult(file_des, INT32, 0, NULL, 0); return GOODBYE; } @@ -1728,6 +1730,7 @@ int lock_server(int file_des) { int get_last_client_ip(int file_des) { ret = OK; + memset(mess, 0, sizeof(mess)); return Server_SendResult(file_des, INT32, 1, lastClientIP, sizeof(lastClientIP)); } @@ -1738,6 +1741,7 @@ int set_port(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int p_number = -1; + char oldLastClientIP[INET_ADDRSTRLEN] = {0}; if (receiveData(file_des, &p_number, sizeof(p_number), INT32) < 0) return printSocketReadError(); @@ -1754,6 +1758,7 @@ int set_port(int file_des) { } else { FILE_LOG(logINFO, ("Setting %s port to %d\n", (isControlServer ? "control":"stop"), p_number)); + strcpy(oldLastClientIP, lastClientIP); sd = bindSocket(p_number); } } @@ -1764,6 +1769,7 @@ int set_port(int file_des) { closeConnection(file_des); exitServer(sockfd); sockfd = sd; + strcpy(lastClientIP, oldLastClientIP); } return ret; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index bf92c04a2..a8092b5f6 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -46,8 +46,8 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) // ensure shared memory was not created before auto shm = SharedMemory(multiId, id); if (shm.IsExisting()) { - cprintf(YELLOW BOLD,"Warning: Weird, this shared memory should have been " - "deleted before! %s. Freeing it again.\n", shm.GetName().c_str()); + FILE_LOG(logWARNING, ("Weird, this shared memory should have been " + "deleted before! %s. Freeing it again.\n", shm.GetName().c_str())); freeSharedMemory(multiId, id); } @@ -90,17 +90,17 @@ slsDetector::~slsDetector() { sharedMemory->UnmapSharedMemory(thisDetector); delete sharedMemory; } - if(thisDetectorControl) + if (thisDetectorControl) delete thisDetectorControl; - if(thisDetectorStop) + if (thisDetectorStop) delete thisDetectorStop; - if(thisReceiver) + if (thisReceiver) delete thisReceiver; - if(controlSocket) + if (controlSocket) delete controlSocket; - if(stopSocket) + if (stopSocket) delete stopSocket; - if(dataSocket) + if (dataSocket) delete dataSocket; /* detectorModules, dacs..ffoerrors are offsets from the @@ -113,8 +113,6 @@ slsDetector::~slsDetector() { int slsDetector::checkVersionCompatibility(portType t) { int fnum = F_CHECK_VERSION; - if (t == DATA_PORT) - fnum = F_RECEIVER_CHECK_VERSION; int ret = FAIL; char mess[MAX_STR_LENGTH] = {0}; int64_t arg = 0; @@ -122,60 +120,38 @@ int slsDetector::checkVersionCompatibility(portType t) { // detector if (t == CONTROL_PORT) { + // get api version number for detector server switch (thisDetector->myDetectorType) { case EIGER: arg = APIEIGER; break; case JUNGFRAU: arg = APIJUNGFRAU; break; case GOTTHARD: arg = APIGOTTHARD; break; default: - std::cout<< "Check version compatibility is not implemented for this " - "detector" << std::endl; + FILE_LOG(logERROR) << "Check version compatibility is not implemented for this detector"; setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); return FAIL; } + FILE_LOG(logDEBUG5) << "Checking version compatibility with detector with " + "value " << std::hex << arg; -#ifdef VERBOSE - std::cout<< std::endl<< "Checking version compatibility with detector with " - "value " << hex << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - // control port - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Detector returned error: (Control Server) %s", mess); - if(strstr(mess,"Unrecognized Function")!=NULL) - std::cout << "The detector server is too old to get API version. " - "Please update detector server!" << std::endl; - setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); - thisDetector->detectorControlAPIVersion = 0; - } else { - thisDetector->detectorControlAPIVersion = arg; - } - disconnectControl(); - } - if (ret!= FAIL) { + + // control server + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); + disconnectControl(); + if (ret == FAIL) + thisDetector->detectorControlAPIVersion = 0; + + // stop server + else { + thisDetector->detectorControlAPIVersion = arg; ret = FAIL; - - // stop port - if (connectStop() == OK){ - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - cprintf(RED, "Detector returned error: (Stop Server) %s", mess); - if(strstr(mess,"Unrecognized Function")!=NULL) - std::cout << "The detector server is too old to get API " - "version. Please update detector server!" << std::endl; - setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); - thisDetector->detectorStopAPIVersion = 0; - } else { - thisDetector->detectorStopAPIVersion = arg; - } + if (connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); disconnectStop(); + if (ret == FAIL) + thisDetector->detectorStopAPIVersion = 0; + else + thisDetector->detectorStopAPIVersion = arg; } } } @@ -183,26 +159,26 @@ int slsDetector::checkVersionCompatibility(portType t) { // receiver else { + fnum = F_RECEIVER_CHECK_VERSION; arg = APIRECEIVER; -#ifdef VERBOSE - std::cout<< std::endl<< "Checking version compatibility with receiver with " - "value " << hex << arg << std::endl; -#endif - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - // data port - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); - if (ret==FAIL){ - setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); - if(strstr(mess,"Unrecognized Function")!=NULL) - std::cout << "The receiver software is too old to get API " - "version. Please update receiver software!" << std::endl; - thisDetector->receiverAPIVersion = 0; - } else { - thisDetector->receiverAPIVersion = arg; - } - disconnectData(); - } + FILE_LOG(logDEBUG5) << "Checking version compatibility with receiver with " + "value " << std::hex << arg; + + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + disconnectData(); + if (ret == FAIL) + thisDetector->receiverAPIVersion = 0; + else + thisDetector->receiverAPIVersion = arg; + } + } + + if (ret == FAIL) { + setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); + if (strstr(mess,"Unrecognized Function") != NULL) { + FILE_LOG(logERROR) << "The " << ((t == CONTROL_PORT) ? "detector" : "receiver") << + " server is too old to get API version. Please update detector server!"; } } @@ -229,32 +205,29 @@ int64_t slsDetector::getId( idMode mode) { // receiver version else if (mode==RECEIVER_VERSION) { fnum = F_GET_RECEIVER_ID; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); - disconnectData(); - } + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + // handle ret if (ret == FAIL) setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if(ret == FORCE_UPDATE) + else if (ret == FORCE_UPDATE) ret = updateReceiver(); } } // detector versions else { - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, - &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if (ret == FORCE_UPDATE) - updateDetector(); - } + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else if (ret == FORCE_UPDATE) + updateDetector(); } } @@ -266,6 +239,7 @@ int64_t slsDetector::getId( idMode mode) { } + void slsDetector::freeSharedMemory(int multiId, int slsId) { auto shm = SharedMemory(multiId, slsId); shm.RemoveSharedMemory(); @@ -316,10 +290,10 @@ void slsDetector::initSharedMemory(bool created, detectorType type, int multiId, else { thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz); if (verify && thisDetector->shmversion != SLS_SHMVERSION) { - cprintf(RED, "Single shared memory (%d-%d:)version mismatch " + FILE_LOG(logERROR, ("Single shared memory (%d-%d:)version mismatch " "(expected 0x%x but got 0x%x)\n", multiId, detId, SLS_SHMVERSION, - thisDetector->shmversion); + thisDetector->shmversion)); throw SharedMemoryException(); } } @@ -394,7 +368,7 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nGappixelsY = 1; break; default: - cprintf(RED,"Unknown detector type!\n"); + FILE_LOG(logERROR, ("Unknown detector type!\n")); throw std::exception(); } } @@ -421,9 +395,7 @@ int slsDetector::calculateSharedMemorySize(detectorType type) { sizeof(int) * nch * nc + sizeof(int) * ng + sizeof(int) * no; -#ifdef VERBOSE - std::cout<<"Size of shared memory is " << sz << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Size of shared memory is " << sz; return sz; } @@ -555,7 +527,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->dynamicRange/8; // special for jctb - if(thisDetector->myDetectorType==JUNGFRAUCTB){ + if (thisDetector->myDetectorType==JUNGFRAUCTB) { getTotalNumberOfChannels(); } @@ -673,20 +645,20 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty } catch(...) { return NULL; } - int *dacs=new int[nd]; - int *adcs=new int[na]; - int *chipregs=new int[nc]; - int *chanregs=new int[nch*nc]; + int *dacs = new int[nd]; + int *adcs = new int[na]; + int *chipregs = new int[nc]; + int *chanregs = new int[nch*nc]; sls_detector_module *myMod = (sls_detector_module*)malloc(sizeof(sls_detector_module)); - myMod->ndac=nd; - myMod->nadc=na; - myMod->nchip=nc; - myMod->nchan=nch*nc; - myMod->dacs=dacs; - myMod->adcs=adcs; - myMod->chipregs=chipregs; - myMod->chanregs=chanregs; + myMod->ndac = nd; + myMod->nadc = na; + myMod->nchip = nc; + myMod->nchan = nch*nc; + myMod->dacs = dacs; + myMod->adcs = adcs; + myMod->chipregs = chipregs; + myMod->chanregs = chanregs; return myMod; } @@ -703,11 +675,11 @@ void slsDetector::deleteModule(sls_detector_module *myMod) { int slsDetector::connectControl() { - if (controlSocket){ + if (controlSocket) { if (controlSocket->Connect() >= 0) return OK; - else{ - std::cout << "cannot connect to detector" << std::endl; + else { + FILE_LOG(logERROR) << "Cannot connect to detector"; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_DETECTOR)); return FAIL; } @@ -723,11 +695,11 @@ void slsDetector::disconnectControl() { int slsDetector::connectData() { - if (dataSocket){ + if (dataSocket) { if (dataSocket->Connect() >= 0) return OK; - else{ - std::cout << "cannot connect to receiver" << std::endl; + else { + FILE_LOG(logERROR) << "Cannot connect to receiver"; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER)); return FAIL;} } @@ -742,11 +714,11 @@ void slsDetector::disconnectData() { int slsDetector::connectStop() { - if (stopSocket){ + if (stopSocket) { if (stopSocket->Connect() >= 0) return OK; - else{ - std::cout << "cannot connect to stop server" << std::endl; + else { + FILE_LOG(logERROR) << "Cannot connect to stop server"; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_DETECTOR)); return FAIL; } @@ -762,23 +734,23 @@ void slsDetector::disconnectStop() { int slsDetector::sendModule(sls_detector_module *myMod) { - int ts=0; + int ts = 0; //send module structure - ts+=controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); - ts+=controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); - ts+=controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); - ts+=controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); - ts+=controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); - ts+=controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg)); - ts+=controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain)); - ts+=controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); + ts += controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); + ts += controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); + ts += controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); + ts += controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); + ts += controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); + ts += controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg)); + ts += controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain)); + ts += controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); // actual data to the pointers - ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); - ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); - if(thisDetector->myDetectorType != JUNGFRAU){ - ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); - ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); + ts += controlSocket->SendDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); + ts += controlSocket->SendDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); + if (thisDetector->myDetectorType != JUNGFRAU) { + ts += controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); + ts += controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); } return ts; } @@ -786,58 +758,45 @@ int slsDetector::sendModule(sls_detector_module *myMod) { int slsDetector::receiveModule(sls_detector_module* myMod) { - int *dacptr=myMod->dacs; - int *adcptr=myMod->adcs; - int *chipptr=myMod->chipregs; - int *chanptr=myMod->chanregs; - int ts=0; + int *dacptr = myMod->dacs; + int *adcptr = myMod->adcs; + int *chipptr = myMod->chipregs; + int *chanptr = myMod->chanregs; + int ts = 0; //send module structure - ts+=controlSocket->ReceiveDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain)); - ts+=controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset)); + ts += controlSocket->ReceiveDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); + ts += controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); + ts += controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg)); + ts += controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain)); + ts += controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset)); - myMod->dacs=dacptr; - myMod->adcs=adcptr; - myMod->chipregs=chipptr; - myMod->chanregs=chanptr; + myMod->dacs = dacptr; + myMod->adcs = adcptr; + myMod->chipregs = chipptr; + myMod->chanregs = chanptr; + FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; -#ifdef VERBOSE - std::cout<< "received module of size "<< ts - << " register " << myMod->reg << std::endl; -#endif - ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); -#ifdef VERBOSE - std::cout<< "received dacs of size "<< ts << std::endl; -#endif - ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); -#ifdef VERBOSE - std::cout<< "received adc of size "<< ts << std::endl; -#endif + ts += controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); + FILE_LOG(logDEBUG5) << "received dacs of size "<< ts; - if(thisDetector->myDetectorType != JUNGFRAU){ - ts+=controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); -#ifdef VERBOSE - std::cout<< "received chips of size "<< ts << std::endl; -#endif - ts+=controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); -#ifdef VERBOSE - std::cout<< "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips; - std::cout<< "mod - nchans= " << myMod->nchan << " nchips= " <nchip; - std::cout<< "received chans of size "<< ts << std::endl; -#endif + ts += controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); + FILE_LOG(logDEBUG5) << "received adc of size "<< ts; + + if (thisDetector->myDetectorType != JUNGFRAU) { + ts += controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); + FILE_LOG(logDEBUG5) << "received chips of size "<< ts; + + ts += controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); + FILE_LOG(logDEBUG5) << "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips + << "mod - nchans= " << myMod->nchan << " nchips= " <nchip; + << "received chans of size "<< ts; } -#ifdef VERBOSE - std::cout<< "received module of size "<< ts << " register " - << myMod->reg << std::endl; -#endif - + FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; return ts; } @@ -845,9 +804,9 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) { auto shm = SharedMemory(multiId, detId); if (!shm.IsExisting()) { - cprintf(RED,"Shared memory %s does not exist.\n" + FILE_LOG(logERROR, ("Shared memory %s does not exist.\n" "Corrupted Multi Shared memory. Please free shared memory.\n", - shm.GetName().c_str()); + shm.GetName().c_str())); throw SharedMemoryException(); } @@ -856,9 +815,9 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b // open, map, verify version auto sdet = (sharedSlsDetector*)shm.OpenSharedMemory(sz); if (verify && sdet->shmversion != SLS_SHMVERSION) { - cprintf(RED, "Single shared memory (%d-%d:)version mismatch " + FILE_LOG(logERROR, ("Single shared memory (%d-%d:)version mismatch " "(expected 0x%x but got 0x%x)\n", - multiId, detId, SLS_SHMVERSION, sdet->shmversion); + multiId, detId, SLS_SHMVERSION, sdet->shmversion)); // unmap and throw sharedMemory->UnmapSharedMemory(thisDetector); throw SharedMemoryException(); @@ -881,7 +840,8 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int try { mySocket = new MySocketTCP(name, cport); } catch(...) { - FILE_LOG(logERROR) << "Cannot create socket to control server " << name << " over port " << cport; + FILE_LOG(logERROR) << "Cannot create socket to control server " << name + << " over port " << cport; return retval; } @@ -904,53 +864,53 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int int slsDetector::setDetectorType(detectorType const type) { - int ret=FAIL; - int fnum=F_GET_DETECTOR_TYPE,fnum2=F_GET_RECEIVER_TYPE; - detectorType retval = type; + int fnum = F_GET_DETECTOR_TYPE; + int ret = FAIL; + detectorType retval = GENERIC; + FILE_LOG(logDEBUG5) << "Setting detector type to " << arg; - if (type != GET_DETECTOR_TYPE) { -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Setting detector type to " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + // if unspecified, then get from detector + if (type == GET_DETECTOR_TYPE) { + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + // ret is never fail with this function + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + thisDetector->myDetectorType = GENERIC; + } else { thisDetector->myDetectorType = (detectorType)retval; -#ifdef VERBOSE - std::cout<< "Detector type retrieved " << retval << std::endl; -#endif - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + FILE_LOG(logDEBUG5) << "Detector Type: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - } else { - std::cout<< "Get detector type failed " << std::endl; - thisDetector->myDetectorType = GENERIC; } - } + } else ret = OK; - //receiver - if((thisDetector->myDetectorType != GENERIC) && - (thisDetector->receiverOnlineFlag==ONLINE_FLAG)) { + // receiver + if ((thisDetector->receiverOnlineFlag == ONLINE_FLAG) && ret == OK) { + fnum = F_GET_RECEIVER_TYPE; ret = FAIL; -#ifdef VERBOSE - std::cout << "Sending detector type to Receiver " << - (int)thisDetector->myDetectorType << std::endl; -#endif - if (connectData() == OK){ - int arg = (int)thisDetector->myDetectorType; - int retval2 = 0; - ret=thisReceiver->Client_Send(fnum2, &arg, sizeof(arg), &retval2, sizeof(retval2)); - disconnectData(); - retval = (detectorType)retval2; - } - if(ret==FAIL){ - std::cout << "ERROR: Could not send detector type to receiver" << std::endl; + int arg = (int)thisDetector->myDetectorType; + retval = GENERIC; + FILE_LOG(logINFO) << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType; + + if (connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + FILE_LOG(logERROR) << "Could not send detector type to receiver"; setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Type: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } + } } return retval; } @@ -977,45 +937,39 @@ std::string slsDetector::getDetectorType() { int slsDetector::getTotalNumberOfChannels() { -#ifdef VERBOSE - std::cout << "total number of channels" << std::endl; -#endif - if(thisDetector->myDetectorType==JUNGFRAUCTB){ - if (thisDetector->roFlags&DIGITAL_ONLY) - thisDetector->nChan[X]=4; - else if (thisDetector->roFlags&ANALOG_AND_DIGITAL) - thisDetector->nChan[X]=36; - else - thisDetector->nChan[X]=32; + FILE_LOG(logDEBUG5) << "Get total number of channels"; - if (thisDetector->nChan[X]>=32) { - if (thisDetector->nROI>0) { - thisDetector->nChan[X]-=32; - for (int iroi=0; iroinROI; ++iroi) - thisDetector->nChan[X]+= - thisDetector->roiLimits[iroi].xmax- - thisDetector->roiLimits[iroi].xmin+1; + if (thisDetector->myDetectorType == JUNGFRAUCTB) { + if (thisDetector->roFlags & DIGITAL_ONLY) + thisDetector->nChan[X] = 4; + else if (thisDetector->roFlags & ANALOG_AND_DIGITAL) + thisDetector->nChan[X] = 36; + else + thisDetector->nChan[X] = 32; + if (thisDetector->nChan[X] >= 32) { + if (thisDetector->nROI > 0) { + thisDetector->nChan[X] -= 32; + for (int iroi = 0; iroi < thisDetector->nROI; ++iroi) + thisDetector->nChan[X] += + thisDetector->roiLimits[iroi].xmax - + thisDetector->roiLimits[iroi].xmin + 1; } } - thisDetector->nChans=thisDetector->nChan[X]; - thisDetector->dataBytes=thisDetector->nChans*thisDetector->nChips* - 2*thisDetector->timerValue[SAMPLES_JCTB]; - thisDetector->dataBytesInclGapPixels = thisDetector->dataBytes; - } else { -#ifdef VERBOSE - std::cout << "det type is "<< thisDetector->myDetectorType << std::endl; - std::cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips* - << " data bytes is " << thisDetector->dataBytes << std::endl; - // excluding gap pixels -#endif - ; + thisDetector->nChans = thisDetector->nChan[X]; + thisDetector->dataBytes = thisDetector->nChans * thisDetector->nChips * 2 + * thisDetector->timerValue[SAMPLES_JCTB]; } - return thisDetector->nChans*thisDetector->nChips; + + FILE_LOG(logDEBUG5) << "Total number of channels: " << + thisDetector->nChans * thisDetector->nChips << + << ". Data bytes: " << thisDetector->dataBytes; + + return thisDetector->nChans * thisDetector->nChips; } int slsDetector::getTotalNumberOfChannels(dimension d) { getTotalNumberOfChannels(); - return thisDetector->nChan[d]*thisDetector->nChip[d]; + return thisDetector->nChan[d] * thisDetector->nChip[d]; } int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) { @@ -1024,8 +978,6 @@ int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) { * thisDetector->nGappixels[d]); } - - int slsDetector::getNChans() { return thisDetector->nChans; } @@ -1058,17 +1010,20 @@ void slsDetector::updateMultiSize(int detx, int dety) { int slsDetector::setOnline(int off) { - int old=thisDetector->onlineFlag; - if (off!=GET_ONLINE_FLAG) { - thisDetector->onlineFlag=off; - if (thisDetector->onlineFlag==ONLINE_FLAG) { + int old = thisDetector->onlineFlag; + // setting it online/offline + if (off != GET_ONLINE_FLAG) { + thisDetector->onlineFlag = off; + if (thisDetector->onlineFlag == ONLINE_FLAG) { setTCPSocket(); - if (thisDetector->onlineFlag==ONLINE_FLAG && old==OFFLINE_FLAG) { - std::cout << "Detector connecting for the first time - updating!" << std::endl; + // connecting first time + if (thisDetector->onlineFlag == ONLINE_FLAG && old == OFFLINE_FLAG) { + FILE_LOG(logINFO) << "Detector connecting for the first time - updating!"; updateDetector(); } - else if(thisDetector->onlineFlag==OFFLINE_FLAG){ - std::cout << "cannot connect to detector" << std::endl; + // error + else if (thisDetector->onlineFlag == OFFLINE_FLAG) { + FILE_LOG(logERROR) << "Cannot connect to detector"; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_DETECTOR)); } } @@ -1077,129 +1032,108 @@ int slsDetector::setOnline(int off) { } - std::string slsDetector::checkOnline() { std::string retval; - if(!controlSocket){ + if (!controlSocket) { //this already sets the online/offline flag setTCPSocket(); - if(thisDetector->onlineFlag==OFFLINE_FLAG) + if (thisDetector->onlineFlag == OFFLINE_FLAG) return std::string(thisDetector->hostname); else return std::string(""); } //still cannot connect to socket, controlSocket=0 - if(controlSocket){ + if (controlSocket) { if (connectControl() == FAIL) { controlSocket->SetTimeOut(5); - thisDetector->onlineFlag=OFFLINE_FLAG; + thisDetector->onlineFlag = OFFLINE_FLAG; delete controlSocket; - controlSocket=0; + controlSocket = 0; retval = std::string(thisDetector->hostname); -#ifdef VERBOSE - std::cout<< "offline!" << std::endl; -#endif + FILE_LOG(logDEBUG5) << "offline!"; } else { - thisDetector->onlineFlag=ONLINE_FLAG; + thisDetector->onlineFlag = ONLINE_FLAG; controlSocket->SetTimeOut(100); disconnectControl(); -#ifdef VERBOSE - std::cout<< "online!" << std::endl; -#endif + FILE_LOG(logDEBUG5) << "online!"; } } //still cannot connect to socket, stopSocket=0 - if(stopSocket){ + if (stopSocket) { if (connectStop() == FAIL) { stopSocket->SetTimeOut(5); - thisDetector->onlineFlag=OFFLINE_FLAG; + thisDetector->onlineFlag = OFFLINE_FLAG; delete stopSocket; - stopSocket=0; + stopSocket = 0; retval = std::string(thisDetector->hostname); -#ifdef VERBOSE - std::cout<< "stop offline!" << std::endl; -#endif + FILE_LOG(logDEBUG5) << "stop offline!"; } else { - thisDetector->onlineFlag=ONLINE_FLAG; + thisDetector->onlineFlag = ONLINE_FLAG; stopSocket->SetTimeOut(100); disconnectStop(); -#ifdef VERBOSE - std::cout<< "stop online!" << std::endl; -#endif + FILE_LOG(logDEBUG5) << "stop online!"; } } return retval; } - - int slsDetector::setTCPSocket(std::string const name, int const control_port, int const stop_port) { - char thisName[MAX_STR_LENGTH]; - int thisCP, thisSP; - int retval=OK; + char thisName[MAX_STR_LENGTH] = {0}; + int thisCP = 0, thisSP = 0; + int ret = OK; - if (name.empty()){ + // hostname + if (name.empty()) { strcpy(thisName,thisDetector->hostname); - }else{ -#ifdef VERBOSE - std::cout<< "setting hostname" << std::endl; -#endif + } else { + FILE_LOG(logDEBUG5) << "Setting hostname"; strcpy(thisName,name.c_str()); strcpy(thisDetector->hostname,thisName); if (controlSocket) { delete controlSocket; - controlSocket=0; + controlSocket = 0; } if (stopSocket) { delete stopSocket; - stopSocket=0; + stopSocket = 0; } } - - if (control_port>0) { -#ifdef VERBOSE - std::cout<< "setting control port" << std::endl; -#endif - thisCP=control_port; - thisDetector->controlPort=thisCP; + // control port + if (control_port > 0) { + FILE_LOG(logDEBUG5) << "Setting control port"; + thisCP = control_port; + thisDetector->controlPort = thisCP; if (controlSocket) { delete controlSocket; - controlSocket=0; + controlSocket = 0; } } else - thisCP=thisDetector->controlPort; + thisCP = thisDetector->controlPort; - if (stop_port>0) { -#ifdef VERBOSE - std::cout<< "setting stop port" << std::endl; -#endif - thisSP=stop_port; - thisDetector->stopPort=thisSP; + // stop port + if (stop_port > 0) { + FILE_LOG(logDEBUG5) << "Setting stop port"; + thisSP = stop_port; + thisDetector->stopPort = thisSP; if (stopSocket) { delete stopSocket; - stopSocket=0; + stopSocket = 0; } } else - thisSP=thisDetector->stopPort; + thisSP = thisDetector->stopPort; // create control socket if (!controlSocket) { try { controlSocket = new MySocketTCP(thisName, thisCP); -#ifdef VERYVERBOSE - std::cout<< "Control socket connected " << - thisName << " " << thisCP << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Control socket connected " << thisName << " " << thisCP; } catch(...) { -#ifdef VERBOSE - std::cout<< "Could not connect Control socket " << - thisName << " " << thisCP << std::endl; -#endif + FILE_LOG(logERROR) << "Could not connect control socket " << thisName << " " << thisCP; controlSocket = 0; - retval = FAIL; + ret = FAIL; } } @@ -1208,22 +1142,22 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (!stopSocket) { try { stopSocket = new MySocketTCP(thisName, thisSP); -#ifdef VERYVERBOSE - std::cout<< "Stop socket connected " << - thisName << " " << thisSP << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Stop socket connected " << thisName << " " << thisSP; } catch(...) { -#ifdef VERBOSE - std::cout<< "Could not connect Stop socket " << - thisName << " " << thisSP << std::endl; -#endif + FILE_LOG(logERROR) << "Could not connect Stop socket " << thisName << " " << thisSP; stopSocket = 0; - retval = FAIL; + ret = FAIL; } } - if (retval!=FAIL) { + if (ret == FAIL) { + thisDetector->onlineFlag = OFFLINE_FLAG; + FILE_LOG(logDEBUG5) << "Detector offline"; + } + + // check online and version compatibility + else { checkOnline(); thisDetectorControl->SetSocket(controlSocket); thisDetectorStop->SetSocket(stopSocket); @@ -1232,6 +1166,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in case EIGER: case JUNGFRAU: case GOTTHARD: + // check version compatibility only if it hasnt been checked yet (shm value) if ((thisDetector->detectorControlAPIVersion == 0) || (thisDetector->detectorStopAPIVersion == 0)) { if (checkVersionCompatibility(CONTROL_PORT) == FAIL) @@ -1241,308 +1176,207 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in default: break; } - - } else { - thisDetector->onlineFlag=OFFLINE_FLAG; -#ifdef VERBOSE - std::cout<< "offline!" << std::endl; -#endif } - return retval; + + return ret; } + int slsDetector::setPort(portType index, int num) { - int fnum=F_SET_PORT, fnum2 = F_SET_RECEIVER_PORT; - int retval; - // uint64_t ut; + int fnum = F_SET_PORT; + int ret = FAIL; + int retval = -1; - int ret=FAIL; - bool online=false; - MySocketTCP *s = 0; + // set + if (num >= 0) { - if (num>1024) { switch(index) { + case CONTROL_PORT: - s=controlSocket; - retval=thisDetector->controlPort; -#ifdef VERBOSE - std::cout << "s="<< s<< std::endl; - std::cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort - << std::endl; -#endif - if (s==0) { + FILE_LOG(logDEBUG5) << "Setting control port " << " to " << num; -#ifdef VERBOSE - std::cout << "s=NULL"<< std::endl; - std::cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort - << std::endl; -#endif - setTCPSocket("",DEFAULT_PORTNO); - } - if (controlSocket) { - s=controlSocket; - } else { -#ifdef VERBOSE - std::cout << "still cannot connect!"<< std::endl; - std::cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort - << std::endl; -#endif - - setTCPSocket("",retval); - } - online = (thisDetector->onlineFlag==ONLINE_FLAG); - - //not an error.could be from config file - if(num==thisDetector->controlPort) - return thisDetector->controlPort; - //reusable port, so print error - else if((num==thisDetector->stopPort)||(num==thisDetector->receiverTCPPort)){ - std::cout<< "Can not connect to port in use " << std::endl; - setErrorMask((getErrorMask())|(COULDNOT_SET_CONTROL_PORT)); + // same port + if (num == thisDetector->controlPort) return thisDetector->controlPort; + + // control socket not created + if (!controlSocket) { + FILE_LOG(logDEBUG5) << "Control socket not created. " + "Connecting to port: " << thisDetector->controlPort; + setTCPSocket(); + } + + // set port + if (controlSocket && thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &num, sizeof(num), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULDNOT_SET_CONTROL_PORT)); + } else { + thisDetector->controlPort = retval; + FILE_LOG(logDEBUG5) << "Control port: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); + } } break; - - case DATA_PORT: - s=dataSocket; - retval=thisDetector->receiverTCPPort; - if(strcmp(thisDetector->receiver_hostname,"none")){ - if (s==0) setReceiverTCPSocket("",retval); - if (dataSocket)s=dataSocket; - } - online = (thisDetector->receiverOnlineFlag==ONLINE_FLAG); - - //not an error. could be from config file - if(num==thisDetector->receiverTCPPort) - return thisDetector->receiverTCPPort; - //reusable port, so print error - else if((num==thisDetector->stopPort)||(num==thisDetector->controlPort)){ - std::cout<< "Can not connect to port in use " << std::endl; - setErrorMask((getErrorMask())|(COULDNOT_SET_DATA_PORT)); - return thisDetector->receiverTCPPort; - } - break; - - case STOP_PORT: - s=stopSocket; - retval=thisDetector->stopPort; - if (s==0) setTCPSocket("",-1,DEFAULT_PORTNO+1); - if (stopSocket) s=stopSocket; - else setTCPSocket("",-1,retval); - online = (thisDetector->onlineFlag==ONLINE_FLAG); + FILE_LOG(logDEBUG5) << "Setting stop port " << " to " << num; - //not an error. could be from config file - if(num==thisDetector->stopPort) - return thisDetector->stopPort; - //reusable port, so print error - else if((num==thisDetector->receiverTCPPort)||(num==thisDetector->controlPort)){ - std::cout<< "Can not connect to port in use " << std::endl; - setErrorMask((getErrorMask())|(COULDNOT_SET_STOP_PORT)); + // same port + if (num == thisDetector->stopPort) return thisDetector->stopPort; + + // stop socket not created + if (!stopSocket) { + FILE_LOG(logDEBUG5) << "Stop socket not created. " + "Connecting to port: " << thisDetector->stopPort; + setTCPSocket(); + } + + // set port + if (stopSocket && thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &num, sizeof(num), &retval, sizeof(retval)); + disconnectStop(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULDNOT_SET_STOP_PORT)); + } else { + thisDetector->stopPort = retval; + FILE_LOG(logDEBUG5) << "Stop port: " << retval; + } + } + break; + + case DATA_PORT: + FILE_LOG(logDEBUG5) << "Setting receiver port " << " to " << num; + + // same port + if (num == thisDetector->receiverTCPPort) + return thisDetector->receiverTCPPort; + + // control socket not created + if (!dataSocket) { + FILE_LOG(logDEBUG5) << "Stop socket not created. " + "Connecting to port: " << thisDetector->receiverTCPPort;; + setReceiverTCPSocket(); + } + + // set port + if (dataSocket && receiverOnlineFlag->onlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &num, sizeof(num), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULDNOT_SET_DATA_PORT)); + } else { + thisDetector->receiverTCPPort = retval; + FILE_LOG(logDEBUG5) << "Receiver port: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } break; default: - s=0; - break; - } - - - - - //send to current port to change port - if (online) { - if (s) { - if (s->Connect()>=0) { - if(s==dataSocket) - fnum = fnum2; - s->SendDataOnly(&fnum,sizeof(fnum)); - s->SendDataOnly(&num,sizeof(num)); - s->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - char mess[MAX_STR_LENGTH]=""; - s->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - s->ReceiveDataOnly(&retval,sizeof(retval)); - - s->Disconnect(); - }else{ - if (index == CONTROL_PORT){ - std::cout << "cannot connect to detector" << std::endl; - setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_DETECTOR)); - }else if (index == DATA_PORT){ - std::cout << "cannot connect to receiver" << std::endl; - setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER)); - } - } - } - } - - - - if (ret!=FAIL) { - switch(index) { - case CONTROL_PORT: - thisDetector->controlPort=retval; - break; - case DATA_PORT: - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ - thisDetector->receiverTCPPort=retval; - setReceiverOnline(ONLINE_FLAG); - setReceiver(thisDetector->receiver_hostname); - } - break; - case STOP_PORT: - thisDetector->stopPort=retval; - break; - default: - break; - } -#ifdef VERBOSE - std::cout << "ret is ok" << std::endl; -#endif - - } else { - switch(index) { - case CONTROL_PORT: - thisDetector->controlPort=num; - setErrorMask((getErrorMask())|(COULDNOT_SET_CONTROL_PORT)); - break; - case DATA_PORT: - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ - thisDetector->receiverTCPPort=retval; - setErrorMask((getErrorMask())|(COULDNOT_SET_DATA_PORT)); - }else{ - thisDetector->receiverTCPPort=num; - if(strcmp(thisDetector->receiver_hostname,"none")) - setReceiver(thisDetector->receiver_hostname); - } - break; - case STOP_PORT: - thisDetector->stopPort=num; - setErrorMask((getErrorMask())|(COULDNOT_SET_STOP_PORT)); - break; - default: - break; - } + FILE_LOG(logERROR) << "Unknown port index " << index; + return -1; } } - - - + // get switch(index) { case CONTROL_PORT: - retval=thisDetector->controlPort; - break; - case DATA_PORT: - retval=thisDetector->receiverTCPPort; - break; + return thisDetector->controlPort; case STOP_PORT: - retval=thisDetector->stopPort; - break; + return thisDetector->stopPort; + case DATA_PORT: + return thisDetector->receiverTCPPort; default: - retval=-1; - break; + return -1; } - - - -#ifdef VERBOSE - std::cout << thisDetector->controlPort<< " " << thisDetector->receiverTCPPort - << " " << thisDetector->stopPort << std::endl; -#endif - - - - return retval; - } int slsDetector::getControlPort() { return thisDetector->controlPort; } + int slsDetector::getStopPort() { return thisDetector->stopPort; } + int slsDetector::getReceiverPort() { return thisDetector->receiverTCPPort; } -int slsDetector::lockServer(int lock) { - int fnum=F_LOCK_SERVER; - int retval=-1; - int ret=OK; - char mess[MAX_STR_LENGTH]=""; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&lock,sizeof(lock)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); +int slsDetector::lockServer(int lock) { + int fnum = F_LOCK_SERVER; + int ret = FAIL; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting detector server lock to " << lock; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &lock, sizeof(lock), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Lock: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return retval; - - } std::string slsDetector::getLastClientIP() { + int fnum = F_LOCK_SERVER; + int ret = FAIL; + char retval[INET_ADDRSTRLEN] = {0}; + FILE_LOG(logDEBUG5) << "Getting last client ip to detector server"; - int fnum=F_GET_LAST_CLIENT_IP; - char clientName[INET_ADDRSTRLEN]; - int ret=OK; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - controlSocket->ReceiveDataOnly(clientName,sizeof(clientName)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Last client IP to detector: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return std::string(clientName); + return std::string(retval); } -int slsDetector::exitServer() { - int ret = FAIL; - int fnum=F_EXIT_SERVER; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (controlSocket) { - controlSocket->Connect(); - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - disconnectControl(); - } - } - if (ret==OK) { - std::cout<< std::endl; - std::cout<< "Shutting down the Detector server" << std::endl; - std::cout<< std::endl; +int slsDetector::exitServer() { + int fnum = F_EXIT_SERVER; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Sending exit command to detector server"; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); + // no ret handling as ret never fail + FILE_LOG(logINFO) << "Shutting down the Detector server"; } return ret; - } @@ -1551,117 +1385,108 @@ int slsDetector::execCommand(std::string cmd) { int ret = FAIL; char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; - - strcpy(arg,cmd.c_str()); + strcpy(arg, cmd.c_str()); FILE_LOG(logDEBUG5) << "Sending command to detector " << arg; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, + arg, sizeof(arg), retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret != FAIL) { - FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; - } return ret; } int slsDetector::updateDetectorNoWait() { - - enum readOutFlags ro; - // int ret=OK; - enum detectorSettings t; - int thr, n = 0, nm; - // int it; - int64_t retval;// tns=-1; + int n = 0, i32 = 0; + int64_t i64 = 0; char lastClientIP[INET_ADDRSTRLEN]; - n += controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); -#ifdef VERBOSE - std::cout << "Updating detector last modified by " << lastClientIP << std::endl; -#endif - n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - thisDetector->dynamicRange=nm; + n += controlSocket->ReceiveDataOnly(lastClientIP, sizeof(lastClientIP)); + FILE_LOG(logDEBUG5) << "Updating detector last modified by " << lastClientIP; - n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); - thisDetector->dataBytes=nm; + n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->dynamicRange = i32; - n += controlSocket->ReceiveDataOnly( &t,sizeof(t)); - thisDetector->currentSettings=t; + n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->dataBytes = i32; - if(thisDetector->myDetectorType == EIGER){ - n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); - thisDetector->currentThresholdEV=thr; + n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->currentSettings = (detectorSettings)i32; + + if (thisDetector->myDetectorType == EIGER) { + n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->currentThresholdEV = i32; } - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[FRAME_NUMBER]=retval; + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[FRAME_NUMBER] = i64; - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[ACQUISITION_TIME]=retval; + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[ACQUISITION_TIME] = i64; - if(thisDetector->myDetectorType == EIGER){ - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]=retval; + if (thisDetector->myDetectorType == EIGER) { + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] = i64; - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[SUBFRAME_DEADTIME]=retval; + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[SUBFRAME_DEADTIME] = i64; } - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[FRAME_PERIOD]=retval; + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[FRAME_PERIOD] = i64; - if(thisDetector->myDetectorType != EIGER) { - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval; + if (thisDetector->myDetectorType != EIGER) { + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[DELAY_AFTER_TRIGGER] = i64; } if ((thisDetector->myDetectorType != JUNGFRAU) && - (thisDetector->myDetectorType != EIGER)){ - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[GATES_NUMBER]=retval; + (thisDetector->myDetectorType != EIGER)) { + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[GATES_NUMBER] = i64; } - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - thisDetector->timerValue[CYCLES_NUMBER]=retval; + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + thisDetector->timerValue[CYCLES_NUMBER] = i64; - if (thisDetector->myDetectorType == JUNGFRAUCTB){ - n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); - if (retval>=0) - thisDetector->timerValue[SAMPLES_JCTB]=retval; - n += controlSocket->ReceiveDataOnly( &ro,sizeof(ro)); + if (thisDetector->myDetectorType == JUNGFRAUCTB) { + n += controlSocket->ReceiveDataOnly(&i64, sizeof(i64)); + if (i64 >= 0) + thisDetector->timerValue[SAMPLES_JCTB] = i64; - thisDetector->roFlags=ro; + n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->roFlags = (readOutFlags)i32; getTotalNumberOfChannels(); } - if (!n) - printf("n: %d\n", n); + FILE_LOG(logERROR) << "Could not update detector, received 0 bytes\n"; return OK; - } - - int slsDetector::updateDetector() { - int fnum=F_UPDATE_CLIENT; - int ret=OK; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - updateDetectorNoWait(); - disconnectControl(); - } + int fnum = F_UPDATE_CLIENT; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Sending update client to detector server"; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + // no ret handling as ret never fail + updateDetectorNoWait(); + disconnectControl(); } return ret; } @@ -1676,113 +1501,80 @@ int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetecto outfile.close(); } else { - std::cout<< "Error opening configuration file " << fname << - " for writing" << std::endl; + FILE_LOG(logERROR) << "Error opening configuration file " << fname << + " for writing"; setErrorMask((getErrorMask())|(CONFIG_FILE)); return FAIL; } - std::cout<< iline << " lines written to configuration file " << std::endl; + FILE_LOG(logINFO) << iline << " lines written to configuration file"; return OK; - - } int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) { - - detectorType type = thisDetector->myDetectorType; - std::string names[100]; - int nvar=0; - + const std::vector names; // common config - names[nvar++] = "hostname"; - names[nvar++] = "port"; - names[nvar++] = "stopport"; - names[nvar++] = "settingsdir"; - names[nvar++] = "ffdir"; - names[nvar++] = "outdir"; - names[nvar++] = "lock"; - + names.push_back("hostname"); + names.push_back("port"); + names.push_back("stopport"); + names.push_back("settingsdir"); + names.push_back("ffdir"); + names.push_back("outdir"); + names.push_back("lock"); // receiver config - names[nvar++] = "detectormac"; - names[nvar++] = "detectorip"; - names[nvar++] = "zmqport"; - names[nvar++] = "rx_zmqport"; - names[nvar++] = "zmqip"; - names[nvar++] = "rx_zmqip"; - names[nvar++] = "rx_tcpport"; - names[nvar++] = "rx_udpport"; - names[nvar++] = "rx_udpport2"; - names[nvar++] = "rx_udpip"; - names[nvar++] = "rx_hostname"; - names[nvar++] = "r_readfreq"; - - + names.push_back("detectormac"); + names.push_back("detectorip"); + names.push_back("zmqport"); + names.push_back("rx_zmqport"); + names.push_back("zmqip"); + names.push_back("rx_zmqip"); + names.push_back("rx_tcpport"); + names.push_back("rx_udpport"); + names.push_back("rx_udpport2"); + names.push_back("rx_udpip"); + names.push_back("rx_hostname"); + names.push_back("r_readfreq"); // detector specific config - switch (type) { + switch (thisDetector->myDetectorType) { case GOTTHARD: - names[nvar++] = "extsig"; - names[nvar++] = "vhighvoltage"; + names.push_back("extsig:0"); + names.push_back("vhighvoltage"); break; case EIGER: - names[nvar++] = "vhighvoltage"; - names[nvar++] = "trimen"; - names[nvar++] = "iodelay"; - names[nvar++] = "tengiga"; + names.push_back("vhighvoltage"); + names.push_back("trimen"); + names.push_back("iodelay"); + names.push_back("tengiga"); break; case JUNGFRAU: - names[nvar++] = "powerchip"; - names[nvar++] = "vhighvoltage"; + names.push_back("powerchip"); + names.push_back("vhighvoltage"); break; case JUNGFRAUCTB: - names[nvar++] = "powerchip"; - names[nvar++] = "vhighvoltage"; + names.push_back("powerchip"); + names.push_back("vhighvoltage"); break; default: - std::cout << "detector type " << - getDetectorType(thisDetector->myDetectorType) << " not implemented in " - "writing config file" << std::endl; - nvar = 0; - break; - } - - - - int nsig=4; - int iv=0; - char *args[100]; - char myargs[100][1000]; - - for (int ia=0; ia<100; ++ia) { - args[ia]=myargs[ia]; + FILE_LOG(logERROR) << "Unknown detector type " << thisDetector->myDetectorType; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + return FAIL; } auto cmd = slsDetectorCommand(m); - for (iv=0; ivsettingsFile); - if (s.length()>6) { - if (s.substr(s.length()-6,3)==std::string(".sn") && s.substr(s.length()-3)!=std::string("xxx") ) + // return without suffix .sn[detid] + if (s.length() > 6) { + if (s.substr(s.length()-6,3) == std::string(".sn") && s.substr(s.length()-3)!=std::string("xxx")) return s.substr(0,s.length()-6); } return std::string(thisDetector->settingsFile); @@ -1790,89 +1582,63 @@ std::string slsDetector::getSettingsFile() { int slsDetector::writeSettingsFile(std::string fname, int iodelay, int tau) { - return writeSettingsFile(fname, detectorModules[0], iodelay, tau); - } -slsDetectorDefs::detectorSettings slsDetector::getSettings() { +slsDetectorDefs::detectorSettings slsDetector::getSettings() { return sendSettingsOnly(GET_SETTINGS); } slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings) { -#ifdef VERBOSE - std::cout<< "slsDetector setSettings " << isettings << std::endl; -#endif + FILE_LOG(logDEBUG5) << "slsDetector setSettings " << isettings; if (isettings == -1) return getSettings(); - detectorType detType = thisDetector->myDetectorType; - switch (detType) { - - // eiger: only set client shared memory variable for Eiger, - // settings threshold loads the module data (trimbits, dacs etc.) - case EIGER: - switch(isettings) { + // eiger: only set shm, setting threshold loads the module data + if (thisDetector->myDetectorType == EIGER) { + switch (isettings) { case STANDARD: case HIGHGAIN: case LOWGAIN: case VERYHIGHGAIN: case VERYLOWGAIN: thisDetector->currentSettings = isettings; - break; + return thisDetector->currentSettings; default: - printf("Unknown settings %s for this detector!\n", - getDetectorSettings(isettings).c_str()); + FILE_LOG(logERROR) << "Unknown settings " << getDetectorSettings(isettings) << + " for this detector!"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); - break; - } - return thisDetector->currentSettings; - - // send only the settings, detector server will update dac values already in server - case GOTTHARD: - case JUNGFRAU: - return sendSettingsOnly(isettings); - - // others send whole module to detector - default: - printf("Unknown detector!\n"); return GET_SETTINGS; + } } -} + // others: send only the settings, detector server will update dac values already in server + return sendSettingsOnly(isettings); +} slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings isettings) { int fnum = F_SET_SETTINGS; int ret = FAIL; - char mess[MAX_STR_LENGTH] = {0}; + int arg = (int)isettings; int retval = -1; - int arg = isettings; -#ifdef VERBOSE - std::cout<< "Setting settings to " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); - } else{ - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentSettings = (detectorSettings)retval; -#ifdef VERBOSE - std::cout<< "Settings are " << retval << std::endl; -#endif - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + FILE_LOG(logDEBUG5) << "Setting settings to " << arg; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Settings: " << retval; + thisDetector->currentSettings = (detectorSettings)retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return thisDetector->currentSettings; @@ -1881,52 +1647,46 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings int slsDetector::getThresholdEnergy() { - - int fnum= F_GET_THRESHOLD_ENERGY; + int fnum = F_GET_THRESHOLD_ENERGY; + int ret = FAIL; int retval = -1; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; -#ifdef VERBOSE - std::cout<< "Getting threshold energy "<< std::endl; -#endif + FILE_LOG(logDEBUG5) << "Getting threshold energy"; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - std::cout<< "Detector returned error: "<< std::endl; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< mess << std::endl; - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentThresholdEV=retval; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Threshold: " << retval; + thisDetector->currentThresholdEV = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return thisDetector->currentThresholdEV; + return thisDetector->currentThresholdEV; } + int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, int tb) { - //currently only for eiger + // check as there is client processing if (thisDetector->myDetectorType == EIGER) { - setThresholdEnergyAndSettings(e_eV,isettings,tb); - return thisDetector->currentThresholdEV; + setThresholdEnergyAndSettings(e_eV, isettings, tb); + return thisDetector->currentThresholdEV; } + FILE_LOG(logERROR) << "Set threshold energy not implemented for this detector"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); return -1; - } - int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb) { - //if settings provided, use that, else use the shared memory variable + // if settings provided, use that, else use the shared memory variable detectorSettings is = ((isettings != GET_SETTINGS) ? isettings: thisDetector->currentSettings); std::string ssettings; @@ -1952,8 +1712,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti thisDetector->currentSettings=VERYLOWGAIN; break; default: - printf("Error: Unknown settings %s for this detector!\n", - getDetectorSettings(is).c_str()); + FILE_LOG(logERROR) << "Unknown settings " << getDetectorSettings(is) << " for this detector!"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); return FAIL; } @@ -1962,7 +1721,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti if (!thisDetector->nTrimEn || (e_eV < thisDetector->trimEnergies[0]) || (e_eV > thisDetector->trimEnergies[thisDetector->nTrimEn-1]) ) { - printf("Error: This energy %d not defined for this module!\n", e_eV); + FILE_LOG(logERROR) << "This energy " << e_eV << " not defined for this module!"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); return FAIL; } @@ -1982,19 +1741,18 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti int tau = -1; //not included in the module //normal - if(!interpolate) { + if (!interpolate) { //find their directory names std::ostringstream ostfn; ostfn << thisDetector->settingsDir << ssettings << "/" << e_eV << "eV" << "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec << getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10); std::string settingsfname = ostfn.str(); -#ifdef VERBOSE - printf("Settings File is %s\n", settingsfname.c_str()); -#endif + FILE_LOG(logDEBUG5) << "Settings File is " << settingsfname; + //read the files myMod=createModule(); if (NULL == readSettingsFile(settingsfname, iodelay, tau, myMod, tb)) { - if(myMod)deleteModule(myMod); + if (myMod)deleteModule(myMod); return FAIL; } } @@ -2023,10 +1781,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10); std::string settingsfname2 = ostfn.str(); //read the files -#ifdef VERBOSE - printf("Settings Files are %s and %s\n",settingsfname1.c_str(), - settingsfname2.c_str()); -#endif + FILE_LOG(logDEBUG5) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; sls_detector_module *myMod1=createModule(); sls_detector_module *myMod2=createModule(); int iodelay1 = -1; //not included in the module @@ -2046,7 +1801,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti return FAIL; } if (iodelay1 != iodelay2) { - printf("iodelays do not match between files\n"); + FILE_LOG(logERROR) << "Iodelays do not match between files"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); deleteModule(myMod1); deleteModule(myMod2); @@ -2057,7 +1812,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti //interpolate module myMod = interpolateTrim( myMod1, myMod2, e_eV, trim1, trim2, tb); if (myMod == NULL) { - printf("Could not interpolate, different dac values in files\n"); + FILE_LOG(logERROR) << "Could not interpolate, different dac values in files"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); deleteModule(myMod1); deleteModule(myMod2); @@ -2075,154 +1830,128 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti myMod->reg=thisDetector->currentSettings; setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb); deleteModule(myMod); - if (getSettings() != is){ - std::cout << "Could not set settings in detector" << std::endl; + if (getSettings() != is) { + FILE_LOG(logERROR) << "Could not set settings in detector"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); return FAIL; } - return OK; } - - std::string slsDetector::getSettingsDir() { return std::string(thisDetector->settingsDir); } + + std::string slsDetector::setSettingsDir(std::string s) { - sprintf(thisDetector->settingsDir, s.c_str()); return thisDetector->settingsDir; + sprintf(thisDetector->settingsDir, s.c_str()); + return thisDetector->settingsDir; } + int slsDetector::loadSettingsFile(std::string fname) { - - sls_detector_module *myMod=NULL; - - int iodelay = -1; - int tau = -1; - std::string fn = fname; - std::ostringstream ostfn; ostfn << fname; - switch (thisDetector->myDetectorType) { - case EIGER: + + // find specific file if it has detid in file name (.snxxx) + if (thisDetector->myDetectorType == EIGER) { if (fname.find(".sn")==std::string::npos && fname.find(".trim")== std::string::npos && fname.find(".settings")==std::string::npos) { ostfn << ".sn" << std::setfill('0') << std::setw(3) << std::dec << getId(DETECTOR_SERIAL_NUMBER); } - break; - default: - break; } - fn=ostfn.str(); - myMod=readSettingsFile(fn, iodelay, tau, myMod); - - if (myMod) { - myMod->reg=-1; - setModule(*myMod,iodelay,tau,-1,0,0); - deleteModule(myMod); - } else - return FAIL; - - return OK; -} - - -int slsDetector::saveSettingsFile(std::string fname) { + fn = ostfn.str(); + // read settings file sls_detector_module *myMod=NULL; - int ret=FAIL; int iodelay = -1; int tau = -1; + myMod = readSettingsFile(fn, iodelay, tau, myMod); - std::string fn=fname; - std::ostringstream ostfn; - ostfn << fname; - switch (thisDetector->myDetectorType) { - case EIGER: - ostfn << ".sn" << std::setfill('0') << std::setw(3) << std::dec << - getId(DETECTOR_SERIAL_NUMBER); - break; - default: - printf("Unknown detector!\n"); - return FAIL; - } - fn=ostfn.str(); - if ((myMod=getModule())) { - - if(thisDetector->myDetectorType == EIGER){ - iodelay = (int)setDAC((int)-1,IO_DELAY,0); - tau = (int64_t)getRateCorrection(); - } - ret=writeSettingsFile(fn, *myMod, iodelay, tau); + // set module + int ret = FAIL; + if (myMod != NULL) { + myMod->reg = -1; + ret = setModule(*myMod, iodelay, tau, -1, 0, 0); deleteModule(myMod); } - return ret; } +int slsDetector::saveSettingsFile(std::string fname) { + std::string fn = fname; + std::ostringstream ostfn; + ostfn << fname; + + // find specific file if it has detid in file name (.snxxx) + if (thisDetector->myDetectorType == EIGER) { + ostfn << ".sn" << std::setfill('0') << std::setw(3) << std::dec << + getId(DETECTOR_SERIAL_NUMBER); + } + fn=ostfn.str(); + + // get module + int ret = FAIL; + sls_detector_module *myMod = NULL; + if ((myMod = getModule())) { + int iodelay = -1; + int tau = -1; + if (thisDetector->myDetectorType == EIGER) { + iodelay = (int)setDAC((int)-1, IO_DELAY, 0); + tau = getRateCorrection(); + } + ret = writeSettingsFile(fn, *myMod, iodelay, tau); + deleteModule(myMod); + } + return ret; +} + slsDetectorDefs::runStatus slsDetector::getRunStatus() { - int fnum=F_GET_RUN_STATUS; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - strcpy(mess,"could not get run status"); - runStatus retval=ERROR; -#ifdef VERBOSE - std::cout<< "Getting status "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (stopSocket) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); + int fnum = F_GET_RUN_STATUS; + int ret = FAIL; + runStatus retval = ERROR; + FILE_LOG(logDEBUG5) << "Getting status"; - //std::cout << "________:::____________" << ret << std::endl; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectStop(); - if (ret==FAIL) { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - //std::cout << "____________________" << retval << std::endl; - } - disconnectStop(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Detector status: " << runStatusType(retval); + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return retval; - - } int slsDetector::prepareAcquisition() { int fnum = F_PREPARE_ACQUISITION; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Preparing Detector for Acquisition"; - if (thisDetector->onlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Preparing Detector for Acquisition" << std::endl; -#endif - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(PREPARE_ACQUISITION)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(PREPARE_ACQUISITION)); + } else { + FILE_LOG(logDEBUG5) << "Prepare Acquisition successful"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - }else - std::cout << "cannot connect to detector" << std::endl; - + } return ret; } @@ -2231,26 +1960,22 @@ int slsDetector::prepareAcquisition() { int slsDetector::startAcquisition() { + int fnum = F_START_ACQUISITION; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Starting Acquisition"; - int fnum=F_START_ACQUISITION; - int ret=FAIL; - -#ifdef VERBOSE - std::cout<< "Starting acquisition "<< std::endl; -#endif - thisDetector->stoppedFlag=0; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - char mess[MAX_STR_LENGTH]=""; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + thisDetector->stoppedFlag = 0; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Starting Acquisition successful"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return ret; @@ -2258,7 +1983,6 @@ int slsDetector::startAcquisition() { int slsDetector::stopAcquisition() { - // get status before stopping acquisition runStatus s = ERROR, r = ERROR; if (thisDetector->receiver_upstream) { @@ -2266,120 +1990,96 @@ int slsDetector::stopAcquisition() { r = getReceiverStatus(); } - int fnum=F_STOP_ACQUISITION; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_STOP_ACQUISITION; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Stopping Acquisition"; -#ifdef VERBOSE - std::cout<< "Stopping acquisition "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (stopSocket) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectStop(); - } + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectStop(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Stopping Acquisition successful"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - thisDetector->stoppedFlag=1; + thisDetector->stoppedFlag = 1; // if rxr streaming and acquisition finished, restream dummy stop packet if ((thisDetector->receiver_upstream) && (s == IDLE) && (r == IDLE)) { restreamStopFromReceiver(); } - return ret; - - } int slsDetector::sendSoftwareTrigger() { + int fnum = F_SOFTWARE_TRIGGER; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Sending software trigger"; - int fnum=F_SOFTWARE_TRIGGER; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + thisDetector->stoppedFlag = 0; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); -#ifdef VERBOSE - std::cout<< "Sending software trigger "<< std::endl; -#endif - thisDetector->stoppedFlag=0; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Sending software trigger successful"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return ret; } - - int slsDetector::startAndReadAll() { - int fnum= F_START_AND_READ_ALL; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_START_AND_READ_ALL; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Starting and reading all frames"; -#ifdef VERBOSE - std::cout<< "Starting and reading all frames "<< std::endl; -#endif - thisDetector->stoppedFlag=0; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - //std::cout<< "connected" << std::endl; - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - if (ret==FAIL) { - thisDetector->stoppedFlag=1; - std::cout<< "Detector returned: " << mess << std::endl; - } else { - ; -#ifdef VERBOSE - std::cout<< "Detector successfully returned: " << mess << " " << n - << std::endl; -#endif - } - disconnectControl(); + thisDetector->stoppedFlag = 0; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + thisDetector->stoppedFlag = 1; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Detector successfully finished acquisition"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return ret; } - int slsDetector::startReadOut() { - int fnum=F_START_READOUT; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_START_READOUT; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Starting readout"; -#ifdef VERBOSE - std::cout<< "Starting readout "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Starting detector readout successful"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return ret; @@ -2387,72 +2087,45 @@ int slsDetector::startReadOut() { int slsDetector::readAll() { + int fnum = F_READ_ALL; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Reading all frames"; - int fnum=F_READ_ALL; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectControl(); -#ifdef VERBOSE - std::cout<< "Reading all frames "<< std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - if (ret==FAIL) { - thisDetector->stoppedFlag=1; - std::cout<< "Detector returned: " << mess << std::endl; - } else { - ; -#ifdef VERBOSE - std::cout<< "Detector successfully returned: " << mess << " " << n - << std::endl; -#endif - } - disconnectControl(); + // handle ret + if (ret == FAIL) { + thisDetector->stoppedFlag = 1; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Detector successfully finished reading all frames"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return ret; } - - int slsDetector::configureMAC() { - int i; - int ret=FAIL; - int fnum=F_CONFIGURE_MAC; - char mess[MAX_STR_LENGTH]=""; - char arg[6][50] = {0}; - int retval=-1; - - // to send 3d positions to detector - bool sendpos = 0; - int pos[3]={0,0,0}; - - // only jungfrau and eiger, send x, y and z in detector udp header - if (thisDetector->myDetectorType == JUNGFRAU || - thisDetector->myDetectorType == EIGER) { - sendpos = true; - int max = thisDetector->multiSize[1]; - - pos[0] = (detId % max); // row - pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1);// col for horiz. udp ports - } -#ifdef VERBOSE - std::cout << "SLS [" << detId << "] - (" << pos[0] << "," << pos[1] << "," << - pos[2] << ")" << std::endl; -#endif + int fnum = F_CONFIGURE_MAC; + int ret = FAIL; + char args[9][50]; + memset(args, 0, sizeof(args)); + char retvals[3][50]; + memset(retvals, 0, sizeof(retvals)); + FILE_LOG(logDEBUG5) << "Configuring MAC"; - //if udpip wasnt initialized in config file - if(!(strcmp(thisDetector->receiverUDPIP,"none"))){ + // if rx_udpip is none + if (!(strcmp(thisDetector->receiverUDPIP,"none"))) { //hostname is an ip address - if(strchr(thisDetector->receiver_hostname,'.')!=NULL) - strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname); + if (strchr(thisDetector->receiver_hostname,'.') != NULL) + strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname); //if hostname not ip, convert it to ip - else{ + else { struct addrinfo *result; if (!dataSocket->ConvertHostnameToInternetAddress( thisDetector->receiver_hostname, &result)) { @@ -2466,33 +2139,39 @@ int slsDetector::configureMAC() { } } } - strcpy(arg[0],thisDetector->receiverUDPIP); - strcpy(arg[1],thisDetector->receiverUDPMAC); - sprintf(arg[2],"%x",thisDetector->receiverUDPPort); - strcpy(arg[3],thisDetector->detectorMAC); - strcpy(arg[4],thisDetector->detectorIP); - sprintf(arg[5],"%x",thisDetector->receiverUDPPort2); -#ifdef VERBOSE - std::cout<< "Configuring MAC"<< std::endl; -#endif - - - - for(i=0;i<2;++i){ - if(!strcmp(arg[i],"none")){ - std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); - return FAIL; - } + // rx_udpip and rx_udpmac is none + if ((!strcmp(thisDetector->receiverUDPIP, "none")) || + (!strcmp(thisDetector->receiverUDPMAC, "none"))) { + FILE_LOG(logERROR) << "Configure MAC Error. IP/MAC Addresses not set"; + setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); + return FAIL; } + FILE_LOG(logDEBUG5) << "rx_hostname and rx_udpip is valid "; -#ifdef VERBOSE - std::cout<< "IP/MAC Addresses valid "<< std::endl; -#endif - - + // copy to args + strcpy(args[0],thisDetector->receiverUDPIP); + strcpy(args[1],thisDetector->receiverUDPMAC); + sprintf(args[2],"%x",thisDetector->receiverUDPPort); + strcpy(args[3],thisDetector->detectorMAC); + strcpy(args[4],thisDetector->detectorIP); + sprintf(args[5],"%x",thisDetector->receiverUDPPort2); + // 2d positions to detector to put into udp header { - //converting IPaddress to hex + int pos[3] = {0, 0, 0}; + int max = thisDetector->multiSize[1]; + // row + pos[0] = (detId % max); + // col for horiz. udp ports + pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); + // pos[2] (z is reserved) + FILE_LOG(logDEBUG5) << "Detector [" << detId << "] - (" + << pos[0] << "," << pos[1] << ")"; + sprintf(args[6], "%x", pos[0]); + sprintf(args[7], "%x", pos[1]); + sprintf(args[8], "%x", pos[2]); + } + { + //converting IPaddress to std::hex std::stringstream ss(arg[0]); char cword[50]=""; bzero(cword, 50); @@ -2502,13 +2181,10 @@ int slsDetector::configureMAC() { } bzero(arg[0], 50); strcpy(arg[0],cword); -#ifdef VERBOSE - std::cout<<"receiver udp ip:"<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - if(sendpos) - controlSocket->SendDataOnly(pos,sizeof(pos)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); + // send to server + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); + } else { + // get detectormac, detector ip + uint64_t idetectormac = 0; + uint32_t idetectorip = 0; + sscanf(retval[1], "%lx", &idetectormac); + sscanf(retval[2], "%x", &idetectorip); + sprintf(retval[1],"%02x:%02x:%02x:%02x:%02x:%02x", + (unsigned int)((idetectormac>>40)&0xFF), + (unsigned int)((idetectormac>>32)&0xFF), + (unsigned int)((idetectormac>>24)&0xFF), + (unsigned int)((idetectormac>>16)&0xFF), + (unsigned int)((idetectormac>>8)&0xFF), + (unsigned int)((idetectormac>>0)&0xFF)); + sprintf(retval[2],"%d.%d.%d.%d", + (idetectorip>>24)&0xff, + (idetectorip>>16)&0xff, + (idetectorip>>8)&0xff, + (idetectorip)&0xff); + // update if different + if (strcasecmp(retval[1],thisDetector->detectorMAC)) { + memset(thisDetector->detectorMAC, 0, MAX_STR_LENGTH); + strcpy(thisDetector->detectorMAC, retval[1]); + FILE_LOG(logINFO, ("%d: Detector MAC updated to %s\n", detId, + thisDetector->detectorMAC)); } - else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - if (thisDetector->myDetectorType == EIGER) { - //rewrite detectormac, detector ip - char arg[2][50] = {0}; - uint64_t idetectormac = 0; - uint32_t idetectorip = 0; - controlSocket->ReceiveDataOnly(arg,sizeof(arg)); - sscanf(arg[0], "%lx", &idetectormac); - sscanf(arg[1], "%x", &idetectorip); - sprintf(arg[0],"%02x:%02x:%02x:%02x:%02x:%02x", - (unsigned int)((idetectormac>>40)&0xFF), - (unsigned int)((idetectormac>>32)&0xFF), - (unsigned int)((idetectormac>>24)&0xFF), - (unsigned int)((idetectormac>>16)&0xFF), - (unsigned int)((idetectormac>>8)&0xFF), - (unsigned int)((idetectormac>>0)&0xFF)); - sprintf(arg[1],"%d.%d.%d.%d", - (idetectorip>>24)&0xff, - (idetectorip>>16)&0xff, - (idetectorip>>8)&0xff, - (idetectorip)&0xff); - if (strcasecmp(arg[0],thisDetector->detectorMAC)) { - memset(thisDetector->detectorMAC, 0, MAX_STR_LENGTH); - strcpy(thisDetector->detectorMAC, arg[0]); - cprintf(RESET,"%d: Detector MAC updated to %s\n", detId, - thisDetector->detectorMAC); - } - if (strcasecmp(arg[1],thisDetector->detectorIP)) { - memset(thisDetector->detectorIP, 0, MAX_STR_LENGTH); - strcpy(thisDetector->detectorIP, arg[1]); - cprintf(RESET,"%d: Detector IP updated to %s\n", detId, - thisDetector->detectorIP); - } - } + if (strcasecmp(retval[2],thisDetector->detectorIP)) { + memset(thisDetector->detectorIP, 0, MAX_STR_LENGTH); + strcpy(thisDetector->detectorIP, retval[2]); + FILE_LOG(logINFO, ("%d: Detector IP updated to %s\n", detId, + thisDetector->detectorIP)); } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret==FAIL) { - ret=FAIL; - std::cout<< "Configuring MAC failed " << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); - } - return ret; } - - int64_t slsDetector::setTimer(timerIndex index, int64_t t) { - - - int fnum=F_SET_TIMER,fnum2=F_SET_RECEIVER_TIMER; + int fnum = F_SET_TIMER; + int ret = FAIL; + int64_t args[2] = {(int64_t)index, t}; int64_t retval = -1; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; + FILE_LOG(logDEBUG5) << "Setting " << getTimerType(index) << " to " << t " ns/value"; - if (index!=MEASUREMENTS_NUMBER) { + // meausurement is only shm level + if (index == MEASUREMENTS_NUMBER) { + if (t >= 0) { + thisDetector->timerValue[index] = t; + FILE_LOG(logDEBUG5) << getTimerType(index) << ": " << t; + } + return thisDetector->timerValue[index]; + } + // send to detector + int64_t oldtimer = thisDetector->timerValue[index]; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); -#ifdef VERBOSE - std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&index,sizeof(index)); - controlSocket->SendDataOnly(&t,sizeof(t)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->timerValue[index]=retval; - } - disconnectControl(); - if (ret==FORCE_UPDATE) { - updateDetector(); -#ifdef VERBOSE - std::cout<< "Updated!" << std::endl; -#endif - - } - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET)); } else { - //std::cout<< "offline " << std::endl; - if (t>=0) - thisDetector->timerValue[index]=t; - if(thisDetector->myDetectorType==JUNGFRAUCTB && index==SAMPLES_JCTB) { - getTotalNumberOfChannels(); + FILE_LOG(logDEBUG5) << getTimerType(index) << ": " << retval; + thisDetector->timerValue[index] = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); + } + } + + // setting timers consequences (eiger (ratecorr) and jctb (databytes)) + // (a get can also change timer value, hence check difference) + if (oldtimer != thisDetector->timerValue[index]) { + // jctb: change samples, change databytes + if (thisDetector->myDetectorType == JUNGFRAUCTB) { + if (index == SAMPLES_JCTB) { + setDynamicRange(); + FILE_LOG(logINFO) << "Changing samples: data size = " << thisDetector->dataBytes; } - } - } else { - if (t>=0) - thisDetector->timerValue[index]=t; - } -#ifdef VERBOSE - std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] - << "ns" << std::endl; -#endif - - if ((thisDetector->myDetectorType==JUNGFRAUCTB) && (index==SAMPLES_JCTB)) { - setDynamicRange(); - std::cout << "Changing samples: data size = " << thisDetector->dataBytes <myDetectorType == EIGER) && (r) && - (((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->dynamicRange == 32))|| - ((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))) { - setRateCorrection(r); + // eiger: change exptime/subexptime, set rate correction to update table + else if (thisDetector->myDetectorType == EIGER) { + int dr = thisDetector->dynamicRange; + if ((dr == 32 && index == SUBFRAME_ACQUISITION_TIME) || + (dr == 16 && index == ACQUISITION_TIME)) { + int r = getRateCorrection(); + if (r) + setRateCorrection(r); + } } } - - - - //send acquisiton time/period/subexptime/frame/cycles/samples to receiver - if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)|| - (index==ACQUISITION_TIME) || (index==SUBFRAME_ACQUISITION_TIME) || - (index==SUBFRAME_DEADTIME) || - (index==SAMPLES_JCTB) || (index==STORAGE_CELL_NUMBER)){ - std::string timername = getTimerType(index); - if(ret != FAIL){ - int64_t args[2]; + // send to reciever + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && ret == OK) { + switch (index) { + case FRAME_NUMBER: + case FRAME_PERIOD: + case CYCLES_NUMBER: + case ACQUISITION_TIME: + case SUBFRAME_ACQUISITION_TIME: + case SUBFRAME_DEADTIME: + case SAMPLES_JCTB: + case STORAGE_CELL_NUMBER: + // send + fnum = F_SET_RECEIVER_TIMER; + ret = FAIL; + args[1] = thisDetector->timerValue[index]; // to the value given by detector retval = -1; - args[0] = index; - args[1] = thisDetector->timerValue[index]; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ - - //set #frames * #cycles - if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)|| - (index==STORAGE_CELL_NUMBER)){ - timername.assign("(Number of Frames) * (Number of cycles) " - "* (Number of storage cells)"); - args[1] = thisDetector->timerValue[FRAME_NUMBER] * - ((thisDetector->timerValue[CYCLES_NUMBER] > 0) ? - (thisDetector->timerValue[CYCLES_NUMBER]) : 1) * - ((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) - ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1); -#ifdef VERBOSE - std::cout << "Setting/Getting " << timername << " " << index - <<" to/from receiver " << args[1] << std::endl; -#endif - } -#ifdef VERBOSE - // set period/exptime/subexptime/subperiod - else std::cout << "Setting/Getting " << timername << " " << index - << " to/from receiver " << args[1] << std::endl; -#endif - - char mess[MAX_STR_LENGTH]=""; - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum2, &args, sizeof(args), &retval, sizeof(retval), mess); - disconnectData(); - } - if((args[1] != retval)|| (ret==FAIL)){ - ret = FAIL; - std::cout << "ERROR: " << timername << " in receiver set incorrectly to " - << retval << " instead of " << args[1] << std::endl; - - if(strstr(mess,"receiver is not idle")==NULL) { - switch(index) { - case ACQUISITION_TIME: - setErrorMask((getErrorMask())|(RECEIVER_ACQ_TIME_NOT_SET)); - break; - case FRAME_PERIOD: - setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET)); - break; - case SUBFRAME_ACQUISITION_TIME: - case SUBFRAME_DEADTIME: - case SAMPLES_JCTB: - setErrorMask((getErrorMask())|(RECEIVER_TIMER_NOT_SET)); - break; - default: - setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET)); - break; - } - } - } - if(ret==FORCE_UPDATE) - updateReceiver(); + // rewrite args + if ((index == FRAME_NUMBER) || (index == CYCLES_NUMBER) || (index == STORAGE_CELL_NUMBER)) { + args[1] = thisDetector->timerValue[FRAME_NUMBER] * + ((thisDetector->timerValue[CYCLES_NUMBER] > 0) ? + (thisDetector->timerValue[CYCLES_NUMBER]) : 1) * + ((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) + ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1); } + FILE_LOG(logDEBUG5) << "Sending " << + (((index == FRAME_NUMBER) || + (index == CYCLES_NUMBER) || + (index == STORAGE_CELL_NUMBER)) ? + "(#Frames) * (#cycles) * (#storage cells)" : getTimerType(index)) << + << " to receiver: " << args[1]; + + if (connectData() == OK) { + char mess[MAX_STR_LENGTH] = {0}; + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval), mess); + disconnectData(); + + // handle ret + if (ret == FAIL) { + switch(index) { + case ACQUISITION_TIME: + setErrorMask((getErrorMask())|(RECEIVER_ACQ_TIME_NOT_SET)); + break; + case FRAME_PERIOD: + setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET)); + break; + case SUBFRAME_ACQUISITION_TIME: + case SUBFRAME_DEADTIME: + case SAMPLES_JCTB: + setErrorMask((getErrorMask())|(RECEIVER_TIMER_NOT_SET)); + break; + case FRAME_NUMBER: + case CYCLES_NUMBER: + case STORAGE_CELL_NUMBER: + setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET)); + break; + default: + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + break; + } + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + break; + default: + break; } } + return thisDetector->timerValue[index]; } @@ -2779,163 +2406,124 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { int64_t slsDetector::getTimeLeft(timerIndex index) { int fnum = F_GET_TIME_LEFT; + int ret = FAIL; int64_t retval = -1; - int ret = OK; + FILE_LOG(logDEBUG5) << "Getting " << getTimerType(index) << " left"; -#ifdef VERBOSE - std::cout<< "Getting timer "<< index << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (stopSocket) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&index,sizeof(index)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - char mess[MAX_STR_LENGTH]=""; - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } else { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectStop(); - } + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &index, sizeof(index), &retval, sizeof(retval)); + disconnectStop(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << getTimerType(index) << " left: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - std::cout<< "Time left is "<< retval << std::endl; -#endif return retval; - } - int slsDetector::setSpeed(speedVariable sp, int value) { + int fnum = F_SET_SPEED; + int ret = FAIL; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting speed index " << sp << " to " << value; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &value, sizeof(value), &retval, sizeof(retval)); + disconnectControl(); - int fnum=F_SET_SPEED; - int retval=-1; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; - -#ifdef VERBOSE - std::cout<< "Setting speed variable"<< sp << " to " << value << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&sp,sizeof(sp)); - controlSocket->SendDataOnly(&value,sizeof(value)); -#ifdef VERBOSE - std::cout<< "Sent "<< n << " bytes " << std::endl; -#endif - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_SET_SPEED_PARAMETERS)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_SET_SPEED_PARAMETERS)); + } else { + FILE_LOG(logDEBUG5) << "Speed index " << sp << ": " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - std::cout<< "Speed set to "<< retval << std::endl; -#endif return retval; - } int slsDetector::setDynamicRange(int n) { + int fnum = F_SET_DYNAMIC_RANGE; + int ret = FAIL; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting dynamic range to " << n; - // std::cout << "single " << std::endl; - int fnum=F_SET_DYNAMIC_RANGE,fnum2=F_SET_RECEIVER_DYNAMIC_RANGE; - int retval=-1,retval1; - char mess[MAX_STR_LENGTH]=""; - int ret=OK, rateret=OK; + // send to detector + int olddr = thisDetector->dynamicRange; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &n, sizeof(n), &retval, sizeof(retval)); + disconnectControl(); -#ifdef VERBOSE - std::cout<< "Setting dynamic range to "<< n << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&n,sizeof(n)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - if(strstr(mess,"Rate Correction")!=NULL){ - // rate correction is switched off if not 32 bit mode - if(strstr(mess,"32")!=NULL) - setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); - else - setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); - } - else ret = OK; + // handle ret + if (ret == FAIL) { + // eiger: dr set correctly, consequent rate correction was a problem + if ((thisDetector->myDetectorType == EIGER && + strstr(mess,"Rate Correction") != NULL)) { + // rate correction is switched off if not 32 bit mode + if (strstr(mess,"32") != NULL) + setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); + else + setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); + ret = OK; // dr was set correctly to reach rate correction } - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + else + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } + // ret might be set to OK above + if (ret != FAIL) { + FILE_LOG(logDEBUG5) << "Dynamic Range: " << retval; + thisDetector->dynamicRange = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - //std::cout << "detector returned dynamic range " << retval << std::endl; - if (ret!=FAIL && retval>0) { - thisDetector->dataBytes=thisDetector->nChips*thisDetector->nChans*retval/8; + + // setting dr consequences on databytes shm + // (a get can also change timer value, hence check difference) + if (olddr != thisDetector->dynamicRange) { + thisDetector->dataBytes = thisDetector->nChips * thisDetector->nChans * retval / 8; thisDetector->dataBytesInclGapPixels = - (thisDetector->nChip[X] * - thisDetector->nChan[X] + thisDetector->gappixels * - thisDetector->nGappixels[X]) * - (thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - retval/8; - if (thisDetector->myDetectorType==JUNGFRAUCTB) { + (thisDetector->nChip[X] * thisDetector->nChan[X] + + thisDetector->gappixels * thisDetector->nGappixels[X]) * + (thisDetector->nChip[Y] * thisDetector->nChan[Y] + + thisDetector->gappixels * thisDetector->nGappixels[Y]) * + retval / 8; + if (thisDetector->myDetectorType == JUNGFRAUCTB) getTotalNumberOfChannels(); - } - - thisDetector->dynamicRange=retval; - - -#ifdef VERBOSE - std::cout<< "Dynamic range set to "<< thisDetector->dynamicRange << std::endl; - std::cout<< "Data bytes "<< thisDetector->dataBytes << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Data bytes " << thisDetector->dataBytes; + FILE_LOG(logDEBUG5) << "Data bytes including gap pixels" << thisDetector->dataBytesInclGapPixels; } + // send to receiver + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && ret == OK) { + fnum = F_SET_RECEIVER_DYNAMIC_RANGE; + ret = FAIL; + n = thisDetector->dynamicRange; + retval = -1; + FILE_LOG(logINFO) << "Sending dynamic range to receiver " << n; + if (connectData() == OK) { + ret=thisReceiver->Client_Send(fnum2, &n, sizeof(n), &retval, sizeof(retval)); + disconnectData(); - //receiver - if(ret != FAIL){ - retval = thisDetector->dynamicRange; - if((n==-1) && (ret!= FORCE_UPDATE)) n =-1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Sending/Getting dynamic range to/from receiver " << - n << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum2, &n, sizeof(n), &retval1, sizeof(retval1)); - disconnectData(); - } - if ((ret==FAIL) || (retval1 != retval)){ - ret = FAIL; - std::cout << "ERROR:Dynamic range in receiver set incorrectly to " << - retval1 << " instead of " << retval << std::endl; + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DYNAMIC_RANGE)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Dynamic range: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if(ret==FORCE_UPDATE) - updateReceiver(); } } - return thisDetector->dynamicRange; } @@ -2951,300 +2539,221 @@ int slsDetector::getDataBytesInclGapPixels() { int slsDetector::setDAC(int val, dacIndex index, int mV) { - if ((index == HV_NEW) && (thisDetector->myDetectorType == GOTTHARD)) index = HV_POT; int fnum = F_SET_DAC; int ret = FAIL; int args[3] = {(int)index, mV, val}; - int retval[2] = {-1, -1}; + int retvals[2] = {-1, -1}; + FILE_LOG(logDEBUG5) << "Setting DAC " << index << " to " << val << (mV ? "mV" : "dac units"); - FILE_LOG(logDEBUG5) << "Setting DAC "<< index << " to " << val << (mV ? "mV" : "dac units"); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, - args, sizeof(args), retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if (ret == FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else { + FILE_LOG(logDEBUG5) << "Dac index " << index << ": " + << retval[0] << " dac units (" << retval[1] << "mV)"; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Dac index " << index << ": " - << retval[0] << " dac units (" << retval[1] << "mV)"; - } - if(mV) + if (mV) return retval[1]; - return retval[0]; } - - int slsDetector::getADC(dacIndex index) { int fnum = F_GET_ADC; int ret = FAIL; int arg = (int)index; int retval = -1; + FILE_LOG(logDEBUG5) << "Getting ADC " << index; - FILE_LOG(logDEBUG5) << "Getting ADC "<< index; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, - &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - /*commented out to allow adc read during acquire + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else + FILE_LOG(logDEBUG5) << "ADC (" << index << "): " << retval; + /*commented out to allow adc read during acquire else if (ret == FORCE_UPDATE) updateDetector();*/ - } } - if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "ADC (" << index << "): " << retval; - } - return retval; } - slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunicationMode( externalCommunicationMode pol) { int fnum = F_SET_EXTERNAL_COMMUNICATION_MODE; int ret = FAIL; - int arg = pol; - externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE;; + int arg = (int)pol; + externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE; + FILE_LOG(logDEBUG5) << "Setting communication to mode " << pol; - FILE_LOG(logDEBUG5) << "Setting communication to mode "<< pol; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if (ret == FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Timing Mode: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Timing Mode: " << retval; - } return retval; } - slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( externalSignalFlag pol, int signalindex) { int fnum = F_SET_EXTERNAL_SIGNAL_FLAG; int ret = FAIL; - int arg[2] = {signalindex, pol}; - externalSignalFlag retval = GET_EXTERNAL_SIGNAL_FLAG; + int args[2] = {signalindex, pol}; + externalCommunicationMode retval = GET_EXTERNAL_SIGNAL_FLAG; + FILE_LOG(logDEBUG5) << "Setting signal " << signalindex << " to flag " << pol; - FILE_LOG(logDEBUG5) << "Setting signal "<< signalindex << " to flag" << pol; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - ret = thisDetectorControl->Client_Send(fnum, arg, sizeof(arg), &retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if (ret == FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Ext Signal (" << signalindex << "): " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Ext Signal (" << signalindex << "): " << retval; - } return retval; } - - int slsDetector::setReadOutFlags(readOutFlags flag) { + int fnum = F_SET_READOUT_FLAGS; + int ret = FAIL; + int arg = (int)flag; + readOutFlags retval = GET_READOUT_FLAGS; + FILE_LOG(logDEBUG5) << "Setting readout flags to " << flag; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - int fnum=F_SET_READOUT_FLAGS; - readOutFlags retval; - char mess[MAX_STR_LENGTH]=""; - int ret=OK; - -#ifdef VERBOSE - std::cout<< "Setting readout flags to "<< flag << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&flag,sizeof(flag)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->roFlags=retval; - if (thisDetector->myDetectorType==JUNGFRAUCTB) { - - getTotalNumberOfChannels(); - //thisDetector->dataBytes=getTotalNumberOfChannels()* - //thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB]; - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS)); + } else { + FILE_LOG(logDEBUG5) << "Readout flag: " << retval; + thisDetector->roFlags = (readOutFlags)retval; + if (thisDetector->myDetectorType == JUNGFRAUCTB) { + getTotalNumberOfChannels(); } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - } else { - if (flag!=GET_READOUT_FLAGS) - thisDetector->roFlags=flag; } - -#ifdef VERBOSE - std::cout<< "Readout flag set to "<< retval << std::endl; -#endif return thisDetector->roFlags; } uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) { + int fnum = F_WRITE_REGISTER; + int ret = FAIL; + uint32_t args[2] = {addr, val}; + uint32_t retval = -1; + FILE_LOG(logDEBUG5) << "Writing to register 0x" << std::hex << + addr << "data: 0x" << std::hex << val << std::dec; - uint32_t retval = 0; - int fnum=F_WRITE_REGISTER; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - uint32_t arg[2]; - arg[0]=addr; - arg[1]=val; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Writing to register "<< hex<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + else { + FILE_LOG(logDEBUG5) << "Register 0x" << + std::hex << addr << ": 0x" << std::hex << retval << std::dec; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - std::cout<< "Register returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Write to register failed " << std::endl; - setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); - } - return retval; } - uint32_t slsDetector::readRegister(uint32_t addr) { + int fnum = F_READ_REGISTER; + int ret = FAIL; + uint32_t arg = -1; + uint32_t retval = -1; + FILE_LOG(logDEBUG5) << "Reading register 0x" << std::hex << addr << std::dec; - uint32_t retval = 0; - int fnum=F_READ_REGISTER; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - uint32_t arg; - arg=addr; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - -#ifdef VERBOSE - std::cout<< std::endl; - std::cout<< "Reading register "<< hex<onlineFlag==ONLINE_FLAG) { - // if (connectControl() == OK){ - if (stopSocket) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - } - disconnectStop(); - } + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + else { + FILE_LOG(logDEBUG5) << "Register 0x" << + std::hex << addr << ": 0x" << std::hex << retval << std::dec; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - std::cout<< "Register returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - std::cout<< "Read register failed " << std::endl; - setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); - } return retval; - } uint32_t slsDetector::setBit(uint32_t addr, int n) { - if (n<0 || n>31) { - std::cout << "Bit number out of Range" << std::endl; + if (n < 0 || n > 31) { + FILE_LOG(logERROR) << "Bit number " << n << " out of Range"; setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + return -1; } - - // normal bit range - //TODO! (Erik) Check for errors! cannot use value since reg is 32bits else { uint32_t val = readRegister(addr); - writeRegister(addr,val | 1<31) { - std::cout << "Bit number out of Range" << std::endl; + if (n < 0 || n > 31) { + FILE_LOG(logERROR) << "Bit number " << n << " out of Range"; setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + return -1; } - - // normal bit range else { uint32_t val = readRegister(addr); - writeRegister(addr,val & ~(1<myDetectorType == EIGER) { - setReceiverUDPPort2(i); + if (thisDetector->myDetectorType == EIGER) { + setReceiverUDPPort2(stoi(value)); return getReceiverUDPPort2(); } else { - setReceiverUDPPort(i); + setReceiverUDPPort(stoi(value)); return getReceiverUDPPort(); } case DETECTOR_TXN_DELAY_LEFT: case DETECTOR_TXN_DELAY_RIGHT: case DETECTOR_TXN_DELAY_FRAME: case FLOW_CONTROL_10G: - sscanf(value.c_str(),"%d",&i); - return setDetectorNetworkParameter(index, i); + return setDetectorNetworkParameter(index, stoi(value)); case CLIENT_STREAMING_PORT: return setClientStreamingPort(value); case RECEIVER_STREAMING_PORT: @@ -3286,18 +2792,14 @@ std::string slsDetector::setNetworkParameter(networkParameter index, std::string case ADDITIONAL_JSON_HEADER: return setAdditionalJsonHeader(value); case RECEIVER_UDP_SCKT_BUF_SIZE: - sscanf(value.c_str(),"%d",&i); - setReceiverUDPSocketBufferSize(i); + setReceiverUDPSocketBufferSize(stoi(value)); return getReceiverUDPSocketBufferSize(); - default: return (char*)("unknown network parameter"); } - } - std::string slsDetector::getNetworkParameter(networkParameter index) { switch (index) { case DETECTOR_MAC: @@ -3341,134 +2843,133 @@ std::string slsDetector::getNetworkParameter(networkParameter index) { } - std::string slsDetector::getDetectorMAC() { return std::string(thisDetector->detectorMAC); } + std::string slsDetector::getDetectorIP() { return std::string(thisDetector->detectorIP); } + std::string slsDetector::getReceiver() { return std::string(thisDetector->receiver_hostname); } + std::string slsDetector::getReceiverUDPIP() { return std::string(thisDetector->receiverUDPIP); } + std::string slsDetector::getReceiverUDPMAC() { return std::string(thisDetector->receiverUDPMAC); } + + std::string slsDetector::getReceiverUDPPort() { - std::ostringstream ss; ss << thisDetector->receiverUDPPort; std::string s = ss.str(); - return s; + return std::to_string(thisDetector->receiverUDPPort); } + + std::string slsDetector::getReceiverUDPPort2() { - std::ostringstream ss; ss << thisDetector->receiverUDPPort2; std::string s = ss.str(); - return s; + return std::to_string(thisDetector->receiverUDPPort2); } + + std::string slsDetector::getClientStreamingPort() { - std::ostringstream ss; ss << thisDetector->zmqport; std::string s = ss.str(); - return s; + return std::to_string(thisDetector->zmqport); } + + std::string slsDetector::getReceiverStreamingPort() { - std::ostringstream ss; ss << thisDetector->receiver_zmqport; std::string s = ss.str(); - return s; + return std::to_string(thisDetector->receiver_zmqport); } + + std::string slsDetector::getClientStreamingIP() { return std::string(thisDetector->zmqip); } + + std::string slsDetector::getReceiverStreamingIP() { return std::string(thisDetector->receiver_zmqip); } + + std::string slsDetector::getAdditionalJsonHeader() { return std::string(thisDetector->receiver_additionalJsonHeader); } + + std::string slsDetector::getReceiverUDPSocketBufferSize() { return setReceiverUDPSocketBufferSize(); } -std::string slsDetector::getReceiverRealUDPSocketBufferSize() { - int fnum=F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE; +std::string slsDetector::getReceiverRealUDPSocketBufferSize() { + int fnum = F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE; int ret = FAIL; int retval = -1; + FILE_LOG(logDEBUG5) << "Getting real UDP Socket Buffer size to receiver"; - if(thisDetector->receiverOnlineFlag == ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Getting real UDP Socket Buffer size to receiver " << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); - disconnectData(); - } - if(ret==FAIL) { + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - printf("Warning: Could not get real socket buffer size\n"); + } else { + FILE_LOG(logDEBUG5) << "Real Receiver UDP Socket Buffer size: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - if(ret==FORCE_UPDATE) - updateReceiver(); } - - std::ostringstream ss; - ss << retval; - std::string s = ss.str(); - return s; + return std::string(retval); } std::string slsDetector::setDetectorMAC(std::string detectorMAC) { - if(detectorMAC.length()==17){ - if((detectorMAC[2]==':')&&(detectorMAC[5]==':')&&(detectorMAC[8]==':')&& - (detectorMAC[11]==':')&&(detectorMAC[14]==':')){ - strcpy(thisDetector->detectorMAC,detectorMAC.c_str()); - if(!strcmp(thisDetector->receiver_hostname,"none")) -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - else if(setUDPConnection()==FAIL) - std::cout<< "Warning: UDP connection set up failed" << std::endl; - }else{ - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: server MAC Address should be in xx:xx:xx:xx:xx:xx " - "format" << std::endl; + + // invalid format + if ((detectorMAC.length() != 17) || + (detectorMAC[2] == ':') || (detectorMAC[5] == ':') || (detectorMAC[8] == ':') || + (detectorMAC[11] == ':') ||(detectorMAC[14] == ':')) { + setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); + FILE_LOG(logERROR) << "server MAC Address should be in xx:xx:xx:xx:xx:xx format"; + } + // valid format + else { + strcpy(thisDetector->detectorMAC, detectorMAC.c_str()); + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + } else if (setUDPConnection() == FAIL) + FILE_LOG(logWARNING) << "UDP connection set up failed"; } } - else{ - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: server MAC Address should be in xx:xx:xx:xx:xx:xx " - "format" << std::endl; - } - return std::string(thisDetector->detectorMAC); } - std::string slsDetector::setDetectorIP(std::string detectorIP) { struct sockaddr_in sa; - //taking function arguments into consideration - if(detectorIP.length()){ - if(detectorIP.length()<16){ - int result = inet_pton(AF_INET, detectorIP.c_str(), &(sa.sin_addr)); - if(result!=0){ - strcpy(thisDetector->detectorIP,detectorIP.c_str()); - if(!strcmp(thisDetector->receiver_hostname,"none")) -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - else if(setUDPConnection()==FAIL) - std::cout<< "Warning: UDP connection set up failed" << std::endl; - }else{ - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: Detector IP Address should be VALID and in " - "xxx.xxx.xxx.xxx format" << std::endl; + if (detectorIP.length() && detectorIP.length() < 16) { + int result = inet_pton(AF_INET, detectorIP.c_str(), &(sa.sin_addr)); + // invalid format + if (result == 0) { + setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); + FILE_LOG(logERROR) << "Detector IP Address should be VALID and in " + "xxx.xxx.xxx.xxx format"; + } + // valid format + else { + strcpy(thisDetector->detectorIP, detectorIP.c_str()); + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + } else if (setUDPConnection() == FAIL) { + FILE_LOG(logWARNING) << "UDP connection set up failed"; } } } @@ -3476,71 +2977,65 @@ std::string slsDetector::setDetectorIP(std::string detectorIP) { } - std::string slsDetector::setReceiver(std::string receiverIP) { - - if(receiverIP == "none") { + FILE_LOG(logDEBUG5) << "Setting up Receiver with " << receiverIP; + // recieverIP is none + if (receiverIP == "none") { memset(thisDetector->receiver_hostname, 0, MAX_STR_LENGTH); - strcpy(thisDetector->receiver_hostname,"none"); + strcpy(thisDetector->receiver_hostname, "none"); thisDetector->receiverOnlineFlag = OFFLINE_FLAG; return std::string(thisDetector->receiver_hostname); } - - if(getRunStatus()==RUNNING){ - cprintf(RED,"Acquisition already running, Stopping it.\n"); + // stop acquisition if running + if (getRunStatus()==RUNNING) { + FILE_LOG(logWARNING, ("Acquisition already running, Stopping it.\n")); stopAcquisition(); } + // update detector before receiver updateDetector(); - strcpy(thisDetector->receiver_hostname,receiverIP.c_str()); + // start updating + strcpy(thisDetector->receiver_hostname, receiverIP.c_str()); - if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Setting up receiver with" << std::endl; - std::cout << "detector type:" << slsDetectorDefs::getDetectorType( - thisDetector->myDetectorType) << std::endl; - std::cout << "detector id:" << detId << std::endl; - std::cout << "detector hostname:" << thisDetector->hostname << std::endl; - std::cout << "file path:" << thisDetector->receiver_filePath << std::endl; - std::cout << "file name:" << thisDetector->receiver_fileName << std::endl; - std::cout << "file index:" << thisDetector->receiver_fileIndex << std::endl; - std::cout << "file format:" << thisDetector->receiver_fileFormatType << std::endl; - std::cout << "framesperfile:" << thisDetector->receiver_framesPerFile << std::endl; - std::cout << "r_discardpolicy:" << thisDetector->receiver_frameDiscardMode << std::endl; - std::cout << "r_padding:" << thisDetector->receiver_framePadding << std::endl; - std::cout << "write enable:" << thisDetector->receiver_fileWriteEnable << std::endl; - std::cout << "overwrite enable:" << thisDetector->receiver_overWriteEnable << std::endl; - std::cout << "frame index needed:" << ((thisDetector->timerValue[FRAME_NUMBER] - *thisDetector->timerValue[CYCLES_NUMBER])>1) << std::endl; - std::cout << "frame period:" << thisDetector->timerValue[FRAME_PERIOD] << std::endl; - std::cout << "frame number:" << thisDetector->timerValue[FRAME_NUMBER] << std::endl; - std::cout << "sub exp time:" << thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] - << std::endl; - std::cout << "sub dead time:" << thisDetector->timerValue[SUBFRAME_DEADTIME] << std::endl; - std::cout << "dynamic range:" << thisDetector->dynamicRange << std::endl; - std::cout << "flippeddatax:" << thisDetector->flippedData[X] << std::endl; - if (thisDetector->myDetectorType == EIGER) { - std::cout << "activated: " << thisDetector->activated << std::endl; - std::cout << "receiver deactivated padding: " << thisDetector->receiver_deactivatedPaddingEnable << std::endl; - } - std::cout << "silent Mode:" << thisDetector->receiver_silentMode << std::endl; - std::cout << "10GbE:" << thisDetector->tenGigaEnable << std::endl; - std::cout << "Gap pixels: " << thisDetector->gappixels << std::endl; - std::cout << "rx streaming source ip:" << thisDetector->receiver_zmqip << std::endl; - std::cout << "rx additional json header:" << thisDetector->receiver_additionalJsonHeader << std::endl; - std::cout << "enable gap pixels:" << thisDetector->gappixels << std::endl; - std::cout << "rx streaming port:" << thisDetector->receiver_zmqport << std::endl; - std::cout << "r_readfreq:" << thisDetector->receiver_read_freq << std::endl; - std::cout << "rx_datastream:" << enableDataStreamingFromReceiver(-1) << std::endl << std::endl; + if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { + FILE_LOG(logDEBUG5) << + "detector type:" << (slsDetectorDefs::getDetectorType(thisDetector->myDetectorType)) << + "\ndetector id:" << detId << + "\ndetector hostname:" << thisDetector->hostname << + "\nfile path:" << thisDetector->receiver_filePath << + "\nfile name:" << thisDetector->receiver_fileName << + "\nfile index:" << thisDetector->receiver_fileIndex << + "\nfile format:" << thisDetector->receiver_fileFormatType << + "\nr_framesperfile:" << thisDetector->receiver_framesPerFile << + "\nr_discardpolicy:" << thisDetector->receiver_frameDiscardMode << + "\nr_padding:" << thisDetector->receiver_framePadding << + "\nwrite enable:" << thisDetector->receiver_fileWriteEnable << + "\noverwrite enable:" << thisDetector->receiver_overWriteEnable << + "\nframe index needed:" << + ((thisDetector->timerValue[FRAME_NUMBER] * thisDetector->timerValue[CYCLES_NUMBER]) > 1) << + "\nframe period:" << (thisDetector->timerValue[FRAME_PERIOD]) << + "\nframe number:" << (thisDetector->timerValue[FRAME_NUMBER]) << + "\nsub exp time:" << (thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]) << + "\nsub dead time:" << (thisDetector->timerValue[SUBFRAME_DEADTIME]) << + "\nsamples:" << (thisDetector->timerValue[SAMPLES_JCTB]) << + "\ndynamic range:" << thisDetector->dynamicRange << + "\nflippeddatax:" << (thisDetector->flippedData[X]) << + "\nactivated: " << thisDetector->activated << + "\nreceiver deactivated padding: " << thisDetector->receiver_deactivatedPaddingEnable << + "\nsilent Mode:" << thisDetector->receiver_silentMode << + "\n10GbE:" << thisDetector->tenGigaEnable << + "\nGap pixels: " << thisDetector->gappixels << + "\nr_readfreq:" << thisDetector->receiver_read_freq << + "\nrx streaming port:" << thisDetector->receiver_zmqport << + "\nrx streaming source ip:" << thisDetector->receiver_zmqip << + "\nrx additional json header:" << thisDetector->receiver_additionalJsonHeader << + "\nrx_datastream:" << enableDataStreamingFromReceiver(-1) << std::endl; -#endif - if(setDetectorType()!= GENERIC){ + if (setDetectorType(thisDetector->myDetectorType) != GENERIC) { sendMultiDetectorSize(); setDetectorId(); setDetectorHostname(); setUDPConnection(); - //setReceiverUDPSocketBufferSize(atoi(getReceiverUDPSocketBufferSize().c_str())); - setFilePath(thisDetector->receiver_filePath); setFileName(thisDetector->receiver_fileName); setFileIndex(thisDetector->receiver_fileIndex); @@ -3553,66 +3048,54 @@ std::string slsDetector::setReceiver(std::string receiverIP) { setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]); setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]); setTimer(ACQUISITION_TIME,thisDetector->timerValue[ACQUISITION_TIME]); - if(thisDetector->myDetectorType == EIGER) { + if (thisDetector->myDetectorType == EIGER) { setTimer(SUBFRAME_ACQUISITION_TIME, thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]); setTimer(SUBFRAME_DEADTIME,thisDetector->timerValue[SUBFRAME_DEADTIME]); } - if(thisDetector->myDetectorType == JUNGFRAUCTB) + if (thisDetector->myDetectorType == JUNGFRAUCTB) setTimer(SAMPLES_JCTB,thisDetector->timerValue[SAMPLES_JCTB]); setDynamicRange(thisDetector->dynamicRange); - if(thisDetector->myDetectorType == EIGER){ + if (thisDetector->myDetectorType == EIGER) { setFlippedData(X,-1); activate(-1); setDeactivatedRxrPaddingMode(thisDetector->receiver_deactivatedPaddingEnable); } setReceiverSilentMode(thisDetector->receiver_silentMode); - - if(thisDetector->myDetectorType == EIGER) + if (thisDetector->myDetectorType == EIGER) enableTenGigabitEthernet(thisDetector->tenGigaEnable); - enableGapPixels(thisDetector->gappixels); - // data streaming setReceiverStreamingFrequency(thisDetector->receiver_read_freq); setReceiverStreamingPort(getReceiverStreamingPort()); setReceiverStreamingIP(getReceiverStreamingIP()); setAdditionalJsonHeader(getAdditionalJsonHeader()); enableDataStreamingFromReceiver(enableDataStreamingFromReceiver(-1)); - - if(thisDetector->myDetectorType == GOTTHARD) + if (thisDetector->myDetectorType == GOTTHARD) sendROI(-1, NULL); } } - return std::string(thisDetector->receiver_hostname); } - - std::string slsDetector::setReceiverUDPIP(std::string udpip) { struct sockaddr_in sa; - //taking function arguments into consideration - if(udpip.length()){ - if(udpip.length()<16){ - int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr)); - if(result==0){ - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: Receiver UDP IP Address should be VALID " - "and in xxx.xxx.xxx.xxx format" << std::endl; - }else{ - strcpy(thisDetector->receiverUDPIP,udpip.c_str()); - if(!strcmp(thisDetector->receiver_hostname,"none")) { -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - } - else if(setUDPConnection()==FAIL){ - std::cout<< "Warning: UDP connection set up failed" << std::endl; - } + if (udpip.length() && udpip.length() < 16) { + int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr)); + // invalid format + if (result == 0) { + setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); + FILE_LOG(logERROR) << "Receiver UDP IP Address should be VALID " + "and in xxx.xxx.xxx.xxx format" << std::endl; + } + // valid format + else { + strcpy(thisDetector->receiverUDPIP,udpip.c_str()); + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + } else if (setUDPConnection() == FAIL) { + FILE_LOG(logWARNING) << "UDP connection set up failed"; } } } @@ -3620,144 +3103,111 @@ std::string slsDetector::setReceiverUDPIP(std::string udpip) { } - - std::string slsDetector::setReceiverUDPMAC(std::string udpmac) { - if(udpmac.length()!=17){ + // invalid format + if ((udpmac.length() != 17) || + (udpmac[2] == ':') || (udpmac[5] == ':') || (udpmac[8] == ':') || + (udpmac[11] == ':') ||(udpmac[14] == ':')) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: receiver udp mac address should be in xx:xx:xx:xx:xx:xx " - "format" << std::endl; + FILE_LOG(logERROR) << "receiver udp MAC Address should be in xx:xx:xx:xx:xx:xx format"; } - else{ - if((udpmac[2]==':')&&(udpmac[5]==':')&&(udpmac[8]==':')&& - (udpmac[11]==':')&&(udpmac[14]==':')){ - strcpy(thisDetector->receiverUDPMAC,udpmac.c_str()); - if(!strcmp(thisDetector->receiver_hostname,"none")) -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - /* else if(setUDPConnection()==FAIL){ commented out to be replaced by user - * defined udpmac - std::cout<< "Warning: UDP connection set up failed" << std::endl; - }*/ - }else{ - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: receiver udp mac address should be in xx:xx:xx:xx:xx:xx " - "format" << std::endl; + // valid format + else { + strcpy(thisDetector->receiverUDPMAC, udpmac.c_str()); + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; } + // not doing setUDPConnection as rx_udpmac will get replaced,(must use configuremac) + strcpy(thisDetector->receiverUDPMAC,udpmac.c_str()); } - - return std::string(thisDetector->receiverUDPMAC); } - int slsDetector::setReceiverUDPPort(int udpport) { thisDetector->receiverUDPPort = udpport; - if(!strcmp(thisDetector->receiver_hostname,"none")) -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - else if(setUDPConnection()==FAIL){ - std::cout<< "Warning: UDP connection set up failed" << std::endl; + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + } + else if (setUDPConnection() == FAIL) { + FILE_LOG(logWARNING) << "UDP connection set up failed"; } return thisDetector->receiverUDPPort; } + int slsDetector::setReceiverUDPPort2(int udpport) { thisDetector->receiverUDPPort2 = udpport; - if(!strcmp(thisDetector->receiver_hostname,"none")) -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#else - ; -#endif - else if(setUDPConnection()==FAIL){ - std::cout<< "Warning: UDP connection set up failed" << std::endl; + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + } + else if (setUDPConnection() == FAIL) { + FILE_LOG(logWARNING) << "UDP connection set up failed"; } return thisDetector->receiverUDPPort2; } std::string slsDetector::setClientStreamingPort(std::string port) { - int arg = 0; - - sscanf(port.c_str(),"%d",&arg); - thisDetector->zmqport = arg; - + thisDetector->zmqport = stoi(port); return getClientStreamingPort(); } - - std::string slsDetector::setReceiverStreamingPort(std::string port) { - int arg = 0; + // copy now else it is lost if rx_hostname not set yet + thisDetector->receiver_zmqport = stoi(port); - sscanf(port.c_str(),"%d",&arg); - thisDetector->receiver_zmqport = arg; - - // send to receiver - int fnum=F_SET_RECEIVER_STREAMING_PORT; + int fnum = F_SET_RECEIVER_STREAMING_PORT; int ret = FAIL; - int retval=-1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Sending receiver streaming port to receiver " << arg << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) { - setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: Could not set receiver zmq port" << std::endl; - } - if(ret==FORCE_UPDATE) - updateReceiver(); - } + int arg = thisDetector->receiver_zmqport; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending receiver streaming port to receiver " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); + } else { + FILE_LOG(logDEBUG5) << "Receiver streaming port: " << retval; + thisDetector->receiver_zmqport = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); + } + } return getReceiverStreamingPort(); } -std::string slsDetector::setClientStreamingIP(std::string sourceIP) { +std::string slsDetector::setClientStreamingIP(std::string sourceIP) { struct addrinfo *result; // on failure to convert to a valid ip if (dataSocket->ConvertHostnameToInternetAddress(sourceIP.c_str(), &result)) { - std::cout << "Warning: Could not convert zmqip into a valid IP" << sourceIP - << std::endl; + FILE_LOG(logWARNING) << "Could not convert zmqip into a valid IP" << sourceIP; setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); return getClientStreamingIP(); } // on success put IP as std::string into arg - else { - memset(thisDetector->zmqip, 0, MAX_STR_LENGTH); - dataSocket->ConvertInternetAddresstoIpString(result, thisDetector->zmqip, - MAX_STR_LENGTH); - } - + memset(thisDetector->zmqip, 0, MAX_STR_LENGTH); + dataSocket->ConvertInternetAddresstoIpString(result, thisDetector->zmqip, MAX_STR_LENGTH); return getClientStreamingIP(); } std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { - - int fnum=F_RECEIVER_STREAMING_SRC_IP; + int fnum = F_RECEIVER_STREAMING_SRC_IP; int ret = FAIL; - char arg[MAX_STR_LENGTH] = {0}; - char retval[MAX_STR_LENGTH] = {0}; + char args[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + FILE_LOG(logDEBUG5) << "Sending receiver streaming IP to receiver " << sourceIP; // if empty, give rx_hostname if (sourceIP.empty()) { - if(!strcmp(thisDetector->receiver_hostname,"none")) { - std::cout << "Receiver hostname not set yet. Cannot create rx_zmqip " - "from none\n" << std::endl; + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logWARNING) << "Receiver hostname not set yet. Cannot create rx_zmqip from none"; setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); return getReceiverStreamingIP(); } @@ -3769,112 +3219,93 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { struct addrinfo *result; // on failure to convert to a valid ip if (dataSocket->ConvertHostnameToInternetAddress(sourceIP.c_str(), &result)) { - std::cout << "Warning: Could not convert rx_zmqip into a valid IP" << - sourceIP << std::endl; + FILE_LOG(logWARNING) << "Could not convert rx_zmqip into a valid IP" << sourceIP; setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); return getReceiverStreamingIP(); } // on success put IP as std::string into arg - else { - dataSocket->ConvertInternetAddresstoIpString(result, arg, sizeof(arg)); - } + dataSocket->ConvertInternetAddresstoIpString(result, args, sizeof(args)); } - // set it anyway, else it is lost + // set it anyway, else it is lost if rx_hostname is not set yet memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); - strcpy(thisDetector->receiver_zmqip, arg); - - + strcpy(thisDetector->receiver_zmqip, args); // if zmqip is empty, update it if (! strlen(thisDetector->zmqip)) - strcpy(thisDetector->zmqip, arg); + strcpy(thisDetector->zmqip, args); + FILE_LOG(logDEBUG5) << "Sending receiver streaming IP to receiver " << args; + // send to receiver + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectData(); - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Sending receiver streaming source ip to receiver " << arg << - std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); - disconnectData(); - } - if(ret==FAIL) { + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: Could not set rx_zmqip" << std::endl; + } else { + FILE_LOG(logDEBUG5) << "Receiver streaming port: " << retvals; + memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); + strcpy(thisDetector->receiver_zmqip, retvals); + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - if(ret==FORCE_UPDATE) - updateReceiver(); } - return getReceiverStreamingIP(); } - std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { - - int fnum=F_ADDITIONAL_JSON_HEADER; + int fnum = F_ADDITIONAL_JSON_HEADER; int ret = FAIL; - char arg[MAX_STR_LENGTH] = {0}; - char retval[MAX_STR_LENGTH] = {0}; + char args[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + strcpy(args, jsonheader.c_str()); + FILE_LOG(logDEBUG5) << "Sending additional json header " << args; - strcpy(arg, jsonheader.c_str()); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectData(); - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Sending additional json header " << arg << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); - disconnectData(); - } - if(ret==FAIL) { + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - std::cout << "Warning: Could not set additional json header" << std::endl; - } else - strcpy(thisDetector->receiver_additionalJsonHeader, retval); - if(ret==FORCE_UPDATE) - updateReceiver(); + } else { + FILE_LOG(logDEBUG5) << "Additional json header: " << retvals; + memset(thisDetector->receiver_additionalJsonHeader, 0, MAX_STR_LENGTH); + strcpy(thisDetector->receiver_additionalJsonHeader, retvals); + if (ret == FORCE_UPDATE) + ret = updateDetector(); + } } - return getAdditionalJsonHeader(); } std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) { - - int fnum=F_RECEIVER_UDP_SOCK_BUF_SIZE; + int fnum = F_RECEIVER_UDP_SOCK_BUF_SIZE; int ret = FAIL; - int retval = -1; int arg = udpsockbufsize; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending UDP Socket Buffer size to receiver " << arg; - if(thisDetector->receiverOnlineFlag == ONLINE_FLAG){ -#ifdef VERBOSE - std::cout << "Sending UDP Socket Buffer size to receiver " << arg << std::endl; -#endif - if (connectData() == OK){ - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if(ret==FAIL) { + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); - printf("Warning: Could not set udp socket buffer size\n"); + } else { + FILE_LOG(logDEBUG5) << "Receiver UDP Socket Buffer size: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } - if(ret==FORCE_UPDATE) - updateReceiver(); } - - std::ostringstream ss; - ss << retval; - std::string s = ss.str(); - return s; + return std::to_string(retval); } - - - std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay) { int fnum = F_SET_NETWORK_PARAMETER; int ret = FAIL; @@ -3882,17 +3313,17 @@ std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int char mess[MAX_STR_LENGTH]=""; #ifdef VERBOSE - std::cout<< "Setting Transmission delay of mode "<< index << " to " << delay << std::endl; + FILE_LOG(logINFO) << "Setting Transmission delay of mode "<< index << " to " << delay << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&index,sizeof(index)); controlSocket->SendDataOnly(&delay,sizeof(delay)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(DETECTOR_NETWORK_PARAMETER)); } else controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -3902,7 +3333,7 @@ std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int } } #ifdef VERBOSE - std::cout<< "Speed set to "<< retval << std::endl; + FILE_LOG(logINFO) << "Speed set to "<< retval << std::endl; #endif std::ostringstream ss; @@ -3920,7 +3351,7 @@ int slsDetector::setUDPConnection() { char retval[MAX_STR_LENGTH] = {0}; //called before set up - if(!strcmp(thisDetector->receiver_hostname,"none")){ + if (!strcmp(thisDetector->receiver_hostname,"none")) { #ifdef VERBOSE std::cout << "Warning: Receiver hostname not set yet." << std::endl; #endif @@ -3928,12 +3359,12 @@ int slsDetector::setUDPConnection() { } //if no udp ip given, use hostname - if(!strcmp(thisDetector->receiverUDPIP,"none")){ + if (!strcmp(thisDetector->receiverUDPIP,"none")) { //hostname is an ip address - if(strchr(thisDetector->receiver_hostname,'.')!=NULL) + if (strchr(thisDetector->receiver_hostname,'.')!=NULL) strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname); //if hostname not ip, convert it to ip - else{ + else { struct addrinfo *result; if (!dataSocket->ConvertHostnameToInternetAddress( thisDetector->receiver_hostname, &result)) { @@ -3960,31 +3391,31 @@ int slsDetector::setUDPConnection() { #endif //set up receiver for UDP Connection and get receivermac address - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &args, sizeof(args), &retval, sizeof(retval)); disconnectData(); } - if(ret!=FAIL){ + if (ret!=FAIL) { strcpy(thisDetector->receiverUDPMAC,retval); #ifdef VERBOSE std::cout << "Receiver mac address: " << thisDetector->receiverUDPMAC << std::endl; #endif - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); //configure detector with udp details, -100 is so it doesnt overwrite //the previous value - if(configureMAC()==FAIL){ + if (configureMAC()==FAIL) { setReceiverOnline(OFFLINE_FLAG); std::cout << "could not configure mac" << std::endl; } } - }else + } else ret=FAIL; #ifdef VERBOSE printReceiverConfiguration(); @@ -4001,9 +3432,9 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) { int retval = -1; FILE_LOG(logDEBUG5) << "Sending digital test of mode " << mode << ", ival " << ival; - + if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); disconnectControl(); @@ -4029,18 +3460,18 @@ int slsDetector::loadImageToDetector(imageType index,std::string const fname) { #ifdef VERBOSE std::cout<< std::endl<< "Loading "; - if(!index) + if (!index) std::cout<<"Dark"; else std::cout<<"Gain"; std::cout<<" image from file " << fname << std::endl; #endif - if(readDataFile(fname,arg,getTotalNumberOfChannels())){ + if (readDataFile(fname,arg,getTotalNumberOfChannels())) { ret = sendImageToDetector(index,arg); return ret; } - std::cout<< "Could not open file "<< fname << std::endl; + FILE_LOG(logERROR) << "Could not open file "<< fname << std::endl; return ret; } @@ -4058,7 +3489,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&index,sizeof(index)); controlSocket->SendDataOnly(imageVals,thisDetector->dataBytes); @@ -4067,7 +3498,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -4083,13 +3514,13 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int slsDetector::writeCounterBlockFile(std::string const fname,int startACQ) { #ifdef VERBOSE std::cout<< std::endl<< "Reading Counter to \""<nChans*thisDetector->nChips]; int ret=getCounterBlock(counterVals,startACQ); - if(ret==OK) + if (ret==OK) ret=writeDataFile(fname, getTotalNumberOfChannels(), counterVals); return ret; } @@ -4099,7 +3530,7 @@ int slsDetector::getCounterBlock(short int arg[],int startACQ) { int fnum=F_READ_COUNTER_BLOCK; if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); @@ -4108,7 +3539,7 @@ int slsDetector::getCounterBlock(short int arg[],int startACQ) { else { char mess[MAX_STR_LENGTH]=""; controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -4127,19 +3558,19 @@ int slsDetector::resetCounterBlock(int startACQ) { #ifdef VERBOSE std::cout<< std::endl<< "Resetting Counter"; - if(startACQ==1) + if (startACQ==1) std::cout<<" and Restarting Acquisition"; std::cout<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -4159,23 +3590,20 @@ int slsDetector::setCounterBit(int i) { int retval=-1; char mess[MAX_STR_LENGTH]=""; - if(thisDetector->onlineFlag==ONLINE_FLAG){ -#ifdef VERBOSE - if(i ==-1) - std::cout<< "Getting counter bit from detector" << std::endl; - else if(i==0) - std::cout<< "Resetting counter bit in detector " << std::endl; - else - std::cout<< "Setting counter bit in detector " << std::endl; -#endif - if (connectControl() == OK){ + if (thisDetector->onlineFlag==ONLINE_FLAG) { + + FILE_LOG(logINFO) << + ((i == -1) ? "Getting" : ((i == 0) ? "Reseting" : "Setting")) << + " counter bit from detector" << std::endl; + + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&i,sizeof(i)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(COULD_NOT_SET_COUNTER_BIT)); } controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -4196,12 +3624,12 @@ int slsDetector::setROI(int n,ROI roiLimits[]) { //sort ascending order int temp; - for(int i=0;imyDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); + if (thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); return ret; } @@ -4230,11 +3658,11 @@ int slsDetector::setROI(int n,ROI roiLimits[]) { slsDetectorDefs::ROI* slsDetector::getROI(int &n) { sendROI(-1,NULL); n=thisDetector->nROI; - if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); + if (thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); return thisDetector->roiLimits; } -int slsDetector::getNRoi(){ +int slsDetector::getNRoi() { return thisDetector->nROI; } @@ -4251,43 +3679,46 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { roiLimits=thisDetector->roiLimits; if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&arg,sizeof(arg)); - if(arg==-1){; + if (arg==-1) {; #ifdef VERBOSE std::cout << "Getting ROI from detector" << std::endl; #endif - }else{ + } else { #ifdef VERBOSE std::cout << "Sending ROI of size " << arg << " to detector" << std::endl; #endif - for(int i = 0; i < n; ++i){ - controlSocket->SendDataOnly(&roiLimits[i].xmin, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].xmax, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].ymin, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].ymax, sizeof(int)); + for(int i = 0; i < n; ++i) { + controlSocket->SendDataOnly(&roiLimits[i].xmin, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].xmax, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].ymin, sizeof(int)); + controlSocket->SendDataOnly(&roiLimits[i].ymax, sizeof(int)); } //controlSocket->SendDataOnly(roiLimits,arg*sizeof(ROI)); } controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL){ + if (ret!=FAIL) { controlSocket->ReceiveDataOnly(&retvalsize,sizeof(retvalsize)); nrec = 0; - nrec += controlSocket->ReceiveDataOnly(&retval[i].xmin, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].xmax, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].ymin, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); + + for(int i = 0; i < retvalsize; ++i) { + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmax, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); + } //nrec = controlSocket->ReceiveDataOnly(retval,retvalsize*sizeof(ROI)); - if(nrec!=(retvalsize*(int)sizeof(ROI))){ + if (nrec!=(retvalsize*(int)sizeof(ROI))) { ret=FAIL; std::cout << " wrong size received: received " << nrec << "but expected " << retvalsize*sizeof(ROI) << std::endl; } - }else { + } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -4296,7 +3727,7 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { } //update client - if(ret==FAIL){ + if (ret==FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); } else { for(int i=0;imyDetectorType == GOTTHARD) { - configureMAC(); + ret = configureMAC(); } // update roi in receiver - if(ret == OK && thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (ret == OK && thisDetector->receiverOnlineFlag==ONLINE_FLAG) { int fnum = F_RECEIVER_SET_ROI; ret = FAIL; #ifdef VERBOSE std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->SendDataOnly(&thisDetector->nROI, sizeof(thisDetector->nROI)); - for(int i = 0; i < thisDetector->nROI; ++i){ + for(int i = 0; i < thisDetector->nROI; ++i) { dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmin, sizeof(int)); dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmax, sizeof(int)); dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymin, sizeof(int)); @@ -4335,7 +3766,7 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { if (ret == FAIL) { dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH); setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); - cprintf(RED, "Receiver %d returned error: %s", detId, mess); + FILE_LOG(logERROR, ("Receiver %d returned error: %s", detId, mess)); } disconnectData(); } @@ -4362,10 +3793,10 @@ int slsDetector::writeAdcRegister(int addr, int val) { #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Writing to adc register "<< hex<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); @@ -4373,7 +3804,7 @@ int slsDetector::writeAdcRegister(int addr, int val) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -4381,10 +3812,10 @@ int slsDetector::writeAdcRegister(int addr, int val) { } } #ifdef VERBOSE - std::cout<< "ADC Register returned "<< retval << std::endl; + FILE_LOG(logINFO) << "ADC Register returned "<< retval << std::endl; #endif if (ret==FAIL) { - std::cout<< "Write ADC to register failed " << std::endl; + FILE_LOG(logERROR) << "Write ADC to register failed " << std::endl; setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); } return retval; @@ -4400,28 +3831,23 @@ int slsDetector::activate(int const enable) { char mess[MAX_STR_LENGTH]=""; int ret = FAIL; - if(thisDetector->myDetectorType != EIGER){ - std::cout<< "Not implemented for this detector" << std::endl; + if (thisDetector->myDetectorType != EIGER) { + FILE_LOG(logERROR) << "Not implemented for this detector" << std::endl; setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); return -1; } -#ifdef VERBOSE - if(!enable) - std::cout<< "Deactivating Detector" << std::endl; - else if(enable == -1) - std::cout<< "Getting Detector activate mode" << std::endl; - else - std::cout<< "Activating Detector" << std::endl; -#endif + FILE_LOG(logDEBUG5) << + (!enable ? "Deactivating" : (enable == -1 ? "Getting activate" : "Activating")) << + " Detector" << std::endl; if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); } else { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -4433,32 +3859,32 @@ int slsDetector::activate(int const enable) { } } #ifdef VERBOSE - if(retval==1) + if (retval==1) std::cout << "Detector Activated" << std::endl; - else if(retval==0) + else if (retval==0) std::cout << "Detector Deactivated" << std::endl; else std::cout << "Detector Activation unknown:" << retval << std::endl; #endif - if(ret!=FAIL){ + if (ret!=FAIL) { int arg = thisDetector->activated; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE std::cout << "Activating/Deactivating Receiver: " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum2, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); } } #ifdef VERBOSE - if(retval==1) + if (retval==1) std::cout << "Receiver Activated" << std::endl; - else if(retval==0) + else if (retval==0) std::cout << "Receiver Deactivated" << std::endl; else std::cout << "Receiver Activation unknown:" << retval << std::endl; @@ -4477,21 +3903,21 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) { int arg = padding; int ret = OK; - if(thisDetector->myDetectorType != EIGER){ - std::cout<< "Not implemented for this detector" << std::endl; + if (thisDetector->myDetectorType != EIGER) { + FILE_LOG(logERROR) << "Not implemented for this detector" << std::endl; setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); return -1; } - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); else thisDetector->receiver_deactivatedPaddingEnable = retval; @@ -4516,7 +3942,7 @@ int slsDetector::setFlippedData(dimension d, int value) { int args[2]={X,-1}; - if(thisDetector->myDetectorType!= EIGER){ + if (thisDetector->myDetectorType!= EIGER) { std::cout << "Flipped Data is not implemented in this detector" << std::endl; setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET)); return -1; @@ -4527,27 +3953,27 @@ int slsDetector::setFlippedData(dimension d, int value) { std::cout << "Setting/Getting flipped data across axis " << d <<" with value " << value << std::endl; #endif - if(value > -1){ + if (value > -1) { thisDetector->flippedData[d] = value; args[1] = value; - }else + } else args[1] = thisDetector->flippedData[d]; args[0] = d; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); disconnectData(); } - if((args[1] != retval && args[1]>=0) || (ret==FAIL)){ + if ((args[1] != retval && args[1]>=0) || (ret==FAIL)) { ret = FAIL; setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET)); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -4562,17 +3988,17 @@ int slsDetector::setAllTrimbits(int val) { int retval = -1; int ret=OK; #ifdef VERBOSE - std::cout<< "Setting all trimbits to "<< val << std::endl; + FILE_LOG(logINFO) << "Setting all trimbits to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&val,sizeof(val)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { char mess[MAX_STR_LENGTH]=""; controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); } else { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -4583,7 +4009,7 @@ int slsDetector::setAllTrimbits(int val) { } } #ifdef VERBOSE - std::cout<< "All trimbits were set to "<< retval << std::endl; + FILE_LOG(logINFO) << "All trimbits were set to "<< retval << std::endl; #endif return retval; } @@ -4592,7 +4018,7 @@ int slsDetector::setAllTrimbits(int val) { int slsDetector::enableGapPixels(int val) { - if(val > 0 && thisDetector->myDetectorType!= EIGER) + if (val > 0 && thisDetector->myDetectorType!= EIGER) val = -1; if (val >= 0) { @@ -4604,16 +4030,16 @@ int slsDetector::enableGapPixels(int val) { int fnum=F_ENABLE_GAPPIXELS_IN_RECEIVER; int arg=val; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if((arg != retval) || (ret==FAIL)){ + if ((arg != retval) || (ret==FAIL)) { ret = FAIL; setErrorMask((getErrorMask())|(RECEIVER_ENABLE_GAPPIXELS_NOT_SET)); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -4633,7 +4059,7 @@ int slsDetector::enableGapPixels(int val) { thisDetector->nGappixels[Y]) * thisDetector->dynamicRange/8; // set data bytes for other detector ( for future use) - if(thisDetector->myDetectorType==JUNGFRAUCTB) + if (thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); } } @@ -4678,13 +4104,13 @@ int slsDetector::pulsePixel(int n,int x,int y) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); } disconnectControl(); @@ -4710,13 +4136,13 @@ int slsDetector::pulsePixelNMove(int n,int x,int y) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); } disconnectControl(); @@ -4741,13 +4167,13 @@ int slsDetector::pulseChip(int n) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&n,sizeof(n)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); } disconnectControl(); @@ -4774,21 +4200,21 @@ int slsDetector::setThresholdTemperature(int val) { #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; + FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK){ + if (connectStop() == OK) { stopSocket->SendDataOnly(&fnum,sizeof(fnum)); stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE - std::cout<< "Threshold Temperature returned "<< retval << std::endl; + FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } disconnectStop(); @@ -4812,21 +4238,21 @@ int slsDetector::setTemperatureControl(int val) { #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; + FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK){ + if (connectStop() == OK) { stopSocket->SendDataOnly(&fnum,sizeof(fnum)); stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE - std::cout<< "Threshold Temperature returned "<< retval << std::endl; + FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } disconnectStop(); @@ -4851,21 +4277,21 @@ int slsDetector::setTemperatureEvent(int val) { #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting/Getting Threshold Temperature to "<< val << std::endl; + FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK){ + if (connectStop() == OK) { stopSocket->SendDataOnly(&fnum,sizeof(fnum)); stopSocket->SendDataOnly(&arg,sizeof(arg)); stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); #ifdef VERBOSE - std::cout<< "Threshold Temperature returned "<< retval << std::endl; + FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; #endif } else { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } disconnectStop(); @@ -4884,19 +4310,19 @@ int slsDetector::setStoragecellStart(int pos) { int retval=-1; #ifdef VERBOSE - std::cout<< "Sending storage cell start index " << pos << std::endl; + FILE_LOG(logINFO) << "Sending storage cell start index " << pos << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&pos,sizeof(pos)); //check opening error controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(STORAGE_CELL_START)); - }else + } else controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); disconnectControl(); if (ret==FORCE_UPDATE) @@ -4915,8 +4341,8 @@ int slsDetector::programFPGA(std::string fname) { size_t filesize=0; char* fpgasrc = NULL; - if(thisDetector->myDetectorType != JUNGFRAU && - thisDetector->myDetectorType != JUNGFRAUCTB){ + if (thisDetector->myDetectorType != JUNGFRAU && + thisDetector->myDetectorType != JUNGFRAUCTB) { std::cout << "Not implemented for this detector" << std::endl; return FAIL; } @@ -4924,7 +4350,7 @@ int slsDetector::programFPGA(std::string fname) { //check if it exists struct stat st; - if(stat(fname.c_str(),&st)){ + if (stat(fname.c_str(),&st)) { std::cout << "Programming file does not exist" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; @@ -4971,18 +4397,18 @@ int slsDetector::programFPGA(std::string fname) { y=y| ( (( x & (1<> i) << (7-i) ); // This swaps the bits write(dst, &y, 1); } - if (filepos < 0x1000000){ + if (filepos < 0x1000000) { std::cout << "Could not convert programming file. EOF before end of flash" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - if(fclose(src)){ + if (fclose(src)) { std::cout << "Could not close source file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - if(close(dst)){ + if (close(dst)) { std::cout << "Could not close destination file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; @@ -4993,41 +4419,41 @@ int slsDetector::programFPGA(std::string fname) { //loading dst file to memory FILE* fp = fopen(destfname,"r"); - if(fp == NULL){ + if (fp == NULL) { std::cout << "Could not open rawbin file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - if(fseek(fp,0,SEEK_END)){ + if (fseek(fp,0,SEEK_END)) { std::cout << "Seek error in rawbin file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } filesize = ftell(fp); - if(filesize <= 0){ + if (filesize <= 0) { std::cout << "Could not get length of rawbin file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } rewind(fp); fpgasrc = (char*)malloc(filesize+1); - if(fpgasrc == NULL){ + if (fpgasrc == NULL) { std::cout << "Could not allocate size of program" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - if(fread(fpgasrc, sizeof(char), filesize, fp) != filesize){ + if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) { std::cout << "Could not read rawbin file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - if(fpgasrc != NULL) + if (fpgasrc != NULL) free(fpgasrc); return FAIL; } - if(fclose(fp)){ + if (fclose(fp)) { std::cout << "Could not close destination file after converting" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - if(fpgasrc != NULL) + if (fpgasrc != NULL) free(fpgasrc); return FAIL; } @@ -5039,31 +4465,31 @@ int slsDetector::programFPGA(std::string fname) { // send program from memory to detector #ifdef VERBOSE - std::cout<< "Sending programming binary to detector " << std::endl; + FILE_LOG(logINFO) << "Sending programming binary to detector " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&filesize,sizeof(filesize)); //check opening error controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); filesize = 0; } //erasing flash - if(ret!=FAIL){ - std::cout<< "This can take awhile. Please be patient..." << std::endl; + if (ret!=FAIL) { + FILE_LOG(logINFO) << "This can take awhile. Please be patient..." << std::endl; printf("Erasing Flash:%d%%\r",0); std::cout << std::flush; //erasing takes 65 seconds, printing here (otherwise need threads //in server-unnecessary) int count = 66; - while(count>0){ + while(count>0) { usleep(1 * 1000 * 1000); --count; printf("Erasing Flash:%d%%\r",(int) (((double)(65-count)/65)*100)); @@ -5079,10 +4505,10 @@ int slsDetector::programFPGA(std::string fname) { size_t unitprogramsize = 0; int currentPointer = 0; size_t totalsize= filesize; - while(ret != FAIL && (filesize > 0)){ + while(ret != FAIL && (filesize > 0)) { unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb - if(unitprogramsize > filesize) //less than 2mb + if (unitprogramsize > filesize) //less than 2mb unitprogramsize = filesize; #ifdef VERBOSE std::cout << "unitprogramsize:" << unitprogramsize << "\t filesize:" @@ -5098,9 +4524,9 @@ int slsDetector::programFPGA(std::string fname) { printf("Writing to Flash:%d%%\r", (int) (((double)(totalsize-filesize)/totalsize)*100)); std::cout << std::flush; - }else{ + } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } } @@ -5114,7 +4540,7 @@ int slsDetector::programFPGA(std::string fname) { controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } } @@ -5131,12 +4557,12 @@ int slsDetector::programFPGA(std::string fname) { (strstr(mess,"-update") == NULL)) { fnum=F_RESET_FPGA; int stopret; - if (connectStop() == OK){ + if (connectStop() == OK) { stopSocket->SendDataOnly(&fnum,sizeof(fnum)); stopSocket->ReceiveDataOnly(&stopret,sizeof(stopret)); if (stopret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } disconnectControl(); @@ -5148,7 +4574,7 @@ int slsDetector::programFPGA(std::string fname) { } //free resources - if(fpgasrc != NULL) + if (fpgasrc != NULL) free(fpgasrc); return ret; @@ -5160,21 +4586,21 @@ int slsDetector::resetFPGA() { int fnum=F_RESET_FPGA; char mess[MAX_STR_LENGTH]=""; - if(thisDetector->myDetectorType != JUNGFRAU){ + if (thisDetector->myDetectorType != JUNGFRAU) { std::cout << "Not implemented for this detector" << std::endl; return FAIL; } #ifdef VERBOSE - std::cout<< "Sending reset to FPGA " << std::endl; + FILE_LOG(logINFO) << "Sending reset to FPGA " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { // control server - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(RESET_ERROR)); } disconnectControl(); @@ -5194,25 +4620,25 @@ int slsDetector::powerChip(int ival) { char mess[MAX_STR_LENGTH]=""; int retval=-1; - if(thisDetector->myDetectorType != JUNGFRAU && - thisDetector->myDetectorType != JUNGFRAUCTB ){ + if (thisDetector->myDetectorType != JUNGFRAU && + thisDetector->myDetectorType != JUNGFRAUCTB ) { std::cout << "Not implemented for this detector" << std::endl; return FAIL; } #ifdef VERBOSE - std::cout<< "Sending power on/off/get to the chip " << std::endl; + FILE_LOG(logINFO) << "Sending power on/off/get to the chip " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&ival,sizeof(ival)); //check opening error controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(POWER_CHIP)); - }else + } else controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); disconnectControl(); if (ret==FORCE_UPDATE) @@ -5230,24 +4656,24 @@ int slsDetector::setAutoComparatorDisableMode(int ival) { char mess[MAX_STR_LENGTH]=""; int retval=-1; - if(thisDetector->myDetectorType != JUNGFRAU){ + if (thisDetector->myDetectorType != JUNGFRAU) { std::cout << "Not implemented for this detector" << std::endl; return FAIL; } #ifdef VERBOSE - std::cout<< "Enabling/disabling Auto comp disable mode " << std::endl; + FILE_LOG(logINFO) << "Enabling/disabling Auto comp disable mode " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&ival,sizeof(ival)); //check opening error controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE)); - }else + } else controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); disconnectControl(); if (ret==FORCE_UPDATE) @@ -5262,11 +4688,11 @@ int slsDetector::setAutoComparatorDisableMode(int ival) { int slsDetector::getChanRegs(double* retval,bool fromDetector) { int n=getTotalNumberOfChannels(); - if(fromDetector){ + if (fromDetector) { getModule(); } //the original array has 0 initialized - if(chanregs){ + if (chanregs) { for (int i=0; ionlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); //to exclude trimbits - if(!tb) { + if (!tb) { module.nchan=0; module.nchip=0; } sendModule(&module); //not included in module - if(gainval && (thisDetector->nGain)) + if (gainval && (thisDetector->nGain)) controlSocket->SendDataOnly(gainval,sizeof(int)*thisDetector->nGain); - if(offsetval && (thisDetector->nOffset)) + if (offsetval && (thisDetector->nOffset)) controlSocket->SendDataOnly(offsetval,sizeof(int)*thisDetector->nOffset); - if(thisDetector->myDetectorType == EIGER) { + if (thisDetector->myDetectorType == EIGER) { controlSocket->SendDataOnly(&iodelay,sizeof(iodelay)); controlSocket->SendDataOnly(&tau,sizeof(tau)); controlSocket->SendDataOnly(&e_eV,sizeof(e_eV)); @@ -5314,34 +4740,34 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - if(strstr(mess,"default tau")!=NULL) + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + if (strstr(mess,"default tau")!=NULL) setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); } disconnectControl(); if (ret==FORCE_UPDATE) - updateDetector(); + ret = updateDetector(); } } if (ret!=FAIL) { if (detectorModules) { - if(tb) { + if (tb) { (detectorModules)->nchan=module.nchan; (detectorModules)->nchip=module.nchip; } (detectorModules)->ndac=module.ndac; (detectorModules)->nadc=module.nadc; - if(tb) { + if (tb) { thisDetector->nChips=module.nchip; thisDetector->nChans=module.nchan/module.nchip; } thisDetector->nDacs=module.ndac; thisDetector->nAdcs=module.nadc; - if(thisDetector->myDetectorType != JUNGFRAU){ - if(tb) { + if (thisDetector->myDetectorType != JUNGFRAU) { + if (tb) { for (int ichip=0; ichipnChips; ++ichip) { if (chipregs) chipregs[ichip]= @@ -5389,10 +4815,10 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, } #ifdef VERBOSE - std::cout<< "Module register returned "<< retval << std::endl; + FILE_LOG(logINFO) << "Module register returned "<< retval << std::endl; #endif - return retval; + return ret; } @@ -5409,9 +4835,9 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { sls_detector_module *myMod=createModule(); int* gainval=0, *offsetval=0; - if(thisDetector->nGain) + if (thisDetector->nGain) gainval=new int[thisDetector->nGain]; - if(thisDetector->nOffset) + if (thisDetector->nOffset) offsetval=new int[thisDetector->nOffset]; @@ -5420,25 +4846,25 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { // int n; #ifdef VERBOSE - std::cout<< "getting module " << std::endl; + FILE_LOG(logINFO) << "getting module " << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { receiveModule(myMod); //extra gain and offset - eiger - if(thisDetector->nGain) + if (thisDetector->nGain) controlSocket->ReceiveDataOnly(gainval,sizeof(int)*thisDetector->nGain); - if(thisDetector->nOffset) + if (thisDetector->nOffset) controlSocket->ReceiveDataOnly(offsetval,sizeof(int)*thisDetector->nOffset); } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -5458,7 +4884,7 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { thisDetector->nDacs=myMod->ndac; thisDetector->nAdcs=myMod->nadc; - if(thisDetector->myDetectorType != JUNGFRAU){ + if (thisDetector->myDetectorType != JUNGFRAU) { for (int ichip=0; ichipnChips; ++ichip) { if (chipregs) chipregs[ichip]= @@ -5467,7 +4893,7 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { if (chanregs) { for (int i=0; inChans; ++i) { chanregs[i+ichip*thisDetector->nChans]= - myMod->chanregs[ichip*thisDetector->nChans+i]; + myMod->chanregs[ichip*thisDetector->nChans+i]; } } } @@ -5481,7 +4907,6 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { if (dacs) { for (int i=0; inDacs; ++i) { dacs[i]=myMod->dacs[i]; - //cprintf(BLUE,"dac%d:%d\n",i, myMod->dacs[i]); } } (detectorModules)->gain=myMod->gain; @@ -5506,8 +4931,8 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule() { myMod=NULL; } - if(gainval) delete[]gainval; - if(offsetval) delete[]offsetval; + if (gainval) delete[]gainval; + if (offsetval) delete[]offsetval; return myMod; } @@ -5526,7 +4951,7 @@ int slsDetector::calibratePedestal(int frames) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&frames,sizeof(frames)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); @@ -5534,7 +4959,7 @@ int slsDetector::calibratePedestal(int frames) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -5549,26 +4974,26 @@ int slsDetector::calibratePedestal(int frames) { int slsDetector::setRateCorrection(int t) { - if (getDetectorsType() == EIGER){ + if (getDetectorsType() == EIGER) { int fnum=F_SET_RATE_CORRECT; int ret=FAIL; char mess[MAX_STR_LENGTH]=""; int64_t arg = t; #ifdef VERBOSE - std::cout<< "Setting Rate Correction to " << arg << std::endl; + FILE_LOG(logINFO) << "Setting Rate Correction to " << arg << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&arg,sizeof(arg)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; - if(strstr(mess,"default tau")!=NULL) + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + if (strstr(mess,"default tau")!=NULL) setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); - if(strstr(mess,"32")!=NULL) + if (strstr(mess,"32")!=NULL) setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); else setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); @@ -5592,17 +5017,17 @@ int slsDetector::getRateCorrection() { char mess[MAX_STR_LENGTH]=""; int64_t retval = -1; #ifdef VERBOSE - std::cout<< "Setting Rate Correction to " << arg << std::endl; + FILE_LOG(logINFO) << "Setting Rate Correction to " << arg << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -5627,7 +5052,7 @@ int slsDetector::printReceiverConfiguration() { std::cout << "Receiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << std::endl; std::cout << "Receiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << std::endl; - if(thisDetector->myDetectorType == EIGER) + if (thisDetector->myDetectorType == EIGER) std::cout << "Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2) << std::endl; std::cout << std::endl; @@ -5642,15 +5067,15 @@ int slsDetector::printReceiverConfiguration() { int slsDetector::setReceiverOnline(int off) { if (off!=GET_ONLINE_FLAG) { // no receiver - if(!strcmp(thisDetector->receiver_hostname,"none")) + if (!strcmp(thisDetector->receiver_hostname,"none")) thisDetector->receiverOnlineFlag = OFFLINE_FLAG; else thisDetector->receiverOnlineFlag = off; // check receiver online - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { setReceiverTCPSocket(); // error in connecting - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==OFFLINE_FLAG) { std::cout << "cannot connect to receiver" << std::endl; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER)); } @@ -5665,23 +5090,23 @@ int slsDetector::setReceiverOnline(int off) { std::string slsDetector::checkReceiverOnline() { std::string retval = ""; //if it doesnt exits, create data socket - if(!dataSocket){ + if (!dataSocket) { //this already sets the online/offline flag setReceiverTCPSocket(); - if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG) + if (thisDetector->receiverOnlineFlag==OFFLINE_FLAG) return std::string(thisDetector->receiver_hostname); else return std::string(""); } //still cannot connect to socket, dataSocket=0 - if(dataSocket){ + if (dataSocket) { if (connectData() == FAIL) { dataSocket->SetTimeOut(5); thisDetector->receiverOnlineFlag=OFFLINE_FLAG; delete dataSocket; dataSocket=0; #ifdef VERBOSE - std::cout<< "receiver offline!" << std::endl; + FILE_LOG(logINFO) << "receiver offline!" << std::endl; #endif return std::string(thisDetector->receiver_hostname); } else { @@ -5689,7 +5114,7 @@ std::string slsDetector::checkReceiverOnline() { dataSocket->SetTimeOut(100); disconnectData(); #ifdef VERBOSE - std::cout<< "receiver online!" << std::endl; + FILE_LOG(logINFO) << "receiver online!" << std::endl; #endif return std::string(""); } @@ -5710,11 +5135,11 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver //if receiver ip given if (strcmp(name.c_str(),"")!=0) { #ifdef VERBOSE - std::cout<< "setting receiver" << std::endl; + FILE_LOG(logINFO) << "setting receiver" << std::endl; #endif strcpy(thisName,name.c_str()); strcpy(thisDetector->receiver_hostname,thisName); - if (dataSocket){ + if (dataSocket) { delete dataSocket; dataSocket=0; } @@ -5724,11 +5149,11 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver //if receiverTCPPort given if (receiver_port>0) { #ifdef VERBOSE - std::cout<< "setting data port" << std::endl; + FILE_LOG(logINFO) << "setting data port" << std::endl; #endif thisRP=receiver_port; thisDetector->receiverTCPPort=thisRP; - if (dataSocket){ + if (dataSocket) { delete dataSocket; dataSocket=0; } @@ -5740,12 +5165,12 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver try { dataSocket = new MySocketTCP(thisName, thisRP); #ifdef VERYVERBOSE - std::cout<< "Data socket connected " << + FILE_LOG(logINFO) << "Data socket connected " << thisName << " " << thisRP << std::endl; #endif } catch(...) { #ifdef VERBOSE - std::cout<< "Could not connect Data socket " << + FILE_LOG(logERROR) << "Could not connect Data socket " << thisName << " " << thisRP << std::endl; #endif dataSocket = 0; @@ -5763,7 +5188,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver case EIGER: case JUNGFRAU: case GOTTHARD: - if (thisDetector->receiverAPIVersion == 0){ + if (thisDetector->receiverAPIVersion == 0) { if (checkVersionCompatibility(DATA_PORT) == FAIL) thisDetector->receiverOnlineFlag=OFFLINE_FLAG; } @@ -5775,7 +5200,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver } else { thisDetector->receiverOnlineFlag=OFFLINE_FLAG; #ifdef VERBOSE - std::cout<< "offline!" << std::endl; + FILE_LOG(logINFO) << "offline!" << std::endl; #endif } return retval; @@ -5790,15 +5215,15 @@ int slsDetector::lockReceiver(int lock) { int arg=lock; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Locking or Unlocking Receiver " << std::endl; + FILE_LOG(logINFO) << "Locking or Unlocking Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -5815,15 +5240,15 @@ std::string slsDetector::getReceiverLastClientIP() { int ret = FAIL; char retval[INET_ADDRSTRLEN]=""; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Geting Last Client IP connected to Receiver " << std::endl; + FILE_LOG(logINFO) << "Geting Last Client IP connected to Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, retval, INET_ADDRSTRLEN); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -5835,7 +5260,7 @@ int slsDetector::exitReceiver() { int fnum = F_EXIT_RECEIVER; int ret = FAIL; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ + if (connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); disconnectData(); } @@ -5856,7 +5281,7 @@ int slsDetector::execReceiverCommand(std::string cmd) { FILE_LOG(logDEBUG5) << "Sending command to receiver " << arg; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } @@ -5877,7 +5302,7 @@ int slsDetector::updateReceiverNoWait() { n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE - std::cout << "Updating receiver last modified by " << lastClientIP << std::endl; + FILE_LOG(logINFO) << "Updating receiver last modified by " << lastClientIP << std::endl; #endif // filepath @@ -5968,12 +5393,12 @@ int slsDetector::updateReceiver() { char mess[MAX_STR_LENGTH]=""; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK){ + if (connectData() == OK) { dataSocket->SendDataOnly(&fnum,sizeof(fnum)); dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret == FAIL) { dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Receiver returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } else updateReceiverNoWait(); @@ -5994,18 +5419,18 @@ void slsDetector::sendMultiDetectorSize() { int ret = FAIL; int retval = -1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending multi detector size to Receiver (" << + FILE_LOG(logINFO) << "Sending multi detector size to Receiver (" << thisDetector->multiSize[0] << "," << thisDetector->multiSize[1] << ")" << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, thisDetector->multiSize, sizeof(thisDetector->multiSize), &retval, sizeof(retval)); disconnectData(); } - if((ret==FAIL)){ - std::cout << "Could not set position Id" << std::endl; + if ((ret==FAIL)) { + FILE_LOG(logERROR) << "Could not set position Id" << std::endl; setErrorMask((getErrorMask())|(RECEIVER_MULTI_DET_SIZE_NOT_SET)); } } @@ -6018,16 +5443,16 @@ void slsDetector::setDetectorId() { int retval = -1; int arg = detId; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending detector pos id to Receiver " << detId << std::endl; + FILE_LOG(logINFO) << "Sending detector pos id to Receiver " << detId << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if((ret==FAIL) || (retval != arg)){ - std::cout << "Could not set position Id" << std::endl; + if ((ret==FAIL) || (retval != arg)) { + FILE_LOG(logERROR) << "Could not set position Id" << std::endl; setErrorMask((getErrorMask())|(RECEIVER_DET_POSID_NOT_SET)); } } @@ -6040,16 +5465,16 @@ void slsDetector::setDetectorHostname() { char retval[MAX_STR_LENGTH]=""; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending detector hostname to Receiver " << + FILE_LOG(logINFO) << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, thisDetector->hostname, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); disconnectData(); } - if((ret==FAIL) || (strcmp(retval,thisDetector->hostname))) + if ((ret==FAIL) || (strcmp(retval,thisDetector->hostname))) setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET)); } } @@ -6073,25 +5498,25 @@ std::string slsDetector::setFilePath(std::string s) { char retval[MAX_STR_LENGTH] = ""; strcpy(arg,s.c_str()); - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending file path to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending file path to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } - if(ret!=FAIL){ + if (ret!=FAIL) { strcpy(thisDetector->receiver_filePath,retval); } else { - if(!s.empty()){ - std::cout << "file path does not exist" << std::endl; + if (!s.empty()) { + FILE_LOG(logERROR) << "file path does not exist" << std::endl; setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); } else setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } return getFilePath(); @@ -6114,11 +5539,11 @@ std::string slsDetector::setFileName(std::string s) { char retval[MAX_STR_LENGTH]=""; strcpy(arg,s.c_str()); - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending file name to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending file name to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); disconnectData(); } @@ -6126,7 +5551,7 @@ std::string slsDetector::setFileName(std::string s) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else strcpy(thisDetector->receiver_fileName,retval); - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6136,7 +5561,7 @@ std::string slsDetector::setFileName(std::string s) { int slsDetector::setReceiverFramesPerFile(int f) { - if(f < 0) + if (f < 0) return thisDetector->receiver_framesPerFile; int fnum = F_SET_RECEIVER_FRAMES_PER_FILE; @@ -6145,11 +5570,11 @@ int slsDetector::setReceiverFramesPerFile(int f) { int arg = f; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending frames per file to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending frames per file to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } @@ -6157,7 +5582,7 @@ int slsDetector::setReceiverFramesPerFile(int f) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else thisDetector->receiver_framesPerFile = retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6172,20 +5597,20 @@ slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy( int arg = f; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending frames discard policy to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending frames discard policy to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else if(ret!=FAIL && retval > -1){ + else if (ret!=FAIL && retval > -1) { thisDetector->receiver_frameDiscardMode = (frameDiscardPolicy)retval; } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6199,20 +5624,20 @@ int slsDetector::setReceiverPartialFramesPadding(int f) { int arg = f; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending partial frames enable to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending partial frames enable to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else if(ret!=FAIL && retval > -1){ + else if (ret!=FAIL && retval > -1) { thisDetector->receiver_framePadding = (bool)retval; } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6226,11 +5651,11 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { int ret = FAIL; int arg = f; int retval = -1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending file format to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending file format to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } @@ -6238,7 +5663,7 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); else thisDetector->receiver_fileFormatType = (fileFormat)retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } return getFileFormat(); @@ -6264,11 +5689,11 @@ int slsDetector::setFileIndex(int i) { int retval=-1; int arg = i; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending file index to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending file index to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } @@ -6276,7 +5701,7 @@ int slsDetector::setFileIndex(int i) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else thisDetector->receiver_fileIndex = retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6300,19 +5725,19 @@ int slsDetector::startReceiver() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Starting Receiver " << std::endl; + FILE_LOG(logINFO) << "Starting Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); - else if (ret == FAIL){ - if(strstr(mess,"UDP")!=NULL) + else if (ret == FAIL) { + if (strstr(mess,"UDP")!=NULL) setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET)); - else if(strstr(mess,"file")!=NULL) + else if (strstr(mess,"file")!=NULL) setErrorMask((getErrorMask())|(COULDNOT_CREATE_FILE)); else setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER)); @@ -6332,13 +5757,13 @@ int slsDetector::stopReceiver() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Stopping Receiver " << std::endl; + FILE_LOG(logINFO) << "Stopping Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); else if (ret == FAIL) setErrorMask((getErrorMask())|(COULDNOT_STOP_RECEIVER)); @@ -6359,15 +5784,15 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Getting Receiver Status" << std::endl; + FILE_LOG(logINFO) << "Getting Receiver Status" << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); disconnectData(); } - if(retval!=-1) + if (retval!=-1) s=(runStatus)retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } return s; @@ -6383,13 +5808,13 @@ int slsDetector::getFramesCaughtByReceiver() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Getting Frames Caught by Receiver " << std::endl; + FILE_LOG(logINFO) << "Getting Frames Caught by Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); } @@ -6411,13 +5836,13 @@ int slsDetector::getReceiverCurrentFrameIndex() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Getting Current Frame Index of Receiver " << std::endl; + FILE_LOG(logINFO) << "Getting Current Frame Index of Receiver " << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); } @@ -6434,13 +5859,13 @@ int slsDetector::resetFramesCaught() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Reset Frames Caught by Receiver" << std::endl; + FILE_LOG(logINFO) << "Reset Frames Caught by Receiver" << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); } @@ -6467,11 +5892,11 @@ int slsDetector::enableWriteToFile(int enable) { int arg = enable; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending enable file write to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending enable file write to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } @@ -6479,7 +5904,7 @@ int slsDetector::enableWriteToFile(int enable) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else thisDetector->receiver_fileWriteEnable = retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6501,11 +5926,11 @@ int slsDetector::overwriteFile(int enable) { int arg = enable; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending enable file write to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending enable file write to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } @@ -6513,7 +5938,7 @@ int slsDetector::overwriteFile(int enable) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else thisDetector->receiver_overWriteEnable = retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } @@ -6536,21 +5961,21 @@ int slsDetector::setReceiverStreamingFrequency(int freq) { int retval=-1; int arg = freq; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending read frequency to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending read frequency to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if((ret == FAIL) || (retval != freq)) { - std::cout << "could not set receiver read frequency to " << freq + if ((ret == FAIL) || (retval != freq)) { + FILE_LOG(logERROR) << "could not set receiver read frequency to " << freq <<" Returned:" << retval << std::endl; setErrorMask((getErrorMask())|(RECEIVER_STREAMING_FREQUENCY)); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } } @@ -6566,20 +5991,20 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) { int arg = time_in_ms; int retval = -1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "Sending read timer to receiver " << arg << std::endl; + FILE_LOG(logINFO) << "Sending read timer to receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } - if ((time_in_ms > 0) && (retval != time_in_ms)){ - std::cout << "could not set receiver read timer to " << time_in_ms + if ((time_in_ms > 0) && (retval != time_in_ms)) { + FILE_LOG(logERROR) << "could not set receiver read timer to " << time_in_ms <<" Returned:" << retval << std::endl; setErrorMask((getErrorMask())|(RECEIVER_STREAMING_TIMER)); } @@ -6588,7 +6013,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) { int slsDetector::enableDataStreamingToClient(int enable) { - cprintf(RED,"ERROR: Must be called from the multi Detector level\n"); + FILE_LOG(logERROR, ("Must be called from the multi Detector level\n")); return 0; } @@ -6605,23 +6030,23 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) { int arg = enable; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "***************Sending Data Streaming in Receiver " + FILE_LOG(logINFO) << "***************Sending Data Streaming in Receiver " << arg << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) { + if (ret==FAIL) { retval = -1; - std::cout << "could not set data streaming in receiver to " << + FILE_LOG(logERROR) << "could not set data streaming in receiver to " << enable <<" Returned:" << retval << std::endl; setErrorMask((getErrorMask())|(DATA_STREAMING)); } else { thisDetector->receiver_upstream = retval; - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) updateReceiver(); } } @@ -6644,13 +6069,13 @@ int slsDetector::enableTenGigabitEthernet(int i) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&i,sizeof(i)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL){ + if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(DETECTOR_TEN_GIGA)); } controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); @@ -6661,28 +6086,28 @@ int slsDetector::enableTenGigabitEthernet(int i) { } - if(ret!=FAIL){ + if (ret!=FAIL) { //must also configuremac - if((i != -1)&&(retval == i)) - if(configureMAC() != FAIL){ - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if ((i != -1)&&(retval == i)) + if (configureMAC() != FAIL) { + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { ret = FAIL; retval=-1; #ifdef VERBOSE - std::cout << "Enabling / Disabling 10Gbe in receiver: " + FILE_LOG(logINFO) << "Enabling / Disabling 10Gbe in receiver: " << i << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum2, &i, sizeof(i), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_TEN_GIGA)); } } } - if(ret != FAIL) + if (ret != FAIL) thisDetector->tenGigaEnable=retval; return retval; } @@ -6696,18 +6121,18 @@ int slsDetector::setReceiverFifoDepth(int i) { int retval=-1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - if(i ==-1) - std::cout<< "Getting Receiver Fifo Depth" << std::endl; + if (i ==-1) + FILE_LOG(logINFO) << "Getting Receiver Fifo Depth" << std::endl; else - std::cout<< "Setting Receiver Fifo Depth to " << i << std::endl; + FILE_LOG(logINFO) << "Setting Receiver Fifo Depth to " << i << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &i, sizeof(i), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(COULD_NOT_SET_FIFO_DEPTH)); } return retval; @@ -6721,18 +6146,18 @@ int slsDetector::setReceiverSilentMode(int i) { int retval=-1; - if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - if(i ==-1) - std::cout<< "Getting Receiver Silent Mode" << std::endl; + if (i ==-1) + FILE_LOG(logINFO) << "Getting Receiver Silent Mode" << std::endl; else - std::cout<< "Setting Receiver Silent Mode to " << i << std::endl; + FILE_LOG(logINFO) << "Setting Receiver Silent Mode to " << i << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &i, sizeof(i), &retval, sizeof(retval)); disconnectData(); } - if(ret==FAIL) + if (ret==FAIL) setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); else thisDetector->receiver_silentMode = retval; @@ -6750,18 +6175,18 @@ int slsDetector::restreamStopFromReceiver() { if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { #ifdef VERBOSE - std::cout << "To Restream stop dummy from Receiver via zmq" << std::endl; + FILE_LOG(logINFO) << "To Restream stop dummy from Receiver via zmq" << std::endl; #endif - if (connectData() == OK){ + if (connectData() == OK) { ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); disconnectData(); } - if(ret==FORCE_UPDATE) + if (ret==FORCE_UPDATE) ret=updateReceiver(); else if (ret == FAIL) { setErrorMask((getErrorMask())|(RESTREAM_STOP_FROM_RECEIVER)); - std::cout << " Could not restream stop dummy packet from receiver" << std::endl; + FILE_LOG(logERROR) << " Could not restream stop dummy packet from receiver" << std::endl; } } @@ -6781,7 +6206,7 @@ int slsDetector::setCTBPattern(std::string fname) { if (fd>0) { while (fread(&word, sizeof(word), 1,fd)) { setCTBWord(addr,word); - // std::cout << hex << addr << " " << word << std::dec << std::endl; + // std::cout << std::hex << addr << " " << word << std::dec << std::endl; ++addr; } @@ -6815,7 +6240,7 @@ uint64_t slsDetector::setCTBWord(int addr,uint64_t word) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); controlSocket->SendDataOnly(&addr,sizeof(addr)); @@ -6825,7 +6250,7 @@ uint64_t slsDetector::setCTBWord(int addr,uint64_t word) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -6861,7 +6286,7 @@ int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); controlSocket->SendDataOnly(&args,sizeof(args)); @@ -6873,7 +6298,7 @@ int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { n=retval[2]; } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -6906,7 +6331,7 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); controlSocket->SendDataOnly(&level,sizeof(level)); @@ -6916,7 +6341,7 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -6948,7 +6373,7 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK){ + if (connectControl() == OK) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&mode,sizeof(mode)); controlSocket->SendDataOnly(&level,sizeof(level)); @@ -6958,7 +6383,7 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; } disconnectControl(); if (ret==FORCE_UPDATE) @@ -6978,7 +6403,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( const int energy, const int e1, const int e2, int tb) { // only implemented for eiger currently (in terms of which dacs) - if(thisDetector->myDetectorType != EIGER) { + if (thisDetector->myDetectorType != EIGER) { printf("Interpolation of Trim values not implemented for this detector!\n"); return NULL; } @@ -6991,7 +6416,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); for (int i = 0; i < num_dacs_to_copy; ++i) { - if(a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { + if (a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { deleteModule(myMod); return NULL; } @@ -7017,7 +6442,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( } //Interpolate all trimbits - if(tb) { + if (tb) { for (int i = 0; inchan; i++) myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]); } @@ -7028,7 +6453,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, - int& iodelay, int& tau, sls_detector_module* myMod, int tb){ + int& iodelay, int& tau, sls_detector_module* myMod, int tb) { int nflag=0; @@ -7081,7 +6506,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string names[id++]="VDAC15"; break; default: - std::cout << "Unknown detector type - unknown format for settings file" << std::endl; + FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file" << std::endl; return NULL; } @@ -7090,7 +6515,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string #endif myfname=fname; #ifdef VERBOSE - std::cout<< "file name is "<< myfname << std::endl; + FILE_LOG(logINFO) << "file name is "<< myfname << std::endl; #endif switch (thisDetector->myDetectorType) { @@ -7103,13 +6528,13 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string infile.read((char*)&tau,sizeof(tau)); #ifdef VERBOSE for(int i=0;indac;i++) - std::cout << "dac " << i << ":" << myMod->dacs[i] << std::endl; - std::cout << "iodelay:" << iodelay << std::endl; - std::cout << "tau:" << tau << std::endl; + FILE_LOG(logINFO) << "dac " << i << ":" << myMod->dacs[i] << std::endl; + FILE_LOG(logINFO) << "iodelay:" << iodelay << std::endl; + FILE_LOG(logINFO) << "tau:" << tau << std::endl; #endif - if(tb) { + if (tb) { infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); - if(infile.eof()){ + if (infile.eof()) { std::cout<> sargname >> ival; - for (i=0;idacs[i]=ival; idac++; #ifdef VERBOSE @@ -7155,8 +6580,8 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string #ifdef VERBOSE std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; #endif - }else - std::cout<< "Unknown dac " << sargname << std::endl; + } else + FILE_LOG(logERROR) << "Unknown dac " << sargname << std::endl; infile.close(); strcpy(thisDetector->settingsFile,fname.c_str()); @@ -7169,7 +6594,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string break; default: - std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl; + FILE_LOG(logERROR) << "Unknown detector type - don't know how to read file" << myfname << std::endl; infile.close(); deleteModule(myMod); return NULL; @@ -7188,7 +6613,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, - int iodelay, int tau){ + int iodelay, int tau) { std::ofstream outfile; @@ -7226,7 +6651,7 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, names[id++]="VDAC15"; break; default: - std::cout << "Unknown detector type - unknown format for settings file" << std::endl; + FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file" << std::endl; return FAIL; } @@ -7240,9 +6665,9 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, iv = 1150; #ifdef VERBOSE for(int i=0;i(&iodelay), sizeof(iodelay)); @@ -7269,7 +6694,7 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, outfile.close(); return OK; } - std::cout<< "could not open SETTINGS file " << fname << std::endl; + FILE_LOG(logERROR) << "could not open SETTINGS file " << fname << std::endl; return FAIL; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 35c24d620..d45fc09eb 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1295,7 +1295,7 @@ public: * @param gainval pointer to extra gain values * @param offsetval pointer to extra offset values * @param tb 1 to include trimbits, 0 to exclude (used for eiger) - * @returns current register value + * @returns ok or fail * \sa ::sls_detector_module */ int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index c5257028b..ad97a15f2 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -398,64 +398,6 @@ private: -class Moench02Data : public GeneralData { - - public: - - /** Bytes Per Adc */ - const static uint32_t bytesPerAdc = (40*2); - - /** Constructor */ - Moench02Data(){ - myDetectorType = slsDetectorDefs::MOENCH; - nPixelsX = 160; - nPixelsY = 160; - headerSizeinPacket = 4; - dataSize = 1280; - packetSize = 1286; - packetsPerFrame = 40; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFF00; - frameIndexOffset = 8; - packetIndexMask = 0xFF; - maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header); - defaultFifoDepth = 2500; - }; - - /** - * Print all variables - */ - void Print() const { - GeneralData::Print(); - FILE_LOG(logINFO) << "Bytes Per Adc: " << bytesPerAdc; - } -}; - - -class Moench03Data : public GeneralData { - - public: - - /** Constructor */ - Moench03Data(){ - myDetectorType = slsDetectorDefs::MOENCH; - nPixelsX = 400; - nPixelsY = 400; - headerSizeinPacket = 22; - dataSize = 8192; - packetSize = headerSizeinPacket + dataSize; - packetsPerFrame = 40; - imageSize = dataSize*packetsPerFrame; - frameIndexMask = 0xFFFFFFFF; - frameIndexOffset = (6+8); - packetIndexMask = 0xFFFFFFFF; - maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE; - fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header); - defaultFifoDepth = 2500; - }; -}; - class JCTBData : public GeneralData { diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index d1ad6bace..93f5dbfaa 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -334,7 +334,7 @@ int slsReceiverTCPIPInterface::exec_command() { int slsReceiverTCPIPInterface::exit_server() { cprintf(RED,"Closing server\n"); - + memset(mess, 0, sizeof(mess)); ret = OK; interface->Server_SendResult(false, ret, NULL, 0); return GOODBYE; @@ -350,6 +350,7 @@ int slsReceiverTCPIPInterface::lock_receiver() { // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, &lock, sizeof(lock)) == FAIL) return FAIL; + FILE_LOG(logDEBUG5) << "Locking Server to " << lock; // execute action if (lock >= 0) { @@ -362,7 +363,6 @@ int slsReceiverTCPIPInterface::lock_receiver() { } else interface->Server_LockedError(ret, mess); } - return interface->Server_SendResult(true, ret, &lockStatus,sizeof(lockStatus), mess); } @@ -548,8 +548,8 @@ int slsReceiverTCPIPInterface::send_update() { int slsReceiverTCPIPInterface::get_id(){ ret = OK; + memset(mess, 0, sizeof(mess)); int64_t retval = getReceiverVersion(); - return interface->Server_SendResult(true, ret, &retval, sizeof(retval)); } @@ -609,8 +609,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){ } //get retval = myDetectorType; - - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); + return interface->Server_SendResult(false, ret, &retval, sizeof(retval), mess); } @@ -700,6 +699,7 @@ int slsReceiverTCPIPInterface::set_roi() { int slsReceiverTCPIPInterface::setup_udp(){ + memset(mess, 0, sizeof(mess)); char args[3][MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -774,29 +774,38 @@ int slsReceiverTCPIPInterface::set_timer() { // base object not null if (ret == OK) { + FILE_LOG(logDEBUG5, ("Setting timer index %d to %lld ns\n", index[0], index[1])); + char timername[100] = {0}; + // set if (index[1] >= 0) { // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { switch (index[0]) { case ACQUISITION_TIME: + strcpy(timername, "exptime"); ret = receiver->setAcquisitionTime(index[1]); break; case FRAME_PERIOD: + strcpy(timername, "period"); ret = receiver->setAcquisitionPeriod(index[1]); break; case FRAME_NUMBER: case CYCLES_NUMBER: case STORAGE_CELL_NUMBER: + strcpy(timername, "frames_cycles_storagecells"); receiver->setNumberOfFrames(index[1]); break; case SUBFRAME_ACQUISITION_TIME: + strcpy(timername, "subexptime"); receiver->setSubExpTime(index[1]); break; case SUBFRAME_DEADTIME: + strcpy(timername, "subdeadtime"); receiver->setSubPeriod(index[1] + receiver->getSubExpTime()); break; case SAMPLES_JCTB: + strcpy(timername, "samples"); if (myDetectorType != JUNGFRAUCTB) { ret = FAIL; sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]); @@ -806,6 +815,7 @@ int slsReceiverTCPIPInterface::set_timer() { receiver->setNumberofSamples(index[1]); break; default: + strcpy(timername, "unknown"); ret = FAIL; sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); FILE_LOG(logERROR) << mess; @@ -849,12 +859,11 @@ int slsReceiverTCPIPInterface::set_timer() { // check if (ret == OK && index[1] >= 0 && retval != index[1]) { ret = FAIL; - strcpy(mess,"Could not set timer\n"); + strcpy(mess,"Could not set timer %s\n", timername); FILE_LOG(logERROR) << mess; } FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1873,8 +1882,6 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, &arg, sizeof(arg)) == FAIL) return FAIL; - - FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg; int64_t client_requiredVersion = arg; int64_t rx_apiVersion = APIRECEIVER; @@ -1902,7 +1909,6 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { FILE_LOG(logERROR) << mess; } else FILE_LOG(logINFO) << "Compatibility with Client: Successful"; - return interface->Server_SendResult(true, ret, NULL, 0, mess); } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 3d5bc07e4..fa7b9106a 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -92,7 +92,6 @@ public: enum { OK, /**< function succeeded */ FAIL, /**< function failed */ - FINISHED, /**< acquisition finished */ FORCE_UPDATE }; From 33ac63d14abb3ebf359d1576fc6ab9c724e01810 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 26 Oct 2018 17:40:18 +0200 Subject: [PATCH 5/7] still updating slsdetector.cpp --- .../slsDetectorFunctionList.c | 162 +- .../slsDetectorServer_defs.h | 2 - .../slsDetectorServer/communication_funcs.c | 246 +- .../slsDetectorServer/communication_funcs.h | 2 - .../slsDetectorFunctionList.h | 11 +- .../slsDetectorServer_funcs.c | 280 +- .../multiSlsDetector/multiSlsDetector.cpp | 33 +- .../multiSlsDetector/multiSlsDetector.h | 20 +- .../slsDetector/slsDetector.cpp | 2977 +++++++---------- slsDetectorSoftware/slsDetector/slsDetector.h | 73 +- .../slsDetector/slsDetectorCommand.cpp | 27 +- .../include/slsReceiverImplementation.h | 8 +- .../src/slsReceiverImplementation.cpp | 49 +- .../src/slsReceiverTCPIPInterface.cpp | 117 +- slsSupportLib/include/sls_detector_defs.h | 15 +- slsSupportLib/include/sls_detector_funcs.h | 2 - 16 files changed, 1501 insertions(+), 2523 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index d1cfcf860..d03c23f3d 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -24,7 +24,6 @@ const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","V int default_tau_from_file= -1; enum detectorSettings thisSettings; sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; int *detectorChans=NULL; int *detectorDacs=NULL; int *detectorAdcs=NULL; @@ -383,26 +382,24 @@ void allocateDetectorStructureMemory() { //Allocation of memory detectorModules=malloc(sizeof(sls_detector_module)); - detectorChips=malloc(NCHIP*sizeof(int)); detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); detectorDacs=malloc(NDAC*sizeof(int)); detectorAdcs=malloc(NADC*sizeof(int)); FILE_LOG(logDEBUG5, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); - FILE_LOG(logDEBUG5, ("chips from 0x%x to 0x%x\n",detectorChips, detectorChips)); FILE_LOG(logDEBUG5, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); FILE_LOG(logDEBUG5, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); (detectorModules)->dacs=detectorDacs; (detectorModules)->adcs=detectorAdcs; - (detectorModules)->chipregs=detectorChips; (detectorModules)->chanregs=detectorChans; (detectorModules)->ndac=NDAC; (detectorModules)->nadc=NADC; (detectorModules)->nchip=NCHIP; (detectorModules)->nchan=NCHIP*NCHAN; - (detectorModules)->gain=0; - (detectorModules)->offset=0; (detectorModules)->reg=0; + (detectorModules)->iodelay=0; + (detectorModules)->tau=0; + (detectorModules)->eV=0; thisSettings = UNINITIALIZED; // if trimval requested, should return -1 to acknowledge unknown @@ -805,63 +802,123 @@ int64_t getTimeLeft(enum timerIndex ind) { -/* parameters - channel, chip, module, settings */ +/* parameters - channel, module, settings */ -int setModule(sls_detector_module myMod, int delay) { - int retval[2]; - int i; +int setModule(sls_detector_module myMod, char* mess) { + FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg)); - //copy module locally (module number, serial number, gain offset, - //dacs (pointless), trimbit values(if needed) - if (detectorModules) - if (copyModule(detectorModules,&myMod) == FAIL) - return FAIL; - // settings setSettings( (enum detectorSettings)myMod.reg); + //copy module locally (module number, serial number + //dacs (pointless), trimbit values(if needed) + if (detectorModules) { + if (copyModule(detectorModules,&myMod) == FAIL) { + sprintf(mess, "Could not copy module\n"); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined\n")); + return FAIL; + } + } + // iodelay - if (setIODelay(delay)!= delay) { - FILE_LOG(logERROR, ("Could not set iodelay %d\n", delay)); + if (setIODelay(myMod.iodelay)!= myMod.iodelay) { + sprintf(mess, "Could not set module. Could not set iodelay %d\n", myMod.iodelay); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined\n")); return FAIL; } - // dacs - for(i=0;i= 0) + setThresholdEnergy(myMod.eV); + else { + // (loading a random trim file) (dont return fail) + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n")); + } + // dacs + { + int i = 0; + int retval[2] = {0, 0}; + for(i = 0; i < myMod.ndac; ++i) { + setDAC((enum DACINDEX)i, myMod.dacs[i] , 0, retval); + if (myMod.dacs[i] != retval[0]) { + sprintf(mess, "Could not set module. Could not set dac %d\n", i); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined\n")); + return FAIL; + } + } + } // trimbits #ifndef VIRTUAL - if (myMod.nchan==0 && myMod.nchip == 0) { + if (myMod.nchan == 0) { FILE_LOG(logINFO, ("Setting module without trimbits\n")); } else { FILE_LOG(logINFO, ("Setting module with trimbits\n")); //includ gap pixels unsigned int tt[263680]; - int iy,ichip,ix,ip=0,ich=0; - for(iy=0;iy<256;iy++) { - for (ichip=0; ichip<4; ichip++) { - for(ix=0;ix<256;ix++) { - tt[ip++]=myMod.chanregs[ich++]; + int iy, ichip, ix, ip = 0, ich = 0; + for (iy = 0; iy < 256; ++iy) { + for (ichip = 0; ichip < 4; ++ichip) { + for (ix = 0; ix < 256; ++ix) { + tt[ip++] = myMod.chanregs[ich++]; } - if (ichip<3) { - tt[ip++]=0; - tt[ip++]=0; + if (ichip < 3) { + tt[ip++] = 0; + tt[ip++] = 0; } } } //set trimbits - if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt)) { - FILE_LOG(logERROR, ("Could not set trimbits\n")); + if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) { + sprintf(mess, "Could not set module. Could not set trimbits\n"); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n")); return FAIL; } } + + + //rate correction + //switch off rate correction: no value read from load settings) + if (myMod.tau == -1) { + if (getRateCorrectionEnable()) { + setRateCorrection(0); + sprintf(mess,"Cannot set module. Cannot set Rate correction. " + "No default tau provided. Deactivating Rate Correction\n"); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n")); + return FAIL; + } + } + //normal tau value (only if enabled) + else { + setDefaultSettingsTau_in_nsec(myMod.tau); + if (getRateCorrectionEnable()) { + int64_t retvalTau = setRateCorrection(myMod.tau); + if (myMod.tau != retvalTau) { + sprintf(mess, "Cannot set module. Could not set rate correction\n"); + FILE_LOG(logERROR, (mess)); + setSettings(UNDEFINED); + FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n")); + return FAIL; + } + } + } #endif - return thisSettings; + return OK; } @@ -882,13 +939,13 @@ int getModule(sls_detector_module *myMod) { tt = Feb_Control_GetTrimbits(); //exclude gap pixels - int iy,ichip,ix,ip=0,ich=0; - for(iy=0;iy<256;iy++) { - for (ichip=0; ichip<4; ichip++) { - for(ix=0;ix<256;ix++) { - myMod->chanregs[ich++]=tt[ip++]; + int iy, ichip, ix, ip = 0, ich = 0; + for (iy = 0; iy < 256; ++iy) { + for (ichip = 0; ichip < 4; ++ichip) { + for (ix = 0; ix < 256; ++iy) { + myMod->chanregs[ich++] = tt[ip++]; } - if (ichip<3) { + if (ichip < 3) { ip++; ip++; } @@ -1728,7 +1785,7 @@ void readFrame(int *ret, char *mess) { int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { - int ichip, idac, ichan, iadc; + int idac, ichan, iadc; int ret=OK; FILE_LOG(logDEBUG5, ("Copying module %x to module %x\n",srcMod,destMod)); @@ -1738,11 +1795,6 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { destMod->serialnumber=srcMod->serialnumber; } //no trimbit feature - if (destMod->nchip && ((srcMod->nchip)>(destMod->nchip))) { - FILE_LOG(logINFO, ("Number of chip of source is larger than number of chips of destination\n")); - return FAIL; - } - //no trimbit feature if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) { FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n")); return FAIL; @@ -1758,7 +1810,6 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { FILE_LOG(logDEBUG5, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac)); FILE_LOG(logDEBUG5, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc)); - FILE_LOG(logDEBUG5, ("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip)); FILE_LOG(logDEBUG5, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan)); destMod->ndac=srcMod->ndac; destMod->nadc=srcMod->nadc; @@ -1766,23 +1817,22 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { destMod->nchan=srcMod->nchan; if (srcMod->reg>=0) destMod->reg=srcMod->reg; + if (srcMod->iodelay>=0) + destMod->iodelay=srcMod->iodelay; + if (srcMod->tau>=0) + destMod->tau=srcMod->tau; + if (srcMod->eV>=0) + destMod->eV=srcMod->eV; FILE_LOG(logDEBUG5, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg )); - if (srcMod->gain>=0) - destMod->gain=srcMod->gain; - if (srcMod->offset>=0) - destMod->offset=srcMod->offset; - if ((destMod->nchip!=0) || (destMod->nchan!=0)) { - for (ichip=0; ichip<(srcMod->nchip); ichip++) { - if (*((srcMod->chipregs)+ichip)>=0) - *((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip); - } + if (destMod->nchan!=0) { for (ichan=0; ichan<(srcMod->nchan); ichan++) { if (*((srcMod->chanregs)+ichan)>=0) *((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan); } } else FILE_LOG(logINFO, ("Not Copying trimbits\n")); + for (idac=0; idac<(srcMod->ndac); idac++) { if (*((srcMod->dacs)+idac)>=0) { *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); @@ -1811,8 +1861,6 @@ int getNumberOfChips() {return NCHIP;} int getNumberOfDACs() {return NDAC;} int getNumberOfADCs() {return NADC;} int getNumberOfChannelsPerChip() {return NCHAN;} -int getNumberOfGains() {return NGAIN;} -int getNumberOfOffsets() {return NOFFSET;} diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h index dfc4d745b..8788688c5 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h @@ -49,8 +49,6 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE}; #define NCHIP (4) #define NADC (0) #define NDAC (16) -#define NGAIN (0) -#define NOFFSET (0) #define TEN_GIGA_BUFFER_SIZE (4112) diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.c b/slsDetectorServers/slsDetectorServer/communication_funcs.c index a82f9bd82..ed9e79d6d 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.c @@ -351,64 +351,36 @@ int receiveDataOnly(int file_des, void* buf,int length) { int sendModule(int file_des, sls_detector_module *myMod) { - return sendModuleGeneral(file_des, myMod, 1); -} - - -int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { int ts = 0, n = 0; - int nChips = myMod->nchip; - int nChans = myMod->nchan; - int nAdcs = myMod->nadc; - int nDacs = myMod->ndac; - - // send module structure n = sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); + n = sendData(file_des,&(myMod->nchan), sizeof(myMod->nchan), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); + n = sendData(file_des,&(myMod->nchip), sizeof(myMod->nchip), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); + n = sendData(file_des,&(myMod->ndac), sizeof(myMod->ndac), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); + n = sendData(file_des,&(myMod->nadc), sizeof(myMod->nadc), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); + n = sendData(file_des,&(myMod->reg), sizeof(myMod->reg), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); + n = sendData(file_des,&(myMod->iodelay), sizeof(myMod->iodelay), INT32); if (!n) return -1; ts += n; - n = sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); + n = sendData(file_des,&(myMod->tau), sizeof(myMod->tau), INT32); if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("module of size %d sent\n",ts)); - - // send dac - n = sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32); + n = sendData(file_des,&(myMod->eV), sizeof(myMod->eV), INT32); if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("dacs of size %d sent\n",ts)); - { - int idac; - for (idac = 0; idac < nDacs; idac++) - FILE_LOG(logDEBUG5, ("dac %d is %d\n",idac,(int)myMod->dacs[idac])); - } - - // send adc - n = sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32); + // dacs + n = sendData(file_des,myMod->dacs, sizeof(int)*(myMod->ndac), INT32); if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("adcs of size %d sent\n", ts)); - - // some detectors dont require sending all trimbits etc. - if(sendAll) { - // chips - n = sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32); - if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("chips of size %d sent\n", ts)); - - // channels - n = sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32); - FILE_LOG(logDEBUG5, ("chans of size %d sent - %d\n", ts, myMod->nchan)); - if (!n) return -1; ts += n; - } - + // adcs + n = sendData(file_des,myMod->adcs, sizeof(int)*(myMod->nadc), INT32); + if (!n) return -1; ts += n; + // channels +#ifdef EIGERD + n = sendData(file_des,myMod->chanregs, sizeof(int) * (myMod->nchan), INT32); + if (!n) return -1; ts += n; +#endif FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg)); return ts; } @@ -416,149 +388,57 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) { int receiveModule(int file_des, sls_detector_module* myMod) { - return receiveModuleGeneral(file_des,myMod,1); -} - -int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) { int ts = 0, n = 0; - int *dacptr = myMod->dacs; - int *adcptr = myMod->adcs; - int *chipptr = myMod->chipregs, *chanptr = myMod->chanregs; - int nChips, nchipold = myMod->nchip, nchipdiff; - int nChans, nchanold = myMod->nchan, nchandiff; - int nDacs, ndold = myMod->ndac, ndacdiff; - int nAdcs, naold = myMod->nadc, nadcdiff; - n = receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->ndac),sizeof(myMod->ndac),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->nadc),sizeof(myMod->nadc),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->reg),sizeof(myMod->reg),INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->gain), sizeof(myMod->gain),OTHER); - if (!n) return -1; ts += n; - n = receiveData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER); - if (!n) return -1; ts += n; - - myMod->dacs = dacptr; - myMod->adcs = adcptr; - myMod->chipregs = chipptr; - myMod->chanregs = chanptr; - + int nDacs = myMod->ndac; + int nAdcs = myMod->nadc; #ifdef EIGERD -//exclude sending of trimbtis, nchips = 0,nchans = 0 in that case - if(myMod->nchip == 0 && myMod->nchan == 0) { - receiveAll = 0; - nchipold = 0; - nchanold = 0; - } + int nChans = myMod->nchan; // can be zero for no trimbits #endif - - - nChips = myMod->nchip; - nchipdiff = nChips-nchipold; - if (nchipold != nChips) { - FILE_LOG(logERROR, ("received wrong number of chips\n")); + n = receiveData(file_des,&(myMod->serialnumber), sizeof(myMod->serialnumber), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nchan), sizeof(myMod->nchan), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nchip), sizeof(myMod->nchip), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->ndac), sizeof(myMod->ndac), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->nadc), sizeof(myMod->nadc), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->reg), sizeof(myMod->reg), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->iodelay), sizeof(myMod->iodelay), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->tau), sizeof(myMod->tau), INT32); + if (!n) return -1; ts += n; + n = receiveData(file_des,&(myMod->eV), sizeof(myMod->eV), INT32); + if (!n) return -1; ts += n; + // dacs + if (nDacs != (myMod->ndac)) { + FILE_LOG(logERROR, ("received wrong number of dacs. " + "Expected %d, got %d\n", nDacs, myMod->ndac)); + return 0; } - else - FILE_LOG(logDEBUG5, ("received %d chips\n",nChips)); - - nChans = myMod->nchan; - nchandiff = nChans-nchanold; - if (nchanold != nChans) { - FILE_LOG(logERROR, ("received wrong number of channels\n")); + n = receiveData(file_des,&(myMod->dacs), sizeof(int) * (myMod->ndac), INT32); + if (!n) return -1; ts += n; + // adcs + if (nAdcs != (myMod->nadc)) { + FILE_LOG(logERROR, ("received wrong number of adcs. " + "Expected %d, got %d\n", nAdcs, myMod->nadc)); + return 0; } - else - FILE_LOG(logDEBUG5, ("received %d chans\n",nChans)); - - - nDacs = myMod->ndac; - ndacdiff = nDacs-ndold; - if (ndold != nDacs) { - FILE_LOG(logERROR, ("received wrong number of dacs\n")); - } - else - FILE_LOG(logDEBUG5, ("received %d dacs\n",nDacs)); - - nAdcs = myMod->nadc; - nadcdiff = nAdcs-naold; - if (naold != nAdcs) { - FILE_LOG(logERROR, ("received wrong number of adcs\n")); - } - else - FILE_LOG(logDEBUG5, ("received %d adcs\n",nAdcs)); - if (ndacdiff <= 0) { - n = receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32); - if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("dacs received\n")); - int id; - for (id = 0; iddacs[id])); - } else { - dacptr = (int*)malloc(ndacdiff*sizeof(int)); - myMod->ndac = ndold; - n = receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32); - if (!n) return -1; ts += n; - free(dacptr); - return FAIL; - } - - if (nadcdiff <= 0) { - n = receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32); - if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("adcs received\n")); - } else { - adcptr = (int*)malloc(nadcdiff*sizeof(int)); - myMod->nadc = naold; - n = receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32); - if (!n) return -1; ts += n; - free(adcptr); - return FAIL; - } - - - // some detectors dont require sending all trimbits etc. - if(receiveAll){ - - if (nchipdiff <= 0) { - n = receiveData(file_des,myMod->chipregs, sizeof(int)*nChips,INT32); - if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("chips received\n")); - } else { - chipptr = (int*)malloc(nchipdiff*sizeof(int)); - myMod->nchip = nchipold; - n = receiveData(file_des,myMod->chipregs, sizeof(int)*nchipold,INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,chipptr, sizeof(int)*nchipdiff,INT32); - if (!n) return -1; ts += n; - free(chipptr); - return FAIL; - } - - if (nchandiff <= 0) { - n = receiveData(file_des,myMod->chanregs, sizeof(int)*nChans,INT32); - if (!n) return -1; ts += n; - FILE_LOG(logDEBUG5, ("chans received\n")); - } else { - chanptr = (int*)malloc(nchandiff*sizeof(int)); - myMod->nchan = nchanold; - n = receiveData(file_des,myMod->chanregs, sizeof(int)*nchanold,INT32); - if (!n) return -1; ts += n; - n = receiveData(file_des,chanptr, sizeof(int)*nchandiff,INT32); - if (!n) return -1; ts += n; - free(chanptr); - return FAIL; - } + n = receiveData(file_des,&(myMod->adcs), sizeof(int) * (myMod->nadc), INT32); + if (!n) return -1; ts += n; + // channels +#ifdef EIGERD + if (((myMod->nchan) != 0 ) || // no trimbits + (nChans != (myMod->nchan))) { // with trimbits + FILE_LOG(logERROR, ("received wrong number of channels. " + "Expected %d, got %d\n", nChans, (myMod->nchan))); + return 0; } + n = receiveData(file_des,&(myMod->chanregs), sizeof(int) * (myMod->nchan), INT32); + if (!n) return -1; ts += n; +#endif FILE_LOG(logDEBUG5, ("received module of size %d register %x\n",ts,myMod->reg)); return ts; } diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.h b/slsDetectorServers/slsDetectorServer/communication_funcs.h index 0089fc16e..25cb8ef9a 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.h +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.h @@ -38,9 +38,7 @@ int sendDataOnly(int file_des, void* buf,int length); int receiveDataOnly(int file_des, void* buf,int length); int sendModule(int file_des, sls_detector_module *myMod); -int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll); int receiveModule(int file_des, sls_detector_module* myMod); -int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll); /** * Servers sets and prints error message for locked server diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index 05861f3e0..592083234 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -102,12 +102,7 @@ int64_t getTimeLeft(enum timerIndex ind); // parameters - module, settings - -#ifdef EIGERD -int setModule(sls_detector_module myMod, int delay); -#else -int setModule(sls_detector_module myMod); -#endif +int setModule(sls_detector_module myMod, char* mess); int getModule(sls_detector_module *myMod); enum detectorSettings setSettings(enum detectorSettings sett); enum detectorSettings getSettings(); @@ -233,10 +228,6 @@ int getTotalNumberOfChannels(); int getNumberOfChips(); int getNumberOfDACs(); int getNumberOfADCs(); -#ifdef EIGERD -int getNumberOfGains(); -int getNumberOfOffsets(); -#endif int getNumberOfChannelsPerChip(); diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index ab06fb6e4..94c830ae3 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -156,7 +156,6 @@ const char* getFunctionName(enum detFuncs func) { case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; - case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL"; case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; @@ -221,7 +220,6 @@ void function_table() { flist[F_LOAD_IMAGE] = &load_image; flist[F_READ_COUNTER_BLOCK] = &read_counter_block; flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block; - flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal; flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga; flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits; flist[F_SET_CTB_PATTERN] = &set_ctb_pattern; @@ -304,7 +302,7 @@ int M_nofunc(int file_des) { memset(mess, 0, sizeof(mess)); // to receive any arguments - int n = 0; + int n = 1; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); @@ -320,7 +318,7 @@ int M_nofuncMode(int file_des) { memset(mess, 0, sizeof(mess)); // to receive any arguments - int n = 0; + int n = 1; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); @@ -836,112 +834,83 @@ int read_register(int file_des) { int set_module(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int retval = -1; + enum detectorSettings retval = -1; sls_detector_module module; int *myDac = NULL; int *myAdc = NULL; - int *myChip = NULL; int *myChan = NULL; -#ifdef EIGERD - int ioDelay = -1; - int tau = -1; - int eV = -1; -#endif + module.dacs = NULL; + module.adcs = NULL; + module.chanregs = NULL; // allocate to receive arguments - // infinite loop to break out when FAIL or a final OK - while(1) { - // allocate dacs - myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); - // error - if (getNumberOfDACs() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess, "Could not allocate dacs\n"); - FILE_LOG(logERROR,(mess)); - break; - } + // allocate dacs + myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); + // error + if (getNumberOfDACs() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess, "Could not allocate dacs\n"); + FILE_LOG(logERROR,(mess)); + } else module.dacs = myDac; - // allocate adcs + // allocate adcs + if (ret == OK) { myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); // error if (getNumberOfADCs() > 0 && myAdc == NULL) { ret = FAIL; sprintf(mess,"Could not allocate adcs\n"); FILE_LOG(logERROR,(mess)); - break; - } - module.adcs=myAdc; + } else + module.adcs = myAdc; + } - // no need to allocate chips and chans for jungfrau, too much memory -#ifdef JUNGFRAUD - module.chipregs = NULL; - module.chanregs = NULL; -#else - // allocate chips - myChip = (int*)malloc(getNumberOfChips() * sizeof(int)); - if (getNumberOfChips() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"Could not allocate chips\n"); - FILE_LOG(logERROR,(mess)); - break; - } - module.chipregs = myChip; - - // allocate chans + // allocate chans +#ifdef EIGERD + if (ret == OK) { myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); if (getTotalNumberOfChannels() > 0 && myChan == NULL) { ret = FAIL; sprintf(mess,"Could not allocate chans\n"); FILE_LOG(logERROR,(mess)); - break; - } - module.chanregs=myChan; + } else + module.chanregs = myChan; + } #endif + // receive arguments + if (ret == OK) { module.nchip = getNumberOfChips(); module.nchan = getTotalNumberOfChannels(); module.ndac = getNumberOfDACs(); module.nadc = getNumberOfADCs(); - - // receive arguments (0 to partially receive module without trimbits - if (receiveModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1) < 0) { - if (myChip != NULL) free(myChip); - if (myChan != NULL) free(myChan); + int ts = receiveModule(file_des, &module); + if (ts < 0) { + if (myChan != NULL) free(myChan); if (myDac != NULL) free(myDac); if (myAdc != NULL) free(myAdc); return printSocketReadError(); } FILE_LOG(logDEBUG5, ("module register is %d, nchan %d, nchip %d, " - "ndac %d, nadc %d, gain %f, offset %f\n", + "ndac %d, nadc %d, iodelay %d, tau %d, eV %d\n", module.reg, module.nchan, module.nchip, - module.ndac, module.nadc, module.gain,module.offset)); - -#ifdef EIGERD - int args[3] = {-1, -1}; - if (receiveData(file_des, args, sizeof(args), INT32) < 0) { - if (myChip != NULL) free(myChip); - if (myChan != NULL) free(myChan); - if (myDac != NULL) free(myDac); - if (myAdc != NULL) free(myAdc); - return printSocketReadError(); - } - ioDelay = args[0]; - tau = args[1]; - eV = args[2]; - FILE_LOG(logDEBUG5, ("ioDelay: %d, tau: d, ev:%d\n", ioDelay, tau, eV)); -#endif + module.ndac, module.nadc, module.iodelay, module.tau, module.eV)); + // should at least have a dac + if (ts <= sizeof(sls_detector_module)) { + ret = FAIL; + sprintf(mess, "Cannot set module. Received incorrect number of dacs or adcs or channels\n"); + FILE_LOG(logERROR,(mess)); + } } - // receive all arguments if (ret == FAIL) { - int n = 0; + int n = 1; while (n > 0) n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER); } - // only set else if (Server_VerifyLock() != FAIL) { // check index @@ -972,52 +941,12 @@ int set_module(int file_des) { break; } - // set -#ifndef EIGERD - retval = setModule(module); - validate(module.reg, retval, "set module (settings)", 0); - // eiger -#else - //set dacs, trimbits and iodelay - ret = setModule(module, ioDelay); - //set threshhold - if (eV >= 0) - setThresholdEnergy(eV); - else { - //changes settings to undefined (loading a random trim file) - setSettings(UNDEFINED); - FILE_LOG(logERROR, ("Settings has been changed to undefined " - "(random trim file)\n")); - } - //rate correction - //switch off rate correction: no value read from load calib/load settings) - if (tau == -1) { - if (getRateCorrectionEnable()) { - setRateCorrection(0); - ret = FAIL; - sprintf(mess,"Cannot set module. Cannot set Rate correction. " - "No default tau provided. Deactivating Rate Correction\n"); - FILE_LOG(logERROR, (mess)); - } - } - //normal tau value (only if enabled) - else { - setDefaultSettingsTau_in_nsec(tau); - if (getRateCorrectionEnable()) { - int64_t retvalTau = setRateCorrection(tau); - if (tau != retvalTau) { - ret = FAIL; - sprintf(mess, "Cannot set module. Could not set rate correction\n"); - FILE_LOG(logERROR, (mess)); - } - } - } + ret = setModule(module, mess); retval = getSettings(); -#endif + validate(module.reg, (int)retval, "set module (settings)", 0); FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); } - if (myChip != NULL) free(myChip); - if (myChan != NULL) free(myChan); + if (myChan != NULL) free(myChan); if (myDac != NULL) free(myDac); if (myAdc != NULL) free(myAdc); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -1026,70 +955,55 @@ int set_module(int file_des) { - - - - int get_module(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); sls_detector_module module; int *myDac = NULL; int *myAdc = NULL; - int *myChip = NULL; int *myChan = NULL; + module.dacs = NULL; + module.adcs = NULL; + module.chanregs = NULL; // allocate to send arguments - // infinite loop to break out when FAIL or a final OK - while(1) { - - // allocate dacs - myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); - // error - if (getNumberOfDACs() > 0 && myDac == NULL) { - ret = FAIL; - sprintf(mess, "Could not allocate dacs\n"); - FILE_LOG(logERROR,(mess)); - break; - } + // allocate dacs + myDac = (int*)malloc(getNumberOfDACs() * sizeof(int)); + // error + if (getNumberOfDACs() > 0 && myDac == NULL) { + ret = FAIL; + sprintf(mess, "Could not allocate dacs\n"); + FILE_LOG(logERROR,(mess)); + } else module.dacs = myDac; - // allocate adcs + // allocate adcs + if (ret == OK) { myAdc = (int*)malloc(getNumberOfADCs() * sizeof(int)); // error if (getNumberOfADCs() > 0 && myAdc == NULL) { ret = FAIL; sprintf(mess,"Could not allocate adcs\n"); FILE_LOG(logERROR,(mess)); - break; - } - module.adcs=myAdc; + } else + module.adcs=myAdc; + } - // no need to allocate chips and chans for jungfrau, too much memory -#ifdef JUNGFRAUD - module.chipregs = NULL; - module.chanregs = NULL; -#else - // allocate chips - myChip = (int*)malloc(getNumberOfChips() * sizeof(int)); - if (getNumberOfChips() > 0 && myChip == NULL) { - ret = FAIL; - sprintf(mess,"Could not allocate chips\n"); - FILE_LOG(logERROR,(mess)); - break; - } - module.chipregs = myChip; - - // allocate chans + // allocate chans +#ifdef EIGERD + if (ret == OK) { myChan = (int*)malloc(getTotalNumberOfChannels() * sizeof(int)); if (getTotalNumberOfChannels() > 0 && myChan == NULL) { ret = FAIL; sprintf(mess,"Could not allocate chans\n"); FILE_LOG(logERROR,(mess)); - break; - } - module.chanregs=myChan; + } else + module.chanregs=myChan; + } #endif + + // get module + if (ret == OK) { module.nchip = getNumberOfChips(); module.nchan = getTotalNumberOfChannels(); module.ndac = getNumberOfDACs(); @@ -1105,10 +1019,9 @@ int get_module(int file_des) { // send module, 0 is to receive partially (without trimbits etc) if (ret != FAIL) { - ret = sendModuleGeneral(file_des, &module, (myDetectorType == JUNGFRAU) ? 0 : 1); + ret = sendModule(file_des, &module); } - if (myChip != NULL) free(myChip); - if (myChan != NULL) free(myChan); + if (myChan != NULL) free(myChan); if (myDac != NULL) free(myDac); if (myAdc != NULL) free(myAdc); return ret; @@ -2014,7 +1927,6 @@ int load_image(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int args[2] = {-1, -1}; - int retval = -1; if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); @@ -2039,10 +1951,9 @@ int load_image(int file_des) { switch (index) { case DARK_IMAGE : case GAIN_IMAGE : - retval = loadImage(index, ImageVals); - FILE_LOG(logDEBUG5, ("Loading image retval: %d\n", retval)); - if (retval == -1) { - ret = FAIL; + ret = loadImage(index, ImageVals); + FILE_LOG(logDEBUG5, ("Loading image ret: %d\n", ret)); + if (ret == FAIL) { sprintf(mess, "Could not load image\n"); FILE_LOG(logERROR,(mess)); } @@ -2053,7 +1964,7 @@ int load_image(int file_des) { } } #endif - return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -2096,8 +2007,6 @@ int reset_counter_block(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int startACQ = -1; - char retval[dataBytes]; - memset(retval, 0, dataBytes); if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) return printSocketReadError(); @@ -2109,7 +2018,7 @@ int reset_counter_block(int file_des) { // only set if (Server_VerifyLock() != FAIL) { - ret = resetCounterBlock(startACQ, retval); + ret = resetCounterBlock(startACQ); if (ret == FAIL) { strcpy(mess, "Could not reset counter block\n"); FILE_LOG(logERROR, (mess)); @@ -2123,27 +2032,6 @@ int reset_counter_block(int file_des) { -int calibrate_pedestal(int file_des) { - ret = OK; - memset(mess, 0, sizeof(mess)); - int frames = -1; - int retval = -1; - - if (receiveData(file_des, &frames, sizeof(frames), INT32) < 0) - return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Calibrate pedestal, frames: %d\n", frames)); - - functionNotImplemented(); - return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); -} - - - - - - - - int enable_ten_giga(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -2215,12 +2103,12 @@ int set_ctb_pattern(int file_des) { int write_adc_register(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - int args[2] = {-1, -1}; + uint32_t args[2] = {-1, -1}; if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); - int addr = args[0]; - int val = args[1]; + uint32_t addr = args[0]; + uint32_t val = args[1]; FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); #ifndef JUNGFRAUD @@ -2484,7 +2372,7 @@ int program_fpga(int file_des) { FILE_LOG(logDEBUG5, ("Programming FPGA\n")); #ifndef JUNGFRAUD //to receive any arguments - int n = 0; + int n = 1; while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); functionNotImplemented(); @@ -2708,7 +2596,7 @@ int prepare_acquisition(int file_des) { - +// stop server int threshold_temp(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -2738,11 +2626,11 @@ int threshold_temp(int file_des) { } } #endif - return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval)); } - +// stop server int temp_control(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -2763,12 +2651,12 @@ int temp_control(int file_des) { validate(arg, retval, "set temperature control", 0); } #endif - return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval)); } - +// stop server int temp_event(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); @@ -2789,7 +2677,7 @@ int temp_event(int file_des) { validate(arg, retval, "set temperature event", 0); } #endif - return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); + return Server_SendResult(file_des, INT32, 0, &retval, sizeof(retval)); } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index ae4e2f10c..f7e69bc84 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2196,14 +2196,7 @@ int multiSlsDetector::writeAdcRegister(int addr, int val, int detPos) { // multi auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val); - if (sls::allEqual(r)) - return r.front(); - - // can't have different values - FILE_LOG(logERROR) << "Error: Different Values for function writeAdcRegister " - "(write 0x" << std::hex << val << " to addr 0x" << std::hex << addr << std::dec << ")"; - setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES); - return -1; + return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; } @@ -2458,33 +2451,22 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) { } -int multiSlsDetector::getChanRegs(double* retval, bool fromDetector, int detPos) { +int multiSlsDetector::getChanRegs(double* retval, int detPos) { int offset = 0; std::vector r; for (auto& d : detectors) { int nch = d->getTotalNumberOfChannels(); double result[nch]; - r.push_back(d->getChanRegs(result, fromDetector)); + r.push_back(d->getChanRegs(result)); memcpy(retval + offset, result, nch * sizeof(double)); } return sls::minusOneIfDifferent(r); } -int multiSlsDetector::calibratePedestal(int frames, int detPos) { - // single - if (detPos >= 0) { - return detectors[detPos]->calibratePedestal(frames); - } - // multi - auto r = parallelCall(&slsDetector::calibratePedestal, frames); - return sls::minusOneIfDifferent(r); -} - - -int multiSlsDetector::setRateCorrection(int t, int detPos) { +int multiSlsDetector::setRateCorrection(int64_t t, int detPos) { // single if (detPos >= 0) { return detectors[detPos]->setRateCorrection(t); @@ -2496,7 +2478,7 @@ int multiSlsDetector::setRateCorrection(int t, int detPos) { } -int multiSlsDetector::getRateCorrection(int detPos) { +int64_t multiSlsDetector::getRateCorrection(int detPos) { // single if (detPos >= 0) { return detectors[detPos]->getRateCorrection(); @@ -2508,15 +2490,14 @@ int multiSlsDetector::getRateCorrection(int detPos) { } -int multiSlsDetector::printReceiverConfiguration(int detPos) { +void multiSlsDetector::printReceiverConfiguration(int detPos) { // single if (detPos >= 0) { return detectors[detPos]->printReceiverConfiguration(); } // multi - auto r = parallelCall(&slsDetector::printReceiverConfiguration); - return sls::allEqualTo(r, static_cast(OK)) ? OK : FAIL; + parallelCall(&slsDetector::printReceiverConfiguration); } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 7dd5d5c49..9c64d1c61 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1153,21 +1153,10 @@ public: /** * Returns the trimbits from the detector's shared memmory (Mythen, Eiger) * @param retval is the array with the trimbits - * @param fromDetector is true if the trimbits shared memory have to be - * uploaded from detector * @param detPos -1 for all detectors in list or specific detector position * @returns total number of channels for the detector */ - int getChanRegs(double* retval,bool fromDetector, int detPos = -1); - - /** - * Calibrate Pedestal (ChipTestBoard) - * Starts acquisition, calibrates pedestal and writes to fpga - * @param frames number of frames - * @param detPos -1 for all detectors in list or specific detector position - * @returns number of frames - */ - int calibratePedestal(int frames = 0, int detPos = -1); + int getChanRegs(double* retval, int detPos = -1); /** * Set Rate correction ( Eiger) @@ -1177,21 +1166,20 @@ public: * @param detPos -1 for all detectors in list or specific detector position * @returns 0 if rate correction disabled, >0 otherwise */ - int setRateCorrection(int t=0, int detPos = -1); + int setRateCorrection(int64_t t = 0, int detPos = -1); /** * Get rate correction ( Eiger) * @param detPos -1 for all detectors in list or specific detector position * @returns 0 if rate correction disabled, > 0 otherwise (ns) */ - int getRateCorrection(int detPos = -1); + int64_t getRateCorrection(int detPos = -1); /** * Prints receiver configuration * @param detPos -1 for all detectors in list or specific detector position - * @returns OK or FAIL */ - int printReceiverConfiguration(int detPos = -1); + void printReceiverConfiguration(int detPos = -1); /** * Sets up receiver socket if online and sets the flag diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index a8092b5f6..0adf416d2 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -36,10 +36,7 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) detectorModules(0), dacs(0), adcs(0), - chipregs(0), - chanregs(0), - gain(0), - offset(0) { + chanregs(0) { /* called from put hostname command, * so sls shared memory will be created */ @@ -71,10 +68,7 @@ slsDetector::slsDetector(int multiId, int id, bool verify) detectorModules(0), dacs(0), adcs(0), - chipregs(0), - chanregs(0), - gain(0), - offset(0) { + chanregs(0) { /* called from multi constructor to populate structure, * so sls shared memory will be opened, not created */ @@ -322,8 +316,6 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nChipY = 1; list.nDacs = 8; list.nAdcs = 5; - list.nGain = 0; - list.nOffset = 0; list.dynamicRange = 16; list.nGappixelsX = 0; list.nGappixelsY = 0; @@ -335,8 +327,6 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nChipY = 2; list.nDacs = 16; list.nAdcs = 0; - list.nGain = 0; - list.nOffset = 0; list.dynamicRange = 16; list.nGappixelsX = 0; list.nGappixelsY = 0; @@ -348,8 +338,6 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nChipY = 1; list.nDacs = 16; list.nAdcs = 9;//???? When calculating size, only d+a=16 how come?FIXME - list.nGain = 0; - list.nOffset = 0; list.dynamicRange =16; list.nGappixelsX = 0; list.nGappixelsY = 0; @@ -361,8 +349,6 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nChipY = 1; list.nDacs = 16; list.nAdcs = 0; - list.nGain = 0; // can be set back to 4 in case we require it again - list.nOffset = 0; // can be set back to 4 in case we require it again list.dynamicRange = 16; list.nGappixelsX = 6; list.nGappixelsY = 1; @@ -381,20 +367,15 @@ int slsDetector::calculateSharedMemorySize(detectorType type) { int nch = detlist.nChanX * detlist.nChanY; int nc = detlist.nChipX * detlist.nChipY; int nd = detlist.nDacs + detlist.nAdcs; - int ng = detlist.nGain; - int no = detlist.nOffset; /** The size of the shared memory is * size of shared structure + - * ffcoefficents+fferrors+modules+dacs+adcs+chips+chans+gain+offset */ + * ffcoefficents+fferrors+modules+dacs+adcs+chans */ int sz = sizeof(sharedSlsDetector) + 2 * nch * nc * sizeof(double) + sizeof(sls_detector_module) + - sizeof(int) * nc + sizeof(int) * nd + - sizeof(int) * nch * nc + - sizeof(int) * ng + - sizeof(int) * no; + sizeof(int) * nch * nc; FILE_LOG(logDEBUG5) << "Size of shared memory is " << sz; return sz; } @@ -505,8 +486,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) { thisDetector->nChip[Y] = detlist.nChipY; thisDetector->nDacs = detlist.nDacs; thisDetector->nAdcs = detlist.nAdcs; - thisDetector->nGain = detlist.nGain; - thisDetector->nOffset = detlist.nOffset; thisDetector->dynamicRange = detlist.dynamicRange; thisDetector->nGappixels[X] = detlist.nGappixelsX; thisDetector->nGappixels[Y] = detlist.nGappixelsY; @@ -539,15 +518,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) { sizeof(sls_detector_module); thisDetector->adcoff = thisDetector->dacoff + sizeof(int) * thisDetector->nDacs; - thisDetector->chipoff = thisDetector->adcoff + - sizeof(int) * thisDetector->nAdcs; - thisDetector->chanoff = thisDetector->chipoff + + thisDetector->chanoff = thisDetector->adcoff + sizeof(int) * thisDetector->nChips; - thisDetector->gainoff = thisDetector->chanoff + - sizeof(int) * thisDetector->nGain; - thisDetector->offsetoff = thisDetector->gainoff + - sizeof(int) * thisDetector->nOffset; - } @@ -558,10 +530,7 @@ void slsDetector::initializeMembers() { detectorModules = (sls_detector_module*)(goff + thisDetector->modoff); dacs = (int*)(goff + thisDetector->dacoff); adcs = (int*)(goff + thisDetector->adcoff); - chipregs = (int*)(goff + thisDetector->chipoff); chanregs = (int*)(goff + thisDetector->chanoff); - gain = (int*)(goff + thisDetector->gainoff); - offset = (int*)(goff + thisDetector->offsetoff); if (thisDetectorControl) { delete thisDetectorControl; thisDetectorControl = 0; @@ -594,11 +563,12 @@ void slsDetector::initializeDetectorStructurePointers() { thisMod->ndac = thisDetector->nDacs; thisMod->nadc = thisDetector->nAdcs; thisMod->reg = 0; - // dacs, adcs, chipregs and chanregs for thisMod is not allocated in + thisMod->iodelay = 0; + thisMod->tau = 0; + thisMod->eV = 0; + // dacs, adcs and chanregs for thisMod is not allocated in // detectorModules in shared memory as they are already allocated separately // in shared memory (below) - thisMod->gain = -1.; - thisMod->offset = -1.; // initializes the dacs values to 0 for (int i = 0; i < thisDetector->nDacs; ++i) { @@ -608,22 +578,10 @@ void slsDetector::initializeDetectorStructurePointers() { for (int i = 0; i < thisDetector->nAdcs; ++i) { *(adcs + i) = 0; } - // initializes the chip registers to 0 - for (int i = 0; i < thisDetector->nChips; ++i) { - *(chipregs + i) = -1; - } // initializes the channel registers to 0 for (int i = 0; i < thisDetector->nChans * thisDetector->nChips; ++i) { *(chanregs + i) = -1; } - // initializes the gain values to 0 - for (int i = 0; i < thisDetector->nGain; ++i) { - *(gain + i) = 0; - } - // initializes the offset values to 0 - for (int i = 0; i < thisDetector->nOffset; ++i) { - *(offset + i) = 0; - } } @@ -647,7 +605,6 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty } int *dacs = new int[nd]; int *adcs = new int[na]; - int *chipregs = new int[nc]; int *chanregs = new int[nch*nc]; sls_detector_module *myMod = (sls_detector_module*)malloc(sizeof(sls_detector_module)); @@ -657,7 +614,6 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty myMod->nchan = nch*nc; myMod->dacs = dacs; myMod->adcs = adcs; - myMod->chipregs = chipregs; myMod->chanregs = chanregs; return myMod; } @@ -666,7 +622,6 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType ty void slsDetector::deleteModule(sls_detector_module *myMod) { delete [] myMod->dacs; delete [] myMod->adcs; - delete [] myMod->chipregs; delete [] myMod->chanregs; delete myMod; } @@ -735,67 +690,47 @@ void slsDetector::disconnectStop() { int slsDetector::sendModule(sls_detector_module *myMod) { int ts = 0; - //send module structure - ts += controlSocket->SendDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); - ts += controlSocket->SendDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); - ts += controlSocket->SendDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); - ts += controlSocket->SendDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); - ts += controlSocket->SendDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); - ts += controlSocket->SendDataOnly(&(myMod->reg),sizeof(myMod->reg)); - ts += controlSocket->SendDataOnly(&(myMod->gain),sizeof(myMod->gain)); - ts += controlSocket->SendDataOnly(&(myMod->offset), sizeof(myMod->offset)); + ts += controlSocket->SendDataOnly(&(myMod->serialnumber), sizeof(myMod->serialnumber)); + ts += controlSocket->SendDataOnly(&(myMod->nchan), sizeof(myMod->nchan)); + ts += controlSocket->SendDataOnly(&(myMod->nchip), sizeof(myMod->nchip)); + ts += controlSocket->SendDataOnly(&(myMod->ndac), sizeof(myMod->ndac)); + ts += controlSocket->SendDataOnly(&(myMod->nadc), sizeof(myMod->nadc)); + ts += controlSocket->SendDataOnly(&(myMod->reg), sizeof(myMod->reg)); + ts += controlSocket->SendDataOnly(&(myMod->iodelay), sizeof(myMod->iodelay)); + ts += controlSocket->SendDataOnly(&(myMod->tau), sizeof(myMod->tau)); + ts += controlSocket->SendDataOnly(&(myMod->eV), sizeof(myMod->eV)); - // actual data to the pointers - ts += controlSocket->SendDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); - ts += controlSocket->SendDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); - if (thisDetector->myDetectorType != JUNGFRAU) { - ts += controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); - ts += controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); + ts += controlSocket->SendDataOnly(myMod->dacs, sizeof(int) * (myMod->ndac)); + ts += controlSocket->SendDataOnly(myMod->adcs, sizeof(int) * (myMod->nadc)); + if (thisDetector->myDetectorType == EIGER) { + ts += controlSocket->SendDataOnly(myMod->chanregs, sizeof(int) * (myMod->nchan)); } return ts; } int slsDetector::receiveModule(sls_detector_module* myMod) { - - int *dacptr = myMod->dacs; - int *adcptr = myMod->adcs; - int *chipptr = myMod->chipregs; - int *chanptr = myMod->chanregs; int ts = 0; - //send module structure - ts += controlSocket->ReceiveDataOnly(&(myMod->serialnumber),sizeof(myMod->serialnumber)); - ts += controlSocket->ReceiveDataOnly(&(myMod->nchan),sizeof(myMod->nchan)); - ts += controlSocket->ReceiveDataOnly(&(myMod->nchip),sizeof(myMod->nchip)); - ts += controlSocket->ReceiveDataOnly(&(myMod->ndac),sizeof(myMod->ndac)); - ts += controlSocket->ReceiveDataOnly(&(myMod->nadc),sizeof(myMod->nadc)); - ts += controlSocket->ReceiveDataOnly(&(myMod->reg),sizeof(myMod->reg)); - ts += controlSocket->ReceiveDataOnly(&(myMod->gain), sizeof(myMod->gain)); - ts += controlSocket->ReceiveDataOnly(&(myMod->offset), sizeof(myMod->offset)); - - - myMod->dacs = dacptr; - myMod->adcs = adcptr; - myMod->chipregs = chipptr; - myMod->chanregs = chanptr; - FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; + ts += controlSocket->ReceiveDataOnly(&(myMod->serialnumber), sizeof(myMod->serialnumber)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nchan), sizeof(myMod->nchan)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nchip), sizeof(myMod->nchip)); + ts += controlSocket->ReceiveDataOnly(&(myMod->ndac), sizeof(myMod->ndac)); + ts += controlSocket->ReceiveDataOnly(&(myMod->nadc), sizeof(myMod->nadc)); + ts += controlSocket->ReceiveDataOnly(&(myMod->reg), sizeof(myMod->reg)); + ts += controlSocket->ReceiveDataOnly(&(myMod->iodelay), sizeof(myMod->iodelay)); + ts += controlSocket->ReceiveDataOnly(&(myMod->tau), sizeof(myMod->tau)); + ts += controlSocket->ReceiveDataOnly(&(myMod->eV), sizeof(myMod->eV)); ts += controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); FILE_LOG(logDEBUG5) << "received dacs of size "<< ts; - ts += controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); FILE_LOG(logDEBUG5) << "received adc of size "<< ts; - - if (thisDetector->myDetectorType != JUNGFRAU) { - ts += controlSocket->ReceiveDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip)); - FILE_LOG(logDEBUG5) << "received chips of size "<< ts; - - ts += controlSocket->ReceiveDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan)); + if (thisDetector->myDetectorType == EIGER) { + ts += controlSocket->ReceiveDataOnly(myMod->chanregs, sizeof(int)*(myMod->nchan)); FILE_LOG(logDEBUG5) << "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips << "mod - nchans= " << myMod->nchan << " nchips= " <nchip; << "received chans of size "<< ts; } - FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; return ts; } @@ -1010,11 +945,11 @@ void slsDetector::updateMultiSize(int detx, int dety) { int slsDetector::setOnline(int off) { - int old = thisDetector->onlineFlag; - // setting it online/offline if (off != GET_ONLINE_FLAG) { thisDetector->onlineFlag = off; + // set online if (thisDetector->onlineFlag == ONLINE_FLAG) { + int old = thisDetector->onlineFlag; setTCPSocket(); // connecting first time if (thisDetector->onlineFlag == ONLINE_FLAG && old == OFFLINE_FLAG) { @@ -1034,13 +969,13 @@ int slsDetector::setOnline(int off) { std::string slsDetector::checkOnline() { std::string retval; + //if it doesnt exit, create socket and call this function again if (!controlSocket) { - //this already sets the online/offline flag setTCPSocket(); if (thisDetector->onlineFlag == OFFLINE_FLAG) return std::string(thisDetector->hostname); else - return std::string(""); + return retval; } //still cannot connect to socket, controlSocket=0 if (controlSocket) { @@ -1088,8 +1023,8 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in strcpy(thisName,thisDetector->hostname); } else { FILE_LOG(logDEBUG5) << "Setting hostname"; - strcpy(thisName,name.c_str()); - strcpy(thisDetector->hostname,thisName); + strcpy(thisName, name.c_str()); + strcpy(thisDetector->hostname, thisName); if (controlSocket) { delete controlSocket; controlSocket = 0; @@ -1101,7 +1036,9 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in } // control port - if (control_port > 0) { + if (control_port <= 0) { + thisCP = thisDetector->controlPort; + } else { FILE_LOG(logDEBUG5) << "Setting control port"; thisCP = control_port; thisDetector->controlPort = thisCP; @@ -1109,11 +1046,12 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in delete controlSocket; controlSocket = 0; } - } else - thisCP = thisDetector->controlPort; + } // stop port - if (stop_port > 0) { + if (stop_port <= 0) { + thisSP = thisDetector->stopPort; + } else { FILE_LOG(logDEBUG5) << "Setting stop port"; thisSP = stop_port; thisDetector->stopPort = thisSP; @@ -1121,9 +1059,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in delete stopSocket; stopSocket = 0; } - } else - thisSP = thisDetector->stopPort; - + } // create control socket if (!controlSocket) { @@ -1342,7 +1278,7 @@ int slsDetector::lockServer(int lock) { std::string slsDetector::getLastClientIP() { - int fnum = F_LOCK_SERVER; + int fnum = F_GET_LAST_CLIENT_IP; int ret = FAIL; char retval[INET_ADDRSTRLEN] = {0}; FILE_LOG(logDEBUG5) << "Getting last client ip to detector server"; @@ -1398,8 +1334,7 @@ int slsDetector::execCommand(std::string cmd) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; - if (ret == FORCE_UPDATE) - ret = updateDetector(); + } } return ret; @@ -1409,7 +1344,7 @@ int slsDetector::execCommand(std::string cmd) { int slsDetector::updateDetectorNoWait() { int n = 0, i32 = 0; int64_t i64 = 0; - char lastClientIP[INET_ADDRSTRLEN]; + char lastClientIP[INET_ADDRSTRLEN] = {0}; n += controlSocket->ReceiveDataOnly(lastClientIP, sizeof(lastClientIP)); FILE_LOG(logDEBUG5) << "Updating detector last modified by " << lastClientIP; @@ -1581,8 +1516,8 @@ std::string slsDetector::getSettingsFile() { } -int slsDetector::writeSettingsFile(std::string fname, int iodelay, int tau) { - return writeSettingsFile(fname, detectorModules[0], iodelay, tau); +int slsDetector::writeSettingsFile(std::string fname) { + return writeSettingsFile(fname, detectorModules[0]); } @@ -1737,8 +1672,6 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti //fill detector module structure sls_detector_module *myMod = NULL; - int iodelay = -1; //not included in the module - int tau = -1; //not included in the module //normal if (!interpolate) { @@ -1751,7 +1684,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti //read the files myMod=createModule(); - if (NULL == readSettingsFile(settingsfname, iodelay, tau, myMod, tb)) { + if (NULL == readSettingsFile(settingsfname, myMod, tb)) { if (myMod)deleteModule(myMod); return FAIL; } @@ -1784,30 +1717,26 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti FILE_LOG(logDEBUG5) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; sls_detector_module *myMod1=createModule(); sls_detector_module *myMod2=createModule(); - int iodelay1 = -1; //not included in the module - int tau1 = -1; //not included in the module - int iodelay2 = -1; //not included in the module - int tau2 = -1; //not included in the module - if (NULL == readSettingsFile(settingsfname1,iodelay1, tau1, myMod1, tb)) { + if (NULL == readSettingsFile(settingsfname1, myMod1, tb)) { setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); deleteModule(myMod1); deleteModule(myMod2); return FAIL; } - if (NULL == readSettingsFile(settingsfname2, iodelay2, tau2, myMod2, tb)) { + if (NULL == readSettingsFile(settingsfname2, myMod2, tb)) { setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN)); deleteModule(myMod1); deleteModule(myMod2); return FAIL; } - if (iodelay1 != iodelay2) { + if (myMod1->iodelay != myMod2->iodelay) { FILE_LOG(logERROR) << "Iodelays do not match between files"; setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); deleteModule(myMod1); deleteModule(myMod2); return FAIL; } - iodelay = iodelay1; + myMod->iodelay = myMod1->iodelay; //interpolate module myMod = interpolateTrim( myMod1, myMod2, e_eV, trim1, trim2, tb); @@ -1819,7 +1748,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti return FAIL; } //interpolate tau - tau = linearInterpolation(e_eV, trim1, trim2, tau1, tau2); + myMod->tau = linearInterpolation(e_eV, trim1, trim2, myMod1->tau, myMod2->tau); //printf("new tau:%d\n",tau); deleteModule(myMod1); @@ -1827,8 +1756,9 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti } - myMod->reg=thisDetector->currentSettings; - setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb); + myMod->reg = thisDetector->currentSettings; + myMod->eV = e_eV; + setModule(*myMod, tb); deleteModule(myMod); if (getSettings() != is) { FILE_LOG(logERROR) << "Could not set settings in detector"; @@ -1867,15 +1797,14 @@ int slsDetector::loadSettingsFile(std::string fname) { // read settings file sls_detector_module *myMod=NULL; - int iodelay = -1; - int tau = -1; - myMod = readSettingsFile(fn, iodelay, tau, myMod); + myMod = readSettingsFile(fn, myMod); // set module int ret = FAIL; if (myMod != NULL) { myMod->reg = -1; - ret = setModule(*myMod, iodelay, tau, -1, 0, 0); + myMod->eV = -1; + ret = setModule(*myMod); deleteModule(myMod); } return ret; @@ -1898,13 +1827,7 @@ int slsDetector::saveSettingsFile(std::string fname) { int ret = FAIL; sls_detector_module *myMod = NULL; if ((myMod = getModule())) { - int iodelay = -1; - int tau = -1; - if (thisDetector->myDetectorType == EIGER) { - iodelay = (int)setDAC((int)-1, IO_DELAY, 0); - tau = getRateCorrection(); - } - ret = writeSettingsFile(fn, *myMod, iodelay, tau); + ret = writeSettingsFile(fn, *myMod); deleteModule(myMod); } return ret; @@ -2924,7 +2847,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() { } else { FILE_LOG(logDEBUG5) << "Real Receiver UDP Socket Buffer size: " << retval; if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateReceiver(); } } return std::string(retval); @@ -3175,7 +3098,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) { FILE_LOG(logDEBUG5) << "Receiver streaming port: " << retval; thisDetector->receiver_zmqport = retval; if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateReceiver(); } } return getReceiverStreamingPort(); @@ -3248,7 +3171,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiver_zmqip, retvals); if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateReceiver(); } } return getReceiverStreamingIP(); @@ -3275,7 +3198,7 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { memset(thisDetector->receiver_additionalJsonHeader, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiver_additionalJsonHeader, retvals); if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateReceiver(); } } return getAdditionalJsonHeader(); @@ -3299,7 +3222,7 @@ std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) { } else { FILE_LOG(logDEBUG5) << "Receiver UDP Socket Buffer size: " << retval; if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateReceiver(); } } return std::to_string(retval); @@ -3309,61 +3232,45 @@ std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) { std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int delay) { int fnum = F_SET_NETWORK_PARAMETER; int ret = FAIL; + int args[2] = {(int)index, delay}; int retval = -1; - char mess[MAX_STR_LENGTH]=""; + FILE_LOG(logDEBUG5) << "Setting network parameter index " << index << " to " << delay; -#ifdef VERBOSE - FILE_LOG(logINFO) << "Setting Transmission delay of mode "<< index << " to " << delay << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&index,sizeof(index)); - controlSocket->SendDataOnly(&delay,sizeof(delay)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(DETECTOR_NETWORK_PARAMETER)); - } else - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(DETECTOR_NETWORK_PARAMETER)); + } else { + FILE_LOG(logDEBUG5) << "Network Parameter (" << index << "): " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - FILE_LOG(logINFO) << "Speed set to "<< retval << std::endl; -#endif - - std::ostringstream ss; - ss << retval; - std::string s = ss.str(); - return s; + return std::to_string(retval); } int slsDetector::setUDPConnection() { - - int ret = FAIL; int fnum = F_SETUP_RECEIVER_UDP; + int ret = FAIL; char args[3][MAX_STR_LENGTH] = {0}; - char retval[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + FILE_LOG(logDEBUG5) << "Setting UDP Connection"; - //called before set up - if (!strcmp(thisDetector->receiver_hostname,"none")) { -#ifdef VERBOSE - std::cout << "Warning: Receiver hostname not set yet." << std::endl; -#endif + // called before set up + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG5) << "Receiver hostname not set yet."; return FAIL; } - - //if no udp ip given, use hostname - if (!strcmp(thisDetector->receiverUDPIP,"none")) { - //hostname is an ip address - if (strchr(thisDetector->receiver_hostname,'.')!=NULL) - strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname); - //if hostname not ip, convert it to ip + // if no udp ip given, use hostname + if (!strcmp(thisDetector->receiverUDPIP, "none")) { + // hostname is an ip address + if (strchr(thisDetector->receiver_hostname,'.') != NULL) + strcpy(thisDetector->receiverUDPIP, thisDetector->receiver_hostname); + // if hostname not ip, convert it to ip else { struct addrinfo *result; if (!dataSocket->ConvertHostnameToInternetAddress( @@ -3378,368 +3285,276 @@ int slsDetector::setUDPConnection() { } } } - - //copy arguments to args[][] strcpy(args[0],thisDetector->receiverUDPIP); sprintf(args[1],"%d",thisDetector->receiverUDPPort); sprintf(args[2],"%d",thisDetector->receiverUDPPort2); -#ifdef VERBOSE - std::cout << "Receiver udp ip address: " << thisDetector->receiverUDPIP << std::endl; - std::cout << "Receiver udp port: " << thisDetector->receiverUDPPort << std::endl; - std::cout << "Receiver udp port2: " << thisDetector->receiverUDPPort2 << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Receiver udp ip address: " << thisDetector->receiverUDPIP; + FILE_LOG(logDEBUG5) << "Receiver udp port: " << thisDetector->receiverUDPPort; + FILE_LOG(logDEBUG5) << "Receiver udp port2: " << thisDetector->receiverUDPPort2; - //set up receiver for UDP Connection and get receivermac address - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Setting up UDP Connection for Receiver " << args[0] << "\t" << args[1] << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &args, sizeof(args), &retval, sizeof(retval)); - disconnectData(); - } - if (ret!=FAIL) { - strcpy(thisDetector->receiverUDPMAC,retval); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectControl(); -#ifdef VERBOSE - std::cout << "Receiver mac address: " << thisDetector->receiverUDPMAC << std::endl; -#endif - if (ret==FORCE_UPDATE) - updateReceiver(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Receiver UDP MAC returned : " << retvals; + memset(thisDetector->receiverUDPMAC, 0, MAX_STR_LENGTH); + strcpy(thisDetector->receiverUDPMAC, retvals); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); - //configure detector with udp details, -100 is so it doesnt overwrite - //the previous value - if (configureMAC()==FAIL) { - setReceiverOnline(OFFLINE_FLAG); - std::cout << "could not configure mac" << std::endl; + //configure detector with udp details + if (configureMAC() == FAIL) { + setReceiverOnline(OFFLINE_FLAG); //FIXME: Needed?? } } - } else - ret=FAIL; -#ifdef VERBOSE - printReceiverConfiguration(); -#endif + } + printReceiverConfiguration(logDEBUG5); return ret; } - int slsDetector::digitalTest( digitalTestMode mode, int ival) { int fnum = F_DIGITAL_TEST; int ret = FAIL; - int args[2] = {mode, ival}; + int args[2] = {(int)mode, ival}; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending digital test of mode " << mode << ", ival " << ival; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, - args, sizeof(args), &retval, sizeof(retval)); - disconnectControl(); - // handle ret - if (ret == FAIL) - setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); - else if (ret == FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Digital Test returned: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - if (ret != FAIL && mode == DIGITAL_BIT_TEST) { - FILE_LOG(logDEBUG5) << "Digital test bit: " << retval; - } - return retval; } int slsDetector::loadImageToDetector(imageType index,std::string const fname) { - - int ret=FAIL; - short int arg[thisDetector->nChans*thisDetector->nChips]; - -#ifdef VERBOSE - std::cout<< std::endl<< "Loading "; - if (!index) - std::cout<<"Dark"; - else - std::cout<<"Gain"; - std::cout<<" image from file " << fname << std::endl; -#endif + int ret = FAIL; + short int args[thisDetector->nChans * thisDetector->nChips]; + FILE_LOG(logDEBUG5) << "Loading " << (!index ? "Dark" : "Gain") << "image from file " << fname; if (readDataFile(fname,arg,getTotalNumberOfChannels())) { ret = sendImageToDetector(index,arg); return ret; } - FILE_LOG(logERROR) << "Could not open file "<< fname << std::endl; + + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + FILE_LOG(logERROR) << "Could not open file " << fname; return ret; } - int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { + int fnum = F_LOAD_IMAGE; + int ret = FAIL; + int arg = (int)isettings; + FILE_LOG(logDEBUG5) << "Sending image to detector"; - int ret=FAIL; - int retval; - int fnum=F_LOAD_IMAGE; - char mess[MAX_STR_LENGTH]=""; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, + imageVals, thisDetector->dataBytes, NULL, 0); + disconnectControl(); -#ifdef VERBOSE - std::cout<<"Sending image to detector " <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&index,sizeof(index)); - controlSocket->SendDataOnly(imageVals,thisDetector->dataBytes); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - return ret; } - int slsDetector::writeCounterBlockFile(std::string const fname,int startACQ) { -#ifdef VERBOSE - std::cout<< std::endl<< "Reading Counter to \""<nChans*thisDetector->nChips]; - int ret=getCounterBlock(counterVals,startACQ); - if (ret==OK) - ret=writeDataFile(fname, getTotalNumberOfChannels(), counterVals); + int ret = FAIL; + short int retvals[thisDetector->nChans * thisDetector->nChips]; + FILE_LOG(logDEBUG5) << "Reading Counter to " << fname << + (startACQ ? " and Restarting Acquisition" : "\n"); + + ret = getCounterBlock(retvals, startACQ); + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else + ret=writeDataFile(fname, getTotalNumberOfChannels(), retvals); return ret; } -int slsDetector::getCounterBlock(short int arg[],int startACQ) { - int ret=FAIL; - int fnum=F_READ_COUNTER_BLOCK; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(arg,thisDetector->dataBytes); - else { - char mess[MAX_STR_LENGTH]=""; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } +int slsDetector::getCounterBlock(short int image[],int startACQ) { + int fnum = F_READ_COUNTER_BLOCK; + int ret = FAIL; + int arg = startACQ; + FILE_LOG(logDEBUG5) << "Reading Counter block with startacq: " << startACQ; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, + &arg, sizeof(arg), image, thisDetector->dataBytes); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } return ret; } int slsDetector::resetCounterBlock(int startACQ) { + int fnum = F_RESET_COUNTER_BLOCK; + int ret = FAIL; + int arg = startACQ; + FILE_LOG(logDEBUG5) << "Resetting Counter with startacq: " << startACQ; - int ret=FAIL; - int fnum=F_RESET_COUNTER_BLOCK; - char mess[MAX_STR_LENGTH]=""; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + disconnectControl(); -#ifdef VERBOSE - std::cout<< std::endl<< "Resetting Counter"; - if (startACQ==1) - std::cout<<" and Restarting Acquisition"; - std::cout<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&startACQ,sizeof(startACQ)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - return ret; } - - int slsDetector::setCounterBit(int i) { - int fnum=F_SET_COUNTER_BIT; + int fnum = F_SET_COUNTER_BIT; int ret = FAIL; - int retval=-1; - char mess[MAX_STR_LENGTH]=""; + int arg = i; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending counter bit " << arg; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - - FILE_LOG(logINFO) << - ((i == -1) ? "Getting" : ((i == 0) ? "Reseting" : "Setting")) << - " counter bit from detector" << std::endl; - - if (connectControl() == OK) { - - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&i,sizeof(i)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_SET_COUNTER_BIT)); - } - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_SET_COUNTER_BIT)); + } else { + FILE_LOG(logDEBUG5) << "Counter bit: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return retval; } - - int slsDetector::setROI(int n,ROI roiLimits[]) { - int ret = FAIL; - //sort ascending order - int temp; - - for(int i=0;imyDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); + int ret = sendROI(n,roiLimits); + if (thisDetector->myDetectorType == JUNGFRAUCTB) + getTotalNumberOfChannels(); return ret; } slsDetectorDefs::ROI* slsDetector::getROI(int &n) { sendROI(-1,NULL); - n=thisDetector->nROI; - if (thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); + n = thisDetector->nROI; + if (thisDetector->myDetectorType == JUNGFRAUCTB) + getTotalNumberOfChannels(); return thisDetector->roiLimits; } + int slsDetector::getNRoi() { return thisDetector->nROI; } -int slsDetector::sendROI(int n,ROI roiLimits[]) { - int ret=FAIL; - int fnum=F_SET_ROI; - char mess[MAX_STR_LENGTH]=""; - int arg = n; - int retvalsize=0; +int slsDetector::sendROI(int n, ROI roiLimits[]) { + int fnum = F_SET_ROI; + int ret = FAIL; + int narg = n; + // send roiLimits if given, else from shm + ROI* arg = (roiLimits != NULL) ? roiLimits : thisDetector->roiLimits; + int nretval = 0; ROI retval[MAX_ROIS]; - int nrec=-1; - if (roiLimits==NULL) - roiLimits=thisDetector->roiLimits; + FILE_LOG(logDEBUG5) << "Sending ROI to detector" << narg; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - if (arg==-1) {; -#ifdef VERBOSE - std::cout << "Getting ROI from detector" << std::endl; -#endif - } else { -#ifdef VERBOSE - std::cout << "Sending ROI of size " << arg << " to detector" << std::endl; -#endif - for(int i = 0; i < n; ++i) { - controlSocket->SendDataOnly(&roiLimits[i].xmin, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].xmax, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].ymin, sizeof(int)); - controlSocket->SendDataOnly(&roiLimits[i].ymax, sizeof(int)); - } - //controlSocket->SendDataOnly(roiLimits,arg*sizeof(ROI)); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + controlSocket->SendDataOnly(&fnum, sizeof(fnum)); + controlSocket->SendDataOnly(&narg, sizeof(narg)); + if (narg != -1) { + for(int i = 0; i < narg; ++i) { + controlSocket->SendDataOnly(&arg[i].xmin, sizeof(int)); + controlSocket->SendDataOnly(&arg[i].xmax, sizeof(int)); + controlSocket->SendDataOnly(&arg[i].ymin, sizeof(int)); + controlSocket->SendDataOnly(&arg[i].ymax, sizeof(int)); } - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retvalsize,sizeof(retvalsize)); - nrec = 0; - - for(int i = 0; i < retvalsize; ++i) { - nrec += controlSocket->ReceiveDataOnly(&retval[i].xmin, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].xmax, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].ymin, sizeof(int)); - nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); - } - //nrec = controlSocket->ReceiveDataOnly(retval,retvalsize*sizeof(ROI)); - if (nrec!=(retvalsize*(int)sizeof(ROI))) { - ret=FAIL; - std::cout << " wrong size received: received " << nrec << - "but expected " << retvalsize*sizeof(ROI) << std::endl; - } - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); } - } + controlSocket->ReceiveDataOnly(&ret, sizeof(ret)); - //update client - if (ret==FAIL) { - setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); - } else { - for(int i=0;iroiLimits[i]=retval[i]; - thisDetector->nROI = retvalsize; - } + // handle ret + if (ret == FAIL) { + char mess[MAX_STR_LENGTH] = {0}; + setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); + controlSocket->ReceiveDataOnly(mess, MAX_STR_LENGTH); + FILE_LOG(logERROR) << "Detector " << detId << " returned error: " << mess; + } else { + controlSocket->ReceiveDataOnly(&nretval, sizeof(nretval)); + int nrec = 0; + for(int i = 0; i < nretval; ++i) { + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].xmax, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymin, sizeof(int)); + nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); + } + thisDetector->nROI = nretval; + FILE_LOG(logDEBUG5) << "nRoi: " << nretval; + for (int i = 0; i < nretval; ++i) { + thisDetector->roiLimits[i] = retval[i]; + FILE_LOG(logDEBUG5) << "ROI [" << i << "] (" << + thisDetector->roiLimits[j].xmin << "," << + thisDetector->roiLimits[j].xmax << "," << + thisDetector->roiLimits[j].ymin << "," << + thisDetector->roiLimits[j].ymax << ")"; + } -#ifdef VERBOSE - for(int j=0;jnROI;++j) - std::cout<<"ROI [" <myDetectorType == GOTTHARD) { @@ -3747,332 +3562,240 @@ int slsDetector::sendROI(int n,ROI roiLimits[]) { } // update roi in receiver - if (ret == OK && thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - int fnum = F_RECEIVER_SET_ROI; + if (ret == OK && thisDetector->receiverOnlineFlag == ONLINE_FLAG) { + fnum = F_RECEIVER_SET_ROI; ret = FAIL; -#ifdef VERBOSE - std::cout << "Sending ROI to receiver " << thisDetector->nROI << std::endl; -#endif + narg = thisDetector->nROI; + arg = thisDetector->roiLimits; + FILE_LOG(logDEBUG5) << "Sending ROI to receiver " << thisDetector->nROI; + if (connectData() == OK) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->SendDataOnly(&thisDetector->nROI, sizeof(thisDetector->nROI)); - for(int i = 0; i < thisDetector->nROI; ++i) { - dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmin, sizeof(int)); - dataSocket->SendDataOnly(&thisDetector->roiLimits[i].xmax, sizeof(int)); - dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymin, sizeof(int)); - dataSocket->SendDataOnly(&thisDetector->roiLimits[i].ymax, sizeof(int)); + dataSocket->SendDataOnly(&fnum, sizeof(fnum)); + dataSocket->SendDataOnly(&narg, sizeof(narg)); + if (narg != -1) { + for(int i = 0; i < narg; ++i) { + dataSocket->SendDataOnly(&arg[i].xmin, sizeof(int)); + dataSocket->SendDataOnly(&arg[i].xmax, sizeof(int)); + dataSocket->SendDataOnly(&arg[i].ymin, sizeof(int)); + dataSocket->SendDataOnly(&arg[i].ymax, sizeof(int)); + } } - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + dataSocket->ReceiveDataOnly(&ret, sizeof(ret)); + + // handle ret + char mess[MAX_STR_LENGTH] = {0}; if (ret == FAIL) { - dataSocket->ReceiveDataOnly(mess,MAX_STR_LENGTH); setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); - FILE_LOG(logERROR, ("Receiver %d returned error: %s", detId, mess)); + dataSocket->ReceiveDataOnly(mess, MAX_STR_LENGTH); + FILE_LOG(logERROR) << "Receiver " << detId << " returned error: " << mess; } disconnectData(); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } - - return ret; } - - int slsDetector::writeAdcRegister(int addr, int val) { + int fnum = F_WRITE_ADC_REG; + int ret = FAIL; + uint32_t args[2] = {addr, val}; + FILE_LOG(logDEBUG5) << "Writing to ADC register 0x" << std::hex << + addr << "data: 0x" << std::hex << val << std::dec; - int retval=-1; - int fnum=F_WRITE_ADC_REG; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); + disconnectControl(); - uint32_t arg[2]; - arg[0]=addr; - arg[1]=val; - - -#ifdef VERBOSE - std::cout<< std::endl; - FILE_LOG(logINFO) << "Writing to adc register "<< std::hex<onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } -#ifdef VERBOSE - FILE_LOG(logINFO) << "ADC Register returned "<< retval << std::endl; -#endif - if (ret==FAIL) { - FILE_LOG(logERROR) << "Write ADC to register failed " << std::endl; - setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); + else if (ret == FORCE_UPDATE) + ret = updateDetector(); } return retval; - } int slsDetector::activate(int const enable) { int fnum = F_ACTIVATE; - int fnum2 = F_RECEIVER_ACTIVATE; - int retval = -1; - int arg = enable; - char mess[MAX_STR_LENGTH]=""; int ret = FAIL; + int arg = enable; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting activate flag to " << arg; - if (thisDetector->myDetectorType != EIGER) { - FILE_LOG(logERROR) << "Not implemented for this detector" << std::endl; - setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); - return -1; - } + // detector + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - FILE_LOG(logDEBUG5) << - (!enable ? "Deactivating" : (enable == -1 ? "Getting activate" : "Activating")) << - " Detector" << std::endl; - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->activated = retval; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); + } else { + FILE_LOG(logDEBUG5) << "Activate: " << retval; + thisDetector->activated = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - if (retval==1) - std::cout << "Detector Activated" << std::endl; - else if (retval==0) - std::cout << "Detector Deactivated" << std::endl; - else - std::cout << "Detector Activation unknown:" << retval << std::endl; -#endif - if (ret!=FAIL) { - int arg = thisDetector->activated; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Activating/Deactivating Receiver: " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum2, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) + // receiver + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && ret == OK) { + fnum = F_RECEIVER_ACTIVATE; + ret = FAIL; + arg = thisDetector->activated; + retval = -1; + FILE_LOG(logDEBUG5) << "Setting activate flag " << arg << " to receiver"; + + if (connectData() == OK) { + ret=thisReceiver->Client_Send(fnum2, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } -#ifdef VERBOSE - if (retval==1) - std::cout << "Receiver Activated" << std::endl; - else if (retval==0) - std::cout << "Receiver Deactivated" << std::endl; - else - std::cout << "Receiver Activation unknown:" << retval << std::endl; -#endif - - return thisDetector->activated; - } - int slsDetector::setDeactivatedRxrPaddingMode(int padding) { int fnum = F_RECEIVER_DEACTIVATED_PADDING_ENABLE; - int retval = -1; - int arg = padding; int ret = OK; + int arg = padding; + int retval = -1; + FILE_LOG(logDEBUG5) << "Deactivated Receiver Padding Enable: " << arg; - if (thisDetector->myDetectorType != EIGER) { - FILE_LOG(logERROR) << "Not implemented for this detector" << std::endl; - setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); - return -1; - } - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl; -#endif - if (connectData() == OK) { + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); - } - if (ret==FAIL) - setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); - else - thisDetector->receiver_deactivatedPaddingEnable = retval; - } + // handle ret + if (ret == FAIL) + setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); + else { + FILE_LOG(logDEBUG5) << "Deactivated Receiver Padding Enable:" << retval; + thisDetector->receiver_deactivatedPaddingEnable = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } return thisDetector->receiver_deactivatedPaddingEnable; } - - int slsDetector::getFlippedData(dimension d) { return thisDetector->flippedData[d]; } - int slsDetector::setFlippedData(dimension d, int value) { - int retval=-1; - int fnum=F_SET_FLIPPED_DATA_RECEIVER; - int ret=FAIL; - int args[2]={X,-1}; + int fnum = F_SET_FLIPPED_DATA_RECEIVER; + int ret = OK; + int args[2] = {(int)d, value}; + int retval = -1; - - if (thisDetector->myDetectorType!= EIGER) { - std::cout << "Flipped Data is not implemented in this detector" << std::endl; + // flipped across y + if (d == Y) { + FILE_LOG(logERROR) << "Flipped across Y axis is not implemented"; setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET)); return -1; } -#ifdef VERBOSE - std::cout << std::endl; - std::cout << "Setting/Getting flipped data across axis " << d <<" with value " - << value << std::endl; -#endif - if (value > -1) { - thisDetector->flippedData[d] = value; - args[1] = value; - } else - args[1] = thisDetector->flippedData[d]; + // replace get with shm value (write to shm right away as it is a det value, not rx value) + if (value > -1) + thisDetector->flippedData[d] = (value > 0) ? 1 : 0; + args[1] = thisDetector->flippedData[d]; + FILE_LOG(logDEBUG5) << "Setting flipped data across axis " << d << " with value: " << value; - args[0] = d; - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK) { + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); - disconnectData(); - } - if ((args[1] != retval && args[1]>=0) || (ret==FAIL)) { - ret = FAIL; + // handle ret + if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET)); + else { + FILE_LOG(logDEBUG5) << "Flipped data:" << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - - if (ret==FORCE_UPDATE) - updateReceiver(); } - - return thisDetector->flippedData[d]; } - int slsDetector::setAllTrimbits(int val) { - int fnum=F_SET_ALL_TRIMBITS; + int fnum = F_SET_ALL_TRIMBITS; + int ret = FAIL; + int arg = val; int retval = -1; - int ret=OK; -#ifdef VERBOSE - FILE_LOG(logINFO) << "Setting all trimbits to "<< val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&val,sizeof(val)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - char mess[MAX_STR_LENGTH]=""; - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); - } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + FILE_LOG(logDEBUG5) << "Setting all trimbits to " << val; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "All trimbit value: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } -#ifdef VERBOSE - FILE_LOG(logINFO) << "All trimbits were set to "<< retval << std::endl; -#endif return retval; } - int slsDetector::enableGapPixels(int val) { - - if (val > 0 && thisDetector->myDetectorType!= EIGER) - val = -1; - if (val >= 0) { - val=(val>0)?1:0; + int fnum = F_ENABLE_GAPPIXELS_IN_RECEIVER; + int ret = OK; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending gap pixels enable to receiver: " << arg; - // send to receiver - int ret=OK; - int retval=-1; - int fnum=F_ENABLE_GAPPIXELS_IN_RECEIVER; - int arg=val; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if ((arg != retval) || (ret==FAIL)) { - ret = FAIL; + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_ENABLE_GAPPIXELS_NOT_SET)); - } + else { + FILE_LOG(logDEBUG5) << "Gap pixels enable to receiver:" << retval; + thisDetector->gappixels = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); - } - - - // update client - if (ret == OK) { - thisDetector->gappixels = val; - thisDetector->dataBytesInclGapPixels = 0; - - if (thisDetector->dynamicRange != 4) { - thisDetector->dataBytesInclGapPixels = - (thisDetector->nChip[X] * - thisDetector->nChan[X] + thisDetector->gappixels * - thisDetector->nGappixels[X]) * - (thisDetector->nChip[Y] * - thisDetector->nChan[Y] + thisDetector->gappixels * - thisDetector->nGappixels[Y]) * - thisDetector->dynamicRange/8; - // set data bytes for other detector ( for future use) - if (thisDetector->myDetectorType==JUNGFRAUCTB) - getTotalNumberOfChannels(); + // update databytes + thisDetector->dataBytesInclGapPixels = 0; + if (thisDetector->dynamicRange != 4) { + thisDetector->dataBytesInclGapPixels = + (thisDetector->nChip[X] * thisDetector->nChan[X] + + thisDetector->gappixels * thisDetector->nGappixels[X]) * + (thisDetector->nChip[Y] * thisDetector->nChan[Y] + + thisDetector->gappixels * thisDetector->nGappixels[Y]) * + thisDetector->dynamicRange / 8; + } + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } } - return thisDetector->gappixels; } - int slsDetector::setTrimEn(int nen, int *en) { if (en) { - for (int ien=0; ientrimEnergies[ien]=en[ien]; thisDetector->nTrimEn=nen; } @@ -4082,421 +3805,326 @@ int slsDetector::setTrimEn(int nen, int *en) { int slsDetector::getTrimEn(int *en) { if (en) { - for (int ien=0; iennTrimEn; ien++) - en[ien]=thisDetector->trimEnergies[ien]; + for (int ien=0; iennTrimEn; ++ien) + en[ien] = thisDetector->trimEnergies[ien]; } return (thisDetector->nTrimEn); } +int slsDetector::pulsePixel(int n, int x, int y) { + int fnum = F_PULSE_PIXEL; + int ret = FAIL; + int args[3] = {n , x, y}; + FILE_LOG(logDEBUG5) << "Pulsing pixel " << n << " number of times at (" << + x << "," << y << ")"; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); + disconnectControl(); -int slsDetector::pulsePixel(int n,int x,int y) { - int ret=FAIL; - int fnum=F_PULSE_PIXEL; - char mess[MAX_STR_LENGTH]=""; - int arg[3]; - arg[0] = n; arg[1] = x; arg[2] = y; - -#ifdef VERBOSE - std::cout<< std::endl<< "Pulsing Pixel " << n << " number of times at (" << - x << "," << "y)" << std::endl << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - return ret; } -int slsDetector::pulsePixelNMove(int n,int x,int y) { - int ret=FAIL; - int fnum=F_PULSE_PIXEL_AND_MOVE; - char mess[MAX_STR_LENGTH]=""; - int arg[3]; - arg[0] = n; arg[1] = x; arg[2] = y; +int slsDetector::pulsePixelNMove(int n, int x, int y) { + int fnum = F_PULSE_PIXEL_AND_MOVE; + int ret = FAIL; + int args[3] = {n, x, y}; + FILE_LOG(logDEBUG5) << "Pulsing pixel " << n << " number of times and move by delta (" << + x << "," << y << ")"; -#ifdef VERBOSE - std::cout<< std::endl<< "Pulsing Pixel " << n << " number of times and move " - "by deltax:" << x << " deltay:" << y << std::endl << std::endl; -#endif + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), NULL, 0); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - return ret; } - int slsDetector::pulseChip(int n) { - int ret=FAIL; - int fnum=F_PULSE_CHIP; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_PULSE_CHIP; + int ret = FAIL; + int arg = n; + FILE_LOG(logDEBUG5) << "Pulsing chip " << n << " number of times"; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + disconnectControl(); -#ifdef VERBOSE - std::cout<< std::endl<< "Pulsing Pixel " << n << " number of times" << std::endl << std::endl; -#endif - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&n,sizeof(n)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(COULD_NOT_PULSE)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - return ret; } - - int slsDetector::setThresholdTemperature(int val) { - - int retval = -1; int fnum = F_THRESHOLD_TEMP; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting threshold temperature to " << val; - int arg=val; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectStop(); - -#ifdef VERBOSE - std::cout<< std::endl; - FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); -#ifdef VERBOSE - FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; -#endif - } else { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); - } - disconnectStop(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); + } else { + FILE_LOG(logDEBUG5) << "Threshold temperature: " << retval; + } // no updateDetector as it is stop server } - return retval; } - int slsDetector::setTemperatureControl(int val) { - - int retval = -1; int fnum = F_TEMP_CONTROL; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting temperature control to " << val; - int arg=val; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectStop(); - -#ifdef VERBOSE - std::cout<< std::endl; - FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); -#ifdef VERBOSE - FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; -#endif - } else { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); - } - disconnectStop(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); + } else { + FILE_LOG(logDEBUG5) << "Temperature control: " << retval; + } // no updateDetector as it is stop server } - return retval; } - - int slsDetector::setTemperatureEvent(int val) { - - int retval = -1; int fnum = F_TEMP_EVENT; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting temperature event to " << val; - int arg=val; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { + ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectStop(); - -#ifdef VERBOSE - std::cout<< std::endl; - FILE_LOG(logINFO) << "Setting/Getting Threshold Temperature to "<< val << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->SendDataOnly(&arg,sizeof(arg)); - stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); -#ifdef VERBOSE - FILE_LOG(logINFO) << "Threshold Temperature returned "<< retval << std::endl; -#endif - } else { - stopSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); - } - disconnectStop(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); + } else { + FILE_LOG(logDEBUG5) << "Temperature event: " << retval; + } // no updateDetector as it is stop server } - return retval; } - int slsDetector::setStoragecellStart(int pos) { - int ret=FAIL; - int fnum=F_STORAGE_CELL_START; - char mess[MAX_STR_LENGTH] = {0}; - int retval=-1; + int fnum = F_STORAGE_CELL_START; + int ret = FAIL; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting storage cell start to " << val; -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending storage cell start index " << pos << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&pos,sizeof(pos)); - //check opening error - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(STORAGE_CELL_START)); - } else - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(STORAGE_CELL_START)); + } else { + FILE_LOG(logDEBUG5) << "Storage cell start: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return retval; } - int slsDetector::programFPGA(std::string fname) { - int ret=FAIL; - int fnum=F_PROGRAM_FPGA; - char mess[MAX_STR_LENGTH]=""; - size_t filesize=0; + // only jungfrau implemented (client processing, so check now) + if (thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != JUNGFRAUCTB) { + FILE_LOG(logERROR) << "Not implemented for this detector"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + FILE_LOG(logDEBUG5) << "Programming FPGA with file name:" << fname; + size_t filesize = 0; char* fpgasrc = NULL; - if (thisDetector->myDetectorType != JUNGFRAU && - thisDetector->myDetectorType != JUNGFRAUCTB) { - std::cout << "Not implemented for this detector" << std::endl; - return FAIL; - } - - //check if it exists - struct stat st; - if (stat(fname.c_str(),&st)) { - std::cout << "Programming file does not exist" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - - // open src - FILE* src = fopen(fname.c_str(),"rb"); - if (src == NULL) { - std::cout << "Could not open source file for programming: " << fname << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - - // create temp destination file - char destfname[] = "/tmp/Jungfrau_MCB.XXXXXX"; - int dst = mkstemp(destfname); // create temporary file and open it in r/w - if (dst == -1) { - std::cout << "Could not create destination file in /tmp for programming: " - << destfname << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - - // convert src to dst rawbin -#ifdef VERBOSE - std::cout << "Converting " << fname << " to " << destfname << std::endl; -#endif - int filepos,x,y,i; - // Remove header (0...11C) - for (filepos=0; filepos < 0x11C; ++filepos) - fgetc(src); - // Write 0x80 times 0xFF (0...7F) { - char c = 0xFF; - for (filepos=0; filepos < 0x80; ++filepos) - write(dst, &c, 1); - } - // Swap bits and write to file - for (filepos=0x80; filepos < 0x1000000; ++filepos) { - x = fgetc(src); - if (x < 0) break; - y=0; - for (i=0; i < 8; ++i) - y=y| ( (( x & (1<> i) << (7-i) ); // This swaps the bits - write(dst, &y, 1); - } - if (filepos < 0x1000000) { - std::cout << "Could not convert programming file. EOF before end of flash" - << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - if (fclose(src)) { - std::cout << "Could not close source file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - if (close(dst)) { - std::cout << "Could not close destination file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } -#ifdef VERBOSE - std::cout << "File has been converted to " << destfname << std::endl; -#endif - - //loading dst file to memory - FILE* fp = fopen(destfname,"r"); - if (fp == NULL) { - std::cout << "Could not open rawbin file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - if (fseek(fp,0,SEEK_END)) { - std::cout << "Seek error in rawbin file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - filesize = ftell(fp); - if (filesize <= 0) { - std::cout << "Could not get length of rawbin file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - rewind(fp); - fpgasrc = (char*)malloc(filesize+1); - if (fpgasrc == NULL) { - std::cout << "Could not allocate size of program" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - return FAIL; - } - if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) { - std::cout << "Could not read rawbin file" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - if (fpgasrc != NULL) - free(fpgasrc); - return FAIL; + struct stat st; + if (stat(fname.c_str(),&st)) { + FILE_LOG(logERROR) << "Programming file does not exist"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } } - if (fclose(fp)) { - std::cout << "Could not close destination file after converting" << std::endl; - setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); - if (fpgasrc != NULL) - free(fpgasrc); - return FAIL; - } - unlink(destfname); // delete temporary file -#ifdef VERBOSE - std::cout << "Successfully loaded the rawbin file to program memory" << std::endl; -#endif + { + // open src + FILE* src = fopen(fname.c_str(),"rb"); + if (src == NULL) { + FILE_LOG(logERROR) << "Could not open source file for programming: " << fname; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + // create temp destination file + char destfname[] = "/tmp/Jungfrau_MCB.XXXXXX"; + int dst = mkstemp(destfname); // create temporary file and open it in r/w + if (dst == -1) { + FILE_LOG(logERROR) << "Could not create destination file in /tmp for programming: " << destfname; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + + // convert src to dst rawbin + FILE_LOG(logDEBUG5) << "Converting " << fname << " to " << destfname; + { + int filepos, x, y, i; + // Remove header (0...11C) + for (filepos=0; filepos < 0x11C; ++filepos) + fgetc(src); + // Write 0x80 times 0xFF (0...7F) + { + char c = 0xFF; + for (filepos=0; filepos < 0x80; ++filepos) + write(dst, &c, 1); + } + // Swap bits and write to file + for (filepos = 0x80; filepos < 0x1000000; ++filepos) { + x = fgetc(src); + if (x < 0) break; + y=0; + for (i = 0; i < 8; ++i) + y=y| ( (( x & (1<> i) << (7-i) ); // This swaps the bits + write(dst, &y, 1); + } + if (filepos < 0x1000000) { + FILE_LOG(logERROR) << "Could not convert programming file. EOF before end of flash"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + } + if (fclose(src)) { + FILE_LOG(logERROR) << "Could not close source file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + if (close(dst)) { + FILE_LOG(logERROR) << "Could not close destination file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + FILE_LOG(logDEBUG5) << "File has been converted to " << destfname; + + //loading dst file to memory + FILE* fp = fopen(destfname,"r"); + if (fp == NULL) { + FILE_LOG(logERROR) << "Could not open rawbin file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + if (fseek(fp, 0, SEEK_END)) { + FILE_LOG(logERROR) << "Seek error in rawbin file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + filesize = ftell(fp); + if (filesize <= 0) { + FILE_LOG(logERROR) << "Could not get length of rawbin file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + rewind(fp); + fpgasrc = (char*)malloc(filesize + 1); + if (fpgasrc == NULL) { + FILE_LOG(logERROR) << "Could not allocate size of program"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + return FAIL; + } + if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) { + FILE_LOG(logERROR) << "Could not read rawbin file"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + if (fpgasrc != NULL) + free(fpgasrc); + return FAIL; + } + + if (fclose(fp)) { + FILE_LOG(logERROR) << "Could not close destination file after converting"; + setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + if (fpgasrc != NULL) + free(fpgasrc); + return FAIL; + } + unlink(destfname); // delete temporary file + FILE_LOG(logDEBUG5) << "Successfully loaded the rawbin file to program memory"; + } // send program from memory to detector -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending programming binary to detector " << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { + int fnum = F_PROGRAM_FPGA; + int ret = FAIL; + char mess[MAX_STR_LENGTH] = {0}; + FILE_LOG(logDEBUG5) << "Sending programming binary to detector"; + + if (thisDetector->onlineFlag == ONLINE_FLAG) { if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&filesize,sizeof(filesize)); - //check opening error + controlSocket->SendDataOnly(&fnum, sizeof(fnum)); + controlSocket->SendDataOnly(&filesize, sizeof(filesize)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + // opening error + if (ret == FAIL) { + controlSocket->ReceiveDataOnly(mess, sizeof(mess)); + FILE_LOG(logERROR) << "Detector " << detId << " returned error: " << mess; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); filesize = 0; } //erasing flash - if (ret!=FAIL) { - FILE_LOG(logINFO) << "This can take awhile. Please be patient..." << std::endl; - printf("Erasing Flash:%d%%\r",0); + if (ret != FAIL) { + FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; + printf("Erasing Flash: %d%%\r", 0); std::cout << std::flush; //erasing takes 65 seconds, printing here (otherwise need threads //in server-unnecessary) - int count = 66; - while(count>0) { + const int ERASE_TIME = 65; + int count = ERASE_TIME + 1; + while(count > 0) { usleep(1 * 1000 * 1000); --count; - printf("Erasing Flash:%d%%\r",(int) (((double)(65-count)/65)*100)); + printf("Erasing Flash:%d%%\r", + (int) (((double)(ERASE_TIME - count) / ERASE_TIME) * 100)); std::cout << std::flush; } - std::cout< 0)) { unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb if (unitprogramsize > filesize) //less than 2mb unitprogramsize = filesize; -#ifdef VERBOSE - std::cout << "unitprogramsize:" << unitprogramsize << "\t filesize:" - << filesize << std::endl; -#endif - controlSocket->SendDataOnly(fpgasrc+currentPointer,unitprogramsize); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - filesize-=unitprogramsize; - currentPointer+=unitprogramsize; + FILE_LOG(logDEBUG5) << "unitprogramsize:" << unitprogramsize << + "\t filesize:" << filesize; + + controlSocket->SendDataOnly(fpgasrc + currentPointer, unitprogramsize); + controlSocket->ReceiveDataOnly(&ret, sizeof(ret)); + if (ret != FAIL) { + filesize -= unitprogramsize; + currentPointer += unitprogramsize; //print progress printf("Writing to Flash:%d%%\r", - (int) (((double)(totalsize-filesize)/totalsize)*100)); + (int) (((double)(totalsize - filesize) / totalsize) * 100)); std::cout << std::flush; } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + FILE_LOG(logERROR) << "Detector returned error: " << mess; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } } - std::cout<ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + controlSocket->ReceiveDataOnly(&ret, sizeof(ret)); + if (ret == FAIL) { + controlSocket->ReceiveDataOnly(mess, sizeof(mess)); + FILE_LOG(logERROR) << "Detector returned error: " << mess; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } } disconnectControl(); - if (ret==FORCE_UPDATE) + if (ret == FORCE_UPDATE) updateDetector(); } @@ -4555,22 +4182,22 @@ int slsDetector::programFPGA(std::string fname) { (strstr(mess,"not implemented") == NULL) && (strstr(mess,"locked") == NULL) && (strstr(mess,"-update") == NULL)) { - fnum=F_RESET_FPGA; - int stopret; + fnum = F_RESET_FPGA; + int stopret = FAIL; if (connectStop() == OK) { - stopSocket->SendDataOnly(&fnum,sizeof(fnum)); - stopSocket->ReceiveDataOnly(&stopret,sizeof(stopret)); + stopSocket->SendDataOnly(&fnum, sizeof(fnum)); + stopSocket->ReceiveDataOnly(&stopret, sizeof(stopret)); if (stopret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; + controlSocket->ReceiveDataOnly(mess, sizeof(mess)); + FILE_LOG(logERROR) << "Detector returned error: " << mess; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); } - disconnectControl(); + disconnectStop(); } } } if (ret != FAIL) { - printf("You can now restart the detector servers in normal mode.\n"); + FILE_LOG(logINFO) << "You can now restart the detector servers in normal mode."; } //free resources @@ -4582,676 +4209,430 @@ int slsDetector::programFPGA(std::string fname) { int slsDetector::resetFPGA() { - int ret=FAIL; - int fnum=F_RESET_FPGA; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_RESET_FPGA; + int ret = FAIL; + int arg = n; + FILE_LOG(logDEBUG5) << "Sending reset FPGA"; - if (thisDetector->myDetectorType != JUNGFRAU) { - std::cout << "Not implemented for this detector" << std::endl; - return FAIL; - } -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending reset to FPGA " << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - // control server - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(RESET_ERROR)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RESET_ERROR)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } return ret; - } - int slsDetector::powerChip(int ival) { - int ret=FAIL; - int fnum=F_POWER_CHIP; - char mess[MAX_STR_LENGTH]=""; - int retval=-1; + int fnum = F_POWER_CHIP; + int ret = FAIL; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting power chip to " << val; - if (thisDetector->myDetectorType != JUNGFRAU && - thisDetector->myDetectorType != JUNGFRAUCTB ) { - std::cout << "Not implemented for this detector" << std::endl; - return FAIL; - } -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending power on/off/get to the chip " << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&ival,sizeof(ival)); - //check opening error - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(POWER_CHIP)); - } else - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(POWER_CHIP)); + } else { + FILE_LOG(logDEBUG5) << "Power chip: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return retval; - } int slsDetector::setAutoComparatorDisableMode(int ival) { - int ret=FAIL; - int fnum=F_AUTO_COMP_DISABLE; - char mess[MAX_STR_LENGTH]=""; - int retval=-1; + int fnum = F_AUTO_COMP_DISABLE; + int ret = FAIL; + int arg = val; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting auto comp disable mode to " << val; - if (thisDetector->myDetectorType != JUNGFRAU) { - std::cout << "Not implemented for this detector" << std::endl; - return FAIL; - } -#ifdef VERBOSE - FILE_LOG(logINFO) << "Enabling/disabling Auto comp disable mode " << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&ival,sizeof(ival)); - //check opening error - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE)); - } else - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE)); + } else { + FILE_LOG(logDEBUG5) << "Auto comp disable: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } return retval; - } -int slsDetector::getChanRegs(double* retval,bool fromDetector) { - int n=getTotalNumberOfChannels(); - if (fromDetector) { - getModule(); - } +int slsDetector::getChanRegs(double* retval) { + int n = getTotalNumberOfChannels(); + // update chanregs + sls_detector_module *myMod = getModule(); + deleteModule(myMod); //the original array has 0 initialized if (chanregs) { - for (int i=0; ionlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - //to exclude trimbits - if (!tb) { - module.nchan=0; - module.nchip=0; - } - sendModule(&module); - - //not included in module - if (gainval && (thisDetector->nGain)) - controlSocket->SendDataOnly(gainval,sizeof(int)*thisDetector->nGain); - if (offsetval && (thisDetector->nOffset)) - controlSocket->SendDataOnly(offsetval,sizeof(int)*thisDetector->nOffset); - if (thisDetector->myDetectorType == EIGER) { - controlSocket->SendDataOnly(&iodelay,sizeof(iodelay)); - controlSocket->SendDataOnly(&tau,sizeof(tau)); - controlSocket->SendDataOnly(&e_eV,sizeof(e_eV)); - } - - - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - if (strstr(mess,"default tau")!=NULL) - setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - ret = updateDetector(); - } + //to exclude trimbits + if (!tb) { + module.nchan = 0; + module.nchip = 0; } + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + controlSocket->SendDataOnly(&fnum, sizeof(fnum)); + sendModule(&module); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { + // handle ret + if (ret == FAIL) { + char mess[MAX_STR_LENGTH] = {0}; + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + FILE_LOG(logERROR) << "Detector " << detId << " returned error: " << mess; + if (strstr(mess,"default tau") != NULL) + setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); + else + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + FILE_LOG(logDEBUG5) << "Set Module returned: " << retval; + + disconnectControl(); + if (ret == FORCE_UPDATE) + ret = updateDetector(); + } + + // update client structure + if (ret = OK) { if (detectorModules) { - if (tb) { - (detectorModules)->nchan=module.nchan; - (detectorModules)->nchip=module.nchip; - } - (detectorModules)->ndac=module.ndac; - (detectorModules)->nadc=module.nadc; - if (tb) { - thisDetector->nChips=module.nchip; - thisDetector->nChans=module.nchan/module.nchip; - } - thisDetector->nDacs=module.ndac; - thisDetector->nAdcs=module.nadc; - - if (thisDetector->myDetectorType != JUNGFRAU) { - if (tb) { - for (int ichip=0; ichipnChips; ++ichip) { - if (chipregs) - chipregs[ichip]= - module.chipregs[ichip]; - - if (chanregs) { - for (int i=0; inChans; ++i) { - chanregs[i+ichip* - thisDetector->nChans]= - module.chanregs[ichip*thisDetector->nChans+i]; - } - } + if (thisDetector->myDetectorType == EIGER && tb && chanregs) { + for (int ichip = 0; ichip < thisDetector->nChips; ++ichip) { + for (int i = 0; i < thisDetector->nChans; ++i) { + chanregs[i + ichip * thisDetector->nChans] = + module.chanregs[ichip * thisDetector->nChans + i]; } } - if (adcs) { - for (int i=0; inAdcs; ++i) - adcs[i]=module.adcs[i]; - } } - + if (adcs) { + for (int i = 0; i < thisDetector->nAdcs; ++i) { + adcs[i] = module.adcs[i]; + } if (dacs) { - for (int i=0; inDacs; ++i) - dacs[i]=module.dacs[i]; + for (int i = 0; i < thisDetector->nDacs; ++i) + dacs[i] = module.dacs[i]; } - - (detectorModules)->gain=module.gain; - (detectorModules)->offset=module.offset; - (detectorModules)->serialnumber=module.serialnumber; - (detectorModules)->reg=module.reg; + (detectorModules)->serialnumber = module.serialnumber; + (detectorModules)->reg = module.reg; + (detectorModules)->iodelay = module.iodelay; + (detectorModules)->tau = module.tau; + (detectorModules)->eV = module.eV; } - - if ((thisDetector->nGain) && (gainval) && (gain)) { - for (int i=0; inGain; ++i) - gain[i]=gainval[i]; - } - - if ((thisDetector->nOffset) && (offsetval) && (offset)) { - for (int i=0; inOffset; ++i) - offset[i]=offsetval[i]; - } - if (e_eV != -1) thisDetector->currentThresholdEV = e_eV; } - -#ifdef VERBOSE - FILE_LOG(logINFO) << "Module register returned "<< retval << std::endl; -#endif - return ret; } - - - slsDetectorDefs::sls_detector_module *slsDetector::getModule() { + int fnum = F_GET_MODULE; + int ret = FAIL; + int arg = (int)isettings; + FILE_LOG(logDEBUG5) << "Getting module"; -#ifdef VERBOSE - std::cout << "slsDetector get module " << std::endl; -#endif + sls_detector_module *myMod = createModule(); - int fnum=F_GET_MODULE; - sls_detector_module *myMod=createModule(); + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); - int* gainval=0, *offsetval=0; - if (thisDetector->nGain) - gainval=new int[thisDetector->nGain]; - if (thisDetector->nOffset) - offsetval=new int[thisDetector->nOffset]; - - - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - // int n; - -#ifdef VERBOSE - FILE_LOG(logINFO) << "getting module " << std::endl; -#endif - - - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - receiveModule(myMod); - - //extra gain and offset - eiger - if (thisDetector->nGain) - controlSocket->ReceiveDataOnly(gainval,sizeof(int)*thisDetector->nGain); - if (thisDetector->nOffset) - controlSocket->ReceiveDataOnly(offsetval,sizeof(int)*thisDetector->nOffset); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + receiveModule(myMod); + if (ret == FORCE_UPDATE) + ret = updateDetector(); } + disconnectControl(); } - - if (ret!=FAIL) { + // update client structure + if (ret == OK) { if (detectorModules) { - (detectorModules)->nchan=myMod->nchan; - (detectorModules)->nchip=myMod->nchip; - (detectorModules)->ndac=myMod->ndac; - (detectorModules)->nadc=myMod->nadc; - thisDetector->nChips=myMod->nchip; - thisDetector->nChans=myMod->nchan/myMod->nchip; - thisDetector->nDacs=myMod->ndac; - thisDetector->nAdcs=myMod->nadc; - - if (thisDetector->myDetectorType != JUNGFRAU) { - for (int ichip=0; ichipnChips; ++ichip) { - if (chipregs) - chipregs[ichip]= - myMod->chipregs[ichip]; - - if (chanregs) { - for (int i=0; inChans; ++i) { - chanregs[i+ichip*thisDetector->nChans]= - myMod->chanregs[ichip*thisDetector->nChans+i]; - } + if (thisDetector->myDetectorType == EIGER && chanregs) { + for (int ichip = 0; ichip < thisDetector->nChips; ++ichip) { + for (int i = 0; i < thisDetector->nChans; ++i) { + chanregs[i+ichip*thisDetector->nChans] = + myMod->chanregs[ichip*thisDetector->nChans+i]; } } - - if (adcs) { - for (int i=0; inAdcs; ++i) - adcs[i]=myMod->adcs[i]; - } } - + if (adcs) { + for (int i = 0; i < thisDetector->nAdcs; ++i) + adcs[i] = myMod->adcs[i]; + } if (dacs) { - for (int i=0; inDacs; ++i) { - dacs[i]=myMod->dacs[i]; + for (int i = 0; i < thisDetector->nDacs; ++i) { + dacs[i] = myMod->dacs[i]; } } - (detectorModules)->gain=myMod->gain; - (detectorModules)->offset=myMod->offset; - (detectorModules)->serialnumber=myMod->serialnumber; - (detectorModules)->reg=myMod->reg; - + (detectorModules)->serialnumber = myMod->serialnumber; + (detectorModules)->reg = myMod->reg; + (detectorModules)->iodelay = myMod->iodelay; + (detectorModules)->tau = myMod->tau; + (detectorModules)->eV = myMod->eV; } - - if ((thisDetector->nGain) && (gainval) && (gain)) { - for (int i=0; inGain; ++i) - gain[i+thisDetector->nGain]=gainval[i]; - } - - if ((thisDetector->nOffset) && (offsetval) && (offset)) { - for (int i=0; inOffset; ++i) - offset[i+thisDetector->nOffset]=offsetval[i]; - } - } else { deleteModule(myMod); - myMod=NULL; + myMod = NULL; } - - if (gainval) delete[]gainval; - if (offsetval) delete[]offsetval; - return myMod; } +int slsDetector::setRateCorrection(int64_t t) { + int fnum = F_SET_RATE_CORRECT; + int ret = FAIL; + int64_t arg = t; + FILE_LOG(logDEBUG5) << "Setting Rate Correction to " << arg; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + disconnectControl(); -int slsDetector::calibratePedestal(int frames) { - int ret=FAIL; - int retval=-1; - int fnum=F_CALIBRATE_PEDESTAL; - char mess[MAX_STR_LENGTH]=""; - -#ifdef VERBOSE - std::cout<<"Calibrating Pedestal " <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&frames,sizeof(frames)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } + // handle ret + if (ret == FAIL) { + if (strstr(mess,"default tau")!=NULL) + setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); + if (strstr(mess,"32")!=NULL) + setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); + else + setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); + } else if (ret == FORCE_UPDATE) + ret = updateDetector(); } - - return retval; + return ret; } - -int slsDetector::setRateCorrection(int t) { - - if (getDetectorsType() == EIGER) { - int fnum=F_SET_RATE_CORRECT; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; - int64_t arg = t; - -#ifdef VERBOSE - FILE_LOG(logINFO) << "Setting Rate Correction to " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&arg,sizeof(arg)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - if (strstr(mess,"default tau")!=NULL) - setErrorMask((getErrorMask())|(RATE_CORRECTION_NO_TAU_PROVIDED)); - if (strstr(mess,"32")!=NULL) - setErrorMask((getErrorMask())|(RATE_CORRECTION_NOT_32or16BIT)); - else - setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION)); - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); - } - } - return ret; //only success/fail - } - printf("unknown detector\n"); - return -1; -} - - - -int slsDetector::getRateCorrection() { - int fnum=F_GET_RATE_CORRECT; - int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; +int64_t slsDetector::getRateCorrection() { + int fnum = F_GET_RATE_CORRECT; + int ret = FAIL; int64_t retval = -1; -#ifdef VERBOSE - FILE_LOG(logINFO) << "Setting Rate Correction to " << arg << std::endl; -#endif - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + FILE_LOG(logDEBUG5) << "Getting rate correction"; + + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Rate correction: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return retval; } - - -int slsDetector::printReceiverConfiguration() { - std::cout << std::endl - << "#Detector " << detId << ":" << std::endl; - std::cout << "Detector IP:\t\t" << getNetworkParameter(DETECTOR_IP) << std::endl; - std::cout << "Detector MAC:\t\t" << getNetworkParameter(DETECTOR_MAC) << std::endl; - - std::cout << "Receiver Hostname:\t" << getNetworkParameter(RECEIVER_HOSTNAME) << std::endl; - std::cout << "Receiver UDP IP:\t" << getNetworkParameter(RECEIVER_UDP_IP) << std::endl; - std::cout << "Receiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << std::endl; - std::cout << "Receiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << std::endl; - - if (thisDetector->myDetectorType == EIGER) - std::cout << "Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2) - << std::endl; - std::cout << std::endl; - - return OK; +void slsDetector::printReceiverConfiguration(int level) { + FILE_LOG(level) << "#Detector " << detId << ":\n" << + "Receiver Hostname:\t" << getNetworkParameter(RECEIVER_HOSTNAME) << + "Detector UDP IP (Source):\t\t" << getNetworkParameter(DETECTOR_IP) << + "Detector UDP MAC:\t\t" << getNetworkParameter(DETECTOR_MAC) << + "Receiver UDP IP:\t" << getNetworkParameter(RECEIVER_UDP_IP) << + "Receiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << + "Receiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << + ((thisDetector->myDetectorType == EIGER) ? + ("Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2) << "\n") + : ("\n")); } - - - int slsDetector::setReceiverOnline(int off) { - if (off!=GET_ONLINE_FLAG) { + if (off != GET_ONLINE_FLAG) { // no receiver - if (!strcmp(thisDetector->receiver_hostname,"none")) + if (!strcmp(thisDetector->receiver_hostname, "none")) thisDetector->receiverOnlineFlag = OFFLINE_FLAG; else thisDetector->receiverOnlineFlag = off; - // check receiver online - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + // set online + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG) { setReceiverTCPSocket(); // error in connecting - if (thisDetector->receiverOnlineFlag==OFFLINE_FLAG) { - std::cout << "cannot connect to receiver" << std::endl; + if (thisDetector->receiverOnlineFlag == OFFLINE_FLAG) { + FILE_LOG(logERROR) << "Cannot connect to receiver"; setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER)); } } - } return thisDetector->receiverOnlineFlag; } - std::string slsDetector::checkReceiverOnline() { - std::string retval = ""; - //if it doesnt exits, create data socket + std::string retval; + //if it doesnt exit, create socket and call this function again if (!dataSocket) { - //this already sets the online/offline flag setReceiverTCPSocket(); - if (thisDetector->receiverOnlineFlag==OFFLINE_FLAG) + if (thisDetector->receiverOnlineFlag == OFFLINE_FLAG) return std::string(thisDetector->receiver_hostname); else - return std::string(""); + return retval; } //still cannot connect to socket, dataSocket=0 if (dataSocket) { if (connectData() == FAIL) { dataSocket->SetTimeOut(5); - thisDetector->receiverOnlineFlag=OFFLINE_FLAG; + thisDetector->receiverOnlineFlag = OFFLINE_FLAG; delete dataSocket; - dataSocket=0; -#ifdef VERBOSE - FILE_LOG(logINFO) << "receiver offline!" << std::endl; -#endif + dataSocket = 0; + FILE_LOG(logDEBUG5) << "receiver " << detId << " offline!"; return std::string(thisDetector->receiver_hostname); } else { - thisDetector->receiverOnlineFlag=ONLINE_FLAG; + thisDetector->receiverOnlineFlag = ONLINE_FLAG; dataSocket->SetTimeOut(100); disconnectData(); -#ifdef VERBOSE - FILE_LOG(logINFO) << "receiver online!" << std::endl; -#endif - return std::string(""); + FILE_LOG(logDEBUG5) << "receiver " << detId << " online!"; } } return retval; } - - - int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver_port) { + char thisName[MAX_STR_LENGTH] = {0}; + int thisRP = 0; + int ret = OK; - char thisName[MAX_STR_LENGTH]; - int thisRP; - int retval=OK; - - //if receiver ip given - if (strcmp(name.c_str(),"")!=0) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "setting receiver" << std::endl; -#endif - strcpy(thisName,name.c_str()); - strcpy(thisDetector->receiver_hostname,thisName); - if (dataSocket) { - delete dataSocket; - dataSocket=0; - } - } else + // rx_hostname + if (name.empty()) { strcpy(thisName,thisDetector->receiver_hostname); - - //if receiverTCPPort given - if (receiver_port>0) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "setting data port" << std::endl; -#endif - thisRP=receiver_port; - thisDetector->receiverTCPPort=thisRP; + } else { + FILE_LOG(logDEBUG5) << "Setting rx_hostname"; + strcpy(thisName, name.c_str()); + strcpy(thisDetector->receiver_hostname, thisName); if (dataSocket) { delete dataSocket; - dataSocket=0; + dataSocket = 0; } - } else - thisRP=thisDetector->receiverTCPPort; + } - //create data socket + // data port + if (receiver_port <= 0) { + thisRP = thisDetector->receiverTCPPort; + } else { + FILE_LOG(logDEBUG5) << "Setting data port"; + thisRP = receiver_port; + thisDetector->receiverTCPPort = thisRP; + if (dataSocket) { + delete dataSocket; + dataSocket = 0; + } + } + + // create data socket if (!dataSocket) { try { dataSocket = new MySocketTCP(thisName, thisRP); -#ifdef VERYVERBOSE - FILE_LOG(logINFO) << "Data socket connected " << - thisName << " " << thisRP << std::endl; -#endif + FILE_LOG(logDEBUG5) << "Data socket connected " << thisName << " " << thisRP; } catch(...) { -#ifdef VERBOSE - FILE_LOG(logERROR) << "Could not connect Data socket " << - thisName << " " << thisRP << std::endl; -#endif + FILE_LOG(logERROR) << "Could not connect Data socket " << thisName << " " << thisRP; dataSocket = 0; - retval = FAIL; + ret = FAIL; } } + if (ret == FAIL) { + thisDetector->receiverOnlineFlag = OFFLINE_FLAG; + FILE_LOG(logDEBUG5) << "Receiver offline"; + } - //check if it connects - if (retval!=FAIL) { + // check online and version compatibility + else { checkReceiverOnline(); thisReceiver->SetSocket(dataSocket); // check for version compatibility - switch (thisDetector->myDetectorType) { - case EIGER: - case JUNGFRAU: - case GOTTHARD: - if (thisDetector->receiverAPIVersion == 0) { - if (checkVersionCompatibility(DATA_PORT) == FAIL) - thisDetector->receiverOnlineFlag=OFFLINE_FLAG; - } - break; - default: - break; + if (thisDetector->receiverAPIVersion == 0) { + if (checkVersionCompatibility(DATA_PORT) == FAIL) + thisDetector->receiverOnlineFlag = OFFLINE_FLAG; } - - } else { - thisDetector->receiverOnlineFlag=OFFLINE_FLAG; -#ifdef VERBOSE - FILE_LOG(logINFO) << "offline!" << std::endl; -#endif } - return retval; + return ret; } - int slsDetector::lockReceiver(int lock) { - int fnum=F_LOCK_RECEIVER; + int fnum = F_LOCK_RECEIVER; int ret = FAIL; - int retval=-1; - int arg=lock; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting receiver server lock to " << lock; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &lock, sizeof(lock), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Locking or Unlocking Receiver " << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Lock: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - updateReceiver(); } - return retval; } - - - - std::string slsDetector::getReceiverLastClientIP() { - int fnum=F_GET_LAST_RECEIVER_CLIENT_IP; + int fnum = F_GET_LAST_RECEIVER_CLIENT_IP; int ret = FAIL; - char retval[INET_ADDRSTRLEN]=""; + char retval[INET_ADDRSTRLEN] = {0}; + FILE_LOG(logDEBUG5) << "Getting last client ip to receiver server"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Geting Last Client IP connected to Receiver " << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, retval, INET_ADDRSTRLEN); - disconnectData(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Last client IP to receiver: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - updateReceiver(); } - return std::string(retval); } @@ -5259,33 +4640,34 @@ std::string slsDetector::getReceiverLastClientIP() { int slsDetector::exitReceiver() { int fnum = F_EXIT_RECEIVER; int ret = FAIL; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK) { - ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); - disconnectData(); - } - } - if (ret == OK) { - std::cout << std::endl << "Shutting down the receiver" << std::endl << std::endl; + FILE_LOG(logDEBUG5) << "Sending exit command to receiver server"; + + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectData(); + // no ret handling as ret never fail + FILE_LOG(logINFO) << "Shutting down the receiver server"; } return ret; } + int slsDetector::execReceiverCommand(std::string cmd) { int fnum = F_EXEC_RECEIVER_COMMAND; int ret = FAIL; char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; - - strcpy(arg,cmd.c_str()); + strcpy(arg, cmd.c_str()); FILE_LOG(logDEBUG5) << "Sending command to receiver " << arg; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); - disconnectData(); - } - if (ret != FAIL) { + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { FILE_LOG(logINFO) << "Receiver " << detId << " returned:\n" << retval; } } @@ -5293,94 +4675,91 @@ int slsDetector::execReceiverCommand(std::string cmd) { } - int slsDetector::updateReceiverNoWait() { - int n = 0,ind; - char path[MAX_STR_LENGTH]; - char lastClientIP[INET_ADDRSTRLEN]; + int n = 0, i32 = 0; + char cstring[MAX_STR_LENGTH] = {0}; + char lastClientIP[INET_ADDRSTRLEN] = {0}; - n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); -#ifdef VERBOSE - FILE_LOG(logINFO) << "Updating receiver last modified by " << lastClientIP << std::endl; -#endif + n += dataSocket->ReceiveDataOnly(lastClientIP, sizeof(lastClientIP)); + FILE_LOG(logDEBUG5) << "Updating receiver last modified by " << lastClientIP; // filepath - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - strcpy(thisDetector->receiver_filePath, path); + n += dataSocket->ReceiveDataOnly(cstring, sizeof(cstring)); + strcpy(thisDetector->receiver_filePath, cstring); // filename - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - strcpy(thisDetector->receiver_fileName, path); + n += dataSocket->ReceiveDataOnly(cstring, sizeof(cstring)); + strcpy(thisDetector->receiver_fileName, cstring); // index - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_fileIndex = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_fileIndex = i32; //file format - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_fileFormatType = (fileFormat)ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_fileFormatType = (fileFormat)i32; // frames per file - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_framesPerFile = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_framesPerFile = i32; // frame discard policy - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_frameDiscardMode = (frameDiscardPolicy)ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_frameDiscardMode = (frameDiscardPolicy)i32; // frame padding - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_framePadding = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_framePadding = i32; // file write enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_fileWriteEnable = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_fileWriteEnable = i32; // file overwrite enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_overWriteEnable = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_overWriteEnable = i32; // gap pixels - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->gappixels = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->gappixels = i32; // receiver read frequency - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_read_freq = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_read_freq = i32; // receiver streaming port - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_zmqport = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_zmqport = i32; // streaming source ip - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - strcpy(thisDetector->receiver_zmqip, path); + n += dataSocket->ReceiveDataOnly(cstring, sizeof(cstring)); + strcpy(thisDetector->receiver_zmqip, cstring); // additional json header - n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); - strcpy(thisDetector->receiver_additionalJsonHeader, path); + n += dataSocket->ReceiveDataOnly(cstring, sizeof(cstring)); + strcpy(thisDetector->receiver_additionalJsonHeader, cstring); // receiver streaming enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_upstream = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_upstream = i32; // activate - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->activated = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->activated = i32; // deactivated padding enable - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_deactivatedPaddingEnable = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_deactivatedPaddingEnable = i32; // silent mode - n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); - thisDetector->receiver_silentMode = ind; + n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); + thisDetector->receiver_silentMode = i32; - if (!n) printf("n: %d\n", n); + if (!n) + FILE_LOG(logERROR) << "Could not update receiver, received 0 bytes\n"; return OK; - } @@ -5388,94 +4767,91 @@ int slsDetector::updateReceiverNoWait() { int slsDetector::updateReceiver() { - int fnum=F_UPDATE_RECEIVER_CLIENT; - int ret=OK; - char mess[MAX_STR_LENGTH]=""; + int fnum = F_UPDATE_RECEIVER_CLIENT; + int ret = FAIL; + FILE_LOG(logDEBUG5) << "Sending update client to receiver server"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - if (connectData() == OK) { - dataSocket->SendDataOnly(&fnum,sizeof(fnum)); - dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret == FAIL) { - dataSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - else - updateReceiverNoWait(); - - //if ret is force update, do not update now as client is updating - //receiver currently - disconnectData(); - } + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); + if (ret == FAIL) + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + else + updateReceiverNoWait(); + disconnectData(); } - return ret; } - void slsDetector::sendMultiDetectorSize() { - int fnum=F_SEND_RECEIVER_MULTIDETSIZE; + int fnum = F_SEND_RECEIVER_MULTIDETSIZE; int ret = FAIL; + int args[2] = thisDetector->multiSize; int retval = -1; + FILE_LOG(logDEBUG5) << "Sending multi detector size to Receiver (" << + thisDetector->multiSize[0] << "," << thisDetector->multiSize[1] << ")"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending multi detector size to Receiver (" << - thisDetector->multiSize[0] << "," - << thisDetector->multiSize[1] << ")" << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, thisDetector->multiSize, sizeof(thisDetector->multiSize), &retval, sizeof(retval)); - disconnectData(); - } - if ((ret==FAIL)) { - FILE_LOG(logERROR) << "Could not set position Id" << std::endl; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_MULTI_DET_SIZE_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver multi size returned: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } + return retval; } void slsDetector::setDetectorId() { - int fnum=F_SEND_RECEIVER_DETPOSID; + int fnum = F_SEND_RECEIVER_DETPOSID; int ret = FAIL; - int retval = -1; int arg = detId; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending detector pos id to Receiver " << detId; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending detector pos id to Receiver " << detId << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if ((ret==FAIL) || (retval != arg)) { - FILE_LOG(logERROR) << "Could not set position Id" << std::endl; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DET_POSID_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Position Id returned: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } + return retval; } void slsDetector::setDetectorHostname() { - int fnum=F_SEND_RECEIVER_DETHOSTNAME; + int fnum = F_SEND_RECEIVER_DETHOSTNAME; int ret = FAIL; - char retval[MAX_STR_LENGTH]=""; + char args[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + strcpy(args, thisDetector->hostname); + FILE_LOG(logDEBUG5) << "Sending detector hostname to Receiver " << args; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending detector hostname to Receiver " << - thisDetector->hostname << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, thisDetector->hostname, MAX_STR_LENGTH, retval, MAX_STR_LENGTH); - disconnectData(); - } - if ((ret==FAIL) || (strcmp(retval,thisDetector->hostname))) + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver set detector hostname: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } } @@ -5485,39 +4861,33 @@ std::string slsDetector::getFilePath() { } - std::string slsDetector::setFilePath(std::string s) { + if (!s.empty()) { + int fnum = F_SET_RECEIVER_FILE_PATH; + int ret = FAIL; + char args[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + strcpy(args, s.c_str()); + FILE_LOG(logDEBUG5) << "Sending file path to Receiver " << args; - if (s.empty()) - return getFilePath(); - - - int fnum = F_SET_RECEIVER_FILE_PATH; - int ret = FAIL; - char arg[MAX_STR_LENGTH]=""; - char retval[MAX_STR_LENGTH] = ""; - - strcpy(arg,s.c_str()); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending file path to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); disconnectData(); + + // handle ret + if (ret == FAIL) { + if (!s.empty()) { + FILE_LOG(logERROR) << "file path does not exist"; + setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); + } else + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file path: " << retvals; + strcpy(thisDetector->receiver_filePath, retvals); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } - if (ret!=FAIL) { - strcpy(thisDetector->receiver_filePath,retval); - } - else { - if (!s.empty()) { - FILE_LOG(logERROR) << "file path does not exist" << std::endl; - setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST)); - } else - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - } - if (ret==FORCE_UPDATE) - updateReceiver(); } return getFilePath(); } @@ -5527,65 +4897,58 @@ std::string slsDetector::getFileName() { return thisDetector->receiver_fileName; } + std::string slsDetector::setFileName(std::string s) { + if (!s.empty()) { + int fnum = F_SET_RECEIVER_FILE_NAME; + int ret = FAIL; + char args[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; + strcpy(args, s.c_str()); + FILE_LOG(logDEBUG5) << "Sending file name to Receiver " << args; - if (s.empty()) - return getFileName(); - - - int fnum=F_SET_RECEIVER_FILE_NAME; - int ret = FAIL; - char arg[MAX_STR_LENGTH]=""; - char retval[MAX_STR_LENGTH]=""; - - strcpy(arg,s.c_str()); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending file name to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - strcpy(thisDetector->receiver_fileName,retval); - if (ret==FORCE_UPDATE) - updateReceiver(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file name: " << retvals; + strcpy(thisDetector->receiver_fileName, retvals); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } + } return getFileName(); } int slsDetector::setReceiverFramesPerFile(int f) { + if (f >= 0) { + int fnum = F_SET_RECEIVER_FRAMES_PER_FILE; + int ret = FAIL; + int arg = f; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting receiver frames per file to " << arg; - if (f < 0) - return thisDetector->receiver_framesPerFile; - - int fnum = F_SET_RECEIVER_FRAMES_PER_FILE; - int ret = FAIL; - int retval = -1; - int arg = f; - - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending frames per file to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_framesPerFile = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver frames per file: " << retval; + thisDetector->receiver_framesPerFile = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } + } return thisDetector->receiver_framesPerFile; } @@ -5593,92 +4956,92 @@ int slsDetector::setReceiverFramesPerFile(int f) { slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) { int fnum = F_RECEIVER_DISCARD_POLICY; int ret = FAIL; - int retval = -1; - int arg = f; + int arg = (int)f; + frameDiscardPolicy retval = (frameDiscardPolicy)-1; + FILE_LOG(logDEBUG5) << "Setting receiver frames discard policy to " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending frames discard policy to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else if (ret!=FAIL && retval > -1) { - thisDetector->receiver_frameDiscardMode = (frameDiscardPolicy)retval; + } else { + FILE_LOG(logDEBUG5) << "Receiver frames discard policy: " << retval; + thisDetector->receiver_frameDiscardMode = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - updateReceiver(); } return thisDetector->receiver_frameDiscardMode; } + int slsDetector::setReceiverPartialFramesPadding(int f) { int fnum = F_RECEIVER_PADDING_ENABLE; int ret = FAIL; - int retval = -1; int arg = f; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting receiver partial frames enable to " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending partial frames enable to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else if (ret!=FAIL && retval > -1) { - thisDetector->receiver_framePadding = (bool)retval; + } else { + FILE_LOG(logDEBUG5) << "Receiver partial frames enable: " << retval; + thisDetector->receiver_framePadding = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - updateReceiver(); } return thisDetector->receiver_framePadding; } + slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { - if (f == GET_FILE_FORMAT) - return getFileFormat(); - int fnum=F_SET_RECEIVER_FILE_FORMAT; - int ret = FAIL; - int arg = f; - int retval = -1; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending file format to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + if (f != GET_FILE_FORMAT) { + int fnum = F_SET_RECEIVER_FILE_FORMAT; + int ret = FAIL; + int arg = f; + fileFormat retval = (fileFormat)-1; + FILE_LOG(logDEBUG5) << "Setting receiver file format to " << arg; + + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file format: " << retval; + thisDetector->receiver_fileFormatType = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT)); - else - thisDetector->receiver_fileFormatType = (fileFormat)retval; - if (ret==FORCE_UPDATE) - updateReceiver(); } return getFileFormat(); } - slsDetectorDefs::fileFormat slsDetector::getFileFormat() { return thisDetector->receiver_fileFormatType; } + int slsDetector::getFileIndex() { return thisDetector->receiver_fileIndex; } + int slsDetector::setFileIndex(int i) { if (i < 0) @@ -6443,7 +5806,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( //Interpolate all trimbits if (tb) { - for (int i = 0; inchan; i++) + for (int i = 0; inchan; ++i) myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]); } return myMod; @@ -6453,7 +5816,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, - int& iodelay, int& tau, sls_detector_module* myMod, int tb) { + sls_detector_module* myMod, int tb) { int nflag=0; @@ -6524,13 +5887,13 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string infile.open(myfname.c_str(),std::ifstream::binary); if (infile.is_open()) { infile.read((char*) myMod->dacs,sizeof(int)*(myMod->ndac)); - infile.read((char*)&iodelay,sizeof(iodelay)); - infile.read((char*)&tau,sizeof(tau)); + infile.read((char*)&myMod->iodelay,sizeof(myMod->iodelay)); + infile.read((char*)&myMod->tau,sizeof(myMod->tau)); #ifdef VERBOSE - for(int i=0;indac;i++) + for(int i=0;indac;++i) FILE_LOG(logINFO) << "dac " << i << ":" << myMod->dacs[i] << std::endl; - FILE_LOG(logINFO) << "iodelay:" << iodelay << std::endl; - FILE_LOG(logINFO) << "tau:" << tau << std::endl; + FILE_LOG(logINFO) << "iodelay:" << myMod->iodelay << std::endl; + FILE_LOG(logINFO) << "tau:" << myMod->tau << std::endl; #endif if (tb) { infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); @@ -6559,16 +5922,16 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string if (infile.is_open()) { while(infile.good()) { getline(infile,str); - iline++; + ++iline; #ifdef VERBOSE std::cout<< str << std::endl; #endif std::istringstream ssstr(str); ssstr >> sargname >> ival; - for (i=0;idacs[i]=ival; - idac++; + ++idac; #ifdef VERBOSE std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; #endif @@ -6612,8 +5975,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string } -int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, - int iodelay, int tau) { +int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) { std::ofstream outfile; @@ -6664,14 +6026,15 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, if (outfile.is_open()) { iv = 1150; #ifdef VERBOSE - for(int i=0;i(&iodelay), sizeof(iodelay)); - outfile.write(reinterpret_cast(&tau), sizeof(tau)); + + outfile.write(reinterpret_cast(&mod.iodelay), sizeof(mod.iodelay)); + outfile.write(reinterpret_cast(&mod.tau), sizeof(mod.tau)); outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); outfile.close(); @@ -6686,7 +6049,7 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod, outfile.open(fname.c_str(), std::ios_base::out); if (outfile.is_open()) { - for (idac=0; idac0 otherwise */ - int setRateCorrection(int t=0); + int setRateCorrection(int64_t t = 0); /** * Get rate correction Eiger) * @returns 0 if rate correction disabled, > 0 otherwise */ - int getRateCorrection(); + int64_t getRateCorrection(); /** * Prints receiver configuration - * @returns OK or FAIL + * #param level print level */ - int printReceiverConfiguration(); + void printReceiverConfiguration(int level = logINFO); /** * Checks if receiver is online and set flag @@ -1824,28 +1789,21 @@ private: /** * reads a trim/settings file * @param fname name of the file to be read - * @param iodelay io delay (detector specific) - * @param tau tau (detector specific) * @param myMod pointer to the module structure which has to be set.
* If it is NULL a new module structure will be created * @param tb 1 to include trimbits, 0 to exclude (used for eiger) * @returns the pointer to myMod or NULL if reading the file failed */ - sls_detector_module* readSettingsFile(std::string fname, - int& iodelay, int& tau, - sls_detector_module* myMod=NULL, int tb=1); + sls_detector_module* readSettingsFile(std::string fname, sls_detector_module* myMod=NULL, int tb=1); /** * writes a trim/settings file * @param fname name of the file to be written * @param mod module structure which has to be written to file - * @param iodelay io delay (detector specific) - * @param tau tau (detector specific) * @returns OK or FAIL if the file could not be written */ - int writeSettingsFile(std::string fname, - sls_detector_module mod, int iodelay, int tau); + int writeSettingsFile(std::string fname, sls_detector_module mod); /** slsDetector Id or position in the detectors list */ @@ -1884,17 +1842,8 @@ private: /** pointer to adc valuse in shared memory */ int *adcs; - /** pointer to chip registers in shared memory */ - int *chipregs; - /** pointer to channal registers in shared memory */ int *chanregs; - - /** pointer to gain values in shared memory */ - int *gain; - - /** pointer to offset values in shared memory */ - int *offset; }; #endif diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 3c57d5fe8..b28868d8c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -924,14 +924,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings; ++i; - /*! \page settings - - pedestal [i] starts acquisition for i frames, calculates pedestal and writes back to fpga. Used in GOTTHARD only. Only put! \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName="pedestal"; // - descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings; - ++i; - - /* pots */ /*! \page settings @@ -2725,16 +2717,16 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int d if (action==HELP_ACTION) { return helpRateCorr(action); } - int fval; + int64_t ival; char answer[1000]; myDet->setOnline(ONLINE_FLAG, detPos); if (action==PUT_ACTION) { - sscanf(args[1],"%d",&fval); - myDet->setRateCorrection(fval, detPos); + sscanf(args[1],"%lld",&ival); + myDet->setRateCorrection(ival, detPos); } - sprintf(answer,"%d",myDet->getRateCorrection(detPos)); + sprintf(answer,"%lld",myDet->getRateCorrection(detPos)); return string(answer); } @@ -3549,15 +3541,6 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action, int d } sprintf(ans,"%d",myDet->setAllTrimbits(-1, detPos)); return ans; - } else if (cmd=="pedestal") { - if (action==GET_ACTION) - return string("cannot get"); - if (sscanf(args[1],"%d",&val)){ - sprintf(ans,"%d",myDet->calibratePedestal(val, detPos)); - return string(ans); - }else - return string("cannot parse frame number")+cmd; - } return string("unknown settings command ")+cmd; @@ -3574,8 +3557,6 @@ string slsDetectorCommand::helpSettings(int action) { os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl; os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl; os << "trimval i \n sets all the trimbits to i" << std::endl; - os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl; - } if (action==GET_ACTION || action==HELP_ACTION) { os << "settings \n gets the settings of the detector"<< std::endl; diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h index b57176962..fc39c27a9 100644 --- a/slsReceiverSoftware/include/slsReceiverImplementation.h +++ b/slsReceiverSoftware/include/slsReceiverImplementation.h @@ -55,7 +55,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { /* * Get detector hostname - * @return NULL or hostname or NULL if uninitialized (max of 1000 characters) + * @return hostname (max of 1000 characters) */ char *getDetectorHostname() const; @@ -80,13 +80,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { fileFormat getFileFormat() const; /** * Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) - * @return NULL or file name prefix (max of 1000 characters) + * @return file name prefix */ char *getFileName() const; /** * Get File Path - * @return NULL or file path (max of 1000 characters) + * @return file path */ char *getFilePath() const; @@ -162,7 +162,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { /** * Get Ehernet Interface - * @ethernet interface. eg. eth0 or "" if listening to all (max of 1000 characters) + * @ethernet interface. eg. eth0 or "" if listening to all */ char *getEthernetInterface() const; diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index ff317a452..01fa3e584 100644 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -146,15 +146,7 @@ int slsReceiverImplementation::getDetectorPositionId() const{ char *slsReceiverImplementation::getDetectorHostname() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //not initialized - if(!strlen(detHostname)) - return NULL; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,detHostname); - //freed by calling function - return output; + return detHostname; } int slsReceiverImplementation::getFlippedData(int axis) const{ @@ -177,28 +169,12 @@ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ char *slsReceiverImplementation::getFileName() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //not initialized - if(!strlen(fileName)) - return NULL; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,fileName); - //freed by calling function - return output; + return fileName; } char *slsReceiverImplementation::getFilePath() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - //not initialized - if(!strlen(filePath)) - return NULL; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,filePath); - //freed by calling function - return output; + return filePath; } uint64_t slsReceiverImplementation::getFileIndex() const{ @@ -296,11 +272,7 @@ uint32_t slsReceiverImplementation::getUDPPortNumber2() const{ char *slsReceiverImplementation::getEthernetInterface() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,eth); - //freed by calling function - return output; + return eth; } @@ -397,21 +369,12 @@ uint32_t slsReceiverImplementation::getStreamingPort() const{ char *slsReceiverImplementation::getStreamingSourceIP() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - strcpy(output,streamingSrcIP); - //freed by calling function - return output; + return streamingSrcIP; } char *slsReceiverImplementation::getAdditionalJsonHeader() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - - char* output = new char[MAX_STR_LENGTH](); - memset(output, 0, MAX_STR_LENGTH); - strcpy(output,additionalJsonHeader); - //freed by calling function - return output; + return additionalJsonHeader; } uint32_t slsReceiverImplementation::getUDPSocketBufferSize() const { diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 93f5dbfaa..655c58094 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -370,6 +370,7 @@ int slsReceiverTCPIPInterface::lock_receiver() { int slsReceiverTCPIPInterface::get_last_client_ip() { ret = OK; + memset(mess, 0, sizeof(mess)); return interface->Server_SendResult(true, ret,mySock->lastClientIP, sizeof(mySock->lastClientIP)); } @@ -446,97 +447,82 @@ int slsReceiverTCPIPInterface::update_client() { int slsReceiverTCPIPInterface::send_update() { int ind = -1; - char defaultVal[MAX_STR_LENGTH] = {0}; - char* path = NULL; + char path[MAX_STR_LENGTH] = {0}; int n = 0; n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); // filepath path = receiver->getFilePath(); - if (path == NULL) - n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - n += mySock->SendDataOnly(path,MAX_STR_LENGTH); - delete[] path; - } + n += mySock->SendDataOnly(path, sizeof(path)); // filename path = receiver->getFileName(); - if(path == NULL) - n += mySock->SendDataOnly(defaultVal,MAX_STR_LENGTH); - else { - n += mySock->SendDataOnly(path,MAX_STR_LENGTH); - delete[] path; - } + n += mySock->SendDataOnly(path, sizeof(path)); // index ind=receiver->getFileIndex(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); //file format ind=(int)receiver->getFileFormat(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); //frames per file ind=(int)receiver->getFramesPerFile(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); //frame discard policy ind=(int)receiver->getFrameDiscardPolicy(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); //frame padding ind=(int)receiver->getFramePaddingEnable(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // file write enable ind=(int)receiver->getFileWriteEnable(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // file overwrite enable ind=(int)receiver->getOverwriteEnable(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // gap pixels ind=(int)receiver->getGapPixelsEnable(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // streaming frequency ind=(int)receiver->getStreamingFrequency(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // streaming port ind=(int)receiver->getStreamingPort(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // streaming source ip path = receiver->getStreamingSourceIP(); - mySock->SendDataOnly(path,MAX_STR_LENGTH); - if (path != NULL) - delete[] path; + n += mySock->SendDataOnly(path, sizeof(path)); // additional json header path = receiver->getAdditionalJsonHeader(); - mySock->SendDataOnly(path,MAX_STR_LENGTH); - if (path != NULL) - delete[] path; + n += mySock->SendDataOnly(path, sizeof(path)); // data streaming enable ind=(int)receiver->getDataStreamEnable(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // activate ind=(int)receiver->getActivate(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // deactivated padding enable ind=(int)receiver->getDeactivatedPadding(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); // silent mode ind=(int)receiver->getSilentMode(); - n += mySock->SendDataOnly(&ind,sizeof(ind)); + n += mySock->SendDataOnly(&ind, sizeof(ind)); if (!lockStatus) strcpy(mySock->lastClientIP,mySock->thisClientIP); @@ -617,7 +603,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){ int slsReceiverTCPIPInterface::set_detector_hostname() { memset(mess, 0, sizeof(mess)); char hostname[MAX_STR_LENGTH] = {0}; - char* retval = NULL; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, hostname,MAX_STR_LENGTH, true, receiver) == FAIL) @@ -633,20 +619,14 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { } // get retval = receiver->getDetectorHostname(); - if(retval == NULL) { + if (strlen(retval)) { ret = FAIL; - cprintf(RED, "Could not set hostname to %s\n", hostname); + sprintf(mess, "hostname not set\n"); FILE_LOG(logERROR) << mess; } } - interface->Server_SendResult(true, ret, - retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - - if(retval != NULL) - delete[] retval; - - return ret; + return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1048,7 +1028,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){ int slsReceiverTCPIPInterface::set_file_dir() { memset(mess, 0, sizeof(mess)); char fPath[MAX_STR_LENGTH] = {0}; - char* retval=NULL; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, fPath, sizeof(fPath), true, receiver) == FAIL) @@ -1062,22 +1042,15 @@ int slsReceiverTCPIPInterface::set_file_dir() { } // get retval = receiver->getFilePath(); - if (retval == NULL || (strlen(fPath) && strcasecmp(fPath, retval))) { + if ((!strlen(retval)) || (strlen(fPath) && strcasecmp(fPath, retval))) { ret = FAIL; strcpy(mess,"receiver file path does not exist\n"); FILE_LOG(logERROR) << mess; - } - if (retval != NULL) { + } else FILE_LOG(logDEBUG1) << "file path:" << retval; - } } - interface->Server_SendResult(true, ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - - if(retval != NULL) - delete[] retval; - - return ret; + return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1085,7 +1058,7 @@ int slsReceiverTCPIPInterface::set_file_dir() { int slsReceiverTCPIPInterface::set_file_name() { memset(mess, 0, sizeof(mess)); char fName[MAX_STR_LENGTH] = {0}; - char* retval = NULL; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, fName, sizeof(fName), true, receiver) == FAIL) @@ -1099,22 +1072,15 @@ int slsReceiverTCPIPInterface::set_file_name() { } // get retval = receiver->getFileName(); - if(retval == NULL) { + if (strlen(retval)) { ret = FAIL; strcpy(mess, "file name is empty\n"); FILE_LOG(logERROR) << mess; - } - if (retval != NULL) { + } else FILE_LOG(logDEBUG1) << "file name:" << retval; - } } - interface->Server_SendResult(true, ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - - if(retval != NULL) - delete[] retval; - - return ret; + return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1624,7 +1590,7 @@ int slsReceiverTCPIPInterface::set_streaming_port() { int slsReceiverTCPIPInterface::set_streaming_source_ip() { memset(mess, 0, sizeof(mess)); char arg[MAX_STR_LENGTH] = {0}; - char* retval=NULL; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, arg, MAX_STR_LENGTH, true, receiver) == FAIL) @@ -1642,13 +1608,7 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; } - interface->Server_SendResult(true, - ret, retval, (retval == NULL) ? 0 : MAX_STR_LENGTH, mess); - - if(retval != NULL) - delete[] retval; - - return ret; + return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1758,7 +1718,7 @@ int slsReceiverTCPIPInterface::restream_stop(){ int slsReceiverTCPIPInterface::set_additional_json_header() { memset(mess, 0, sizeof(mess)); char arg[MAX_STR_LENGTH] = {0}; - char* retval=NULL; + char retval[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, arg, sizeof(arg), true, receiver) == FAIL) @@ -1776,12 +1736,7 @@ int slsReceiverTCPIPInterface::set_additional_json_header() { FILE_LOG(logDEBUG1) << "additional json header:" << retval; } - interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); - - if (retval != NULL) - delete[] retval; - - return ret; + return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index fa7b9106a..aed49a260 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -240,16 +240,13 @@ public: int nchip; /**< is the number of chips on the module */ int ndac; /**< is the number of dacs on the module */ int nadc; /**< is the number of adcs on the module */ - int reg; /**< is the module register (e.g. dynamic range?) - \see moduleRegisterBit */ + int reg; /**< is the module register settings (gain level) */ + int iodelay; /**< iodelay */ + int tau; /**< tau */ + int eV; /**< threshold energy */ int *dacs; /**< is the pointer to the array of the dac values (in V) */ - int *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/ - int *chipregs; /**< is the pointer to the array of the chip registers - \see ::chipRegisterBit */ - int *chanregs; /**< is the pointer to the array of the channel registers - \see ::channelRegisterBit */ - double gain; /**< is the module gain (V/keV) */ - double offset; /**< is the module offset (V) */ + int *adcs; /**< is the pointer to the array of the adc values (in V) */ + int *chanregs; /**< is the pointer to the array of the channel registers */ } sls_detector_module; diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 1ed9f1192..6ff0b521a 100644 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -45,7 +45,6 @@ enum detFuncs{ F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */ F_READ_COUNTER_BLOCK, /**< reads the counter block memory for gotthard */ F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */ - F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */ F_ENABLE_TEN_GIGA, /**< enable 10Gbe */ F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */ F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */ @@ -160,7 +159,6 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case F_LOAD_IMAGE: return "F_LOAD_IMAGE"; case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK"; case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK"; - case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL"; case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA"; case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS"; case F_SET_CTB_PATTERN: return "F_SET_CTB_PATTERN"; From 92fc837eb490650d91c2283943cbd729b2e36567 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 29 Oct 2018 15:23:52 +0100 Subject: [PATCH 6/7] compiles, but doesnt run --- .../slsDetectorServer_funcs.c | 143 +- .../multiSlsDetector/multiSlsDetector.cpp | 4 +- .../multiSlsDetector/multiSlsDetector.h | 1 + .../slsDetector/slsDetector.cpp | 1524 ++++++++--------- slsDetectorSoftware/slsDetector/slsDetector.h | 19 +- .../slsDetector/slsDetectorCommand.cpp | 5 +- .../include/slsReceiverImplementation.h | 12 +- .../include/slsReceiverTCPIPInterface.h | 7 + .../src/slsReceiverImplementation.cpp | 24 +- .../src/slsReceiverTCPIPInterface.cpp | 580 +++---- slsSupportLib/include/ClientInterface.cpp | 1 - 11 files changed, 1034 insertions(+), 1286 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 94c830ae3..207b5add6 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -306,7 +306,7 @@ int M_nofunc(int file_des) { while (n > 0) n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); + sprintf(mess,"Unrecognized Function enum %d. Please do not proceed.\n", fnum); FILE_LOG(logERROR, (mess)); return Server_SendResult(file_des, OTHER, 0, NULL, 0); } @@ -344,7 +344,7 @@ int exec_command(int file_des) { FILE_LOG(logINFO, ("Executing command (%s)\n", cmd)); // set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { FILE* sysFile = popen(cmd, "r"); const size_t tempsize = 256; char temp[tempsize]; @@ -398,7 +398,7 @@ int set_external_signal_flag(int file_des) { functionNotImplemented(); #else // set - if ((flag != GET_EXTERNAL_SIGNAL_FLAG) && (Server_VerifyLock() != FAIL)) { + if ((flag != GET_EXTERNAL_SIGNAL_FLAG) && (Server_VerifyLock() == OK)) { setExtSignal(signalindex, flag); } // get @@ -424,7 +424,7 @@ int set_external_communication_mode(int file_des) { FILE_LOG(logDEBUG5, ("Setting external communication mode to %d\n", arg)); // set - if ((arg != GET_EXTERNAL_COMMUNICATION_MODE) && (Server_VerifyLock() != FAIL)) { + if ((arg != GET_EXTERNAL_COMMUNICATION_MODE) && (Server_VerifyLock() == OK)) { switch (arg) { case AUTO_TIMING: case TRIGGER_EXPOSURE: @@ -501,7 +501,7 @@ int digital_test(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { switch (mode) { #ifdef GOTTHARDD case DIGITAL_BIT_TEST: @@ -634,7 +634,7 @@ int set_dac(int file_des) { (mV ? "mV" : "dac units"))); // set & get - if ((val == -1) || ((val != -1) && (Server_VerifyLock() != FAIL))) { + if ((val == -1) || ((val != -1) && (Server_VerifyLock() == OK))) { switch(ind) { // io delay @@ -793,7 +793,7 @@ int write_register(int file_des) { FILE_LOG(logDEBUG5, ("Writing to register 0x%x, data 0x%x\n", addr, val)); // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { retval = writeRegister(addr, val); // validate if (retval != val) { @@ -912,7 +912,7 @@ int set_module(int file_des) { } // only set - else if (Server_VerifyLock() != FAIL) { + else if (Server_VerifyLock() == OK) { // check index switch (module.reg) { #ifdef EIGERD @@ -1043,7 +1043,7 @@ int set_settings(int file_des) { FILE_LOG(logDEBUG5, ("Setting settings %d\n", isett)); //set & get - if ((isett == GET_SETTINGS) || ((isett != GET_SETTINGS) && (Server_VerifyLock() != FAIL))) { + if ((isett == GET_SETTINGS) || ((isett != GET_SETTINGS) && (Server_VerifyLock() == OK))) { // check index switch(isett) { @@ -1123,7 +1123,7 @@ int start_acquisition(int file_des) { FILE_LOG(logDEBUG5, ("Starting Acquisition\n")); // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = startStateMachine(); if (ret == FAIL) { sprintf(mess, "Could not start acquisition\n"); @@ -1142,7 +1142,7 @@ int stop_acquisition(int file_des) { FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = stopStateMachine(); if (ret == FAIL) { sprintf(mess, "Could not stop acquisition\n"); @@ -1166,7 +1166,7 @@ int start_readout(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = startReadOut(); if (ret == FAIL) { sprintf(mess, "Could not start readout\n"); @@ -1207,7 +1207,7 @@ int start_and_read_all(int file_des) { // start state machine FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = startStateMachine(); if (ret == FAIL) { sprintf(mess, "Could not start acquisition\n"); @@ -1234,7 +1234,7 @@ int read_all(int file_des) { FILE_LOG(logDEBUG5, ("Reading all frames\n")); // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { readFrame(&ret, mess); } return Server_SendResult(file_des, INT32, 1 , NULL, 0); @@ -1261,7 +1261,7 @@ int set_timer(int file_des) { FILE_LOG(logDEBUG5, ("Setting timer index %d to %lld ns\n", ind, tns)); // set & get - if ((tns == -1) || ((tns != -1) && (Server_VerifyLock() != FAIL))) { + if ((tns == -1) || ((tns != -1) && (Server_VerifyLock() == OK))) { // check index switch (ind) { @@ -1395,7 +1395,7 @@ int set_dynamic_range(int file_des) { FILE_LOG(logDEBUG5, ("Setting dr to %d\n", dr)); // set & get - if ((dr == -1) || ((dr != -1) && (Server_VerifyLock() != FAIL))) { + if ((dr == -1) || ((dr != -1) && (Server_VerifyLock() == OK))) { #ifdef EIGERD int old_dr = setDynamicRange(-1); @@ -1463,7 +1463,7 @@ int set_readout_flags(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == GET_READOUT_FLAGS) || ((arg != GET_READOUT_FLAGS) && (Server_VerifyLock() != FAIL))) { + if ((arg == GET_READOUT_FLAGS) || ((arg != GET_READOUT_FLAGS) && (Server_VerifyLock() == OK))) { switch(arg) { case STORE_IN_RAM: @@ -1516,7 +1516,7 @@ int set_roi(int file_des) { return printSocketReadError(); } } - FILE_LOG(logDEBUG5, ("Set ROI (nroi:%d)\n", narg)); + FILE_LOG(logDEBUG5, ("Set ROI (narg:%d)\n", narg)); { int iloop = 0; for (iloop = 0; iloop < narg; ++iloop) { @@ -1529,7 +1529,7 @@ int set_roi(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == GET_READOUT_FLAGS) || ((arg != GET_READOUT_FLAGS) && (Server_VerifyLock() != FAIL))) { + if ((arg == GET_READOUT_FLAGS) || ((arg != GET_READOUT_FLAGS) && (Server_VerifyLock() == OK))) { retval = setROI(narg, arg, &nretval, &ret); if (ret == FAIL) { sprintf(mess,"Could not set all roi. " @@ -1574,7 +1574,7 @@ int set_speed(int file_des) { FILE_LOG(logDEBUG5, ("Setting speed index %d to %d\n", ind, val)); // set & get - if ((val == -1) || ((val != -1) && (Server_VerifyLock() != FAIL))) { + if ((val == -1) || ((val != -1) && (Server_VerifyLock() == OK))) { // check index switch(ind) { #ifdef JUNGFRAUD @@ -1605,7 +1605,7 @@ int set_speed(int file_des) { int exit_server(int file_des) { - cprintf(BG_RED,"Closing Server\n"); + cprintf(BG_RED, "Closing Server\n"); ret = OK; memset(mess, 0, sizeof(mess)); Server_SendResult(file_des, INT32, 0, NULL, 0); @@ -1661,7 +1661,7 @@ int set_port(int file_des) { // set only int sd = -1; - if ((Server_VerifyLock() != FAIL)) { + if ((Server_VerifyLock() == OK)) { // port number too low if (p_number < 1024) { ret = FAIL; @@ -1701,68 +1701,67 @@ int update_client(int file_des) { int send_update(int file_des) { - int n = 0; // if (n<0) should fail to stop talking to a closed client socket - int nm = 0; - int64_t retval = 0; + int n = 0; + int i32 = -1; + int64_t i64 = -1; n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER); if (n < 0) return printSocketReadError(); - - nm = setDynamicRange(GET_FLAG); - n = sendData(file_des,&nm,sizeof(nm),INT32); + i32 = setDynamicRange(GET_FLAG); + n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); dataBytes = calculateDataBytes(); n = sendData(file_des,&dataBytes,sizeof(dataBytes),INT32); if (n < 0) return printSocketReadError(); - nm = (int)setSettings(GET_SETTINGS); - n = sendData(file_des,&nm,sizeof(nm),INT32); + i32 = (int)setSettings(GET_SETTINGS); + n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); #ifdef EIGERD - nm = getThresholdEnergy(GET_FLAG); - n = sendData(file_des,&nm,sizeof(nm),INT32); + i32 = getThresholdEnergy(GET_FLAG); + n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); #endif - retval = setTimer(FRAME_NUMBER,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(FRAME_NUMBER,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); - retval = setTimer(ACQUISITION_TIME,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(ACQUISITION_TIME,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); #ifdef EIGERD - retval = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); - retval = setTimer(SUBFRAME_DEADTIME,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(SUBFRAME_DEADTIME,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); #endif - retval = setTimer(FRAME_PERIOD,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(FRAME_PERIOD,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); #ifndef EIGERD - retval = setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(DELAY_AFTER_TRIGGER,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); #endif #if !defined(EIGERD) && !defined(JUNGFRAUD) - retval = setTimer(GATES_NUMBER,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(GATES_NUMBER,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); #endif - retval = setTimer(CYCLES_NUMBER,GET_FLAG); - n = sendData(file_des,&retval,sizeof(int64_t),INT64); + i64 = setTimer(CYCLES_NUMBER,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); if (lockStatus == 0) { @@ -1851,7 +1850,7 @@ int configure_mac(int file_des) { #endif // set only - if ((Server_VerifyLock() != FAIL)) { + if ((Server_VerifyLock() == OK)) { // stop detector if it was running if (getRunStatus() != IDLE) { @@ -1947,7 +1946,7 @@ int load_image(int file_des) { #else // set only - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { switch (index) { case DARK_IMAGE : case GAIN_IMAGE : @@ -1988,7 +1987,7 @@ int read_counter_block(int file_des) { #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = readCounterBlock(startACQ, retval); if (ret == FAIL) { strcpy(mess, "Could not read counter block\n"); @@ -2017,7 +2016,7 @@ int reset_counter_block(int file_des) { #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = resetCounterBlock(startACQ); if (ret == FAIL) { strcpy(mess, "Could not reset counter block\n"); @@ -2046,7 +2045,7 @@ int enable_ten_giga(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = enableTenGigabitEthernet(arg); FILE_LOG(logDEBUG5, ("10GbE: %d\n", retval)); validate(arg, retval, "enable/disable 10GbE", 0); @@ -2073,7 +2072,7 @@ int set_all_trimbits(int file_des) { #else // set - if (arg >= 0 && Server_VerifyLock() != FAIL) { + if (arg >= 0 && Server_VerifyLock() == OK) { ret = setAllTrimbits(arg); //changes settings to undefined setSettings(UNDEFINED); @@ -2115,7 +2114,7 @@ int write_adc_register(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) + if (Server_VerifyLock() == OK) setAdc(addr, val); #endif return Server_SendResult(file_des, INT32, 1, NULL, 0); @@ -2139,7 +2138,7 @@ int set_counter_bit(int file_des) { #else // set - if (arg >= 0 && Server_VerifyLock() != FAIL) { + if (arg >= 0 && Server_VerifyLock() == OK) { setCounterBit(arg); } // get @@ -2167,7 +2166,7 @@ int pulse_pixel(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = pulsePixel(args[0], args[1], args[2]); if (ret == FAIL) { strcpy(mess, "Could not pulse pixel\n"); @@ -2195,7 +2194,7 @@ int pulse_pixel_and_move(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = pulsePixelNMove(args[0], args[1], args[2]); if (ret == FAIL) { strcpy(mess, "Could not pulse pixel and move\n"); @@ -2224,7 +2223,7 @@ int pulse_chip(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = pulseChip(arg); if (ret == FAIL) { strcpy(mess, "Could not pulse chip\n"); @@ -2252,7 +2251,7 @@ int set_rate_correct(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { int dr = setDynamicRange(-1); @@ -2320,7 +2319,7 @@ int set_network_parameter(int file_des) { functionNotImplemented(); #else // set & get - if ((value == -1) || ((value != -1) && (Server_VerifyLock() != FAIL))) { + if ((value == -1) || ((value != -1) && (Server_VerifyLock() == OK))) { // check index switch (mode) { #ifdef EIGERD @@ -2378,7 +2377,7 @@ int program_fpga(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { // not in programming mode if (debugflag != PROGRAMMING_MODE) { @@ -2499,7 +2498,7 @@ int reset_fpga(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { if (isControlServer) { basictests(debugflag); // mapping of control server at least if (debugflag != PROGRAMMING_MODE) @@ -2528,7 +2527,7 @@ int power_chip(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = powerChip(arg); FILE_LOG(logDEBUG5, ("Power chip: %d\n", retval)); validate(arg, retval, "power on/off chip", 0); @@ -2561,7 +2560,7 @@ int set_activate(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = activate(arg); FILE_LOG(logDEBUG5, ("Activate: %d\n", retval)); validate(arg, retval, "set activate", 0); @@ -2582,7 +2581,7 @@ int prepare_acquisition(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = prepareAcquisition(); if (ret == FAIL) { strcpy(mess, "Could not prepare acquisition\n"); @@ -2611,7 +2610,7 @@ int threshold_temp(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { if (arg > MAX_THRESHOLD_TEMP_VAL) { ret = FAIL; sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", @@ -2645,7 +2644,7 @@ int temp_control(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = setTemperatureControl(arg); FILE_LOG(logDEBUG5, ("Temperature control: %d\n", retval)); validate(arg, retval, "set temperature control", 0); @@ -2671,7 +2670,7 @@ int temp_event(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = setTemperatureEvent(arg); FILE_LOG(logDEBUG5, ("Temperature event: %d\n", retval)); validate(arg, retval, "set temperature event", 0); @@ -2698,7 +2697,7 @@ int auto_comp_disable(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = autoCompDisable(arg); FILE_LOG(logDEBUG5, ("Auto comp disable: %d\n", retval)); validate(arg, retval, "set auto comp disable", 0); @@ -2725,7 +2724,7 @@ int storage_cell_start(int file_des) { functionNotImplemented(); #else // set & get - if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() != FAIL))) { + if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { if (arg > MAX_STORAGE_CELL_VAL) { ret = FAIL; strcpy(mess,"Max Storage cell number should not exceed 15\n"); @@ -2817,7 +2816,7 @@ int software_trigger(int file_des) { functionNotImplemented(); #else // only set - if (Server_VerifyLock() != FAIL) { + if (Server_VerifyLock() == OK) { ret = softwareTrigger(); if (ret == FAIL) { sprintf(mess, "Could not send software trigger\n"); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index f7e69bc84..6102a8dbe 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -7,7 +7,6 @@ #include "multiSlsDetectorCommand.h" #include "utilities.h" #include "detectorData.h" -#include "logger.h" #include #include @@ -2497,7 +2496,8 @@ void multiSlsDetector::printReceiverConfiguration(int detPos) { } // multi - parallelCall(&slsDetector::printReceiverConfiguration); + for (auto& d : detectors) + d->printReceiverConfiguration(); } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 9c64d1c61..7abe974df 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -9,6 +9,7 @@ #include "sls_detector_defs.h" #include "error_defs.h" +#include "logger.h" class slsDetector; class SharedMemory; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 0adf416d2..ef3aab5c7 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -43,8 +43,8 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify) // ensure shared memory was not created before auto shm = SharedMemory(multiId, id); if (shm.IsExisting()) { - FILE_LOG(logWARNING, ("Weird, this shared memory should have been " - "deleted before! %s. Freeing it again.\n", shm.GetName().c_str())); + FILE_LOG(logWARNING) << "Weird, this shared memory should have been " + "deleted before! " << shm.GetName() << ". Freeing it again"; freeSharedMemory(multiId, id); } @@ -125,7 +125,7 @@ int slsDetector::checkVersionCompatibility(portType t) { return FAIL; } FILE_LOG(logDEBUG5) << "Checking version compatibility with detector with " - "value " << std::hex << arg; + "value " << std::hex << arg << std::dec; // control server @@ -156,7 +156,7 @@ int slsDetector::checkVersionCompatibility(portType t) { fnum = F_RECEIVER_CHECK_VERSION; arg = APIRECEIVER; FILE_LOG(logDEBUG5) << "Checking version compatibility with receiver with " - "value " << std::hex << arg; + "value " << std::hex << arg << std::dec; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); @@ -226,7 +226,7 @@ int64_t slsDetector::getId( idMode mode) { } if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Id ("<< mode << "): 0x" << std::hex << retval << std::setbase(10); + FILE_LOG(logDEBUG5) << "Id ("<< mode << "): 0x" << std::hex << retval << std::dec; } return retval; @@ -284,10 +284,11 @@ void slsDetector::initSharedMemory(bool created, detectorType type, int multiId, else { thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz); if (verify && thisDetector->shmversion != SLS_SHMVERSION) { - FILE_LOG(logERROR, ("Single shared memory (%d-%d:)version mismatch " - "(expected 0x%x but got 0x%x)\n", - multiId, detId, SLS_SHMVERSION, - thisDetector->shmversion)); + FILE_LOG(logERROR) << "Single shared memory " + "(" << multiId << "-" << detId << ":) " + "version mismatch " + "(expected 0x" << std::hex << SLS_SHMVERSION << + " but got 0x" << thisDetector->shmversion << ")" << std::dec; throw SharedMemoryException(); } } @@ -354,7 +355,7 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL list.nGappixelsY = 1; break; default: - FILE_LOG(logERROR, ("Unknown detector type!\n")); + FILE_LOG(logERROR) << "Unknown detector type!"; throw std::exception(); } } @@ -728,8 +729,8 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { if (thisDetector->myDetectorType == EIGER) { ts += controlSocket->ReceiveDataOnly(myMod->chanregs, sizeof(int)*(myMod->nchan)); FILE_LOG(logDEBUG5) << "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips - << "mod - nchans= " << myMod->nchan << " nchips= " <nchip; - << "received chans of size "<< ts; + << "mod - nchans= " << myMod->nchan << " nchips= " <nchip + << "received chans of size "<< ts; } FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; return ts; @@ -739,9 +740,8 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) { auto shm = SharedMemory(multiId, detId); if (!shm.IsExisting()) { - FILE_LOG(logERROR, ("Shared memory %s does not exist.\n" - "Corrupted Multi Shared memory. Please free shared memory.\n", - shm.GetName().c_str())); + FILE_LOG(logERROR) << "Shared memory " << shm.GetName() << " does not exist.\n" + "Corrupted Multi Shared memory. Please free shared memory."; throw SharedMemoryException(); } @@ -750,9 +750,10 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b // open, map, verify version auto sdet = (sharedSlsDetector*)shm.OpenSharedMemory(sz); if (verify && sdet->shmversion != SLS_SHMVERSION) { - FILE_LOG(logERROR, ("Single shared memory (%d-%d:)version mismatch " - "(expected 0x%x but got 0x%x)\n", - multiId, detId, SLS_SHMVERSION, sdet->shmversion)); + FILE_LOG(logERROR) << "Single shared memory " + "(" << multiId << "-" << detId << ":)version mismatch " + "(expected 0x" << std::hex << SLS_SHMVERSION << + " but got 0x" << sdet->shmversion << ")" << std::dec; // unmap and throw sharedMemory->UnmapSharedMemory(thisDetector); throw SharedMemoryException(); @@ -802,7 +803,7 @@ int slsDetector::setDetectorType(detectorType const type) { int fnum = F_GET_DETECTOR_TYPE; int ret = FAIL; detectorType retval = GENERIC; - FILE_LOG(logDEBUG5) << "Setting detector type to " << arg; + FILE_LOG(logDEBUG5) << "Setting detector type to " << type; // if unspecified, then get from detector if (type == GET_DETECTOR_TYPE) { @@ -892,12 +893,12 @@ int slsDetector::getTotalNumberOfChannels() { } thisDetector->nChans = thisDetector->nChan[X]; thisDetector->dataBytes = thisDetector->nChans * thisDetector->nChips * 2 - * thisDetector->timerValue[SAMPLES_JCTB]; + * thisDetector->timerValue[SAMPLES_JCTB]; } FILE_LOG(logDEBUG5) << "Total number of channels: " << thisDetector->nChans * thisDetector->nChips << - << ". Data bytes: " << thisDetector->dataBytes; + ". Data bytes: " << thisDetector->dataBytes; return thisDetector->nChans * thisDetector->nChips; } @@ -1205,7 +1206,7 @@ int slsDetector::setPort(portType index, int num) { } // set port - if (dataSocket && receiverOnlineFlag->onlineFlag == ONLINE_FLAG && connectData() == OK) { + if (dataSocket && thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &num, sizeof(num), &retval, sizeof(retval)); disconnectData(); @@ -1405,8 +1406,9 @@ int slsDetector::updateDetectorNoWait() { getTotalNumberOfChannels(); } - if (!n) - FILE_LOG(logERROR) << "Could not update detector, received 0 bytes\n"; + if (!n) { + FILE_LOG(logERROR) << "Could not update detector, received 0 bytes"; + } return OK; } @@ -1447,7 +1449,10 @@ int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetecto int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) { - const std::vector names; + + FILE_LOG(logDEBUG5) << "Write configuration file"; + + std::vector names; // common config names.push_back("hostname"); names.push_back("port"); @@ -1496,10 +1501,10 @@ int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector } auto cmd = slsDetectorCommand(m); - for (int iline = 0; iline < nvar; ++iline) { + for (unsigned int iline = 0; iline < names.size(); ++iline) { char* args[] = {(char*)names[iline].c_str()}; - outfile << detId << ":"; - outfile << names[iline] << " " << cmd.executeLine(1, args, GET_ACTION) << std::endl; + outfile << detId << ":"; + outfile << names[iline] << " " << cmd.executeLine(1, args, GET_ACTION) << std::endl; } return OK; } @@ -1627,23 +1632,23 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti std::string ssettings; switch (is) { case STANDARD: - ssettings="/standard"; + ssettings = "/standard"; thisDetector->currentSettings=STANDARD; break; case HIGHGAIN: - ssettings="/highgain"; + ssettings = "/highgain"; thisDetector->currentSettings=HIGHGAIN; break; case LOWGAIN: - ssettings="/lowgain"; + ssettings = "/lowgain"; thisDetector->currentSettings=LOWGAIN; break; case VERYHIGHGAIN: - ssettings="/veryhighgain"; + ssettings = "/veryhighgain"; thisDetector->currentSettings=VERYHIGHGAIN; break; case VERYLOWGAIN: - ssettings="/verylowgain"; + ssettings = "/verylowgain"; thisDetector->currentSettings=VERYLOWGAIN; break; default: @@ -1683,9 +1688,10 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti FILE_LOG(logDEBUG5) << "Settings File is " << settingsfname; //read the files - myMod=createModule(); + myMod = createModule(); // readSettings also checks if create module is null if (NULL == readSettingsFile(settingsfname, myMod, tb)) { - if (myMod)deleteModule(myMod); + if (myMod) + deleteModule(myMod); return FAIL; } } @@ -1819,7 +1825,7 @@ int slsDetector::saveSettingsFile(std::string fname) { // find specific file if it has detid in file name (.snxxx) if (thisDetector->myDetectorType == EIGER) { ostfn << ".sn" << std::setfill('0') << std::setw(3) << std::dec << - getId(DETECTOR_SERIAL_NUMBER); + getId(DETECTOR_SERIAL_NUMBER); } fn=ostfn.str(); @@ -2095,60 +2101,60 @@ int slsDetector::configureMAC() { } { //converting IPaddress to std::hex - std::stringstream ss(arg[0]); + std::stringstream ss(args[0]); char cword[50]=""; bzero(cword, 50); std::string s; while (getline(ss, s, '.')) { sprintf(cword,"%s%02x",cword,atoi(s.c_str())); } - bzero(arg[0], 50); - strcpy(arg[0],cword); - FILE_LOG(logDEBUG5) << "receiver udp ip:" << arg[0] << "-"; + bzero(args[0], 50); + strcpy(args[0],cword); + FILE_LOG(logDEBUG5) << "receiver udp ip:" << args[0] << "-"; } { //converting MACaddress to std::hex - std::stringstream ss(arg[1]); + std::stringstream ss(args[1]); char cword[50]=""; bzero(cword, 50); std::string s; while (getline(ss, s, ':')) { sprintf(cword,"%s%s",cword,s.c_str()); } - bzero(arg[1], 50); - strcpy(arg[1],cword); - FILE_LOG(logDEBUG5) << "receiver udp mac:" << arg[1] << "-"; + bzero(args[1], 50); + strcpy(args[1],cword); + FILE_LOG(logDEBUG5) << "receiver udp mac:" << args[1] << "-"; } - FILE_LOG(logDEBUG5) << "receiver udp port:" << arg[2] << "-"; + FILE_LOG(logDEBUG5) << "receiver udp port:" << args[2] << "-"; { - std::stringstream ss(arg[3]); + std::stringstream ss(args[3]); char cword[50]=""; bzero(cword, 50); std::string s; while (getline(ss, s, ':')) { sprintf(cword,"%s%s",cword,s.c_str()); } - bzero(arg[3], 50); - strcpy(arg[3],cword); - FILE_LOG(logDEBUG5) << "detecotor udp mac:" << arg[3] << "-"; + bzero(args[3], 50); + strcpy(args[3],cword); + FILE_LOG(logDEBUG5) << "detecotor udp mac:" << args[3] << "-"; } { //converting IPaddress to std::hex - std::stringstream ss(arg[4]); + std::stringstream ss(args[4]); char cword[50]=""; bzero(cword, 50); std::string s; while (getline(ss, s, '.')) { sprintf(cword,"%s%02x",cword,atoi(s.c_str())); } - bzero(arg[4], 50); - strcpy(arg[4],cword); - FILE_LOG(logDEBUG5) << "detecotor udp ip:" << arg[4] << "-"; + bzero(args[4], 50); + strcpy(args[4],cword); + FILE_LOG(logDEBUG5) << "detecotor udp ip:" << args[4] << "-"; } - FILE_LOG(logDEBUG5) << "receiver udp port2:" << arg[5] << "-"; - FILE_LOG(logDEBUG5) << "row:" << arg[6] << "-"; - FILE_LOG(logDEBUG5) << "col:" << arg[7] << "-"; - FILE_LOG(logDEBUG5) << "reserved:" << arg[8] << "-"; + FILE_LOG(logDEBUG5) << "receiver udp port2:" << args[5] << "-"; + FILE_LOG(logDEBUG5) << "row:" << args[6] << "-"; + FILE_LOG(logDEBUG5) << "col:" << args[7] << "-"; + FILE_LOG(logDEBUG5) << "reserved:" << args[8] << "-"; // send to server @@ -2163,32 +2169,32 @@ int slsDetector::configureMAC() { // get detectormac, detector ip uint64_t idetectormac = 0; uint32_t idetectorip = 0; - sscanf(retval[1], "%lx", &idetectormac); - sscanf(retval[2], "%x", &idetectorip); - sprintf(retval[1],"%02x:%02x:%02x:%02x:%02x:%02x", + sscanf(retvals[1], "%lx", &idetectormac); + sscanf(retvals[2], "%x", &idetectorip); + sprintf(retvals[1],"%02x:%02x:%02x:%02x:%02x:%02x", (unsigned int)((idetectormac>>40)&0xFF), (unsigned int)((idetectormac>>32)&0xFF), (unsigned int)((idetectormac>>24)&0xFF), (unsigned int)((idetectormac>>16)&0xFF), (unsigned int)((idetectormac>>8)&0xFF), (unsigned int)((idetectormac>>0)&0xFF)); - sprintf(retval[2],"%d.%d.%d.%d", + sprintf(retvals[2],"%d.%d.%d.%d", (idetectorip>>24)&0xff, (idetectorip>>16)&0xff, (idetectorip>>8)&0xff, (idetectorip)&0xff); // update if different - if (strcasecmp(retval[1],thisDetector->detectorMAC)) { + if (strcasecmp(retvals[1],thisDetector->detectorMAC)) { memset(thisDetector->detectorMAC, 0, MAX_STR_LENGTH); - strcpy(thisDetector->detectorMAC, retval[1]); - FILE_LOG(logINFO, ("%d: Detector MAC updated to %s\n", detId, - thisDetector->detectorMAC)); + strcpy(thisDetector->detectorMAC, retvals[1]); + FILE_LOG(logINFO) << detId << ": Detector MAC updated to " << + thisDetector->detectorMAC; } - if (strcasecmp(retval[2],thisDetector->detectorIP)) { + if (strcasecmp(retvals[2],thisDetector->detectorIP)) { memset(thisDetector->detectorIP, 0, MAX_STR_LENGTH); - strcpy(thisDetector->detectorIP, retval[2]); - FILE_LOG(logINFO, ("%d: Detector IP updated to %s\n", detId, - thisDetector->detectorIP)); + strcpy(thisDetector->detectorIP, retvals[2]); + FILE_LOG(logINFO) << detId << ": Detector IP updated to " << + thisDetector->detectorIP; } if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2203,7 +2209,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { int ret = FAIL; int64_t args[2] = {(int64_t)index, t}; int64_t retval = -1; - FILE_LOG(logDEBUG5) << "Setting " << getTimerType(index) << " to " << t " ns/value"; + FILE_LOG(logDEBUG5) << "Setting " << getTimerType(index) << " to " << t << " ns/value"; // meausurement is only shm level if (index == MEASUREMENTS_NUMBER) { @@ -2282,8 +2288,8 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { (((index == FRAME_NUMBER) || (index == CYCLES_NUMBER) || (index == STORAGE_CELL_NUMBER)) ? - "(#Frames) * (#cycles) * (#storage cells)" : getTimerType(index)) << - << " to receiver: " << args[1]; + "(#Frames) * (#cycles) * (#storage cells)" : getTimerType(index)) << + " to receiver: " << args[1]; if (connectData() == OK) { char mess[MAX_STR_LENGTH] = {0}; @@ -2383,7 +2389,8 @@ int slsDetector::setDynamicRange(int n) { // send to detector int olddr = thisDetector->dynamicRange; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, &n, sizeof(n), &retval, sizeof(retval)); + char mess[MAX_STR_LENGTH] = {0}; + ret = thisDetectorControl->Client_Send(fnum, &n, sizeof(n), &retval, sizeof(retval), mess); disconnectControl(); // handle ret @@ -2434,7 +2441,7 @@ int slsDetector::setDynamicRange(int n) { retval = -1; FILE_LOG(logINFO) << "Sending dynamic range to receiver " << n; if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum2, &n, sizeof(n), &retval, sizeof(retval)); + ret=thisReceiver->Client_Send(fnum, &n, sizeof(n), &retval, sizeof(retval)); disconnectData(); // handle ret @@ -2480,14 +2487,14 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); else { FILE_LOG(logDEBUG5) << "Dac index " << index << ": " - << retval[0] << " dac units (" << retval[1] << "mV)"; + << retvals[0] << " dac units (" << retvals[1] << "mV)"; if (ret == FORCE_UPDATE) ret = updateDetector(); } } if (mV) - return retval[1]; - return retval[0]; + return retvals[1]; + return retvals[0]; } @@ -2545,7 +2552,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( int fnum = F_SET_EXTERNAL_SIGNAL_FLAG; int ret = FAIL; int args[2] = {signalindex, pol}; - externalCommunicationMode retval = GET_EXTERNAL_SIGNAL_FLAG; + externalSignalFlag retval = GET_EXTERNAL_SIGNAL_FLAG; FILE_LOG(logDEBUG5) << "Setting signal " << signalindex << " to flag " << pol; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -2850,7 +2857,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() { ret = updateReceiver(); } } - return std::string(retval); + return std::to_string(retval); } @@ -2868,7 +2875,7 @@ std::string slsDetector::setDetectorMAC(std::string detectorMAC) { strcpy(thisDetector->detectorMAC, detectorMAC.c_str()); if (!strcmp(thisDetector->receiver_hostname, "none")) { FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; - } else if (setUDPConnection() == FAIL) + } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; } } @@ -2911,7 +2918,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) { } // stop acquisition if running if (getRunStatus()==RUNNING) { - FILE_LOG(logWARNING, ("Acquisition already running, Stopping it.\n")); + FILE_LOG(logWARNING) << "Acquisition already running, Stopping it."; stopAcquisition(); } // update detector before receiver @@ -3347,8 +3354,8 @@ int slsDetector::loadImageToDetector(imageType index,std::string const fname) { short int args[thisDetector->nChans * thisDetector->nChips]; FILE_LOG(logDEBUG5) << "Loading " << (!index ? "Dark" : "Gain") << "image from file " << fname; - if (readDataFile(fname,arg,getTotalNumberOfChannels())) { - ret = sendImageToDetector(index,arg); + if (readDataFile(fname, args, getTotalNumberOfChannels())) { + ret = sendImageToDetector(index,args); return ret; } @@ -3361,7 +3368,6 @@ int slsDetector::loadImageToDetector(imageType index,std::string const fname) { int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int fnum = F_LOAD_IMAGE; int ret = FAIL; - int arg = (int)isettings; FILE_LOG(logDEBUG5) << "Sending image to detector"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -3373,7 +3379,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateDetector(); } return ret; } @@ -3409,7 +3415,7 @@ int slsDetector::getCounterBlock(short int image[],int startACQ) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateDetector(); } return ret; } @@ -3429,7 +3435,7 @@ int slsDetector::resetCounterBlock(int startACQ) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateDetector(); } return ret; } @@ -3544,10 +3550,10 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { for (int i = 0; i < nretval; ++i) { thisDetector->roiLimits[i] = retval[i]; FILE_LOG(logDEBUG5) << "ROI [" << i << "] (" << - thisDetector->roiLimits[j].xmin << "," << - thisDetector->roiLimits[j].xmax << "," << - thisDetector->roiLimits[j].ymin << "," << - thisDetector->roiLimits[j].ymax << ")"; + thisDetector->roiLimits[i].xmin << "," << + thisDetector->roiLimits[i].xmax << "," << + thisDetector->roiLimits[i].ymin << "," << + thisDetector->roiLimits[i].ymax << ")"; } } @@ -3601,7 +3607,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { int slsDetector::writeAdcRegister(int addr, int val) { int fnum = F_WRITE_ADC_REG; int ret = FAIL; - uint32_t args[2] = {addr, val}; + uint32_t args[2] = {(uint32_t)addr, (uint32_t)val}; FILE_LOG(logDEBUG5) << "Writing to ADC register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec; @@ -3613,9 +3619,9 @@ int slsDetector::writeAdcRegister(int addr, int val) { if (ret == FAIL) setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); else if (ret == FORCE_UPDATE) - ret = updateDetector(); + ret = updateDetector(); } - return retval; + return ret; } @@ -3651,7 +3657,7 @@ int slsDetector::activate(int const enable) { FILE_LOG(logDEBUG5) << "Setting activate flag " << arg << " to receiver"; if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum2, &arg, sizeof(arg), &retval, sizeof(retval)); + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); // handle ret @@ -3673,8 +3679,8 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) { FILE_LOG(logDEBUG5) << "Deactivated Receiver Padding Enable: " << arg; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); + ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); // handle ret if (ret == FAIL) @@ -3715,8 +3721,8 @@ int slsDetector::setFlippedData(dimension d, int value) { FILE_LOG(logDEBUG5) << "Setting flipped data across axis " << d << " with value: " << value; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); - disconnectData(); + ret=thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectData(); // handle ret if (ret == FAIL) @@ -3943,9 +3949,9 @@ int slsDetector::setTemperatureEvent(int val) { int slsDetector::setStoragecellStart(int pos) { int fnum = F_STORAGE_CELL_START; int ret = FAIL; - int arg = val; + int arg = pos; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting storage cell start to " << val; + FILE_LOG(logDEBUG5) << "Setting storage cell start to " << pos; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4211,11 +4217,10 @@ int slsDetector::programFPGA(std::string fname) { int slsDetector::resetFPGA() { int fnum = F_RESET_FPGA; int ret = FAIL; - int arg = n; FILE_LOG(logDEBUG5) << "Sending reset FPGA"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); disconnectControl(); // handle ret @@ -4231,9 +4236,9 @@ int slsDetector::resetFPGA() { int slsDetector::powerChip(int ival) { int fnum = F_POWER_CHIP; int ret = FAIL; - int arg = val; + int arg = ival; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting power chip to " << val; + FILE_LOG(logDEBUG5) << "Setting power chip to " << ival; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4255,9 +4260,9 @@ int slsDetector::powerChip(int ival) { int slsDetector::setAutoComparatorDisableMode(int ival) { int fnum = F_AUTO_COMP_DISABLE; int ret = FAIL; - int arg = val; + int arg = ival; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting auto comp disable mode to " << val; + FILE_LOG(logDEBUG5) << "Setting auto comp disable mode to " << ival; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4295,7 +4300,6 @@ int slsDetector::setModule(sls_detector_module module, int tb) { int fnum = F_SET_MODULE; int ret = FAIL; int retval = -1; - char mess[MAX_STR_LENGTH] = {0}; FILE_LOG(logDEBUG5) << "Setting module with tb:" << tb; //to exclude trimbits @@ -4328,7 +4332,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) { } // update client structure - if (ret = OK) { + if (ret == OK) { if (detectorModules) { if (thisDetector->myDetectorType == EIGER && tb && chanregs) { for (int ichip = 0; ichip < thisDetector->nChips; ++ichip) { @@ -4341,20 +4345,21 @@ int slsDetector::setModule(sls_detector_module module, int tb) { if (adcs) { for (int i = 0; i < thisDetector->nAdcs; ++i) { adcs[i] = module.adcs[i]; + } + if (dacs) { + for (int i = 0; i < thisDetector->nDacs; ++i) + dacs[i] = module.dacs[i]; + } + (detectorModules)->serialnumber = module.serialnumber; + (detectorModules)->reg = module.reg; + (detectorModules)->iodelay = module.iodelay; + (detectorModules)->tau = module.tau; + (detectorModules)->eV = module.eV; } - if (dacs) { - for (int i = 0; i < thisDetector->nDacs; ++i) - dacs[i] = module.dacs[i]; - } - (detectorModules)->serialnumber = module.serialnumber; - (detectorModules)->reg = module.reg; - (detectorModules)->iodelay = module.iodelay; - (detectorModules)->tau = module.tau; - (detectorModules)->eV = module.eV; } - if (e_eV != -1) - thisDetector->currentThresholdEV = e_eV; - + if (module.eV != -1) { + thisDetector->currentThresholdEV = module.eV; + } } return ret; } @@ -4363,13 +4368,18 @@ int slsDetector::setModule(sls_detector_module module, int tb) { slsDetectorDefs::sls_detector_module *slsDetector::getModule() { int fnum = F_GET_MODULE; int ret = FAIL; - int arg = (int)isettings; FILE_LOG(logDEBUG5) << "Getting module"; sls_detector_module *myMod = createModule(); + if (myMod == NULL) { + FILE_LOG(logERROR) << "Could not create module"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + return NULL; + + } if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + ret = thisDetectorControl->Client_Send(fnum,NULL, 0, NULL, 0); // handle ret if (ret == FAIL) { @@ -4423,7 +4433,8 @@ int slsDetector::setRateCorrection(int64_t t) { FILE_LOG(logDEBUG5) << "Setting Rate Correction to " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); + char mess[MAX_STR_LENGTH] = {0}; + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0, mess); disconnectControl(); // handle ret @@ -4448,7 +4459,7 @@ int64_t slsDetector::getRateCorrection() { FILE_LOG(logDEBUG5) << "Getting rate correction"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); disconnectControl(); // handle ret @@ -4464,7 +4475,7 @@ int64_t slsDetector::getRateCorrection() { } -void slsDetector::printReceiverConfiguration(int level) { +void slsDetector::printReceiverConfiguration(TLogLevel level) { FILE_LOG(level) << "#Detector " << detId << ":\n" << "Receiver Hostname:\t" << getNetworkParameter(RECEIVER_HOSTNAME) << "Detector UDP IP (Source):\t\t" << getNetworkParameter(DETECTOR_IP) << @@ -4472,9 +4483,7 @@ void slsDetector::printReceiverConfiguration(int level) { "Receiver UDP IP:\t" << getNetworkParameter(RECEIVER_UDP_IP) << "Receiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << "Receiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << - ((thisDetector->myDetectorType == EIGER) ? - ("Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2) << "\n") - : ("\n")); + "Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2); } @@ -4756,9 +4765,9 @@ int slsDetector::updateReceiverNoWait() { n += dataSocket->ReceiveDataOnly(&i32, sizeof(i32)); thisDetector->receiver_silentMode = i32; - if (!n) + if (!n) { FILE_LOG(logERROR) << "Could not update receiver, received 0 bytes\n"; - + } return OK; } @@ -4786,7 +4795,7 @@ int slsDetector::updateReceiver() { void slsDetector::sendMultiDetectorSize() { int fnum = F_SEND_RECEIVER_MULTIDETSIZE; int ret = FAIL; - int args[2] = thisDetector->multiSize; + int args[2] = {thisDetector->multiSize[0], thisDetector->multiSize[1]}; int retval = -1; FILE_LOG(logDEBUG5) << "Sending multi detector size to Receiver (" << thisDetector->multiSize[0] << "," << thisDetector->multiSize[1] << ")"; @@ -4804,7 +4813,6 @@ void slsDetector::sendMultiDetectorSize() { ret = updateReceiver(); } } - return retval; } @@ -4828,7 +4836,6 @@ void slsDetector::setDetectorId() { ret = updateReceiver(); } } - return retval; } @@ -4848,7 +4855,7 @@ void slsDetector::setDetectorHostname() { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver set detector hostname: " << retval; + FILE_LOG(logDEBUG5) << "Receiver set detector hostname: " << retvals; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4889,7 +4896,7 @@ std::string slsDetector::setFilePath(std::string s) { } } } - return getFilePath(); + return thisDetector->receiver_filePath; } @@ -4922,7 +4929,7 @@ std::string slsDetector::setFileName(std::string s) { } } } - return getFileName(); + return thisDetector->receiver_fileName; } @@ -5043,460 +5050,374 @@ int slsDetector::getFileIndex() { int slsDetector::setFileIndex(int i) { + if (i >= 0) { + int fnum = F_SET_RECEIVER_FILE_INDEX; + int ret = FAIL; + int arg = i; + int retval = -1; + FILE_LOG(logDEBUG5) << "Setting file index to " << arg; - if (i < 0) - return getFileIndex(); - - int fnum=F_SET_RECEIVER_FILE_INDEX; - int ret = FAIL; - int retval=-1; - int arg = i; - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending file index to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_fileIndex = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); - } - return getFileIndex(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file index: " << retval; + thisDetector->receiver_fileIndex = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } + } + return thisDetector->receiver_fileIndex; } int slsDetector::incrementFileIndex() { if (thisDetector->receiver_fileWriteEnable) - return setFileIndex(thisDetector->receiver_fileIndex+1); + return setFileIndex(thisDetector->receiver_fileIndex + 1); return thisDetector->receiver_fileIndex; } - - int slsDetector::startReceiver() { - int fnum=F_START_RECEIVER; + int fnum = F_START_RECEIVER; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + char mess[MAX_STR_LENGTH] = {0}; + FILE_LOG(logDEBUG5) << "Starting Receiver"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Starting Receiver " << std::endl; -#endif + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); + disconnectData(); - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); - disconnectData(); - } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); - else if (ret == FAIL) { + // handle ret + if (ret == FAIL) { if (strstr(mess,"UDP")!=NULL) setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET)); else if (strstr(mess,"file")!=NULL) setErrorMask((getErrorMask())|(COULDNOT_CREATE_FILE)); else setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER)); - } + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - return ret; } - - int slsDetector::stopReceiver() { - int fnum=F_STOP_RECEIVER; + int fnum = F_STOP_RECEIVER; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + FILE_LOG(logDEBUG5) << "Stopping Receiver"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Stopping Receiver " << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); - disconnectData(); - } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); - else if (ret == FAIL) + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_STOP_RECEIVER)); + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - return ret; } - - - slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { - int fnum=F_GET_RECEIVER_STATUS; + int fnum = F_GET_RECEIVER_STATUS; int ret = FAIL; - int retval=-1; - runStatus s = ERROR; + runStatus retval = ERROR; + FILE_LOG(logDEBUG5) << "Getting Receiver Status"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Getting Receiver Status" << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); - disconnectData(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Status: " << runStatusType(retval); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (retval!=-1) - s=(runStatus)retval; - if (ret==FORCE_UPDATE) - updateReceiver(); } - return s; + return retval; } - - int slsDetector::getFramesCaughtByReceiver() { - int fnum=F_GET_RECEIVER_FRAMES_CAUGHT; + int fnum = F_GET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; - int retval=-1; + int retval = -1; + FILE_LOG(logDEBUG5) << "Getting Frames Caught by Receiver"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Getting Frames Caught by Receiver " << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); - disconnectData(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Frames Caught by Receiver: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); } - return retval; } - -int slsDetector::getFramesCaughtByAnyReceiver() { - return getFramesCaughtByReceiver(); -} - - - int slsDetector::getReceiverCurrentFrameIndex() { - int fnum=F_GET_RECEIVER_FRAME_INDEX; + int fnum = F_GET_RECEIVER_FRAME_INDEX; int ret = FAIL; - int retval=-1; + int retval = -1; + FILE_LOG(logDEBUG5) << "Getting Current Frame Index of Receiver"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Getting Current Frame Index of Receiver " << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); - disconnectData(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Current Frame Index of Receiver: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); } - return retval; } - - int slsDetector::resetFramesCaught() { - int fnum=F_RESET_RECEIVER_FRAMES_CAUGHT; + int fnum = F_RESET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + FILE_LOG(logDEBUG5) << "Reset Frames Caught by Receiver"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Reset Frames Caught by Receiver" << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); - disconnectData(); - } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - return ret; } - - - - - - - - int slsDetector::enableWriteToFile(int enable) { + if (enable >= 0) { + int fnum = F_ENABLE_RECEIVER_FILE_WRITE; + int ret = FAIL; + int arg = enable; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending enable file write to receiver: " << arg; - if (enable < 0) - return thisDetector->receiver_fileWriteEnable; - - int fnum=F_ENABLE_RECEIVER_FILE_WRITE; - int ret = FAIL; - int retval=-1; - int arg = enable; - - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending enable file write to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file write enable: " << retval; + thisDetector->receiver_fileWriteEnable = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_fileWriteEnable = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); } - - return thisDetector->receiver_fileWriteEnable; } - - int slsDetector::overwriteFile(int enable) { + if (enable >= 0) { + int fnum = F_ENABLE_RECEIVER_OVERWRITE; + int ret = FAIL; + int arg = enable; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending enable file overwrite to receiver: " << arg; - if (enable < 0) - return thisDetector->receiver_overWriteEnable; - - int fnum=F_ENABLE_RECEIVER_OVERWRITE; - int ret = FAIL; - int retval=-1; - int arg = enable; - - - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending enable file write to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); disconnectData(); - } - if (ret == FAIL) - setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else - thisDetector->receiver_overWriteEnable = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); - } + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } else { + FILE_LOG(logDEBUG5) << "Receiver file overwrite enable: " << retval; + thisDetector->receiver_overWriteEnable = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } + } return thisDetector->receiver_overWriteEnable; } - - - - - int slsDetector::setReceiverStreamingFrequency(int freq) { - if (freq >= 0) { - thisDetector->receiver_read_freq = freq; - - int fnum=F_RECEIVER_STREAMING_FREQUENCY; + int fnum = F_RECEIVER_STREAMING_FREQUENCY; int ret = FAIL; - int retval=-1; int arg = freq; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending read frequency to receiver: " << arg; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending read frequency to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if ((ret == FAIL) || (retval != freq)) { - FILE_LOG(logERROR) << "could not set receiver read frequency to " << freq - <<" Returned:" << retval << std::endl; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_STREAMING_FREQUENCY)); + } else { + FILE_LOG(logDEBUG5) << "Receiver read frequency: " << retval; + thisDetector->receiver_read_freq = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - - if (ret==FORCE_UPDATE) - updateReceiver(); } } - return thisDetector->receiver_read_freq; } int slsDetector::setReceiverStreamingTimer(int time_in_ms) { - int fnum=F_RECEIVER_STREAMING_TIMER; + int fnum = F_RECEIVER_STREAMING_TIMER; int ret = FAIL; int arg = time_in_ms; int retval = -1; + FILE_LOG(logDEBUG5) << "Sending read timer to receiver: " << arg; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "Sending read timer to receiver " << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_STREAMING_TIMER)); + } else { + FILE_LOG(logDEBUG5) << "Receiver read timer: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - if (ret==FORCE_UPDATE) - updateReceiver(); - } - - if ((time_in_ms > 0) && (retval != time_in_ms)) { - FILE_LOG(logERROR) << "could not set receiver read timer to " << time_in_ms - <<" Returned:" << retval << std::endl; - setErrorMask((getErrorMask())|(RECEIVER_STREAMING_TIMER)); } return retval; } -int slsDetector::enableDataStreamingToClient(int enable) { - FILE_LOG(logERROR, ("Must be called from the multi Detector level\n")); - return 0; -} - - - - - int slsDetector::enableDataStreamingFromReceiver(int enable) { - if (enable >= 0) { - int fnum=F_STREAM_DATA_FROM_RECEIVER; + int fnum = F_STREAM_DATA_FROM_RECEIVER; int ret = FAIL; - int retval=-1; int arg = enable; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending Data Streaming to receiver: " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "***************Sending Data Streaming in Receiver " - << arg << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) { - retval = -1; - FILE_LOG(logERROR) << "could not set data streaming in receiver to " << - enable <<" Returned:" << retval << std::endl; + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(DATA_STREAMING)); } else { + FILE_LOG(logDEBUG5) << "Receiver Data Streaming: " << retval; thisDetector->receiver_upstream = retval; - if (ret==FORCE_UPDATE) - updateReceiver(); + if (ret == FORCE_UPDATE) + ret = updateReceiver(); } } } - return thisDetector->receiver_upstream; } - - int slsDetector::enableTenGigabitEthernet(int i) { - int ret=FAIL; + int fnum = F_ENABLE_TEN_GIGA; + int ret = FAIL; + int arg = i; int retval = -1; - int fnum=F_ENABLE_TEN_GIGA,fnum2 = F_ENABLE_RECEIVER_TEN_GIGA; - char mess[MAX_STR_LENGTH]=""; + FILE_LOG(logDEBUG5) << "Enabling / Disabling 10Gbe: " << arg; -#ifdef VERBOSE - std::cout<< std::endl<< "Enabling / Disabling 10Gbe" << std::endl; -#endif + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectControl(); - if (thisDetector->onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&i,sizeof(i)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - setErrorMask((getErrorMask())|(DETECTOR_TEN_GIGA)); - } - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(DETECTOR_TEN_GIGA)); + } else { + FILE_LOG(logDEBUG5) << "10Gbe: " << retval; + thisDetector->tenGigaEnable = retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); + // have to configure mac after setting 10GbE + ret = configureMAC(); } } - if (ret!=FAIL) { - //must also configuremac - if ((i != -1)&&(retval == i)) - if (configureMAC() != FAIL) { - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { - ret = FAIL; - retval=-1; -#ifdef VERBOSE - FILE_LOG(logINFO) << "Enabling / Disabling 10Gbe in receiver: " - << i << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum2, &i, sizeof(i), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) - setErrorMask((getErrorMask())|(RECEIVER_TEN_GIGA)); - } - } - } + // receiver + if ((thisDetector->receiverOnlineFlag == ONLINE_FLAG) && ret == OK) { + fnum = F_ENABLE_RECEIVER_TEN_GIGA; + ret = FAIL; + arg = thisDetector->tenGigaEnable; + retval = -1; + FILE_LOG(logINFO) << "Sending 10Gbe enable to Receiver " << arg; - if (ret != FAIL) - thisDetector->tenGigaEnable=retval; - return retval; + if (connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); + + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(RECEIVER_TEN_GIGA)); + } else { + FILE_LOG(logDEBUG5) << "Receiver 10Gbe enable: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } + } + } + return thisDetector->tenGigaEnable; } - - int slsDetector::setReceiverFifoDepth(int i) { - int fnum=F_SET_RECEIVER_FIFO_DEPTH; + int fnum = F_SET_RECEIVER_FIFO_DEPTH; int ret = FAIL; - int retval=-1; + int arg = i; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending Receiver Fifo Depth: " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - if (i ==-1) - FILE_LOG(logINFO) << "Getting Receiver Fifo Depth" << std::endl; - else - FILE_LOG(logINFO) << "Setting Receiver Fifo Depth to " << i << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &i, sizeof(i), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(COULD_NOT_SET_FIFO_DEPTH)); + } else { + FILE_LOG(logDEBUG5) << "Receiver Fifo Depth: " << retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } return retval; } @@ -5504,26 +5425,25 @@ int slsDetector::setReceiverFifoDepth(int i) { int slsDetector::setReceiverSilentMode(int i) { - int fnum=F_SET_RECEIVER_SILENT_MODE; + int fnum = F_SET_RECEIVER_SILENT_MODE; int ret = FAIL; - int retval=-1; + int arg = i; + int retval = -1; + FILE_LOG(logDEBUG5) << "Sending Receiver Silent Mode: " << arg; + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); + disconnectData(); - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - if (i ==-1) - FILE_LOG(logINFO) << "Getting Receiver Silent Mode" << std::endl; - else - FILE_LOG(logINFO) << "Setting Receiver Silent Mode to " << i << std::endl; -#endif - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, &i, sizeof(i), &retval, sizeof(retval)); - disconnectData(); - } - if (ret==FAIL) + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); - else + } else { + FILE_LOG(logDEBUG5) << "Receiver Data Streaming: " << retval; thisDetector->receiver_silentMode = retval; + if (ret == FORCE_UPDATE) + ret = updateReceiver(); + } } return thisDetector->receiver_silentMode; } @@ -5532,231 +5452,144 @@ int slsDetector::setReceiverSilentMode(int i) { int slsDetector::restreamStopFromReceiver() { - int fnum=F_RESTREAM_STOP_FROM_RECEIVER; + int fnum = F_RESTREAM_STOP_FROM_RECEIVER; int ret = FAIL; - char mess[MAX_STR_LENGTH] = ""; + FILE_LOG(logDEBUG5) << "Restream stop dummy from Receiver via zmq"; - if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { -#ifdef VERBOSE - FILE_LOG(logINFO) << "To Restream stop dummy from Receiver via zmq" << std::endl; -#endif + if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { + ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); + disconnectData(); - if (connectData() == OK) { - ret=thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); - disconnectData(); - } - if (ret==FORCE_UPDATE) - ret=updateReceiver(); - else if (ret == FAIL) { + // handle ret + if (ret == FAIL) { setErrorMask((getErrorMask())|(RESTREAM_STOP_FROM_RECEIVER)); - FILE_LOG(logERROR) << " Could not restream stop dummy packet from receiver" << std::endl; - } + } else if (ret == FORCE_UPDATE) + ret = updateReceiver(); } - return ret; } - int slsDetector::setCTBPattern(std::string fname) { - uint64_t word; - - int addr=0; - - FILE *fd=fopen(fname.c_str(),"r"); - if (fd>0) { - while (fread(&word, sizeof(word), 1,fd)) { - setCTBWord(addr,word); - // std::cout << std::hex << addr << " " << word << std::dec << std::endl; + int addr = 0; + FILE *fd = fopen(fname.c_str(),"r"); + if (fd > 0) { + while (fread(&word, sizeof(word), 1, fd)) { + setCTBWord(addr, word); ++addr; } - fclose(fd); } else return -1; - - - - - return addr; - - } -uint64_t slsDetector::setCTBWord(int addr,uint64_t word) { +uint64_t slsDetector::setCTBWord(int addr, uint64_t word) { + int fnum = F_SET_CTB_PATTERN; + int ret = FAIL; + int mode = 0; // sets word + uint64_t args[3] = {(uint64_t) mode, (uint64_t)addr, word}; + uint64_t retval = -1; + FILE_LOG(logDEBUG5) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; - //uint64_t ret; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); - int ret=FAIL; - uint64_t retval=-1; - int fnum=F_SET_CTB_PATTERN; - int mode=0; //sets word - - char mess[MAX_STR_LENGTH]=""; - -#ifdef VERBOSE - std::cout<<"Setting CTB word" <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(&addr,sizeof(addr)); - controlSocket->SendDataOnly(&word,sizeof(word)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Set CTB word: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return retval; - - } int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { + int fnum = F_SET_CTB_PATTERN; + int ret = FAIL; + int mode = 1; // sets loop + uint64_t args[5] = {(uint64_t) mode, (uint64_t)level, (uint64_t)start, (uint64_t)stop, (uint64_t)n}; + uint64_t retvals[3] = {0, 0, 0}; + FILE_LOG(logDEBUG5) << "Setting CTB Pat Loops, " + "level: " << level << ", start: " << start << ", stop: " << stop << ", n: " << n; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); + disconnectControl(); - int retval[3], args[4]; - - args[0]=level; - args[1]=start; - args[2]=stop; - args[3]=n; - - - int ret=FAIL; - int fnum=F_SET_CTB_PATTERN; - int mode=1; //sets loop - - char mess[MAX_STR_LENGTH]=""; - -#ifdef VERBOSE - std::cout<<"Setting CTB word" <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(&args,sizeof(args)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - start=retval[0]; - stop=retval[1]; - n=retval[2]; - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Set CTB Pat Loops: " << + retvals[0] << ", " << retvals[1] << ", " << retvals[2]; + start = retvals[0]; + stop = retvals[1]; + n = retvals[2]; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return ret; - - } int slsDetector::setCTBPatWaitAddr(int level, int addr) { + int fnum = F_SET_CTB_PATTERN; + int ret = FAIL; + int mode = 2; // sets loop + uint64_t args[3] = {(uint64_t) mode, (uint64_t)level, (uint64_t)addr}; + uint64_t retval = -1; + FILE_LOG(logDEBUG5) << "Setting CTB Wait Addr, " + "level: " << level << ", addr: 0x" << std::hex << addr << std::dec; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); - - - int retval=-1; - - - int ret=FAIL; - int fnum=F_SET_CTB_PATTERN; - int mode=2; //sets loop - - char mess[MAX_STR_LENGTH]=""; - -#ifdef VERBOSE - std::cout<<"Setting CTB word" <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(&level,sizeof(level)); - controlSocket->SendDataOnly(&addr,sizeof(addr)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Set CTB Wait Addr: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return retval; - - - } int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { + int fnum = F_SET_CTB_PATTERN; + int ret = FAIL; + int mode = 3; // sets loop + uint64_t args[3] = {(uint64_t) mode, (uint64_t)level, t}; + uint64_t retval = -1; + FILE_LOG(logDEBUG5) << "Setting CTB Wait Time, level: " << level << ", t: " << t; + if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { + ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + disconnectControl(); - uint64_t retval=-1; - - int ret=FAIL; - // uint64_t retval=-1; - int fnum=F_SET_CTB_PATTERN; - int mode=3; //sets loop - - char mess[MAX_STR_LENGTH]=""; - -#ifdef VERBOSE - std::cout<<"Setting CTB word" <onlineFlag==ONLINE_FLAG) { - if (connectControl() == OK) { - controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - controlSocket->SendDataOnly(&mode,sizeof(mode)); - controlSocket->SendDataOnly(&level,sizeof(level)); - controlSocket->SendDataOnly(&t,sizeof(t)); - controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); - if (ret!=FAIL) { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } else { - controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - FILE_LOG(logERROR) << "Detector returned error: " << mess << std::endl; - } - disconnectControl(); - if (ret==FORCE_UPDATE) - updateDetector(); + // handle ret + if (ret == FAIL) { + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + } else { + FILE_LOG(logDEBUG5) << "Set CTB Wait Time: " << retval; + if (ret == FORCE_UPDATE) + ret = updateDetector(); } } - return retval; - - } @@ -5767,16 +5600,23 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( // only implemented for eiger currently (in terms of which dacs) if (thisDetector->myDetectorType != EIGER) { - printf("Interpolation of Trim values not implemented for this detector!\n"); + FILE_LOG(logERROR) << "Interpolation of Trim values not implemented for this detector!"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); return NULL; } sls_detector_module* myMod = createModule(thisDetector->myDetectorType); - enum eiger_DacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL, - VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS}; + if (myMod == NULL) { + FILE_LOG(logERROR) << "Could not create module"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + return NULL; + + } + enum eiger_DacIndex{SVP, VTR, VRF, VRS, SVN, VTGSTV, VCMP_LL, VCMP_LR, CAL, + VCMP_RL, RXB_RB, RXB_LB, VCMP_RR, VCP, VCN, VIS}; //Copy other dacs - int dacs_to_copy[] = {SVP,VTR,SVN,VTGSTV,RXB_RB,RXB_LB,VCN,VIS}; + int dacs_to_copy[] = {SVP, VTR, SVN, VTGSTV, RXB_RB, RXB_LB, VCN, VIS}; int num_dacs_to_copy = sizeof(dacs_to_copy) / sizeof(dacs_to_copy[0]); for (int i = 0; i < num_dacs_to_copy; ++i) { if (a->dacs[dacs_to_copy[i]] != b->dacs[dacs_to_copy[i]]) { @@ -5789,15 +5629,15 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( //Copy irrelevant dacs (without failing): CAL if (a->dacs[CAL] != b->dacs[CAL]) { - printf("Warning: DAC CAL differs in both energies (%d, %d)! ", - a->dacs[CAL], b->dacs[CAL]); - printf("Taking first: %d\n", a->dacs[CAL]); + FILE_LOG(logWARNING) << "DAC CAL differs in both energies " + "(" << a->dacs[CAL] << "," << b->dacs[CAL] << ")!\n" + "Taking first: " << a->dacs[CAL]; } myMod->dacs[CAL] = a->dacs[CAL]; //Interpolate vrf, vcmp, vcp - int dacs_to_interpolate[] = {VRF,VCMP_LL,VCMP_LR,VCMP_RL,VCMP_RR,VCP, VRS}; + int dacs_to_interpolate[] = {VRF, VCMP_LL, VCMP_LR, VCMP_RL, VCMP_RR, VCP, VRS}; int num_dacs_to_interpolate = sizeof(dacs_to_interpolate) / sizeof(dacs_to_interpolate[0]); for (int i = 0; i < num_dacs_to_interpolate; ++i) { myMod->dacs[dacs_to_interpolate[i]] = linearInterpolation(energy, e1, e2, @@ -5813,257 +5653,229 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( } - - slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, sls_detector_module* myMod, int tb) { + FILE_LOG(logDEBUG5) << "Read settings file " << fname; - int nflag=0; - if (myMod==NULL) { - myMod=createModule(thisDetector->myDetectorType); - nflag=1; + // flag creating module to delete later + bool modCreated = false; + if (myMod == NULL) { + myMod = createModule(thisDetector->myDetectorType); + if (myMod == NULL) { + FILE_LOG(logERROR) << "Could not create module"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + return NULL; + + } + modCreated = true; } - int id=0,i; - std::string names[100]; - std::string myfname; - std::string str; + std::vector names; + switch (thisDetector->myDetectorType) { + case GOTTHARD: + names.push_back("Vref"); + names.push_back("VcascN"); + names.push_back("VcascP"); + names.push_back("Vout"); + names.push_back("Vcasc"); + names.push_back("Vin"); + names.push_back("Vref_comp"); + names.push_back("Vib_test"); + break; + case EIGER: + break; + case JUNGFRAU: + names.push_back("VDAC0"); + names.push_back("VDAC1"); + names.push_back("VDAC2"); + names.push_back("VDAC3"); + names.push_back("VDAC4"); + names.push_back("VDAC5"); + names.push_back("VDAC6"); + names.push_back("VDAC7"); + names.push_back("VDAC8"); + names.push_back("VDAC9"); + names.push_back("VDAC10"); + names.push_back("VDAC11"); + names.push_back("VDAC12"); + names.push_back("VDAC13"); + names.push_back("VDAC14"); + names.push_back("VDAC15"); + break; + default: + FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + return NULL; + } + + + // open file std::ifstream infile; - std::ostringstream oss; - int iline=0; - std::string sargname; - int ival; - int idac=0; - - //ascii settings/trim file - switch (thisDetector->myDetectorType) { - case GOTTHARD: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; - break; - case EIGER: - break; - case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; - break; - default: - FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file" << std::endl; + if (thisDetector->myDetectorType == EIGER) + infile.open(fname.c_str(), std::ifstream::binary); + else + infile.open(fname.c_str(), std::ios_base::in); + if (!infile.is_open()) { + FILE_LOG(logERROR) << "Could not open settings file for reading: " << fname; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + if (modCreated) + deleteModule(myMod); return NULL; } -#ifdef VERBOSE - std::cout<< "reading settings file" << std::endl; -#endif - myfname=fname; -#ifdef VERBOSE - FILE_LOG(logINFO) << "file name is "<< myfname << std::endl; -#endif - - switch (thisDetector->myDetectorType) { - - case EIGER: - infile.open(myfname.c_str(),std::ifstream::binary); - if (infile.is_open()) { - infile.read((char*) myMod->dacs,sizeof(int)*(myMod->ndac)); - infile.read((char*)&myMod->iodelay,sizeof(myMod->iodelay)); - infile.read((char*)&myMod->tau,sizeof(myMod->tau)); -#ifdef VERBOSE - for(int i=0;indac;++i) - FILE_LOG(logINFO) << "dac " << i << ":" << myMod->dacs[i] << std::endl; - FILE_LOG(logINFO) << "iodelay:" << myMod->iodelay << std::endl; - FILE_LOG(logINFO) << "tau:" << myMod->tau << std::endl; -#endif - if (tb) { - infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan)); - if (infile.eof()) { - std::cout<settingsFile,fname.c_str()); - printf("Settings file loaded: %s\n",thisDetector->settingsFile); - return myMod; - - } - - break; - - case GOTTHARD: - case JUNGFRAU: - //---------------dacs--------------- - infile.open(myfname.c_str(), std::ios_base::in); - if (infile.is_open()) { - while(infile.good()) { - getline(infile,str); - ++iline; -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - std::istringstream ssstr(str); - ssstr >> sargname >> ival; - for (i=0;idacs[i]=ival; - ++idac; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - break; + // eiger + if (thisDetector->myDetectorType == EIGER) { + bool allread = false; + infile.read((char*) myMod->dacs, sizeof(int) * (myMod->ndac)); + if (infile.good()) { + infile.read((char*)&myMod->iodelay, sizeof(myMod->iodelay)); + if(infile.good()) { + infile.read((char*)&myMod->tau, sizeof(myMod->tau)); + if (tb) { + if(infile.good()) { + infile.read((char*) myMod->chanregs, sizeof(int) * (myMod->nchan)); + if (infile) + allread = true; } - } + } else if (infile) + allread = true; + } - if (i < id) { -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - } else - FILE_LOG(logERROR) << "Unknown dac " << sargname << std::endl; - - infile.close(); - strcpy(thisDetector->settingsFile,fname.c_str()); - printf("Settings file loaded: %s\n",thisDetector->settingsFile); - return myMod; - } - - //---------------------------------- - break; - - default: - FILE_LOG(logERROR) << "Unknown detector type - don't know how to read file" << myfname << std::endl; - infile.close(); - deleteModule(myMod); - return NULL; - + if (!allread) { + FILE_LOG(logERROR) << "Could not load all values for settings for " << fname; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + if (modCreated) + deleteModule(myMod); + return NULL; + } + for(int i = 0; i < myMod->ndac; ++i) + FILE_LOG(logDEBUG5) << "dac " << i << ":" << myMod->dacs[i]; + FILE_LOG(logDEBUG5) << "iodelay:" << myMod->iodelay; + FILE_LOG(logDEBUG5) << "tau:" << myMod->tau; } - printf("Error: Could not open settings file %s\n", myfname.c_str()); - if (nflag) - deleteModule(myMod); - - return NULL; - - + // gotthard, jungfrau + else { + size_t idac = 0; + std::string str; + while(infile.good()) { + getline(infile,str); + FILE_LOG(logDEBUG5) << str; + std::string sargname; + int ival = 0; + std::istringstream ssstr(str); + ssstr >> sargname >> ival; + bool found = false; + for (size_t i = 0; i < names.size(); ++i) { + if (sargname == names[i]) { + myMod->dacs[i] = ival; + found = true; + FILE_LOG(logDEBUG5) << names[i] << "(" << i << "): " << ival; + ++idac; + } + } + if (!found) { + FILE_LOG(logERROR) << "Unknown dac " << sargname; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + if (modCreated) + deleteModule(myMod); + return NULL; + } + } + // not all read + if (idac != names.size()) { + FILE_LOG(logERROR) << "Could read only " << idac << " dacs. Expected " << names.size() << "dacs"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); + if (modCreated) + deleteModule(myMod); + return NULL; + } + } + infile.close(); + strcpy(thisDetector->settingsFile, fname.c_str()); + FILE_LOG(logINFO) << "Settings file loaded: " << thisDetector->settingsFile; + return myMod; } int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) { - std::ofstream outfile; + FILE_LOG(logDEBUG5) << "Write settings file " << fname; - std::string names[100]; - int id=0; + std::vector names; switch (thisDetector->myDetectorType) { case GOTTHARD: - names[id++]="Vref"; - names[id++]="VcascN"; - names[id++]="VcascP"; - names[id++]="Vout"; - names[id++]="Vcasc"; - names[id++]="Vin"; - names[id++]="Vref_comp"; - names[id++]="Vib_test"; + names.push_back("Vref"); + names.push_back("VcascN"); + names.push_back("VcascP"); + names.push_back("Vout"); + names.push_back("Vcasc"); + names.push_back("Vin"); + names.push_back("Vref_comp"); + names.push_back("Vib_test"); break; case EIGER: break; case JUNGFRAU: - names[id++]="VDAC0"; - names[id++]="VDAC1"; - names[id++]="VDAC2"; - names[id++]="VDAC3"; - names[id++]="VDAC4"; - names[id++]="VDAC5"; - names[id++]="VDAC6"; - names[id++]="VDAC7"; - names[id++]="VDAC8"; - names[id++]="VDAC9"; - names[id++]="VDAC10"; - names[id++]="VDAC11"; - names[id++]="VDAC12"; - names[id++]="VDAC13"; - names[id++]="VDAC14"; - names[id++]="VDAC15"; + names.push_back("VDAC0"); + names.push_back("VDAC1"); + names.push_back("VDAC2"); + names.push_back("VDAC3"); + names.push_back("VDAC4"); + names.push_back("VDAC5"); + names.push_back("VDAC6"); + names.push_back("VDAC7"); + names.push_back("VDAC8"); + names.push_back("VDAC9"); + names.push_back("VDAC10"); + names.push_back("VDAC11"); + names.push_back("VDAC12"); + names.push_back("VDAC13"); + names.push_back("VDAC14"); + names.push_back("VDAC15"); break; default: - FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file" << std::endl; + FILE_LOG(logERROR) << "Unknown detector type - unknown format for settings file"; + setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); return FAIL; } - int iv; - int idac; - - switch (thisDetector->myDetectorType) { - case EIGER: + // open file + std::ofstream outfile; + if (thisDetector->myDetectorType == EIGER) outfile.open(fname.c_str(), std::ofstream::binary); - if (outfile.is_open()) { - iv = 1150; -#ifdef VERBOSE - for(int i=0;i(&mod.iodelay), sizeof(mod.iodelay)); - outfile.write(reinterpret_cast(&mod.tau), sizeof(mod.tau)); - outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); - - outfile.close(); - return slsDetectorDefs::OK; - } - - printf("Could not open Settings file %s\n", fname.c_str()); - return slsDetectorDefs::FAIL; - default: - - + else outfile.open(fname.c_str(), std::ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idacmyDetectorType == EIGER) { + for(int i = 0; i < mod.ndac; ++i) + FILE_LOG(logINFO) << "dac " << i << ":" << mod.dacs[i]; + FILE_LOG(logINFO) << "iodelay: " << mod.iodelay; + FILE_LOG(logINFO) << "tau: " << mod.tau; + + outfile.write((char*)mod.dacs, sizeof(int) * (mod.ndac)); + outfile.write(reinterpret_cast(&mod.iodelay), sizeof(mod.iodelay)); + outfile.write(reinterpret_cast(&mod.tau), sizeof(mod.tau)); + outfile.write((char*)mod.chanregs, sizeof(int) * (mod.nchan)); + } + + // gotthard, jungfrau + else { + for (int i = 0; i < mod.ndac; ++i) { + FILE_LOG(logDEBUG5) << "dac " << i << ": " << mod.dacs[i]; + outfile << names[i] << " " << (int)mod.dacs[i] << std::endl; + } + } + + outfile.close(); + return OK; } - - - - diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 530e0e791..b3b908fd5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -11,6 +11,8 @@ #include "sls_detector_defs.h" #include "error_defs.h" +#include "logger.h" + #include "math.h" class multiSlsDetector; @@ -1261,7 +1263,7 @@ public: * @param retval is the array with the trimbits * @returns total number of channels for the detector */ - int getChanRegs(double* retval,bool fromDetector); + int getChanRegs(double* retval); /** * Configure Module (Eiger) @@ -1300,7 +1302,7 @@ public: * Prints receiver configuration * #param level print level */ - void printReceiverConfiguration(int level = logINFO); + void printReceiverConfiguration(TLogLevel level = logINFO); /** * Checks if receiver is online and set flag @@ -1486,12 +1488,6 @@ public: */ int getFramesCaughtByReceiver(); - /** - * Gets the number of frames caught by any one receiver (to avoid using threadpool) - * @returns number of frames caught by any one receiver (master receiver if exists) - */ - int getFramesCaughtByAnyReceiver(); - /** * Gets the current frame index of receiver * @returns current frame index of receiver @@ -1538,13 +1534,6 @@ public: */ int setReceiverStreamingTimer(int time_in_ms=500); - /** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ - int enableDataStreamingToClient(int enable=-1); - /** * Enable or disable streaming data from receiver to client * @param enable 0 to disable 1 to enable -1 to only get the value diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index b28868d8c..673876488 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -2723,7 +2723,7 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int d myDet->setOnline(ONLINE_FLAG, detPos); if (action==PUT_ACTION) { - sscanf(args[1],"%lld",&ival); + sscanf(args[1], "%ld",&ival); myDet->setRateCorrection(ival, detPos); } sprintf(answer,"%lld",myDet->getRateCorrection(detPos)); @@ -4908,7 +4908,8 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action, myDet->setReceiverOnline(ONLINE_FLAG, detPos); if (action==PUT_ACTION) return string("cannot put"); - return string(""+myDet->printReceiverConfiguration(detPos)); + myDet->printReceiverConfiguration(detPos); + return string(""); }else if (cmd=="parameters") { myDet->setReceiverOnline(ONLINE_FLAG, detPos); if (action==PUT_ACTION) { diff --git a/slsReceiverSoftware/include/slsReceiverImplementation.h b/slsReceiverSoftware/include/slsReceiverImplementation.h index fc39c27a9..82f415482 100644 --- a/slsReceiverSoftware/include/slsReceiverImplementation.h +++ b/slsReceiverSoftware/include/slsReceiverImplementation.h @@ -57,7 +57,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { * Get detector hostname * @return hostname (max of 1000 characters) */ - char *getDetectorHostname() const; + std::string getDetectorHostname() const; /* * Get flipped data across 'axis' @@ -82,13 +82,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { * Get File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw)) * @return file name prefix */ - char *getFileName() const; + std::string getFileName() const; /** * Get File Path * @return file path */ - char *getFilePath() const; + std::string getFilePath() const; /** * Get File Index @@ -164,7 +164,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { * Get Ehernet Interface * @ethernet interface. eg. eth0 or "" if listening to all */ - char *getEthernetInterface() const; + std::string getEthernetInterface() const; //***acquisition parameters*** @@ -288,13 +288,13 @@ class slsReceiverImplementation: private virtual slsDetectorDefs { * Get streaming source ip * @return streaming source ip */ - char *getStreamingSourceIP() const; + std::string getStreamingSourceIP() const; /** * Get additional json header * @return additional json header */ - char *getAdditionalJsonHeader() const; + std::string getAdditionalJsonHeader() const; /** (not saved in client shared memory) * Get UDP Socket Buffer Size diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index f24da2dff..00d6df141 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -115,6 +115,13 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs { /** function not implemented for specific detector */ void functionNotImplemented(); + /** mode not implemented for specific detector */ + void modeNotImplemented(std::string modename, int mode); + + /** validate and set error */ + template + void validate(T arg, T retval, std::string modename, bool hex); + /** Unrecognized Function */ int M_nofunc(); diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index 01fa3e584..35c6813fc 100644 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -144,9 +144,9 @@ int slsReceiverImplementation::getDetectorPositionId() const{ return detID; } -char *slsReceiverImplementation::getDetectorHostname() const{ +std::string slsReceiverImplementation::getDetectorHostname() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return detHostname; + return std::string(detHostname); } int slsReceiverImplementation::getFlippedData(int axis) const{ @@ -167,14 +167,14 @@ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ } -char *slsReceiverImplementation::getFileName() const{ +std::string slsReceiverImplementation::getFileName() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileName; + return std::string(fileName); } -char *slsReceiverImplementation::getFilePath() const{ +std::string slsReceiverImplementation::getFilePath() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return filePath; + return std::string(filePath); } uint64_t slsReceiverImplementation::getFileIndex() const{ @@ -270,9 +270,9 @@ uint32_t slsReceiverImplementation::getUDPPortNumber2() const{ return udpPortNum[1]; } -char *slsReceiverImplementation::getEthernetInterface() const{ +std::string slsReceiverImplementation::getEthernetInterface() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return eth; + return std::string(eth); } @@ -367,14 +367,14 @@ uint32_t slsReceiverImplementation::getStreamingPort() const{ return streamingPort; } -char *slsReceiverImplementation::getStreamingSourceIP() const{ +std::string slsReceiverImplementation::getStreamingSourceIP() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return streamingSrcIP; + return std::string(streamingSrcIP); } -char *slsReceiverImplementation::getAdditionalJsonHeader() const{ +std::string slsReceiverImplementation::getAdditionalJsonHeader() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; - return additionalJsonHeader; + return std::string(additionalJsonHeader); } uint32_t slsReceiverImplementation::getUDPSocketBufferSize() const { diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 655c58094..92645edb0 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -229,7 +229,7 @@ int slsReceiverTCPIPInterface::function_table(){ flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable; for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { - FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" << + FILE_LOG(logDEBUG5) << "function fnum: " << i << " (" << getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i]; } @@ -277,19 +277,37 @@ void slsReceiverTCPIPInterface::functionNotImplemented() { FILE_LOG(logERROR) << mess; } +void slsReceiverTCPIPInterface::modeNotImplemented(std::string modename, int mode) { + ret = FAIL; + sprintf(mess, "%s (%d) is not implemented for this detector\n", modename.c_str(), mode); + FILE_LOG(logERROR) << mess; +} + +template +void slsReceiverTCPIPInterface::validate(T arg, T retval, std::string modename, bool hex) { + if (ret == OK && arg != -1 && retval != arg) { + ret = FAIL; + if (hex) + sprintf(mess, "Could not %s. Set 0x%x, but read 0x%x\n", + modename.c_str(), arg, retval); + else + sprintf(mess, "Could not %s. Set %d, but read %d\n", + modename.c_str(), arg, retval); + FILE_LOG(logERROR) << mess; + } +} int slsReceiverTCPIPInterface::M_nofunc(){ ret = FAIL; memset(mess, 0, sizeof(mess)); - int n = 0; // to receive any arguments + int n = 1; while (n > 0) - n = mySock->ReceiveDataOnly(mess,MAX_STR_LENGTH); + n = mySock->ReceiveDataOnly(mess, MAX_STR_LENGTH); - strcpy(mess,"Unrecognized Function. Please do not proceed.\n"); + sprintf(mess,"Unrecognized Function enum %d. Please do not proceed.\n", fnum); FILE_LOG(logERROR) << mess; - return interface->Server_SendResult(false, ret, NULL, 0, mess); } @@ -297,7 +315,7 @@ int slsReceiverTCPIPInterface::M_nofunc(){ int slsReceiverTCPIPInterface::exec_command() { - ret = FAIL; + ret = OK; memset(mess, 0, sizeof(mess)); char cmd[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -305,6 +323,7 @@ int slsReceiverTCPIPInterface::exec_command() { // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, cmd, MAX_STR_LENGTH) == FAIL) return FAIL; + FILE_LOG(logINFO) << "Executing command (" << cmd << ")"; // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { @@ -324,18 +343,18 @@ int slsReceiverTCPIPInterface::exec_command() { } strncpy(retval, sresult.c_str(), MAX_STR_LENGTH); ret = OK; + FILE_LOG(logINFO) << "Result of cmd (" << cmd << "):\n" << retval; } } - return interface->Server_SendResult(false, ret, retval, MAX_STR_LENGTH, mess); } int slsReceiverTCPIPInterface::exit_server() { - cprintf(RED,"Closing server\n"); - memset(mess, 0, sizeof(mess)); + cprintf(BG_RED, "Closing server\n"); ret = OK; + memset(mess, 0, sizeof(mess)); interface->Server_SendResult(false, ret, NULL, 0); return GOODBYE; } @@ -421,7 +440,6 @@ int slsReceiverTCPIPInterface::set_port() { mySock = mySocket; interface->SetSocket(mySock); } - return ret; } @@ -446,86 +464,87 @@ int slsReceiverTCPIPInterface::update_client() { int slsReceiverTCPIPInterface::send_update() { - int ind = -1; - char path[MAX_STR_LENGTH] = {0}; int n = 0; + int i32 = -1; + char cstring[MAX_STR_LENGTH] = {0}; + n += mySock->SendDataOnly(mySock->lastClientIP,sizeof(mySock->lastClientIP)); // filepath - path = receiver->getFilePath(); - n += mySock->SendDataOnly(path, sizeof(path)); + strcpy(cstring, receiver->getFilePath().c_str()); + n += mySock->SendDataOnly(cstring, sizeof(cstring)); // filename - path = receiver->getFileName(); - n += mySock->SendDataOnly(path, sizeof(path)); + strcpy(cstring, receiver->getFileName().c_str()); + n += mySock->SendDataOnly(cstring, sizeof(cstring)); // index - ind=receiver->getFileIndex(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=receiver->getFileIndex(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); //file format - ind=(int)receiver->getFileFormat(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getFileFormat(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); //frames per file - ind=(int)receiver->getFramesPerFile(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getFramesPerFile(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); //frame discard policy - ind=(int)receiver->getFrameDiscardPolicy(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getFrameDiscardPolicy(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); //frame padding - ind=(int)receiver->getFramePaddingEnable(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getFramePaddingEnable(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // file write enable - ind=(int)receiver->getFileWriteEnable(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getFileWriteEnable(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // file overwrite enable - ind=(int)receiver->getOverwriteEnable(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getOverwriteEnable(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // gap pixels - ind=(int)receiver->getGapPixelsEnable(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getGapPixelsEnable(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // streaming frequency - ind=(int)receiver->getStreamingFrequency(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getStreamingFrequency(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // streaming port - ind=(int)receiver->getStreamingPort(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getStreamingPort(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // streaming source ip - path = receiver->getStreamingSourceIP(); - n += mySock->SendDataOnly(path, sizeof(path)); + strcpy(cstring, receiver->getStreamingSourceIP().c_str()); + n += mySock->SendDataOnly(cstring, sizeof(cstring)); // additional json header - path = receiver->getAdditionalJsonHeader(); - n += mySock->SendDataOnly(path, sizeof(path)); + strcpy(cstring, receiver->getAdditionalJsonHeader().c_str()); + n += mySock->SendDataOnly(cstring, sizeof(cstring)); // data streaming enable - ind=(int)receiver->getDataStreamEnable(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getDataStreamEnable(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // activate - ind=(int)receiver->getActivate(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getActivate(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // deactivated padding enable - ind=(int)receiver->getDeactivatedPadding(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getDeactivatedPadding(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); // silent mode - ind=(int)receiver->getSilentMode(); - n += mySock->SendDataOnly(&ind, sizeof(ind)); + i32=(int)receiver->getSilentMode(); + n += mySock->SendDataOnly(&i32, sizeof(i32)); if (!lockStatus) - strcpy(mySock->lastClientIP,mySock->thisClientIP); + strcpy(mySock->lastClientIP, mySock->thisClientIP); return OK; } @@ -542,23 +561,24 @@ int slsReceiverTCPIPInterface::get_id(){ int slsReceiverTCPIPInterface::set_detector_type(){ + ret = OK; memset(mess, 0, sizeof(mess)); - detectorType dr = GENERIC; + detectorType arg = GENERIC; detectorType retval = GENERIC; // get args, return if socket crashed - if (interface->Server_ReceiveArg(ret, mess, &dr, sizeof(dr)) == FAIL) + if (interface->Server_ReceiveArg(ret, mess, &arg, sizeof(arg)) == FAIL) return FAIL; // set - if (dr >= 0) { + if (arg >= 0) { // if object exists, verify unlocked and idle, else only verify lock (connecting first time) if (receiver == NULL) interface->Server_VerifyLock(ret, mess, lockStatus); else interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum); if (ret == OK) { - switch(dr) { + switch(arg) { case GOTTHARD: case EIGER: case JUNGFRAUCTB: @@ -566,7 +586,7 @@ int slsReceiverTCPIPInterface::set_detector_type(){ break; default: ret = FAIL; - sprintf(mess,"Unknown detector type: %d\n", dr); + sprintf(mess,"Unknown detector type: %d\n", arg); FILE_LOG(logERROR) << mess; break; } @@ -582,25 +602,27 @@ int slsReceiverTCPIPInterface::set_detector_type(){ if(rawDataModifyReadyCallBack) receiver->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady); } - myDetectorType = dr; + myDetectorType = arg; ret = receiver->setDetectorType(myDetectorType); retval = myDetectorType; // client has started updating receiver, update ip if (!lockStatus) - strcpy(mySock->lastClientIP,mySock->thisClientIP); + strcpy(mySock->lastClientIP, mySock->thisClientIP); } } } //get retval = myDetectorType; + validate((int)arg, (int)retval, std::string("set detector type"), 0); return interface->Server_SendResult(false, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_detector_hostname() { + ret = OK; memset(mess, 0, sizeof(mess)); char hostname[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -618,8 +640,9 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { receiver->setDetectorHostname(hostname); } // get - retval = receiver->getDetectorHostname(); - if (strlen(retval)) { + std::string s = receiver->getDetectorHostname(); + strcpy(retval, s.c_str()); + if (s.length()) { ret = FAIL; sprintf(mess, "hostname not set\n"); FILE_LOG(logERROR) << mess; @@ -634,25 +657,29 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { int slsReceiverTCPIPInterface::set_roi() { ret = OK; memset(mess, 0, sizeof(mess)); - int nroi = 0; + int narg = -1; + std::vector arg; // receive arguments - if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 ) + if (mySock->ReceiveDataOnly(&narg,sizeof(narg)) < 0 ) return interface->Server_SocketCrash(); - - std::vector roiLimits; - int iloop = 0; - for (iloop = 0; iloop < nroi; iloop++) { + for (int iloop = 0; iloop < narg; ++iloop) { ROI temp; - if ( mySock->ReceiveDataOnly(&temp.xmin,sizeof(int)) < 0 ) + if ( mySock->ReceiveDataOnly(&temp.xmin, sizeof(int)) < 0 ) return interface->Server_SocketCrash(); - if ( mySock->ReceiveDataOnly(&temp.xmax,sizeof(int)) < 0 ) + if ( mySock->ReceiveDataOnly(&temp.xmax, sizeof(int)) < 0 ) return interface->Server_SocketCrash(); - if ( mySock->ReceiveDataOnly(&temp.ymin,sizeof(int)) < 0 ) + if ( mySock->ReceiveDataOnly(&temp.ymin, sizeof(int)) < 0 ) return interface->Server_SocketCrash(); - if ( mySock->ReceiveDataOnly(&temp.ymax,sizeof(int)) < 0 ) + if ( mySock->ReceiveDataOnly(&temp.ymax, sizeof(int)) < 0 ) return interface->Server_SocketCrash(); - roiLimits.push_back(temp); + arg.push_back(temp); + } + FILE_LOG(logDEBUG5) << "Set ROI narg: " << narg; + for (int iloop = 0; iloop < narg; ++iloop) { + FILE_LOG(logDEBUG5) << "(" << arg[iloop].xmin << ", " << + arg[iloop].xmax << ", " << arg[iloop].ymin << ", " << + arg[iloop].ymax << ")"; } // only for gotthard @@ -666,19 +693,16 @@ int slsReceiverTCPIPInterface::set_roi() { // only set // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) - ret = receiver->setROI(roiLimits); + ret = receiver->setROI(arg); } - - interface->Server_SendResult(true, ret, NULL, 0, mess); - - roiLimits.clear(); - - return ret; + arg.clear(); + return interface->Server_SendResult(true, ret, NULL, 0, mess); } int slsReceiverTCPIPInterface::setup_udp(){ + ret = OK; memset(mess, 0, sizeof(mess)); char args[3][MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -737,13 +761,13 @@ int slsReceiverTCPIPInterface::setup_udp(){ } } } - return interface->Server_SendResult(true, ret, retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_timer() { + ret = OK; memset(mess, 0, sizeof(mess)); int64_t index[2] = {-1, -1}; int64_t retval = -1; @@ -754,8 +778,7 @@ int slsReceiverTCPIPInterface::set_timer() { // base object not null if (ret == OK) { - FILE_LOG(logDEBUG5, ("Setting timer index %d to %lld ns\n", index[0], index[1])); - char timername[100] = {0}; + FILE_LOG(logDEBUG5) << "Setting timer index " << index[0] << " to " << index[1]; // set if (index[1] >= 0) { @@ -763,42 +786,32 @@ int slsReceiverTCPIPInterface::set_timer() { if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { switch (index[0]) { case ACQUISITION_TIME: - strcpy(timername, "exptime"); - ret = receiver->setAcquisitionTime(index[1]); + ret = receiver->setAcquisitionTime(index[1]); break; case FRAME_PERIOD: - strcpy(timername, "period"); ret = receiver->setAcquisitionPeriod(index[1]); break; case FRAME_NUMBER: case CYCLES_NUMBER: case STORAGE_CELL_NUMBER: - strcpy(timername, "frames_cycles_storagecells"); receiver->setNumberOfFrames(index[1]); break; case SUBFRAME_ACQUISITION_TIME: - strcpy(timername, "subexptime"); receiver->setSubExpTime(index[1]); break; case SUBFRAME_DEADTIME: - strcpy(timername, "subdeadtime"); receiver->setSubPeriod(index[1] + receiver->getSubExpTime()); break; case SAMPLES_JCTB: - strcpy(timername, "samples"); if (myDetectorType != JUNGFRAUCTB) { - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]); - FILE_LOG(logERROR) << "Warning: " << mess; + modeNotImplemented("(Samples) Timer index", (int)index[0]); break; } receiver->setNumberofSamples(index[1]); break; default: - strcpy(timername, "unknown"); - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); - FILE_LOG(logERROR) << mess; + modeNotImplemented("Timer index", (int)index[0]); + break; } } } @@ -831,18 +844,11 @@ int slsReceiverTCPIPInterface::set_timer() { retval=receiver->getNumberofSamples(); break; default: - ret = FAIL; - sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]); - FILE_LOG(logERROR) << mess; + modeNotImplemented("Timer index", (int)index[0]); + break; } - - // check - if (ret == OK && index[1] >= 0 && retval != index[1]) { - ret = FAIL; - strcpy(mess,"Could not set timer %s\n", timername); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; + validate((int)index[1], (int)retval, std::string("set timer"), 0); + FILE_LOG(logDEBUG5) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -850,6 +856,7 @@ int slsReceiverTCPIPInterface::set_timer() { int slsReceiverTCPIPInterface::set_dynamic_range() { + ret = OK; memset(mess, 0, sizeof(mess)); int dr = -1; int retval = -1; @@ -864,6 +871,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { if (dr >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting dynamic range: " << dr; bool exists = false; switch (dr) { case 16: @@ -880,9 +888,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { } // invalid dr if (!exists) { - ret = FAIL; - sprintf(mess,"This dynamic range %d does not exist for this detector\n",dr); - FILE_LOG(logERROR) << mess; + modeNotImplemented("Dynamic range", dr); } // valid dr else { @@ -896,20 +902,16 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { } // get retval = receiver->getDynamicRange(); - if(dr > 0 && retval != dr) { - ret = FAIL; - strcpy(mess, "Could not set dynamic range\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "dynamic range: " << retval; + validate(dr, retval, std::string("set dynamic range"), 0); + FILE_LOG(logDEBUG5) << "dynamic range: " << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } -int slsReceiverTCPIPInterface::set_streaming_frequency(){ +int slsReceiverTCPIPInterface::set_streaming_frequency() { + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -924,6 +926,7 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting streaming frequency: " << index; ret = receiver->setStreamingFrequency(index); if(ret == FAIL) { strcpy(mess, "Could not allocate memory for listening fifo\n"); @@ -932,15 +935,9 @@ int slsReceiverTCPIPInterface::set_streaming_frequency(){ } } // get - retval=receiver->getStreamingFrequency(); - // check retval for failure - if(ret == OK && index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set streaming frequency"); - FILE_LOG(logERROR) << mess; - } + retval = receiver->getStreamingFrequency(); + validate(index, retval, std::string("set streaming frequency"), 0); } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -954,15 +951,18 @@ int slsReceiverTCPIPInterface::get_status(){ // no arg, check receiver is null interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); - if (ret == OK) + if (ret == OK) { + FILE_LOG(logDEBUG5) << "Getting Status"; retval = receiver->getStatus(); - + FILE_LOG(logDEBUG5) << "Status:" << runStatusType(retval); + } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::start_receiver(){ + ret = OK; memset(mess, 0, sizeof(mess)); // no arg, and check receiver is null @@ -980,20 +980,21 @@ int slsReceiverTCPIPInterface::start_receiver(){ sprintf(mess,"Cannot start Receiver as it is in %s state\n",runStatusType(s).c_str()); FILE_LOG(logERROR) << mess; }else { - ret=receiver->startReceiver(mess); + FILE_LOG(logDEBUG5) << "Starting Reciever"; + ret = receiver->startReceiver(mess); if (ret == FAIL) { FILE_LOG(logERROR) << mess; } } } } - return interface->Server_SendResult(true, ret, NULL, 0, mess); } int slsReceiverTCPIPInterface::stop_receiver(){ + ret = OK; memset(mess, 0, sizeof(mess)); // no arg, and check receiver is null @@ -1004,8 +1005,10 @@ int slsReceiverTCPIPInterface::stop_receiver(){ // only set // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { - if(receiver->getStatus() != IDLE) + if(receiver->getStatus() != IDLE) { + FILE_LOG(logDEBUG5) << "Stopping Reciever"; receiver->stopReceiver(); + } enum runStatus s = receiver->getStatus(); if (s == IDLE) ret = OK; @@ -1016,16 +1019,13 @@ int slsReceiverTCPIPInterface::stop_receiver(){ } } } - return interface->Server_SendResult(true, ret, NULL, 0, mess); } - - - int slsReceiverTCPIPInterface::set_file_dir() { + ret = OK; memset(mess, 0, sizeof(mess)); char fPath[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -1038,24 +1038,26 @@ int slsReceiverTCPIPInterface::set_file_dir() { if (ret == OK) { // set if (strlen(fPath)) { + FILE_LOG(logDEBUG5) << "Setting file path: " << fPath; receiver->setFilePath(fPath); } // get - retval = receiver->getFilePath(); - if ((!strlen(retval)) || (strlen(fPath) && strcasecmp(fPath, retval))) { + std::string s = receiver->getFilePath(); + strcpy(retval, s.c_str()); + if ((s.length()) || (strlen(fPath) && strcasecmp(fPath, retval))) { ret = FAIL; strcpy(mess,"receiver file path does not exist\n"); FILE_LOG(logERROR) << mess; } else - FILE_LOG(logDEBUG1) << "file path:" << retval; + FILE_LOG(logDEBUG5) << "file path:" << retval; } - return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } int slsReceiverTCPIPInterface::set_file_name() { + ret = OK; memset(mess, 0, sizeof(mess)); char fName[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -1068,24 +1070,26 @@ int slsReceiverTCPIPInterface::set_file_name() { if (ret == OK) { // set if (strlen(fName)) { + FILE_LOG(logDEBUG5) << "Setting file name: " << fName; receiver->setFileName(fName); } // get - retval = receiver->getFileName(); - if (strlen(retval)) { + std::string s = receiver->getFileName(); + strcpy(retval, s.c_str()); + if (s.length()) { ret = FAIL; strcpy(mess, "file name is empty\n"); FILE_LOG(logERROR) << mess; } else - FILE_LOG(logDEBUG1) << "file name:" << retval; + FILE_LOG(logDEBUG5) << "file name:" << retval; } - return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } int slsReceiverTCPIPInterface::set_file_index() { + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1100,58 +1104,58 @@ int slsReceiverTCPIPInterface::set_file_index() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting file index: " << index; receiver->setFileIndex(index); } } // get retval=receiver->getFileIndex(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set file index\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "file index:" << retval; + validate(index, retval, std::string("set file index"), 0); + FILE_LOG(logDEBUG5) << "file index:" << retval; } - return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } - - - int slsReceiverTCPIPInterface::get_frame_index(){ + ret = OK; memset(mess, 0, sizeof(mess)); int retval = -1; // no arg, check receiver is null interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); - if (ret == OK) - retval=receiver->getAcquisitionIndex(); - + if (ret == OK) { + FILE_LOG(logDEBUG5) << "Getting frame index"; + retval = receiver->getAcquisitionIndex(); + FILE_LOG(logDEBUG5) << "frame index:" << retval; + } return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } int slsReceiverTCPIPInterface::get_frames_caught(){ + ret = OK; memset(mess, 0, sizeof(mess)); int retval = -1; // no arg, check receiver is null interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); - if (ret == OK) - retval=receiver->getTotalFramesCaught(); - + if (ret == OK) { + FILE_LOG(logDEBUG5) << "Getting frames caught"; + retval = receiver->getTotalFramesCaught(); + FILE_LOG(logDEBUG5) << "frames caught:" << retval; + } return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } int slsReceiverTCPIPInterface::reset_frames_caught(){ + ret = OK; memset(mess, 0, sizeof(mess)); // no arg, and check receiver is null @@ -1162,16 +1166,17 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){ // only set // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { + FILE_LOG(logDEBUG5) << "Reset frames caught"; receiver->resetAcquisitionCount(); } } - return interface->Server_SendResult(true, ret, NULL, 0, mess); } int slsReceiverTCPIPInterface::enable_file_write(){ + ret = OK; memset(mess, 0, sizeof(mess)); int enable = -1; int retval = -1; @@ -1186,27 +1191,22 @@ int slsReceiverTCPIPInterface::enable_file_write(){ if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting File write enable:" << enable; receiver->setFileWriteEnable(enable); } } // get - retval=receiver->getFileWriteEnable(); - if(enable >= 0 && enable != retval) { - ret=FAIL; - strcpy(mess,"Could not set file write enable"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "file write enable:" << retval; + retval = receiver->getFileWriteEnable(); + validate(enable, retval, std::string("set file write enable"), 0); + FILE_LOG(logDEBUG5) << "file write enable:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - - int slsReceiverTCPIPInterface::enable_overwrite() { + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1221,25 +1221,22 @@ int slsReceiverTCPIPInterface::enable_overwrite() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting File overwrite enable:" << index; receiver->setOverwriteEnable(index); } } // get - retval=receiver->getOverwriteEnable(); - if(index >=0 && retval != index) { - ret = FAIL; - strcpy(mess,"Could not set file over write enable\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval; + retval = receiver->getOverwriteEnable(); + validate(index, retval, std::string("set file overwrite enable"), 0); + FILE_LOG(logDEBUG5) << "file overwrite enable:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::enable_tengiga() { + ret = OK; memset(mess, 0, sizeof(mess)); int val = -1; int retval = -1; @@ -1257,26 +1254,22 @@ int slsReceiverTCPIPInterface::enable_tengiga() { if (val >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting 10GbE:" << val; ret = receiver->setTenGigaEnable(val); } } // get - retval=receiver->getTenGigaEnable(); - if((val >= 0) && (val != retval)) { - ret = FAIL; - strcpy(mess,"Could not set ten giga enable"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "10Gbe:" << retval; + retval = receiver->getTenGigaEnable(); + validate(val, retval, std::string("set 10GbE"), 0); + FILE_LOG(logDEBUG5) << "10Gbe:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::set_fifo_depth() { + ret = OK; memset(mess, 0, sizeof(mess)); int value = -1; int retval = -1; @@ -1291,6 +1284,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { if (value >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting fifo depth:" << value; ret = receiver->setFifoDepth(value); if (ret == FAIL) { strcpy(mess,"Could not set fifo depth"); @@ -1300,20 +1294,16 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { } // get retval = receiver->getFifoDepth(); - if(value >= 0 && retval != value) { - ret = FAIL; - strcpy(mess, "Could not set fifo depth\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "fifo depth:" << retval; + validate(value, retval, std::string("set fifo depth"), 0); + FILE_LOG(logDEBUG5) << "fifo depth:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_activate() { + ret = OK; memset(mess, 0, sizeof(mess)); int enable = -1; int retval = -1; @@ -1331,25 +1321,22 @@ int slsReceiverTCPIPInterface::set_activate() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting activate:" << enable; receiver->setActivate(enable > 0 ? true : false); } } // get retval = (int)receiver->getActivate(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Activate: " << retval; + validate(enable, retval, std::string("set activate"), 0); + FILE_LOG(logDEBUG5) << "Activate: " << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_data_stream_enable(){ + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1364,25 +1351,22 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){ if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting data stream enable:" << index; ret = receiver->setDataStreamEnable(index); } } // get retval = receiver->getDataStreamEnable(); - if(index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set data stream enable"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "data streaming enable:" << retval; + validate(index, retval, std::string("set data stream enable"), 0); + FILE_LOG(logDEBUG5) << "data streaming enable:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_streaming_timer(){ + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1397,25 +1381,22 @@ int slsReceiverTCPIPInterface::set_streaming_timer(){ if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting streaming timer:" << index; receiver->setStreamingTimer(index); } } // get retval=receiver->getStreamingTimer(); - if(index >= 0 && retval != index){ - ret = FAIL; - strcpy(mess,"Could not set datastream timer"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Streaming timer:" << retval; + validate(index, retval, std::string("set data stream timer"), 0); + FILE_LOG(logDEBUG5) << "Streaming timer:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_flipped_data(){ + ret = OK; memset(mess, 0, sizeof(mess)); int args[2] = {0,-1}; int retval = -1; @@ -1433,26 +1414,22 @@ int slsReceiverTCPIPInterface::set_flipped_data(){ if (args[1] >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting flipped data:" << args[1]; receiver->setFlippedData(args[0],args[1]); } } // get retval=receiver->getFlippedData(args[0]); - if (args[1] > -1 && retval != args[1]) { - ret = FAIL; - strcpy(mess, "Could not set flipped data\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Flipped Data:" << retval; + validate(args[1], retval, std::string("set flipped data"), 0); + FILE_LOG(logDEBUG5) << "Flipped Data:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::set_file_format() { + ret = OK; memset(mess, 0, sizeof(mess)); fileFormat retval = GET_FILE_FORMAT; fileFormat f = GET_FILE_FORMAT; @@ -1467,26 +1444,22 @@ int slsReceiverTCPIPInterface::set_file_format() { if (f >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting file format:" << f; receiver->setFileFormat(f); } } // get retval = receiver->getFileFormat(); - if(f >= 0 && retval != f){ - ret = FAIL; - sprintf(mess,"Could not set file format to %s, returned %s\n", - getFileFormatType(f).c_str(),getFileFormatType(retval).c_str()); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "File Format: " << retval; + validate(f, retval, std::string("set file format"), 0); + FILE_LOG(logDEBUG5) << "File Format: " << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::set_detector_posid() { + ret = OK; memset(mess, 0, sizeof(mess)); int arg = -1; int retval = -1; @@ -1501,28 +1474,22 @@ int slsReceiverTCPIPInterface::set_detector_posid() { if (arg >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting detector position id:" << arg; receiver->setDetectorPositionId(arg); } } // get - retval=receiver->getDetectorPositionId(); - if (arg >= 0 && retval != arg) { - ret = FAIL; - strcpy(mess,"Could not set detector position id"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Position Id:" << retval; + retval = receiver->getDetectorPositionId(); + validate(arg, retval, std::string("set detector position id"), 0); + FILE_LOG(logDEBUG5) << "Position Id:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - - - int slsReceiverTCPIPInterface::set_multi_detector_size() { + ret = OK; memset(mess, 0, sizeof(mess)); int arg[2] = {-1, -1}; int retval = -1; @@ -1537,6 +1504,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { if((arg[0] > 0) && (arg[1] > 0)) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting multi detector size:" << arg[0] << "," << arg[1]; receiver->setMultiDetectorSize(arg); } } @@ -1548,16 +1516,15 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { else retval *= temp[i]; } - FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval; + FILE_LOG(logDEBUG5) << "Multi Detector Size:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::set_streaming_port() { + ret = OK; memset(mess, 0, sizeof(mess)); int port = -1; int retval = -1; @@ -1572,22 +1539,22 @@ int slsReceiverTCPIPInterface::set_streaming_port() { if (port >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting streaming port:" << port; receiver->setStreamingPort(port); } } // get - retval=receiver->getStreamingPort(); - FILE_LOG(logDEBUG1) << "streaming port:" << retval; + retval = receiver->getStreamingPort(); + validate(port, retval, std::string("set streaming port"), 0); + FILE_LOG(logDEBUG5) << "streaming port:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - - int slsReceiverTCPIPInterface::set_streaming_source_ip() { + ret = OK; memset(mess, 0, sizeof(mess)); char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -1601,23 +1568,20 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { // only set // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting streaming source ip:" << arg; receiver->setStreamingSourceIP(arg); } // get - retval = receiver->getStreamingSourceIP(); - FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; + strcpy(retval, receiver->getStreamingSourceIP().c_str()); + FILE_LOG(logDEBUG5) << "streaming source ip:" << retval; } - return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } - - - - int slsReceiverTCPIPInterface::set_silent_mode() { + ret = OK; memset(mess, 0, sizeof(mess)); int value = -1; int retval = -1; @@ -1632,23 +1596,22 @@ int slsReceiverTCPIPInterface::set_silent_mode() { if (value >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting silent mode:" << value; receiver->setSilentMode(value); } } // get retval = (int)receiver->getSilentMode(); - FILE_LOG(logDEBUG1) << "silent mode:" << retval; + validate(value, retval, std::string("set silent mode"), 0); + FILE_LOG(logDEBUG5) << "silent mode:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - - - int slsReceiverTCPIPInterface::enable_gap_pixels() { + ret = OK; memset(mess, 0, sizeof(mess)); int enable = -1; int retval = -1; @@ -1666,26 +1629,22 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting gap pixels enable:" << enable; receiver->setGapPixelsEnable(enable); } } // get retval = receiver->getGapPixelsEnable(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set gap pixels to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << "Warning: " << mess; - } - FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval; + validate(enable, retval, std::string("set gap pixels enable"), 0); + FILE_LOG(logDEBUG5) << "Gap Pixels Enable: " << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::restream_stop(){ + ret = OK; memset(mess, 0, sizeof(mess)); // no arg, and check receiver is null @@ -1701,6 +1660,7 @@ int slsReceiverTCPIPInterface::restream_stop(){ sprintf(mess,"Could not restream stop packet as data Streaming is disabled.\n"); FILE_LOG(logERROR) << mess; } else { + FILE_LOG(logDEBUG5) << "Restreaming stop"; ret = receiver->restreamStop(); if (ret == FAIL) { sprintf(mess,"Could not restream stop packet.\n"); @@ -1709,13 +1669,13 @@ int slsReceiverTCPIPInterface::restream_stop(){ } } } - return interface->Server_SendResult(true, ret, NULL, 0, mess); } int slsReceiverTCPIPInterface::set_additional_json_header() { + ret = OK; memset(mess, 0, sizeof(mess)); char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; @@ -1729,19 +1689,20 @@ int slsReceiverTCPIPInterface::set_additional_json_header() { // only set // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting additional json header: " << arg; receiver->setAdditionalJsonHeader(arg); } // get - retval = receiver->getAdditionalJsonHeader(); - FILE_LOG(logDEBUG1) << "additional json header:" << retval; + strcpy(retval, receiver->getAdditionalJsonHeader().c_str()); + FILE_LOG(logDEBUG5) << "additional json header:" << retval; } - return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1756,7 +1717,8 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - if (receiver->setUDPSocketBufferSize(index) == FAIL) { + FILE_LOG(logDEBUG5) << "Setting UDP Socket Buffer size: " << index; + if (receiver->setUDPSocketBufferSize(index) == FAIL) { ret = FAIL; strcpy(mess, "Could not create dummy UDP Socket to test buffer size\n"); FILE_LOG(logERROR) << mess; @@ -1764,30 +1726,27 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { } } // get - retval=receiver->getUDPSocketBufferSize(); - if(index >= 0 && ((retval != index) || ((int)receiver->getActualUDPSocketBufferSize() != (index*2)))) { - ret = FAIL; - strcpy(mess, "Could not set UDP Socket buffer size (No CAP_NET_ADMIN privileges?)\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval; + retval = receiver->getUDPSocketBufferSize(); + validate(index, retval, std::string("set udp socket buffer size (No CAP_NET_ADMIN privileges?)"), 0); + FILE_LOG(logDEBUG5) << "UDP Socket Buffer Size:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){ + ret = OK; memset(mess, 0, sizeof(mess)); int retval = -1; // no arg, check receiver is null interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); - if (ret == OK) + if (ret == OK) { + FILE_LOG(logDEBUG5) << "Getting actual UDP buffer size"; retval = receiver->getActualUDPSocketBufferSize(); - + } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1809,35 +1768,29 @@ int slsReceiverTCPIPInterface::set_frames_per_file() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting frames per file: " << index; receiver->setFramesPerFile(index); } } // get - retval=receiver->getFramesPerFile(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frames per file\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "frames per file:" << retval; + retval = receiver->getFramesPerFile(); + validate(index, retval, std::string("set frames per file"), 0); + FILE_LOG(logDEBUG5) << "frames per file:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - - - int slsReceiverTCPIPInterface::check_version_compatibility() { + ret = OK; memset(mess, 0, sizeof(mess)); int64_t arg = -1; // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, &arg, sizeof(arg)) == FAIL) return FAIL; - FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg; + FILE_LOG(logDEBUG5) << "Checking versioning compatibility with value " << arg; int64_t client_requiredVersion = arg; int64_t rx_apiVersion = APIRECEIVER; int64_t rx_version = getReceiverVersion(); @@ -1869,8 +1822,8 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { - int slsReceiverTCPIPInterface::set_discard_policy() { + ret = OK; memset(mess, 0, sizeof(mess)); int index = -1; int retval = -1; @@ -1885,25 +1838,20 @@ int slsReceiverTCPIPInterface::set_discard_policy() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting frames discard policy: " << index; receiver->setFrameDiscardPolicy((frameDiscardPolicy)index); } } // get - retval=receiver->getFrameDiscardPolicy(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frame discard policy\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "frame discard policy:" << retval; + retval = receiver->getFrameDiscardPolicy(); + validate(index, retval, std::string("set discard policy"), 0); + FILE_LOG(logDEBUG5) << "frame discard policy:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::set_padding_enable() { ret = OK; memset(mess, 0, sizeof(mess)); @@ -1921,26 +1869,22 @@ int slsReceiverTCPIPInterface::set_padding_enable() { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { index = (index == 0) ? 0 : 1; + FILE_LOG(logDEBUG5) << "Setting frames padding enable: " << index; receiver->setFramePaddingEnable(index); } } // get - retval=(int)receiver->getFramePaddingEnable(); - if(index >= 0 && retval != index) { - ret = FAIL; - strcpy(mess, "Could not set frame padding enable\n"); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval; + retval = (int)receiver->getFramePaddingEnable(); + validate(index, retval, std::string("set frame padding enable"), 0); + FILE_LOG(logDEBUG5) << "Frame Padding Enable:" << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } - int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { + ret = OK; memset(mess, 0, sizeof(mess)); int enable = -1; int retval = -1; @@ -1958,18 +1902,14 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { + FILE_LOG(logDEBUG5) << "Setting deactivated padding enable: " << enable; receiver->setDeactivatedPadding(enable > 0 ? true : false); } } // get retval = (int)receiver->getDeactivatedPadding(); - if(enable >= 0 && retval != enable){ - ret = FAIL; - sprintf(mess,"Could not set deactivated padding enable to %d, returned %d\n",enable,retval); - FILE_LOG(logERROR) << mess; - } - FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; + validate(enable, retval, std::string("set deactivated padding enable"), 0); + FILE_LOG(logDEBUG5) << "Deactivated Padding Enable: " << retval; } - return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } diff --git a/slsSupportLib/include/ClientInterface.cpp b/slsSupportLib/include/ClientInterface.cpp index 4d387da76..92d3f89ee 100644 --- a/slsSupportLib/include/ClientInterface.cpp +++ b/slsSupportLib/include/ClientInterface.cpp @@ -82,7 +82,6 @@ int ClientInterface::Server_ReceiveArg(int& ret, char* mess, void* arg, int size if (sizeofArg && mySocket->ReceiveDataOnly(arg, sizeofArg) < 0) return Server_SocketCrash(); - ret = OK; // check if server object created if (checkbase && base == NULL) Server_NullObjectError(ret, mess); From dfa8cf73814addc668f9771ff4954a2f37042f2a Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 30 Oct 2018 13:35:20 +0100 Subject: [PATCH 7/7] runs, prints right in reciever --- CMakeLists.txt | 2 +- manual/manual-api/mainReceiver.cpp | 10 +- slsDetectorServers/eigerDetectorServer/Beb.c | 42 +- .../eigerDetectorServer/FebControl.c | 46 +- .../eigerDetectorServer/FebInterface.c | 2 +- .../eigerDetectorServer/LocalLinkInterface.c | 20 +- .../eigerDetectorServer/gitInfo.txt | 8 +- .../eigerDetectorServer/gitInfoEiger.h | 6 +- .../slsDetectorFunctionList.c | 74 +-- .../slsDetectorServer/communication_funcs.c | 18 +- .../slsDetectorServer/slsDetectorServer.c | 2 +- .../slsDetectorServer_funcs.c | 253 ++++---- .../sharedMemory/SharedMemory.cpp | 41 +- .../slsDetector/slsDetector.cpp | 556 +++++++++--------- .../slsDetector/slsDetectorCommand.cpp | 2 +- .../include/BinaryFileStatic.h | 10 +- slsReceiverSoftware/include/File.h | 30 +- slsReceiverSoftware/include/GeneralData.h | 62 +- slsReceiverSoftware/include/HDF5File.h | 2 +- slsReceiverSoftware/include/HDF5FileStatic.h | 84 +-- slsReceiverSoftware/src/BinaryFile.cpp | 3 +- slsReceiverSoftware/src/DataProcessor.cpp | 51 +- slsReceiverSoftware/src/DataStreamer.cpp | 68 +-- slsReceiverSoftware/src/Fifo.cpp | 9 +- slsReceiverSoftware/src/File.cpp | 4 +- slsReceiverSoftware/src/HDF5File.cpp | 19 +- slsReceiverSoftware/src/Listener.cpp | 56 +- slsReceiverSoftware/src/ThreadObject.cpp | 6 +- slsReceiverSoftware/src/main.cpp | 43 +- .../src/slsReceiverImplementation.cpp | 428 +++++++------- .../src/slsReceiverTCPIPInterface.cpp | 171 +++--- slsSupportLib/include/logger.h | 68 +-- 32 files changed, 1058 insertions(+), 1138 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 056a65561..f6c884905 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option (USE_GUI "GUI" OFF) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -Wno-misleading-indentation") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ") endif () set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp index f59cccae0..53bc76db5 100644 --- a/manual/manual-api/mainReceiver.cpp +++ b/manual/manual-api/mainReceiver.cpp @@ -101,15 +101,15 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, "#### %d GetData: ####\n" - "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" - "\t\ttimestamp: %llu\t\tmodId: %u\t\t" + "frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu" + "\t\ttimestamp: %lu\t\tmodId: %u\t\t" "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" //"\t\tpacketsMask:%s" "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId, - (long long unsigned int)detectorHeader.timestamp, detectorHeader.modId, + detectorHeader.row, (long unsigned int)detectorHeader.frameNumber, + detectorHeader.expLength, detectorHeader.packetNumber, (long unsigned int)detectorHeader.bunchId, + (long unsigned int)detectorHeader.timestamp, detectorHeader.modId, detectorHeader.row, detectorHeader.column, detectorHeader.reserved, detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.detType, detectorHeader.version, diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c index 7c20c2b40..70f7eae54 100644 --- a/slsDetectorServers/eigerDetectorServer/Beb.c +++ b/slsDetectorServers/eigerDetectorServer/Beb.c @@ -134,7 +134,7 @@ void Beb_Beb(int id) { if (!Beb_InitBebInfos()) exit(1); - FILE_LOG(logDEBUG5, ("Printing Beb infos:\n")); + FILE_LOG(logDEBUG1, ("Printing Beb infos:\n")); unsigned int i; for(i=1;iratemax) b0[b] = beforemax; else b0[b] = ratemax; } - /*FILE_LOG(logDEBUG5, ("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " + /*FILE_LOG(logDEBUG1, ("After Loop s: %f,\t sx: %f,\t sy: %f,\t sxx: %f,\t sxy: %f,\t " "next_i: %d,\t b: %d,\t Feb_Control_rate_meas[next_i]: %f\n", s, sx, sy, sxx, sxy, next_i, b, Feb_Control_rate_meas[next_i]));*/ // cout<0xfff) return 0; - FILE_LOG(logDEBUG5, ("FIW ch %d\n", ch)); + FILE_LOG(logDEBUG1, ("FIW ch %d\n", ch)); Feb_Interface_send_data_raw[0] = 0x8fff0000; if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; diff --git a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c index 7679ad432..d180a729c 100644 --- a/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c +++ b/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c @@ -10,18 +10,18 @@ void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) { - FILE_LOG(logDEBUG5, ("Initialize PLB LL FIFOs\n")); + FILE_LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n")); ll->ll_fifo_base=0; ll->ll_fifo_ctrl_reg=0; if (Local_Init(ll,ll_fifo_badr)) { Local_Reset(ll); - FILE_LOG(logDEBUG5, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll))); + FILE_LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll))); } else FILE_LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr)); } void Local_LocalLinkInterface(struct LocalLinkInterface* ll) { - FILE_LOG(logDEBUG5, ("Initializing new memory\n")); + FILE_LOG(logDEBUG1, ("Initializing new memory\n")); } @@ -57,7 +57,7 @@ int Local_Reset(struct LocalLinkInterface* ll) { int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) { ll->ll_fifo_ctrl_reg |= rst_mask; - FILE_LOG(logDEBUG5, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg)); + FILE_LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg)); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); @@ -92,9 +92,9 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf last_word = (buffer_len-1)/4; word_ptr = (unsigned int *)buffer; - FILE_LOG(logDEBUG5, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base)); + FILE_LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base)); for (i=0; i < buffer_len/4; i++) - FILE_LOG(logDEBUG5, ("%.8X ",*(((unsigned *) buffer)+i))); + FILE_LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i))); while (words_send <= last_word) { @@ -138,7 +138,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff volatile unsigned int fifo_val; int sof = 0; - FILE_LOG(logDEBUG5, ("LL Read - If: %X - Data: ",ll->ll_fifo_base)); + FILE_LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base)); word_ptr = (unsigned int *)buffer; do @@ -164,7 +164,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff { if ( (buffer_len >> 2) > buffer_ptr) { - FILE_LOG(logDEBUG5, ("%.8X ", fifo_val)); + FILE_LOG(logDEBUG1, ("%.8X ", fifo_val)); word_ptr[buffer_ptr++] = fifo_val; //write to buffer } else @@ -176,7 +176,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff if (status & PLB_LL_FIFO_STATUS_LL_EOF) { len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT ); - FILE_LOG(logDEBUG5, ("Len: %d\n",len)); + FILE_LOG(logDEBUG1, ("Len: %d\n",len)); buffer_ptr = 0; return len; } @@ -209,7 +209,7 @@ int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff do{ len = Local_Read(ll,rec_buff_len,rec_buffer); - FILE_LOG(logDEBUG5, ("receive length: %i\n",len)); + FILE_LOG(logDEBUG1, ("receive length: %i\n",len)); if (len > 0) { rec_buffer[len]=0; diff --git a/slsDetectorServers/eigerDetectorServer/gitInfo.txt b/slsDetectorServers/eigerDetectorServer/gitInfo.txt index 136474476..f5bf1d811 100644 --- a/slsDetectorServers/eigerDetectorServer/gitInfo.txt +++ b/slsDetectorServers/eigerDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: dfad145e1492e961c95063aa5b2f54e5e1b418a0 -Revision: 3 +Repsitory UUID: 92fc837eb490650d91c2283943cbd729b2e36567 +Revision: 6 Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4127 -Last Changed Date: 2018-10-23 12:30:26.000000002 +0200 ./Beb.c +Last Changed Rev: 4131 +Last Changed Date: 2018-10-29 17:14:27.000000002 +0100 ./Beb.c diff --git a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h b/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h index 2254b38c9..7181daf9c 100644 --- a/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h +++ b/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "dfad145e1492e961c95063aa5b2f54e5e1b418a0" +#define GITREPUUID "92fc837eb490650d91c2283943cbd729b2e36567" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4127 -#define GITDATE 0x20181023 +#define GITREV 0x4131 +#define GITDATE 0x20181029 #define GITBRANCH "refactor" diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index d03c23f3d..f145a556e 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -306,10 +306,10 @@ void initControlServer() { if (Feb_Control_OpenSerialCommunication()) ;// Feb_Control_CloseSerialCommunication(); } - FILE_LOG(logDEBUG5, ("Control server: FEB Initialization done\n")); + FILE_LOG(logDEBUG1, ("Control server: FEB Initialization done\n")); Beb_Beb(detid); Beb_SetDetectorNumber(getDetectorNumber()); - FILE_LOG(logDEBUG5, ("Control server: BEB Initialization done\n")); + FILE_LOG(logDEBUG1, ("Control server: BEB Initialization done\n")); setupDetector(); @@ -325,7 +325,7 @@ void initStopServer() { Feb_Interface_FebInterface(); Feb_Control_FebControl(); Feb_Control_Init(master,top,normal,getDetectorNumber()); - FILE_LOG(logDEBUG5, ("Stop server: FEB Initialization done\n")); + FILE_LOG(logDEBUG1, ("Stop server: FEB Initialization done\n")); #endif } @@ -385,10 +385,10 @@ void allocateDetectorStructureMemory() { detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); detectorDacs=malloc(NDAC*sizeof(int)); detectorAdcs=malloc(NADC*sizeof(int)); - FILE_LOG(logDEBUG5, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); - FILE_LOG(logDEBUG5, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); - FILE_LOG(logDEBUG5, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); - FILE_LOG(logDEBUG5, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); + FILE_LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); + FILE_LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); + FILE_LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); + FILE_LOG(logDEBUG1, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); (detectorModules)->dacs=detectorDacs; (detectorModules)->adcs=detectorAdcs; (detectorModules)->chanregs=detectorChans; @@ -455,7 +455,7 @@ void setupDetector() { #ifndef VIRTUAL Feb_Control_CheckSetup(); #endif - FILE_LOG(logDEBUG5, ("Setup detector done\n\n")); + FILE_LOG(logDEBUG1, ("Setup detector done\n\n")); } @@ -491,7 +491,7 @@ int setDynamicRange(int dr) { return eiger_dynamicrange; #else if (dr > 0) { - FILE_LOG(logDEBUG5, ("Setting dynamic range: %d\n", dr)); + FILE_LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr)); if (Feb_Control_SetDynamicRange(dr)) { //EigerSetBitMode(dr); @@ -518,7 +518,7 @@ int setDynamicRange(int dr) { enum speedVariable setSpeed(int val) { if (val != -1) { - FILE_LOG(logDEBUG5, ("Setting Read out Speed: %d\n", val)); + FILE_LOG(logDEBUG1, ("Setting Read out Speed: %d\n", val)); #ifndef VIRTUAL if (Feb_Control_SetReadoutSpeed(val)) #endif @@ -538,15 +538,15 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) { switch(val) { case PARALLEL: val=E_PARALLEL; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Parallel\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Parallel\n")); break; case NONPARALLEL: val=E_NON_PARALLEL; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Non Parallel\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Non Parallel\n")); break; case SAFE: val=E_SAFE; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Safe\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Safe\n")); break; default: @@ -567,11 +567,11 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) { switch(val) { case SHOW_OVERFLOW: val=1; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Overflow in 32 bit mode\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Overflow in 32 bit mode\n")); break; case NOOVERFLOW: val=0; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: No overflow in 32 bit mode\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: No overflow in 32 bit mode\n")); break; default: FILE_LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", val)); @@ -591,11 +591,11 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) { switch(val) { case STORE_IN_RAM: val=1; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Store in Ram\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Store in Ram\n")); break; case CONTINOUS_RO: val=0; - FILE_LOG(logDEBUG5, ("Setting Read out Flag: Continuous Readout\n")); + FILE_LOG(logDEBUG1, ("Setting Read out Flag: Continuous Readout\n")); break; default: @@ -638,7 +638,7 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) { break; } - FILE_LOG(logDEBUG5, ("Read out Flag: 0x%x\n", retval)); + FILE_LOG(logDEBUG1, ("Read out Flag: 0x%x\n", retval)); return retval; } @@ -659,7 +659,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { switch(ind) { case FRAME_NUMBER: if (val >= 0) { - FILE_LOG(logDEBUG5, ("Setting number of frames: %d * %d\n", (unsigned int)val, eiger_ncycles)); + FILE_LOG(logDEBUG1, ("Setting number of frames: %d * %d\n", (unsigned int)val, eiger_ncycles)); #ifndef VIRTUAL if (Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)) { eiger_nexposures = val; @@ -678,7 +678,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { case ACQUISITION_TIME: if (val >= 0) { - FILE_LOG(logDEBUG5, ("Setting exp time: %fs\n", val/(1E9))); + FILE_LOG(logDEBUG1, ("Setting exp time: %fs\n", val/(1E9))); #ifndef VIRTUAL Feb_Control_SetExposureTime(val/(1E9)); #else @@ -693,7 +693,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { case SUBFRAME_ACQUISITION_TIME: if (val >= 0) { - FILE_LOG(logDEBUG5, ("Setting sub exp time: %lldns\n", (long long int)val)); + FILE_LOG(logDEBUG1, ("Setting sub exp time: %lldns\n", (long long int)val)); #ifndef VIRTUAL // calculate subdeadtime before settings subexptime subdeadtime = Feb_Control_GetSubFramePeriod() - @@ -743,7 +743,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { case FRAME_PERIOD: if (val >= 0) { - FILE_LOG(logDEBUG5, ("Setting acq period: %fs\n", val/(1E9))); + FILE_LOG(logDEBUG1, ("Setting acq period: %fs\n", val/(1E9))); #ifndef VIRTUAL Feb_Control_SetExposurePeriod(val/(1E9)); #else @@ -758,7 +758,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { case CYCLES_NUMBER: if (val >= 0) { - FILE_LOG(logDEBUG5, ("Setting number of triggers: %d * %d\n", + FILE_LOG(logDEBUG1, ("Setting number of triggers: %d * %d\n", (unsigned int)val,eiger_nexposures)); #ifndef VIRTUAL if (Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)) { @@ -1005,7 +1005,7 @@ int setThresholdEnergy(int ev) { /* parameters - dac, adc, hv */ void setDAC(enum DACINDEX ind, int val, int mV, int retval[]) { - FILE_LOG(logDEBUG5, ("Going to set dac %d to %d with mv mode %d \n", (int)ind, val, mV)); + FILE_LOG(logDEBUG1, ("Going to set dac %d to %d with mv mode %d \n", (int)ind, val, mV)); if (ind == VTHRESHOLD) { int ret[5]; setDAC(VCMP_LL,val,mV,retval); @@ -1040,7 +1040,7 @@ void setDAC(enum DACINDEX ind, int val, int mV, int retval[]) { FILE_LOG(logINFO, ("dac value outside range:%d\n",(int)ind)); strcpy(iname,dac_names[0]); } - FILE_LOG(logDEBUG5, ("%s dac %d: %s to %d %s\n", + FILE_LOG(logDEBUG1, ("%s dac %d: %s to %d %s\n", (val >= 0) ? "Setting" : "Getting", ind, iname, val, mV ? "mV" : "dac units")); @@ -1166,7 +1166,7 @@ void setTiming( enum externalCommunicationMode arg) { case BURST_TRIGGER: ret = 1; break; case GATE_FIX_NUMBER: ret = 3; break; } - FILE_LOG(logDEBUG5, ("Setting Triggering Mode: %d\n", (int)ret)); + FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret)); #ifndef VIRTUAL if (Feb_Control_SetTriggerMode(ret,1)) #endif @@ -1216,10 +1216,10 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t FILE_LOG(logINFO, ("src_port:%d\n" - "src_ip:%s\n" - "dst_ip:%s\n" - "src_mac:%s\n" - "dst_mac:%s\n", + "\tsrc_ip:%s\n" + "\tdst_ip:%s\n" + "\tsrc_mac:%s\n" + "\tdst_mac:%s\n", src_port, src_ip, dst_ip, src_mac, dst_mac)); @@ -1229,7 +1229,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t if (!top) dst_port = udpport2; - FILE_LOG(logINFO, ("dst_port:%d\n", dst_port)); + FILE_LOG(logINFO, ("\tdst_port:%d\n", dst_port)); int i=0; /* for(i=0;i<32;i++) { modified for Aldo*/ @@ -1282,7 +1282,7 @@ int setDetectorPosition(int pos[]) { int setIODelay(int val) { if (val!=-1) { - FILE_LOG(logDEBUG5, ("Setting IO Delay: %d\n",val)); + FILE_LOG(logDEBUG1, ("Setting IO Delay: %d\n",val)); #ifndef VIRTUAL if (Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val)) #endif @@ -1788,7 +1788,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { int idac, ichan, iadc; int ret=OK; - FILE_LOG(logDEBUG5, ("Copying module %x to module %x\n",srcMod,destMod)); + FILE_LOG(logDEBUG1, ("Copying module %x to module %x\n",srcMod,destMod)); if (srcMod->serialnumber>=0) { @@ -1808,9 +1808,9 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { return FAIL; } - FILE_LOG(logDEBUG5, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac)); - FILE_LOG(logDEBUG5, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc)); - FILE_LOG(logDEBUG5, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan)); + FILE_LOG(logDEBUG1, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac)); + FILE_LOG(logDEBUG1, ("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc)); + FILE_LOG(logDEBUG1, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan)); destMod->ndac=srcMod->ndac; destMod->nadc=srcMod->nadc; destMod->nchip=srcMod->nchip; @@ -1823,7 +1823,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { destMod->tau=srcMod->tau; if (srcMod->eV>=0) destMod->eV=srcMod->eV; - FILE_LOG(logDEBUG5, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg )); + FILE_LOG(logDEBUG1, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg )); if (destMod->nchan!=0) { for (ichan=0; ichan<(srcMod->nchan); ichan++) { diff --git a/slsDetectorServers/slsDetectorServer/communication_funcs.c b/slsDetectorServers/slsDetectorServer/communication_funcs.c index ed9e79d6d..ea89d2747 100755 --- a/slsDetectorServers/slsDetectorServer/communication_funcs.c +++ b/slsDetectorServers/slsDetectorServer/communication_funcs.c @@ -95,7 +95,7 @@ int bindSocket(unsigned short int port_number) { // success myport = port_number; ret = OK; - FILE_LOG(logDEBUG5, ("%s socket bound: isock=%d, port=%d, fd=%d\n", + FILE_LOG(logDEBUG1, ("%s socket bound: isock=%d, port=%d, fd=%d\n", (isControlServer ? "Control":"Stop"), isock, port_number, socketDescriptor)); } @@ -136,7 +136,7 @@ int acceptConnection(int socketDescriptor) { // timeout if (result == 0) { - FILE_LOG(logDEBUG5, ("%s socket select() timed out!\n", + FILE_LOG(logDEBUG1, ("%s socket select() timed out!\n", (isControlServer ? "control":"stop"), myport)); } @@ -148,14 +148,14 @@ int acceptConnection(int socketDescriptor) { // activity in descriptor set else if (result > 0) { - FILE_LOG(logDEBUG5, ("%s select returned!\n", (isControlServer ? "control":"stop"))); + FILE_LOG(logDEBUG1, ("%s select returned!\n", (isControlServer ? "control":"stop"))); // loop through the file descriptor set for (j = 0; j < maxfd + 1; ++j) { // checks if file descriptor part of set if (FD_ISSET(j, &tempset)) { - FILE_LOG(logDEBUG5, ("fd %d is set\n",j)); + FILE_LOG(logDEBUG1, ("fd %d is set\n",j)); // clear the temporary set FD_CLR(j, &tempset); @@ -216,7 +216,7 @@ int acceptConnection(int socketDescriptor) { // accept success else { inet_ntop(AF_INET, &(addressC.sin_addr), dummyClientIP, INET_ADDRSTRLEN); - FILE_LOG(logDEBUG5, ("%s socket accepted connection, fd= %d\n", + FILE_LOG(logDEBUG1, ("%s socket accepted connection, fd= %d\n", (isControlServer ? "control":"stop"), file_des)); // add the file descriptor from accept FD_SET(file_des, &readset); @@ -244,7 +244,7 @@ void closeConnection(int file_des) { void exitServer(int socketDescriptor) { if (socketDescriptor >= 0) close(socketDescriptor); - FILE_LOG(logDEBUG5, ("Closing %s server\n", (isControlServer ? "control":"stop"))); + FILE_LOG(logDEBUG1, ("Closing %s server\n", (isControlServer ? "control":"stop"))); FD_CLR(socketDescriptor, &readset); isock--; } @@ -320,7 +320,7 @@ int receiveDataOnly(int file_des, void* buf,int length) { int nreceiving; int nreceived; if (file_des<0) return -1; - FILE_LOG(logDEBUG5, ("want to receive %d Bytes to %s server\n", + FILE_LOG(logDEBUG1, ("want to receive %d Bytes to %s server\n", length, (isControlServer ? "control":"stop"))); while(length > 0) { @@ -381,7 +381,7 @@ int sendModule(int file_des, sls_detector_module *myMod) { n = sendData(file_des,myMod->chanregs, sizeof(int) * (myMod->nchan), INT32); if (!n) return -1; ts += n; #endif - FILE_LOG(logDEBUG5, ("module of size %d sent register %x\n", ts, myMod->reg)); + FILE_LOG(logDEBUG1, ("module of size %d sent register %x\n", ts, myMod->reg)); return ts; } @@ -439,7 +439,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) { n = receiveData(file_des,&(myMod->chanregs), sizeof(int) * (myMod->nchan), INT32); if (!n) return -1; ts += n; #endif - FILE_LOG(logDEBUG5, ("received module of size %d register %x\n",ts,myMod->reg)); + FILE_LOG(logDEBUG1, ("received module of size %d register %x\n",ts,myMod->reg)); return ts; } diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c index ef85d11b5..3dd67b651 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer.c @@ -72,7 +72,7 @@ int main(int argc, char *argv[]){ for (i = 0; i < argc; ++i) sprintf(cmd, "%s %s", cmd, argv[i]); sprintf(cmd,"%s -stopserver&", cmd); - FILE_LOG(logDEBUG5, ("Command to start stop server:%s\n", cmd)); + FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd)); system(cmd); } #endif diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 207b5add6..5b092ce80 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -84,11 +84,11 @@ int decode_function(int file_des) { int n = receiveData(file_des,&fnum,sizeof(fnum),INT32); if (n <= 0) { - FILE_LOG(logDEBUG5, ("ERROR reading from socket n=%d, fnum=%d, file_des=%d, fname=%s\n", + FILE_LOG(logDEBUG3, ("ERROR reading from socket n=%d, fnum=%d, file_des=%d, fname=%s\n", n, fnum, file_des, getFunctionName((enum detFuncs)fnum))); return FAIL; } else - FILE_LOG(logDEBUG5, ("Received %d bytes\n", n )); + FILE_LOG(logDEBUG3, ("Received %d bytes\n", n )); // jungfrau in programming mode #ifdef JUNGFRAUD @@ -106,14 +106,15 @@ int decode_function(int file_des) { FILE_LOG(logERROR, ("Unknown function enum %d\n", fnum)); ret=(M_nofunc)(file_des); } else { - FILE_LOG(logDEBUG5, (" calling function fnum=%d, (%s)\n", + FILE_LOG(logDEBUG1, (" calling function fnum=%d, (%s)\n", fnum, getFunctionName((enum detFuncs)fnum))); ret = (*flist[fnum])(file_des); if (ret == FAIL) { - FILE_LOG(logDEBUG5, ("Error executing the function = %d (%s)\n", + FILE_LOG(logDEBUG1, ("Error executing the function = %d (%s)\n", fnum, getFunctionName((enum detFuncs)fnum))); - } + } else FILE_LOG(logDEBUG1, ("Function (%s) executed ok\n", + getFunctionName((enum detFuncs)fnum))); } return ret; } @@ -252,7 +253,7 @@ void function_table() { int iloop = 0; for (iloop = 0; iloop < NUM_DET_FUNCTIONS ; ++iloop) { - FILE_LOG(logDEBUG5, ("function fnum=%d, (%s) located at 0x%x\n", iloop, + FILE_LOG(logDEBUG1, ("function fnum=%d, (%s) located at 0x%x\n", iloop, getFunctionName((enum detFuncs)iloop), (unsigned int)flist[iloop])); } } @@ -373,7 +374,7 @@ int get_detector_type(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); enum detectorType retval = myDetectorType; - FILE_LOG(logDEBUG5,("Returning detector type %d\n", retval)); + FILE_LOG(logDEBUG1,("Returning detector type %d\n", retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -392,7 +393,7 @@ int set_external_signal_flag(int file_des) { int signalindex = args[0]; enum externalSignalFlag flag = args[1]; - FILE_LOG(logDEBUG5, ("Setting external signal %d to flag %d\n", signalindex, flag)); + FILE_LOG(logDEBUG1, ("Setting external signal %d to flag %d\n", signalindex, flag)); #ifndef GOTTHARDD functionNotImplemented(); @@ -404,7 +405,7 @@ int set_external_signal_flag(int file_des) { // get retval = getExtSignal(signalindex); validate((int)flag, (int)retval, "set external signal flag", 1); - FILE_LOG(logDEBUG5, ("External Signal Flag: %d\n", retval)); + FILE_LOG(logDEBUG1, ("External Signal Flag: %d\n", retval)); } #endif return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -421,7 +422,7 @@ int set_external_communication_mode(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting external communication mode to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg)); // set if ((arg != GET_EXTERNAL_COMMUNICATION_MODE) && (Server_VerifyLock() == OK)) { @@ -442,7 +443,7 @@ int set_external_communication_mode(int file_des) { // get retval = getTiming(); validate((int)arg, (int)retval, "set timing mode", 0); - FILE_LOG(logDEBUG5, ("Timing Mode: %d\n",retval)); + FILE_LOG(logDEBUG1, ("Timing Mode: %d\n",retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -457,7 +458,7 @@ int get_id(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Getting Id %d\n", arg)); + FILE_LOG(logDEBUG1, ("Getting Id %d\n", arg)); // get switch (arg) { @@ -468,7 +469,7 @@ int get_id(int file_des) { case DETECTOR_FIRMWARE_VERSION: case DETECTOR_SOFTWARE_VERSION: retval = getDetectorId(arg); - FILE_LOG(logDEBUG5, ("Id(%d): %lld\n", retval)); + FILE_LOG(logDEBUG1, ("Id(%d): %lld\n", retval)); break; default: modeNotImplemented("ID Index", (int)arg); @@ -492,9 +493,9 @@ int digital_test(int file_des) { enum digitalTestMode mode = args[0]; #ifdef GOTTHARDD int ival = args[1]; - FILE_LOG(logDEBUG5, ("Digital test, mode = %d, ival:%d\n", mode, ival)); + FILE_LOG(logDEBUG1, ("Digital test, mode = %d, ival:%d\n", mode, ival)); #else - FILE_LOG(logDEBUG5, ("Digital test, mode = %d\n", mode)); + FILE_LOG(logDEBUG1, ("Digital test, mode = %d\n", mode)); #endif #ifdef EIGERD @@ -505,7 +506,7 @@ int digital_test(int file_des) { switch (mode) { #ifdef GOTTHARDD case DIGITAL_BIT_TEST: - FILE_LOG(logDEBUG5, ("Setting digital test bit: %d\n", ival)); + FILE_LOG(logDEBUG1, ("Setting digital test bit: %d\n", ival)); if (ival >= 0) digitalTestBit = (ival > 0) ? 1 : 0; retval = digitalTestBit; @@ -514,7 +515,7 @@ int digital_test(int file_des) { case DETECTOR_FIRMWARE_TEST: case DETECTOR_BUS_TEST: retval = detectorTest(mode); - FILE_LOG(logDEBUG5, ("Digital Test (%d): %d\n", mode, retval)); + FILE_LOG(logDEBUG1, ("Digital Test (%d): %d\n", mode, retval)); break; default: modeNotImplemented("Digital Test Mode", (int)mode); @@ -630,7 +631,7 @@ int set_dac(int file_des) { // index exists if (ret == OK) { - FILE_LOG(logDEBUG5, ("Setting DAC %d to %d %s\n", serverDacIndex, val, + FILE_LOG(logDEBUG1, ("Setting DAC %d to %d %s\n", serverDacIndex, val, (mV ? "mV" : "dac units"))); // set & get @@ -641,7 +642,7 @@ int set_dac(int file_des) { #ifdef EIGERD case IO_DELAY: retval[0] = setIODelay(val); - FILE_LOG(logDEBUG5, ("IODelay: %d\n", retval[0])); + FILE_LOG(logDEBUG1, ("IODelay: %d\n", retval[0])); break; #endif @@ -649,7 +650,7 @@ int set_dac(int file_des) { case HV_POT: case HV_NEW: retval[0] = setHighVoltage(val); - FILE_LOG(logDEBUG5, ("High Voltage: %d\n", retval[0])); + FILE_LOG(logDEBUG1, ("High Voltage: %d\n", retval[0])); #ifdef EIGERD if ((retval[0] != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval[0] < 0)) { ret = FAIL; @@ -704,7 +705,7 @@ int set_dac(int file_des) { FILE_LOG(logERROR,(mess)); } } - FILE_LOG(logDEBUG5, ("Dac (%d): %d dac units and %d mV\n", serverDacIndex, retval[0], retval[1])); + FILE_LOG(logDEBUG1, ("Dac (%d): %d dac units and %d mV\n", serverDacIndex, retval[0], retval[1])); break; } } @@ -769,9 +770,9 @@ int get_adc(int file_des) { // valid index if (ret == OK) { - FILE_LOG(logDEBUG5, ("Getting ADC %d\n", serverAdcIndex)); + FILE_LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex)); retval = getADC(serverAdcIndex); - FILE_LOG(logDEBUG5, ("ADC(%d): %d\n", retval)); + FILE_LOG(logDEBUG1, ("ADC(%d): %d\n", retval)); } return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -790,7 +791,7 @@ int write_register(int file_des) { return printSocketReadError(); uint32_t addr = args[0]; uint32_t val = args[1]; - FILE_LOG(logDEBUG5, ("Writing to register 0x%x, data 0x%x\n", addr, val)); + FILE_LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val)); // only set if (Server_VerifyLock() == OK) { @@ -801,7 +802,7 @@ int write_register(int file_des) { sprintf(mess,"Could not write to register 0x%x. Wrote 0x%x but read 0x%x\n", addr, val, retval); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Write register (0x%x): 0x%x\n", retval)); + FILE_LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval)); } return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -819,11 +820,11 @@ int read_register(int file_des) { if (receiveData(file_des, &addr, sizeof(addr), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Reading from register 0x%x\n", addr)); + FILE_LOG(logDEBUG1, ("Reading from register 0x%x\n", addr)); // get retval = readRegister(addr); - FILE_LOG(logDEBUG5, ("Read register (0x%x): 0x%x\n", retval)); + FILE_LOG(logDEBUG1, ("Read register (0x%x): 0x%x\n", retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -892,7 +893,7 @@ int set_module(int file_des) { if (myAdc != NULL) free(myAdc); return printSocketReadError(); } - FILE_LOG(logDEBUG5, ("module register is %d, nchan %d, nchip %d, " + FILE_LOG(logDEBUG1, ("module register is %d, nchan %d, nchip %d, " "ndac %d, nadc %d, iodelay %d, tau %d, eV %d\n", module.reg, module.nchan, module.nchip, module.ndac, module.nadc, module.iodelay, module.tau, module.eV)); @@ -944,7 +945,7 @@ int set_module(int file_des) { ret = setModule(module, mess); retval = getSettings(); validate(module.reg, (int)retval, "set module (settings)", 0); - FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Settings: %d\n", retval)); } if (myChan != NULL) free(myChan); if (myDac != NULL) free(myDac); @@ -1010,9 +1011,9 @@ int get_module(int file_des) { module.nadc = getNumberOfADCs(); // only get - FILE_LOG(logDEBUG5, ("Getting module\n")); + FILE_LOG(logDEBUG1, ("Getting module\n")); getModule(&module); - FILE_LOG(logDEBUG5, ("Getting module. Settings:%d\n", module.reg)); + FILE_LOG(logDEBUG1, ("Getting module. Settings:%d\n", module.reg)); } Server_SendResult(file_des, INT32, 1, NULL, 0); @@ -1040,7 +1041,7 @@ int set_settings(int file_des) { if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting settings %d\n", isett)); + FILE_LOG(logDEBUG1, ("Setting settings %d\n", isett)); //set & get if ((isett == GET_SETTINGS) || ((isett != GET_SETTINGS) && (Server_VerifyLock() == OK))) { @@ -1076,7 +1077,7 @@ int set_settings(int file_des) { // if index is okay, set & get if (ret == OK) { retval = setSettings(isett); - FILE_LOG(logDEBUG5, ("Settings: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Settings: %d\n", retval)); validate((int)isett, (int)retval, "set settings", 0); #if defined(JUNGFRAUD) || defined (GOTTHARDD) if (ret == OK && isett >= 0) { @@ -1101,13 +1102,13 @@ int get_threshold_energy(int file_des) { memset(mess, 0, sizeof(mess)); int retval = -1; - FILE_LOG(logDEBUG5, ("Getting Threshold energy\n")); + FILE_LOG(logDEBUG1, ("Getting Threshold energy\n")); #ifndef EIGERD functionNotImplemented(); #else // only get retval = getThresholdEnergy(); - FILE_LOG(logDEBUG5, ("Threshold energy: %d eV\n", retval)); + FILE_LOG(logDEBUG1, ("Threshold energy: %d eV\n", retval)); #endif return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1121,7 +1122,7 @@ int start_acquisition(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Starting Acquisition\n")); + FILE_LOG(logDEBUG1, ("Starting Acquisition\n")); // only set if (Server_VerifyLock() == OK) { ret = startStateMachine(); @@ -1129,7 +1130,7 @@ int start_acquisition(int file_des) { sprintf(mess, "Could not start acquisition\n"); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Starting Acquisition ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Starting Acquisition ret: %d\n", ret)); } return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -1140,7 +1141,7 @@ int stop_acquisition(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); + FILE_LOG(logDEBUG1, ("Stopping Acquisition\n")); // only set if (Server_VerifyLock() == OK) { ret = stopStateMachine(); @@ -1148,7 +1149,7 @@ int stop_acquisition(int file_des) { sprintf(mess, "Could not stop acquisition\n"); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Stopping Acquisition ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret)); } return Server_SendResult(file_des, INT32, 1, NULL, 0); } @@ -1161,7 +1162,7 @@ int start_readout(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Starting readout\n")); + FILE_LOG(logDEBUG1, ("Starting readout\n")); #ifdef JUNGFRAUD functionNotImplemented(); #else @@ -1172,7 +1173,7 @@ int start_readout(int file_des) { sprintf(mess, "Could not start readout\n"); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Starting readout ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Starting readout ret: %d\n", ret)); } #endif return Server_SendResult(file_des, INT32, 1, NULL, 0); @@ -1188,10 +1189,10 @@ int get_run_status(int file_des) { memset(mess, 0, sizeof(mess)); enum runStatus retval = ERROR; - FILE_LOG(logDEBUG5, ("Getting status\n")); + FILE_LOG(logDEBUG1, ("Getting status\n")); // only get retval = getRunStatus(); - FILE_LOG(logDEBUG5, ("Status: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Status: %d\n", retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); } @@ -1203,9 +1204,9 @@ int start_and_read_all(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Starting Acquisition and read all frames\n")); + FILE_LOG(logDEBUG1, ("Starting Acquisition and read all frames\n")); // start state machine - FILE_LOG(logDEBUG5, ("Stopping Acquisition\n")); + FILE_LOG(logDEBUG1, ("Stopping Acquisition\n")); // only set if (Server_VerifyLock() == OK) { ret = startStateMachine(); @@ -1213,7 +1214,7 @@ int start_and_read_all(int file_des) { sprintf(mess, "Could not start acquisition\n"); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Starting Acquisition ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Starting Acquisition ret: %d\n", ret)); } @@ -1232,7 +1233,7 @@ int read_all(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Reading all frames\n")); + FILE_LOG(logDEBUG1, ("Reading all frames\n")); // only set if (Server_VerifyLock() == OK) { readFrame(&ret, mess); @@ -1258,7 +1259,7 @@ int set_timer(int file_des) { #ifdef EIGERD int64_t subexptime = 0; #endif - FILE_LOG(logDEBUG5, ("Setting timer index %d to %lld ns\n", ind, tns)); + FILE_LOG(logDEBUG1, ("Setting timer index %d to %lld ns\n", ind, tns)); // set & get if ((tns == -1) || ((tns != -1) && (Server_VerifyLock() == OK))) { @@ -1318,7 +1319,7 @@ int set_timer(int file_des) { validate64(tns, retval, "set timer", 0); } if (ret != FAIL) { - FILE_LOG(logDEBUG5, ("Timer index %d: %lld\n", ind, retval)); + FILE_LOG(logDEBUG1, ("Timer index %d: %lld\n", ind, retval)); } return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -1337,7 +1338,7 @@ int get_time_left(int file_des) { if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Getting timer left index %d\n", ind)); + FILE_LOG(logDEBUG1, ("Getting timer left index %d\n", ind)); // only get // check index @@ -1362,7 +1363,7 @@ int get_time_left(int file_des) { case MEASUREMENT_TIME: #endif retval = getTimeLeft(ind); - FILE_LOG(logDEBUG5, ("Timer left index %d: %lld\n", ind, retval)); + FILE_LOG(logDEBUG1, ("Timer left index %d: %lld\n", ind, retval)); break; #ifdef JUNGFRAUD case DELAY_AFTER_TRIGGER: @@ -1392,7 +1393,7 @@ int set_dynamic_range(int file_des) { if (receiveData(file_des, &dr, sizeof(dr), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting dr to %d\n", dr)); + FILE_LOG(logDEBUG1, ("Setting dr to %d\n", dr)); // set & get if ((dr == -1) || ((dr != -1) && (Server_VerifyLock() == OK))) { @@ -1408,7 +1409,7 @@ int set_dynamic_range(int file_des) { case 4: case 8: case 32: #endif retval = setDynamicRange(dr); - FILE_LOG(logDEBUG5, ("Dynamic range: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Dynamic range: %d\n", retval)); validate(dr, retval, "set dynamic range", 0); if (dr >= 0) dataBytes=calculateDataBytes(); @@ -1457,7 +1458,7 @@ int set_readout_flags(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting readout flags to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting readout flags to %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -1474,8 +1475,8 @@ int set_readout_flags(int file_des) { case SHOW_OVERFLOW: case NOOVERFLOW: retval = setReadOutFlags(arg); - FILE_LOG(logDEBUG5, ("Read out flags: %d\n", retval)); - validate((int)arg, (int)retval, "set readout flag", 0); + FILE_LOG(logDEBUG1, ("Read out flags: 0x%x\n", retval)); + validate((int)arg, (int)(retval & arg), "set readout flag", 1); break; default: modeNotImplemented("Read out flag index", (int)arg); @@ -1516,11 +1517,11 @@ int set_roi(int file_des) { return printSocketReadError(); } } - FILE_LOG(logDEBUG5, ("Set ROI (narg:%d)\n", narg)); + FILE_LOG(logDEBUG1, ("Set ROI (narg:%d)\n", narg)); { int iloop = 0; for (iloop = 0; iloop < narg; ++iloop) { - FILE_LOG(logDEBUG5, ("%d: %d\t%d\t%d\t%d\n", + FILE_LOG(logDEBUG1, ("%d: %d\t%d\t%d\t%d\n", arg[iloop].xmin, arg[iloop].xmax, arg[iloop].ymin, arg[iloop].ymax)); } } @@ -1536,7 +1537,7 @@ int set_roi(int file_des) { "Set %d rois, but read %d rois\n", narg, nretval); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("nRois: %d\n", nretval)); + FILE_LOG(logDEBUG1, ("nRois: %d\n", nretval)); } #endif @@ -1571,7 +1572,7 @@ int set_speed(int file_des) { return printSocketReadError(); enum speedVariable ind = args[0]; int val = args[1]; - FILE_LOG(logDEBUG5, ("Setting speed index %d to %d\n", ind, val)); + FILE_LOG(logDEBUG1, ("Setting speed index %d to %d\n", ind, val)); // set & get if ((val == -1) || ((val != -1) && (Server_VerifyLock() == OK))) { @@ -1580,7 +1581,7 @@ int set_speed(int file_des) { #ifdef JUNGFRAUD case ADC_PHASE: retval = adcPhase(val); - FILE_LOG(logDEBUG5, ("ADc Phase: %d\n", retval)); + FILE_LOG(logDEBUG1, ("ADc Phase: %d\n", retval)); if (val != 100000) { validate(val, retval, "set adc phase ", 0); } @@ -1588,7 +1589,7 @@ int set_speed(int file_des) { #endif case CLOCK_DIVIDER: retval = setSpeed(val); - FILE_LOG(logDEBUG5, ("Clock: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Clock: %d\n", retval)); validate(val, retval, "set clock ", 0); break; default: @@ -1622,7 +1623,7 @@ int lock_server(int file_des) { if (receiveData(file_des, &lock, sizeof(lock), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Locking Server to %d\n", lock)); + FILE_LOG(logDEBUG1, ("Locking Server to %d\n", lock)); // set if (lock >= 0) { @@ -1787,13 +1788,13 @@ int configure_mac(int file_des) { if (receiveData(file_des, args, sizeof(args), OTHER) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("\n Configuring UDP Destination\n")); + FILE_LOG(logDEBUG1, ("\n Configuring UDP Destination\n")); #ifdef GOTTHARDD - FILE_LOG(logDEBUG5, ("Digital Test Bit %d\t", digitalTestBit); + FILE_LOG(logDEBUG1, ("Digital Test Bit %d\t", digitalTestBit); #endif uint32_t dstIp = 0; sscanf(args[0], "%x", &dstIp); - FILE_LOG(logDEBUG5, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n", + FILE_LOG(logDEBUG1, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n", (dstIp >> 24) & 0xff, (dstIp >> 16) & 0xff, (dstIp >> 8) & 0xff, (dstIp) & 0xff, dstIp)); uint64_t dstMac = 0; @@ -1802,43 +1803,43 @@ int configure_mac(int file_des) { #else sscanf(args[1], "%llx", &dstMac); #endif - FILE_LOG(logDEBUG5, ("Dst Mac Addr: (0x) ")); + FILE_LOG(logDEBUG1, ("Dst Mac Addr: (0x) ")); { int iloop = 5; for (iloop = 5; iloop >= 0; --iloop) { - FILE_LOG(logDEBUG5, ("%x", (unsigned int)(((dstMac >> (8 * iloop)) & 0xFF)))); + FILE_LOG(logDEBUG1, ("%x", (unsigned int)(((dstMac >> (8 * iloop)) & 0xFF)))); if (iloop > 0) { - FILE_LOG(logDEBUG5, (":")); + FILE_LOG(logDEBUG1, (":")); } } } - FILE_LOG(logDEBUG5, (" = %llx\n", dstMac)); + FILE_LOG(logDEBUG1, (" = %llx\n", dstMac)); uint32_t dstPort = 0; sscanf(args[2], "%x", &dstPort); - FILE_LOG(logDEBUG5, ("Dst Port: %x\n", dstPort)); + FILE_LOG(logDEBUG1, ("Dst Port: %x\n", dstPort)); uint32_t dstPort2 = 0; sscanf(args[5], "%x", &dstPort2); - FILE_LOG(logDEBUG5, ("Dst Port2: %x\n", dstPort2)); + FILE_LOG(logDEBUG1, ("Dst Port2: %x\n", dstPort2)); uint64_t srcMac = 0; #ifdef VIRTUAL sscanf(args[3], "%lx", &srcMac); #else sscanf(args[3], "%llx", &srcMac); #endif - FILE_LOG(logDEBUG5, ("Src Mac Addr: (0x) ")); + FILE_LOG(logDEBUG1, ("Src Mac Addr: (0x) ")); { int iloop = 5; for (iloop = 5; iloop >= 0; --iloop) { - FILE_LOG(logDEBUG5, ("%x", (unsigned int)(((srcMac >> (8 * iloop)) & 0xFF)))); + FILE_LOG(logDEBUG1, ("%x", (unsigned int)(((srcMac >> (8 * iloop)) & 0xFF)))); if (iloop > 0) { - FILE_LOG(logDEBUG5, (":")); + FILE_LOG(logDEBUG1, (":")); } } } - FILE_LOG(logDEBUG5, (" = %llx\n", srcMac)); + FILE_LOG(logDEBUG1, (" = %llx\n", srcMac)); uint32_t srcIp = 0; sscanf(args[4], "%x", &srcIp); - FILE_LOG(logDEBUG5, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n", + FILE_LOG(logDEBUG1, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n", (srcIp >> 24) & 0xff, (srcIp >> 16) & 0xff, (srcIp >> 8) & 0xff, (srcIp) & 0xff, srcIp)); #if defined(JUNGFRAUD) || defined(EIGERD) @@ -1846,7 +1847,7 @@ int configure_mac(int file_des) { sscanf(args[6], "%x", &pos[0]); sscanf(args[7], "%x", &pos[1]); sscanf(args[8], "%x", &pos[2]); - FILE_LOG(logDEBUG5, ("Position: [%d, %d, %d]\n", pos[0], pos[1], pos[2])); + FILE_LOG(logDEBUG1, ("Position: [%d, %d, %d]\n", pos[0], pos[1], pos[2])); #endif // set only @@ -1863,12 +1864,12 @@ int configure_mac(int file_des) { #ifdef EIGERD // change mac to hardware mac if (srcMac != getDetectorMAC()) { - FILE_LOG(logERROR, ("actual detector mac address %llx does not match " + FILE_LOG(logWARNING, ("actual detector mac address %llx does not match " "the one from client %llx\n", (long long unsigned int)getDetectorMAC(), (long long unsigned int)srcMac)); srcMac = getDetectorMAC(); - FILE_LOG(logERROR,("matched detectormac to the hardware mac now\n")); + FILE_LOG(logWARNING,("matched detectormac to the hardware mac now\n")); } // always remember the ip sent from the client (could be for 10g(if not dhcp)) @@ -1877,7 +1878,7 @@ int configure_mac(int file_des) { //only for 1Gbe, change ip to hardware ip if (!enableTenGigabitEthernet(-1)) { - FILE_LOG(logERROR, ("using DHCP IP for Configuring MAC\n")); + FILE_LOG(logWARNING, ("Using DHCP IP for Configuring MAC\n")); srcIp = getDetectorIP(); } // 10 gbe (use ip given from client) @@ -1887,11 +1888,11 @@ int configure_mac(int file_des) { #endif #ifdef GOTTHARDD iretval = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2, digitalTestBit); - FILE_LOG(logDEBUG5, ("Configure mac retval: %d\n", iretval)); + FILE_LOG(logDEBUG1, ("Configure mac retval: %d\n", iretval)); FILE_LOG(logINFO, ("Configure MAC successful: %d\n", iretval)); #else iretval = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2); - FILE_LOG(logDEBUG5, ("Configure mac retval: %d\n", iretval)); + FILE_LOG(logDEBUG1, ("Configure mac retval: %d\n", iretval)); if (iretval == -1) { ret = FAIL; @@ -1938,7 +1939,7 @@ int load_image(int file_des) { return printSocketReadError(); } } - FILE_LOG(logDEBUG5, ("Loading %s image (ind:%d)\n", (index == DARK_IMAGE) ? "dark" : + FILE_LOG(logDEBUG1, ("Loading %s image (ind:%d)\n", (index == DARK_IMAGE) ? "dark" : ((index == GAIN_IMAGE) ? "gain" : "unknown"), index)); #ifndef GOTTHARDD @@ -1951,7 +1952,7 @@ int load_image(int file_des) { case DARK_IMAGE : case GAIN_IMAGE : ret = loadImage(index, ImageVals); - FILE_LOG(logDEBUG5, ("Loading image ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Loading image ret: %d\n", ret)); if (ret == FAIL) { sprintf(mess, "Could not load image\n"); FILE_LOG(logERROR,(mess)); @@ -1980,7 +1981,7 @@ int read_counter_block(int file_des) { if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Read counter block with start acq bit: %d\n", startACQ)); + FILE_LOG(logDEBUG1, ("Read counter block with start acq bit: %d\n", startACQ)); #ifndef GOTTHARDD functionNotImplemented(); @@ -2009,7 +2010,7 @@ int reset_counter_block(int file_des) { if (receiveData(file_des, &startACQ, sizeof(startACQ), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Reset counter block with start acq bit: %d\n", startACQ)); + FILE_LOG(logDEBUG1, ("Reset counter block with start acq bit: %d\n", startACQ)); #ifndef GOTTHARDD functionNotImplemented(); @@ -2039,7 +2040,7 @@ int enable_ten_giga(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Enable/ Disable 10GbE : %d\n", arg)); + FILE_LOG(logDEBUG1, ("Enable/ Disable 10GbE : %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -2047,7 +2048,7 @@ int enable_ten_giga(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = enableTenGigabitEthernet(arg); - FILE_LOG(logDEBUG5, ("10GbE: %d\n", retval)); + FILE_LOG(logDEBUG1, ("10GbE: %d\n", retval)); validate(arg, retval, "enable/disable 10GbE", 0); } #endif @@ -2065,7 +2066,7 @@ int set_all_trimbits(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Set all trmbits to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Set all trmbits to %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -2080,7 +2081,7 @@ int set_all_trimbits(int file_des) { } // get retval = getAllTrimbits(); - FILE_LOG(logDEBUG5, ("All trimbits: %d\n", retval)); + FILE_LOG(logDEBUG1, ("All trimbits: %d\n", retval)); validate(arg, retval, "set all trimbits", 0); #endif return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -2108,7 +2109,7 @@ int write_adc_register(int file_des) { return printSocketReadError(); uint32_t addr = args[0]; uint32_t val = args[1]; - FILE_LOG(logDEBUG5, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); + FILE_LOG(logDEBUG1, ("Writing 0x%x to ADC Register 0x%x\n", val, addr)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2131,7 +2132,7 @@ int set_counter_bit(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Set counter bit with value: %d\n", arg)); + FILE_LOG(logDEBUG1, ("Set counter bit with value: %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -2143,7 +2144,7 @@ int set_counter_bit(int file_des) { } // get retval = setCounterBit(-1); - FILE_LOG(logDEBUG5, ("Set counter bit retval: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Set counter bit retval: %d\n", retval)); validate(arg, retval, "set counter bit", 0); #endif return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); @@ -2160,7 +2161,7 @@ int pulse_pixel(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Pulse pixel, n: %d, x: %d, y: %d\n", args[0], args[1], args[2])); + FILE_LOG(logDEBUG1, ("Pulse pixel, n: %d, x: %d, y: %d\n", args[0], args[1], args[2])); #ifndef EIGERD functionNotImplemented(); @@ -2187,7 +2188,7 @@ int pulse_pixel_and_move(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Pulse pixel and move, n: %d, x: %d, y: %d\n", + FILE_LOG(logDEBUG1, ("Pulse pixel and move, n: %d, x: %d, y: %d\n", args[0], args[1], args[2])); #ifndef EIGERD @@ -2217,7 +2218,7 @@ int pulse_chip(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Pulse chip: %d\n", arg)); + FILE_LOG(logDEBUG1, ("Pulse chip: %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -2245,7 +2246,7 @@ int set_rate_correct(int file_des) { if (receiveData(file_des, &tau_ns, sizeof(tau_ns), INT64) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Set rate correct with tau %lld\n", (long long int)tau_ns)); + FILE_LOG(logDEBUG1, ("Set rate correct with tau %lld\n", (long long int)tau_ns)); #ifndef EIGERD functionNotImplemented(); @@ -2288,12 +2289,12 @@ int get_rate_correct(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; - FILE_LOG(logDEBUG5, ("Getting rate correction\n")); + FILE_LOG(logDEBUG1, ("Getting rate correction\n")); #ifndef EIGERD functionNotImplemented(); #else retval = getCurrentTau(); - FILE_LOG(logDEBUG5, ("Tau: %lld\n", (long long int)retval)); + FILE_LOG(logDEBUG1, ("Tau: %lld\n", (long long int)retval)); #endif return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); } @@ -2313,7 +2314,7 @@ int set_network_parameter(int file_des) { enum networkParameter mode = args[0]; int value = args[1]; enum NETWORKINDEX serverIndex = 0; - FILE_LOG(logDEBUG5, ("Set network parameter index %d to %d\n", mode, value)); + FILE_LOG(logDEBUG1, ("Set network parameter index %d to %d\n", mode, value)); #ifdef GOTTHARDD functionNotImplemented(); @@ -2351,7 +2352,7 @@ int set_network_parameter(int file_des) { // valid index if (ret == OK) { retval = setNetworkParameter(serverIndex, value); - FILE_LOG(logDEBUG5, ("Network Parameter index %d: %d\n", serverIndex, retval)); + FILE_LOG(logDEBUG1, ("Network Parameter index %d: %d\n", serverIndex, retval)); validate(value, retval, "set network parameter", 0); } } @@ -2368,7 +2369,7 @@ int program_fpga(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Programming FPGA\n")); + FILE_LOG(logDEBUG1, ("Programming FPGA\n")); #ifndef JUNGFRAUD //to receive any arguments int n = 1; @@ -2404,7 +2405,7 @@ int program_fpga(int file_des) { if (receiveData(file_des,&filesize,sizeof(filesize),INT32) < 0) return printSocketReadError(); totalsize = filesize; - FILE_LOG(logDEBUG5, ("Total program size is: %d\n", totalsize); + FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize); // opening file pointer to flash and telling FPGA to not touch flash if (startWritingFPGAprogram(&fp) != OK) { @@ -2428,7 +2429,7 @@ int program_fpga(int file_des) { unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb if (unitprogramsize > filesize) //less than 2mb unitprogramsize = filesize; - FILE_LOG(logDEBUG5, ("unit size to receive is:%d\n" + FILE_LOG(logDEBUG1, ("unit size to receive is:%d\n" "filesize:%d currentpointer:%d\n", unitprogramsize, filesize, currentPointer)); @@ -2473,7 +2474,7 @@ int program_fpga(int file_des) { if (fp != NULL) fclose(fp); - FILE_LOG(logDEBUG5, ("Done with program receiving command\n")); + FILE_LOG(logDEBUG1, ("Done with program receiving command\n")); if (isControlServer) { basictests(debugflag); @@ -2493,7 +2494,7 @@ int reset_fpga(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Reset FPGA\n")); + FILE_LOG(logDEBUG1, ("Reset FPGA\n")); #ifndef JUNGFRAUD functionNotImplemented(); #else @@ -2521,7 +2522,7 @@ int power_chip(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Powering chip to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Powering chip to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2529,7 +2530,7 @@ int power_chip(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = powerChip(arg); - FILE_LOG(logDEBUG5, ("Power chip: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Power chip: %d\n", retval)); validate(arg, retval, "power on/off chip", 0); // narrow down error when powering on if (ret == FAIL && arg > 0) { @@ -2554,7 +2555,7 @@ int set_activate(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting activate mode to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting activate mode to %d\n", arg)); #ifndef EIGERD functionNotImplemented(); @@ -2562,7 +2563,7 @@ int set_activate(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = activate(arg); - FILE_LOG(logDEBUG5, ("Activate: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Activate: %d\n", retval)); validate(arg, retval, "set activate", 0); } #endif @@ -2576,7 +2577,7 @@ int prepare_acquisition(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Preparing Acquisition\n")); + FILE_LOG(logDEBUG1, ("Preparing Acquisition\n")); #ifndef EIGERD functionNotImplemented(); #else @@ -2604,7 +2605,7 @@ int threshold_temp(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting threshold temperature to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting threshold temperature to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2620,7 +2621,7 @@ int threshold_temp(int file_des) { // valid temp else { retval = setThresholdTemperature(arg); - FILE_LOG(logDEBUG5, ("Threshold temperature: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Threshold temperature: %d\n", retval)); validate(arg, retval, "set threshold temperature", 0); } } @@ -2638,7 +2639,7 @@ int temp_control(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting temperature control to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting temperature control to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2646,7 +2647,7 @@ int temp_control(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = setTemperatureControl(arg); - FILE_LOG(logDEBUG5, ("Temperature control: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Temperature control: %d\n", retval)); validate(arg, retval, "set temperature control", 0); } #endif @@ -2664,7 +2665,7 @@ int temp_event(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting temperature event to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting temperature event to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2672,7 +2673,7 @@ int temp_event(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = setTemperatureEvent(arg); - FILE_LOG(logDEBUG5, ("Temperature event: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Temperature event: %d\n", retval)); validate(arg, retval, "set temperature event", 0); } #endif @@ -2691,7 +2692,7 @@ int auto_comp_disable(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting Auto comp disable to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting Auto comp disable to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2699,7 +2700,7 @@ int auto_comp_disable(int file_des) { // set & get if ((arg == -1) || ((arg != -1) && (Server_VerifyLock() == OK))) { retval = autoCompDisable(arg); - FILE_LOG(logDEBUG5, ("Auto comp disable: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Auto comp disable: %d\n", retval)); validate(arg, retval, "set auto comp disable", 0); } #endif @@ -2718,7 +2719,7 @@ int storage_cell_start(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - FILE_LOG(logDEBUG5, ("Setting Storage cell start to %d\n", arg)); + FILE_LOG(logDEBUG1, ("Setting Storage cell start to %d\n", arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -2731,7 +2732,7 @@ int storage_cell_start(int file_des) { FILE_LOG(logERROR, (mess)); } else { retval = selectStoragecellStart(arg); - FILE_LOG(logDEBUG5, ("Storage cell start: %d\n", retval)); + FILE_LOG(logDEBUG1, ("Storage cell start: %d\n", retval)); validate(arg, retval, "set storage cell start", 0); } #endif @@ -2751,7 +2752,7 @@ int check_version(int file_des) { // check software- firmware compatibility and basic tests if (isControlServer) { - FILE_LOG(logDEBUG5, ("Checking software-firmware compatibility and basic test result\n")); + FILE_LOG(logDEBUG1, ("Checking software-firmware compatibility and basic test result\n")); // check if firmware check is done if (!isFirmwareCheckDone()) { @@ -2775,7 +2776,7 @@ int check_version(int file_des) { } if (ret == OK) { - FILE_LOG(logDEBUG5, ("Checking versioning compatibility with value %d\n",arg)); + FILE_LOG(logDEBUG1, ("Checking versioning compatibility with value %d\n",arg)); int64_t client_requiredVersion = arg; int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION); @@ -2811,7 +2812,7 @@ int software_trigger(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - FILE_LOG(logDEBUG5, ("Software Trigger\n")); + FILE_LOG(logDEBUG1, ("Software Trigger\n")); #ifndef EIGERD functionNotImplemented(); #else @@ -2822,7 +2823,7 @@ int software_trigger(int file_des) { sprintf(mess, "Could not send software trigger\n"); FILE_LOG(logERROR,(mess)); } - FILE_LOG(logDEBUG5, ("Software trigger ret: %d\n", ret)); + FILE_LOG(logDEBUG1, ("Software trigger ret: %d\n", ret)); } #endif return Server_SendResult(file_des, INT32, 1 , NULL, 0); diff --git a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp index 0dc645545..44911ddb4 100644 --- a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp +++ b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp @@ -1,6 +1,7 @@ #include "SharedMemory.h" #include "sls_detector_exceptions.h" #include "ansi.h" +#include "logger.h" #include #include // printf @@ -51,15 +52,13 @@ void* SharedMemory::CreateSharedMemory(size_t sz){ // create fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); if (fd < 0) { - cprintf(RED, "Error: Create shared memory %s failed: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Create shared memory " << name << " failed: " << strerror(errno); throw SharedMemoryException(); } // resize if (ftruncate(fd, sz) < 0) { - cprintf(RED, "Error: Create shared memory %s failed at ftruncate: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Create shared memory " << name << " failed at ftruncate: " << strerror(errno); close(fd); RemoveSharedMemory(); throw SharedMemoryException(); @@ -67,7 +66,7 @@ void* SharedMemory::CreateSharedMemory(size_t sz){ // map void* addr = MapSharedMemory(sz); - printf("Shared memory created %s \n", name.c_str()); + FILE_LOG(logINFO) << "Shared memory created " << name; return addr; } @@ -75,8 +74,7 @@ void* SharedMemory::OpenSharedMemory(size_t sz){ // open fd = shm_open(name.c_str(), O_RDWR, 0); if (fd < 0) { - cprintf(RED, "Error: Open existing shared memory %s failed: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Open existing shared memory " << name << " failed: " << strerror(errno); throw SharedMemoryException(); } @@ -86,8 +84,7 @@ void* SharedMemory::OpenSharedMemory(size_t sz){ void SharedMemory::UnmapSharedMemory(void* addr) { if (munmap(addr, shmSize) < 0) { - cprintf(RED, "Error: Unmapping shared memory %s failed: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Unmapping shared memory " << name << " failed: " << strerror(errno); close(fd); throw SharedMemoryException(); } @@ -98,19 +95,17 @@ void SharedMemory::RemoveSharedMemory() { // silent exit if shm did not exist anyway if (errno == ENOENT) return; - cprintf(RED, "Error: Free Shared Memory %s Failed: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Free Shared Memory " << name << " Failed: " << strerror(errno); throw SharedMemoryException(); } - printf("Shared memory deleted %s \n", name.c_str()); + FILE_LOG(logINFO) << "Shared memory deleted " << name; } void* SharedMemory::MapSharedMemory(size_t sz) { void* addr = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) { - cprintf(RED, "Error: Mapping shared memory %s failed: %s\n", - name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Mapping shared memory " << name << " failed: " << strerror(errno); close(fd); throw SharedMemoryException(); } @@ -138,10 +133,9 @@ std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) { std::string temp = ss.str(); if (temp.length() > NAME_MAX) { - cprintf(RED, "Error: Shared memory initialization failed. " - "%s has %lu characters. \n" - "Maximum is %d. Change the environment variable %s\n", - temp.c_str(), temp.length(), NAME_MAX, SHM_ENV_NAME); + FILE_LOG(logERROR) << "Shared memory initialization failed. " << + temp << " has " << temp.length() << " characters. \n" + "Maximum is " << NAME_MAX << ". Change the environment variable " << SHM_ENV_NAME; throw SharedMemoryException(); } return temp; @@ -152,8 +146,8 @@ int SharedMemory::VerifySizeMatch(size_t expectedSize) { struct stat sb; // could not fstat if (fstat(fd, &sb) < 0) { - cprintf(RED, "Error: Could not verify existing shared memory %s size match " - "(could not fstat): %s\n", name.c_str(), strerror(errno)); + FILE_LOG(logERROR) << "Could not verify existing shared memory " << name << " size match " + "(could not fstat): " << strerror(errno); close(fd); throw SharedMemoryException(); } @@ -161,11 +155,8 @@ int SharedMemory::VerifySizeMatch(size_t expectedSize) { //size does not match long unsigned int sz = (long unsigned int)sb.st_size; if (sz != expectedSize) { - cprintf(RED, "Warning: Existing shared memory %s size does not match.\n", - name.c_str()); -#ifdef VERBOSE - cprintf(RED, " Expected %ld, found %ld\n", expectedSize, sz); -#endif + FILE_LOG(logERROR) << "Existing shared memory " << name << " size does not match"; + FILE_LOG(logDEBUG1) << "Expected " << expectedSize << ", found " << sz; throw SharedMemoryException(); return 1; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index ef3aab5c7..2ca1c7d8e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -124,7 +124,7 @@ int slsDetector::checkVersionCompatibility(portType t) { setErrorMask((getErrorMask())|(VERSION_COMPATIBILITY)); return FAIL; } - FILE_LOG(logDEBUG5) << "Checking version compatibility with detector with " + FILE_LOG(logDEBUG1) << "Checking version compatibility with detector with " "value " << std::hex << arg << std::dec; @@ -155,7 +155,7 @@ int slsDetector::checkVersionCompatibility(portType t) { else { fnum = F_RECEIVER_CHECK_VERSION; arg = APIRECEIVER; - FILE_LOG(logDEBUG5) << "Checking version compatibility with receiver with " + FILE_LOG(logDEBUG1) << "Checking version compatibility with receiver with " "value " << std::hex << arg << std::dec; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { @@ -188,7 +188,7 @@ int64_t slsDetector::getId( idMode mode) { int arg = (int)mode; int64_t retval = -1; - FILE_LOG(logDEBUG5) << "Getting id type " << mode; + FILE_LOG(logDEBUG1) << "Getting id type " << mode; // client version if (mode == THIS_SOFTWARE_VERSION) { @@ -226,7 +226,7 @@ int64_t slsDetector::getId( idMode mode) { } if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Id ("<< mode << "): 0x" << std::hex << retval << std::dec; + FILE_LOG(logDEBUG1) << "Id ("<< mode << "): 0x" << std::hex << retval << std::dec; } return retval; @@ -377,7 +377,7 @@ int slsDetector::calculateSharedMemorySize(detectorType type) { sizeof(sls_detector_module) + sizeof(int) * nd + sizeof(int) * nch * nc; - FILE_LOG(logDEBUG5) << "Size of shared memory is " << sz; + FILE_LOG(logDEBUG1) << "Size of shared memory is " << sz; return sz; } @@ -723,16 +723,16 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { ts += controlSocket->ReceiveDataOnly(&(myMod->eV), sizeof(myMod->eV)); ts += controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(int)*(myMod->ndac)); - FILE_LOG(logDEBUG5) << "received dacs of size "<< ts; + FILE_LOG(logDEBUG1) << "received dacs of size "<< ts; ts += controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(int)*(myMod->nadc)); - FILE_LOG(logDEBUG5) << "received adc of size "<< ts; + FILE_LOG(logDEBUG1) << "received adc of size "<< ts; if (thisDetector->myDetectorType == EIGER) { ts += controlSocket->ReceiveDataOnly(myMod->chanregs, sizeof(int)*(myMod->nchan)); - FILE_LOG(logDEBUG5) << "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips + FILE_LOG(logDEBUG1) << "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips << "mod - nchans= " << myMod->nchan << " nchips= " <nchip << "received chans of size "<< ts; } - FILE_LOG(logDEBUG5) << "received module of size "<< ts << " register " << myMod->reg; + FILE_LOG(logDEBUG1) << "received module of size "<< ts << " register " << myMod->reg; return ts; } @@ -781,7 +781,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int return retval; } - FILE_LOG(logDEBUG5) << "Getting detector type "; + FILE_LOG(logDEBUG1) << "Getting detector type "; if (mySocket->Connect() >= 0) { mySocket->SendDataOnly(&fnum,sizeof(fnum)); mySocket->ReceiveDataOnly(&ret,sizeof(ret)); @@ -791,7 +791,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport; } if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Detector type is " << retval; + FILE_LOG(logDEBUG1) << "Detector type is " << retval; } delete mySocket; @@ -803,7 +803,7 @@ int slsDetector::setDetectorType(detectorType const type) { int fnum = F_GET_DETECTOR_TYPE; int ret = FAIL; detectorType retval = GENERIC; - FILE_LOG(logDEBUG5) << "Setting detector type to " << type; + FILE_LOG(logDEBUG1) << "Setting detector type to " << type; // if unspecified, then get from detector if (type == GET_DETECTOR_TYPE) { @@ -818,7 +818,7 @@ int slsDetector::setDetectorType(detectorType const type) { thisDetector->myDetectorType = GENERIC; } else { thisDetector->myDetectorType = (detectorType)retval; - FILE_LOG(logDEBUG5) << "Detector Type: " << retval; + FILE_LOG(logDEBUG1) << "Detector Type: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -842,7 +842,7 @@ int slsDetector::setDetectorType(detectorType const type) { FILE_LOG(logERROR) << "Could not send detector type to receiver"; setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver Type: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Type: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -873,7 +873,7 @@ std::string slsDetector::getDetectorType() { int slsDetector::getTotalNumberOfChannels() { - FILE_LOG(logDEBUG5) << "Get total number of channels"; + FILE_LOG(logDEBUG1) << "Get total number of channels"; if (thisDetector->myDetectorType == JUNGFRAUCTB) { if (thisDetector->roFlags & DIGITAL_ONLY) @@ -896,7 +896,7 @@ int slsDetector::getTotalNumberOfChannels() { * thisDetector->timerValue[SAMPLES_JCTB]; } - FILE_LOG(logDEBUG5) << "Total number of channels: " << + FILE_LOG(logDEBUG1) << "Total number of channels: " << thisDetector->nChans * thisDetector->nChips << ". Data bytes: " << thisDetector->dataBytes; @@ -986,12 +986,12 @@ std::string slsDetector::checkOnline() { delete controlSocket; controlSocket = 0; retval = std::string(thisDetector->hostname); - FILE_LOG(logDEBUG5) << "offline!"; + FILE_LOG(logDEBUG1) << "offline!"; } else { thisDetector->onlineFlag = ONLINE_FLAG; controlSocket->SetTimeOut(100); disconnectControl(); - FILE_LOG(logDEBUG5) << "online!"; + FILE_LOG(logDEBUG1) << "online!"; } } //still cannot connect to socket, stopSocket=0 @@ -1002,12 +1002,12 @@ std::string slsDetector::checkOnline() { delete stopSocket; stopSocket = 0; retval = std::string(thisDetector->hostname); - FILE_LOG(logDEBUG5) << "stop offline!"; + FILE_LOG(logDEBUG1) << "stop offline!"; } else { thisDetector->onlineFlag = ONLINE_FLAG; stopSocket->SetTimeOut(100); disconnectStop(); - FILE_LOG(logDEBUG5) << "stop online!"; + FILE_LOG(logDEBUG1) << "stop online!"; } } return retval; @@ -1023,7 +1023,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (name.empty()) { strcpy(thisName,thisDetector->hostname); } else { - FILE_LOG(logDEBUG5) << "Setting hostname"; + FILE_LOG(logDEBUG1) << "Setting hostname"; strcpy(thisName, name.c_str()); strcpy(thisDetector->hostname, thisName); if (controlSocket) { @@ -1040,7 +1040,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (control_port <= 0) { thisCP = thisDetector->controlPort; } else { - FILE_LOG(logDEBUG5) << "Setting control port"; + FILE_LOG(logDEBUG1) << "Setting control port"; thisCP = control_port; thisDetector->controlPort = thisCP; if (controlSocket) { @@ -1053,7 +1053,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (stop_port <= 0) { thisSP = thisDetector->stopPort; } else { - FILE_LOG(logDEBUG5) << "Setting stop port"; + FILE_LOG(logDEBUG1) << "Setting stop port"; thisSP = stop_port; thisDetector->stopPort = thisSP; if (stopSocket) { @@ -1066,7 +1066,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (!controlSocket) { try { controlSocket = new MySocketTCP(thisName, thisCP); - FILE_LOG(logDEBUG5) << "Control socket connected " << thisName << " " << thisCP; + FILE_LOG(logDEBUG1) << "Control socket connected " << thisName << " " << thisCP; } catch(...) { FILE_LOG(logERROR) << "Could not connect control socket " << thisName << " " << thisCP; controlSocket = 0; @@ -1079,7 +1079,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (!stopSocket) { try { stopSocket = new MySocketTCP(thisName, thisSP); - FILE_LOG(logDEBUG5) << "Stop socket connected " << thisName << " " << thisSP; + FILE_LOG(logDEBUG1) << "Stop socket connected " << thisName << " " << thisSP; } catch(...) { FILE_LOG(logERROR) << "Could not connect Stop socket " << thisName << " " << thisSP; stopSocket = 0; @@ -1090,7 +1090,7 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in if (ret == FAIL) { thisDetector->onlineFlag = OFFLINE_FLAG; - FILE_LOG(logDEBUG5) << "Detector offline"; + FILE_LOG(logDEBUG1) << "Detector offline"; } // check online and version compatibility @@ -1132,7 +1132,7 @@ int slsDetector::setPort(portType index, int num) { switch(index) { case CONTROL_PORT: - FILE_LOG(logDEBUG5) << "Setting control port " << " to " << num; + FILE_LOG(logDEBUG1) << "Setting control port " << " to " << num; // same port if (num == thisDetector->controlPort) @@ -1140,7 +1140,7 @@ int slsDetector::setPort(portType index, int num) { // control socket not created if (!controlSocket) { - FILE_LOG(logDEBUG5) << "Control socket not created. " + FILE_LOG(logDEBUG1) << "Control socket not created. " "Connecting to port: " << thisDetector->controlPort; setTCPSocket(); } @@ -1155,7 +1155,7 @@ int slsDetector::setPort(portType index, int num) { setErrorMask((getErrorMask())|(COULDNOT_SET_CONTROL_PORT)); } else { thisDetector->controlPort = retval; - FILE_LOG(logDEBUG5) << "Control port: " << retval; + FILE_LOG(logDEBUG1) << "Control port: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1163,7 +1163,7 @@ int slsDetector::setPort(portType index, int num) { break; case STOP_PORT: - FILE_LOG(logDEBUG5) << "Setting stop port " << " to " << num; + FILE_LOG(logDEBUG1) << "Setting stop port " << " to " << num; // same port if (num == thisDetector->stopPort) @@ -1171,7 +1171,7 @@ int slsDetector::setPort(portType index, int num) { // stop socket not created if (!stopSocket) { - FILE_LOG(logDEBUG5) << "Stop socket not created. " + FILE_LOG(logDEBUG1) << "Stop socket not created. " "Connecting to port: " << thisDetector->stopPort; setTCPSocket(); } @@ -1186,21 +1186,27 @@ int slsDetector::setPort(portType index, int num) { setErrorMask((getErrorMask())|(COULDNOT_SET_STOP_PORT)); } else { thisDetector->stopPort = retval; - FILE_LOG(logDEBUG5) << "Stop port: " << retval; + FILE_LOG(logDEBUG1) << "Stop port: " << retval; } } break; case DATA_PORT: - FILE_LOG(logDEBUG5) << "Setting receiver port " << " to " << num; + FILE_LOG(logDEBUG1) << "Setting receiver port " << " to " << num; // same port if (num == thisDetector->receiverTCPPort) return thisDetector->receiverTCPPort; + // if receiver hostname not given yet + if (!strcmp(thisDetector->receiver_hostname, "none")) { + thisDetector->receiverTCPPort = num; + break; + } + // control socket not created if (!dataSocket) { - FILE_LOG(logDEBUG5) << "Stop socket not created. " + FILE_LOG(logDEBUG1) << "Data socket not created. " "Connecting to port: " << thisDetector->receiverTCPPort;; setReceiverTCPSocket(); } @@ -1215,7 +1221,7 @@ int slsDetector::setPort(portType index, int num) { setErrorMask((getErrorMask())|(COULDNOT_SET_DATA_PORT)); } else { thisDetector->receiverTCPPort = retval; - FILE_LOG(logDEBUG5) << "Receiver port: " << retval; + FILE_LOG(logDEBUG1) << "Receiver port: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -1259,7 +1265,7 @@ int slsDetector::lockServer(int lock) { int fnum = F_LOCK_SERVER; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting detector server lock to " << lock; + FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &lock, sizeof(lock), &retval, sizeof(retval)); @@ -1269,7 +1275,7 @@ int slsDetector::lockServer(int lock) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Lock: " << retval; + FILE_LOG(logDEBUG1) << "Lock: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1282,7 +1288,7 @@ std::string slsDetector::getLastClientIP() { int fnum = F_GET_LAST_CLIENT_IP; int ret = FAIL; char retval[INET_ADDRSTRLEN] = {0}; - FILE_LOG(logDEBUG5) << "Getting last client ip to detector server"; + FILE_LOG(logDEBUG1) << "Getting last client ip to detector server"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -1292,7 +1298,7 @@ std::string slsDetector::getLastClientIP() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Last client IP to detector: " << retval; + FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1305,7 +1311,7 @@ std::string slsDetector::getLastClientIP() { int slsDetector::exitServer() { int fnum = F_EXIT_SERVER; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending exit command to detector server"; + FILE_LOG(logDEBUG1) << "Sending exit command to detector server"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -1323,7 +1329,7 @@ int slsDetector::execCommand(std::string cmd) { char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; strcpy(arg, cmd.c_str()); - FILE_LOG(logDEBUG5) << "Sending command to detector " << arg; + FILE_LOG(logDEBUG1) << "Sending command to detector " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, @@ -1348,7 +1354,7 @@ int slsDetector::updateDetectorNoWait() { char lastClientIP[INET_ADDRSTRLEN] = {0}; n += controlSocket->ReceiveDataOnly(lastClientIP, sizeof(lastClientIP)); - FILE_LOG(logDEBUG5) << "Updating detector last modified by " << lastClientIP; + FILE_LOG(logDEBUG1) << "Updating detector last modified by " << lastClientIP; n += controlSocket->ReceiveDataOnly(&i32, sizeof(i32)); thisDetector->dynamicRange = i32; @@ -1417,7 +1423,7 @@ int slsDetector::updateDetectorNoWait() { int slsDetector::updateDetector() { int fnum = F_UPDATE_CLIENT; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending update client to detector server"; + FILE_LOG(logDEBUG1) << "Sending update client to detector server"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -1450,7 +1456,7 @@ int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetecto int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) { - FILE_LOG(logDEBUG5) << "Write configuration file"; + FILE_LOG(logDEBUG1) << "Write configuration file"; std::vector names; // common config @@ -1532,7 +1538,7 @@ slsDetectorDefs::detectorSettings slsDetector::getSettings() { slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings isettings) { - FILE_LOG(logDEBUG5) << "slsDetector setSettings " << isettings; + FILE_LOG(logDEBUG1) << "slsDetector setSettings " << isettings; if (isettings == -1) return getSettings(); @@ -1565,7 +1571,7 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings int ret = FAIL; int arg = (int)isettings; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting settings to " << arg; + FILE_LOG(logDEBUG1) << "Setting settings to " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -1575,7 +1581,7 @@ slsDetectorDefs::detectorSettings slsDetector::sendSettingsOnly(detectorSettings if (ret == FAIL) { setErrorMask((getErrorMask())|(SETTINGS_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Settings: " << retval; + FILE_LOG(logDEBUG1) << "Settings: " << retval; thisDetector->currentSettings = (detectorSettings)retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -1590,7 +1596,7 @@ int slsDetector::getThresholdEnergy() { int fnum = F_GET_THRESHOLD_ENERGY; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Getting threshold energy"; + FILE_LOG(logDEBUG1) << "Getting threshold energy"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -1600,7 +1606,7 @@ int slsDetector::getThresholdEnergy() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Threshold: " << retval; + FILE_LOG(logDEBUG1) << "Threshold: " << retval; thisDetector->currentThresholdEV = retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -1685,7 +1691,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti ostfn << thisDetector->settingsDir << ssettings << "/" << e_eV << "eV" << "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec << getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10); std::string settingsfname = ostfn.str(); - FILE_LOG(logDEBUG5) << "Settings File is " << settingsfname; + FILE_LOG(logDEBUG1) << "Settings File is " << settingsfname; //read the files myMod = createModule(); // readSettings also checks if create module is null @@ -1720,7 +1726,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10); std::string settingsfname2 = ostfn.str(); //read the files - FILE_LOG(logDEBUG5) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; + FILE_LOG(logDEBUG1) << "Settings Files are " << settingsfname1 << " and " << settingsfname2; sls_detector_module *myMod1=createModule(); sls_detector_module *myMod2=createModule(); if (NULL == readSettingsFile(settingsfname1, myMod1, tb)) { @@ -1844,7 +1850,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() { int fnum = F_GET_RUN_STATUS; int ret = FAIL; runStatus retval = ERROR; - FILE_LOG(logDEBUG5) << "Getting status"; + FILE_LOG(logDEBUG1) << "Getting status"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { ret = thisDetectorStop->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -1854,7 +1860,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Detector status: " << runStatusType(retval); + FILE_LOG(logDEBUG1) << "Detector status: " << runStatusType(retval); if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1866,7 +1872,7 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus() { int slsDetector::prepareAcquisition() { int fnum = F_PREPARE_ACQUISITION; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Preparing Detector for Acquisition"; + FILE_LOG(logDEBUG1) << "Preparing Detector for Acquisition"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -1876,7 +1882,7 @@ int slsDetector::prepareAcquisition() { if (ret == FAIL) { setErrorMask((getErrorMask())|(PREPARE_ACQUISITION)); } else { - FILE_LOG(logDEBUG5) << "Prepare Acquisition successful"; + FILE_LOG(logDEBUG1) << "Prepare Acquisition successful"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1891,7 +1897,7 @@ int slsDetector::prepareAcquisition() { int slsDetector::startAcquisition() { int fnum = F_START_ACQUISITION; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Starting Acquisition"; + FILE_LOG(logDEBUG1) << "Starting Acquisition"; thisDetector->stoppedFlag = 0; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -1902,7 +1908,7 @@ int slsDetector::startAcquisition() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Starting Acquisition successful"; + FILE_LOG(logDEBUG1) << "Starting Acquisition successful"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1921,7 +1927,7 @@ int slsDetector::stopAcquisition() { int fnum = F_STOP_ACQUISITION; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Stopping Acquisition"; + FILE_LOG(logDEBUG1) << "Stopping Acquisition"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { ret = thisDetectorStop->Client_Send(fnum, NULL, 0, NULL, 0); @@ -1931,7 +1937,7 @@ int slsDetector::stopAcquisition() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Stopping Acquisition successful"; + FILE_LOG(logDEBUG1) << "Stopping Acquisition successful"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1949,7 +1955,7 @@ int slsDetector::stopAcquisition() { int slsDetector::sendSoftwareTrigger() { int fnum = F_SOFTWARE_TRIGGER; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending software trigger"; + FILE_LOG(logDEBUG1) << "Sending software trigger"; thisDetector->stoppedFlag = 0; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -1960,7 +1966,7 @@ int slsDetector::sendSoftwareTrigger() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Sending software trigger successful"; + FILE_LOG(logDEBUG1) << "Sending software trigger successful"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1972,7 +1978,7 @@ int slsDetector::sendSoftwareTrigger() { int slsDetector::startAndReadAll() { int fnum = F_START_AND_READ_ALL; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Starting and reading all frames"; + FILE_LOG(logDEBUG1) << "Starting and reading all frames"; thisDetector->stoppedFlag = 0; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -1984,7 +1990,7 @@ int slsDetector::startAndReadAll() { thisDetector->stoppedFlag = 1; setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Detector successfully finished acquisition"; + FILE_LOG(logDEBUG1) << "Detector successfully finished acquisition"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -1996,7 +2002,7 @@ int slsDetector::startAndReadAll() { int slsDetector::startReadOut() { int fnum = F_START_READOUT; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Starting readout"; + FILE_LOG(logDEBUG1) << "Starting readout"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -2006,7 +2012,7 @@ int slsDetector::startReadOut() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Starting detector readout successful"; + FILE_LOG(logDEBUG1) << "Starting detector readout successful"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2018,7 +2024,7 @@ int slsDetector::startReadOut() { int slsDetector::readAll() { int fnum = F_READ_ALL; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Reading all frames"; + FILE_LOG(logDEBUG1) << "Reading all frames"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -2029,7 +2035,7 @@ int slsDetector::readAll() { thisDetector->stoppedFlag = 1; setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Detector successfully finished reading all frames"; + FILE_LOG(logDEBUG1) << "Detector successfully finished reading all frames"; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2045,7 +2051,7 @@ int slsDetector::configureMAC() { memset(args, 0, sizeof(args)); char retvals[3][50]; memset(retvals, 0, sizeof(retvals)); - FILE_LOG(logDEBUG5) << "Configuring MAC"; + FILE_LOG(logDEBUG1) << "Configuring MAC"; // if rx_udpip is none @@ -2075,7 +2081,7 @@ int slsDetector::configureMAC() { setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); return FAIL; } - FILE_LOG(logDEBUG5) << "rx_hostname and rx_udpip is valid "; + FILE_LOG(logDEBUG1) << "rx_hostname and rx_udpip is valid "; // copy to args strcpy(args[0],thisDetector->receiverUDPIP); @@ -2093,7 +2099,7 @@ int slsDetector::configureMAC() { // col for horiz. udp ports pos[1] = (detId / max) * ((thisDetector->myDetectorType == EIGER) ? 2 : 1); // pos[2] (z is reserved) - FILE_LOG(logDEBUG5) << "Detector [" << detId << "] - (" + FILE_LOG(logDEBUG1) << "Detector [" << detId << "] - (" << pos[0] << "," << pos[1] << ")"; sprintf(args[6], "%x", pos[0]); sprintf(args[7], "%x", pos[1]); @@ -2110,7 +2116,7 @@ int slsDetector::configureMAC() { } bzero(args[0], 50); strcpy(args[0],cword); - FILE_LOG(logDEBUG5) << "receiver udp ip:" << args[0] << "-"; + FILE_LOG(logDEBUG1) << "receiver udp ip:" << args[0] << "-"; } { //converting MACaddress to std::hex @@ -2123,9 +2129,9 @@ int slsDetector::configureMAC() { } bzero(args[1], 50); strcpy(args[1],cword); - FILE_LOG(logDEBUG5) << "receiver udp mac:" << args[1] << "-"; + FILE_LOG(logDEBUG1) << "receiver udp mac:" << args[1] << "-"; } - FILE_LOG(logDEBUG5) << "receiver udp port:" << args[2] << "-"; + FILE_LOG(logDEBUG1) << "receiver udp port:" << args[2] << "-"; { std::stringstream ss(args[3]); char cword[50]=""; @@ -2136,7 +2142,7 @@ int slsDetector::configureMAC() { } bzero(args[3], 50); strcpy(args[3],cword); - FILE_LOG(logDEBUG5) << "detecotor udp mac:" << args[3] << "-"; + FILE_LOG(logDEBUG1) << "detecotor udp mac:" << args[3] << "-"; } { //converting IPaddress to std::hex @@ -2149,12 +2155,12 @@ int slsDetector::configureMAC() { } bzero(args[4], 50); strcpy(args[4],cword); - FILE_LOG(logDEBUG5) << "detecotor udp ip:" << args[4] << "-"; + FILE_LOG(logDEBUG1) << "detecotor udp ip:" << args[4] << "-"; } - FILE_LOG(logDEBUG5) << "receiver udp port2:" << args[5] << "-"; - FILE_LOG(logDEBUG5) << "row:" << args[6] << "-"; - FILE_LOG(logDEBUG5) << "col:" << args[7] << "-"; - FILE_LOG(logDEBUG5) << "reserved:" << args[8] << "-"; + FILE_LOG(logDEBUG1) << "receiver udp port2:" << args[5] << "-"; + FILE_LOG(logDEBUG1) << "row:" << args[6] << "-"; + FILE_LOG(logDEBUG1) << "col:" << args[7] << "-"; + FILE_LOG(logDEBUG1) << "reserved:" << args[8] << "-"; // send to server @@ -2209,13 +2215,13 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { int ret = FAIL; int64_t args[2] = {(int64_t)index, t}; int64_t retval = -1; - FILE_LOG(logDEBUG5) << "Setting " << getTimerType(index) << " to " << t << " ns/value"; + FILE_LOG(logDEBUG1) << "Setting " << getTimerType(index) << " to " << t << " ns/value"; // meausurement is only shm level if (index == MEASUREMENTS_NUMBER) { if (t >= 0) { thisDetector->timerValue[index] = t; - FILE_LOG(logDEBUG5) << getTimerType(index) << ": " << t; + FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << t; } return thisDetector->timerValue[index]; } @@ -2230,7 +2236,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { if (ret == FAIL) { setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << getTimerType(index) << ": " << retval; + FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval; thisDetector->timerValue[index] = retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2284,7 +2290,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) { ((thisDetector->timerValue[STORAGE_CELL_NUMBER] > 0) ? (thisDetector->timerValue[STORAGE_CELL_NUMBER])+1 : 1); } - FILE_LOG(logDEBUG5) << "Sending " << + FILE_LOG(logDEBUG1) << "Sending " << (((index == FRAME_NUMBER) || (index == CYCLES_NUMBER) || (index == STORAGE_CELL_NUMBER)) ? @@ -2337,7 +2343,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index) { int fnum = F_GET_TIME_LEFT; int ret = FAIL; int64_t retval = -1; - FILE_LOG(logDEBUG5) << "Getting " << getTimerType(index) << " left"; + FILE_LOG(logDEBUG1) << "Getting " << getTimerType(index) << " left"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { @@ -2348,7 +2354,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << getTimerType(index) << " left: " << retval; + FILE_LOG(logDEBUG1) << getTimerType(index) << " left: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2361,7 +2367,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { int fnum = F_SET_SPEED; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting speed index " << sp << " to " << value; + FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &value, sizeof(value), &retval, sizeof(retval)); @@ -2371,7 +2377,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULD_NOT_SET_SPEED_PARAMETERS)); } else { - FILE_LOG(logDEBUG5) << "Speed index " << sp << ": " << retval; + FILE_LOG(logDEBUG1) << "Speed index " << sp << ": " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2384,7 +2390,7 @@ int slsDetector::setDynamicRange(int n) { int fnum = F_SET_DYNAMIC_RANGE; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting dynamic range to " << n; + FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n; // send to detector int olddr = thisDetector->dynamicRange; @@ -2410,7 +2416,7 @@ int slsDetector::setDynamicRange(int n) { } // ret might be set to OK above if (ret != FAIL) { - FILE_LOG(logDEBUG5) << "Dynamic Range: " << retval; + FILE_LOG(logDEBUG1) << "Dynamic Range: " << retval; thisDetector->dynamicRange = retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2429,8 +2435,8 @@ int slsDetector::setDynamicRange(int n) { retval / 8; if (thisDetector->myDetectorType == JUNGFRAUCTB) getTotalNumberOfChannels(); - FILE_LOG(logDEBUG5) << "Data bytes " << thisDetector->dataBytes; - FILE_LOG(logDEBUG5) << "Data bytes including gap pixels" << thisDetector->dataBytesInclGapPixels; + FILE_LOG(logDEBUG1) << "Data bytes " << thisDetector->dataBytes; + FILE_LOG(logDEBUG1) << "Data bytes including gap pixels" << thisDetector->dataBytesInclGapPixels; } // send to receiver @@ -2448,7 +2454,7 @@ int slsDetector::setDynamicRange(int n) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DYNAMIC_RANGE)); } else { - FILE_LOG(logDEBUG5) << "Receiver Dynamic range: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Dynamic range: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -2476,7 +2482,7 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { int ret = FAIL; int args[3] = {(int)index, mV, val}; int retvals[2] = {-1, -1}; - FILE_LOG(logDEBUG5) << "Setting DAC " << index << " to " << val << (mV ? "mV" : "dac units"); + FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val << (mV ? "mV" : "dac units"); if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -2486,7 +2492,7 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { if (ret == FAIL) setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); else { - FILE_LOG(logDEBUG5) << "Dac index " << index << ": " + FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retvals[0] << " dac units (" << retvals[1] << "mV)"; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2503,7 +2509,7 @@ int slsDetector::getADC(dacIndex index) { int ret = FAIL; int arg = (int)index; int retval = -1; - FILE_LOG(logDEBUG5) << "Getting ADC " << index; + FILE_LOG(logDEBUG1) << "Getting ADC " << index; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -2513,7 +2519,7 @@ int slsDetector::getADC(dacIndex index) { if (ret == FAIL) setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); else - FILE_LOG(logDEBUG5) << "ADC (" << index << "): " << retval; + FILE_LOG(logDEBUG1) << "ADC (" << index << "): " << retval; /*commented out to allow adc read during acquire else if (ret == FORCE_UPDATE) updateDetector();*/ @@ -2528,7 +2534,7 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication int ret = FAIL; int arg = (int)pol; externalCommunicationMode retval = GET_EXTERNAL_COMMUNICATION_MODE; - FILE_LOG(logDEBUG5) << "Setting communication to mode " << pol; + FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -2538,7 +2544,7 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Timing Mode: " << retval; + FILE_LOG(logDEBUG1) << "Timing Mode: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2553,7 +2559,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( int ret = FAIL; int args[2] = {signalindex, pol}; externalSignalFlag retval = GET_EXTERNAL_SIGNAL_FLAG; - FILE_LOG(logDEBUG5) << "Setting signal " << signalindex << " to flag " << pol; + FILE_LOG(logDEBUG1) << "Setting signal " << signalindex << " to flag " << pol; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -2563,7 +2569,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags( if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Ext Signal (" << signalindex << "): " << retval; + FILE_LOG(logDEBUG1) << "Ext Signal (" << signalindex << "): " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2577,7 +2583,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag) { int ret = FAIL; int arg = (int)flag; readOutFlags retval = GET_READOUT_FLAGS; - FILE_LOG(logDEBUG5) << "Setting readout flags to " << flag; + FILE_LOG(logDEBUG1) << "Setting readout flags to " << flag; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -2587,11 +2593,8 @@ int slsDetector::setReadOutFlags(readOutFlags flag) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS)); } else { - FILE_LOG(logDEBUG5) << "Readout flag: " << retval; + FILE_LOG(logDEBUG1) << "Readout flag: " << retval; thisDetector->roFlags = (readOutFlags)retval; - if (thisDetector->myDetectorType == JUNGFRAUCTB) { - getTotalNumberOfChannels(); - } if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -2605,7 +2608,7 @@ uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) { int ret = FAIL; uint32_t args[2] = {addr, val}; uint32_t retval = -1; - FILE_LOG(logDEBUG5) << "Writing to register 0x" << std::hex << + FILE_LOG(logDEBUG1) << "Writing to register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -2616,7 +2619,7 @@ uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) { if (ret == FAIL) setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); else { - FILE_LOG(logDEBUG5) << "Register 0x" << + FILE_LOG(logDEBUG1) << "Register 0x" << std::hex << addr << ": 0x" << std::hex << retval << std::dec; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2631,7 +2634,7 @@ uint32_t slsDetector::readRegister(uint32_t addr) { int ret = FAIL; uint32_t arg = -1; uint32_t retval = -1; - FILE_LOG(logDEBUG5) << "Reading register 0x" << std::hex << addr << std::dec; + FILE_LOG(logDEBUG1) << "Reading register 0x" << std::hex << addr << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -2641,7 +2644,7 @@ uint32_t slsDetector::readRegister(uint32_t addr) { if (ret == FAIL) setErrorMask((getErrorMask())|(REGISER_WRITE_READ)); else { - FILE_LOG(logDEBUG5) << "Register 0x" << + FILE_LOG(logDEBUG1) << "Register 0x" << std::hex << addr << ": 0x" << std::hex << retval << std::dec; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -2842,7 +2845,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() { int fnum = F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Getting real UDP Socket Buffer size to receiver"; + FILE_LOG(logDEBUG1) << "Getting real UDP Socket Buffer size to receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -2852,7 +2855,7 @@ std::string slsDetector::getReceiverRealUDPSocketBufferSize() { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Real Receiver UDP Socket Buffer size: " << retval; + FILE_LOG(logDEBUG1) << "Real Receiver UDP Socket Buffer size: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -2874,7 +2877,7 @@ std::string slsDetector::setDetectorMAC(std::string detectorMAC) { else { strcpy(thisDetector->detectorMAC, detectorMAC.c_str()); if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; } @@ -2897,7 +2900,7 @@ std::string slsDetector::setDetectorIP(std::string detectorIP) { else { strcpy(thisDetector->detectorIP, detectorIP.c_str()); if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; } @@ -2908,7 +2911,7 @@ std::string slsDetector::setDetectorIP(std::string detectorIP) { std::string slsDetector::setReceiver(std::string receiverIP) { - FILE_LOG(logDEBUG5) << "Setting up Receiver with " << receiverIP; + FILE_LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP; // recieverIP is none if (receiverIP == "none") { memset(thisDetector->receiver_hostname, 0, MAX_STR_LENGTH); @@ -2928,7 +2931,7 @@ std::string slsDetector::setReceiver(std::string receiverIP) { strcpy(thisDetector->receiver_hostname, receiverIP.c_str()); if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { - FILE_LOG(logDEBUG5) << + FILE_LOG(logDEBUG1) << "detector type:" << (slsDetectorDefs::getDetectorType(thisDetector->myDetectorType)) << "\ndetector id:" << detId << "\ndetector hostname:" << thisDetector->hostname << @@ -3023,7 +3026,7 @@ std::string slsDetector::setReceiverUDPIP(std::string udpip) { else { strcpy(thisDetector->receiverUDPIP,udpip.c_str()); if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; } @@ -3045,7 +3048,7 @@ std::string slsDetector::setReceiverUDPMAC(std::string udpmac) { else { strcpy(thisDetector->receiverUDPMAC, udpmac.c_str()); if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } // not doing setUDPConnection as rx_udpmac will get replaced,(must use configuremac) strcpy(thisDetector->receiverUDPMAC,udpmac.c_str()); @@ -3057,7 +3060,7 @@ std::string slsDetector::setReceiverUDPMAC(std::string udpmac) { int slsDetector::setReceiverUDPPort(int udpport) { thisDetector->receiverUDPPort = udpport; if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; @@ -3069,7 +3072,7 @@ int slsDetector::setReceiverUDPPort(int udpport) { int slsDetector::setReceiverUDPPort2(int udpport) { thisDetector->receiverUDPPort2 = udpport; if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet"; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; } else if (setUDPConnection() == FAIL) { FILE_LOG(logWARNING) << "UDP connection set up failed"; @@ -3092,7 +3095,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) { int ret = FAIL; int arg = thisDetector->receiver_zmqport; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending receiver streaming port to receiver " << arg; + FILE_LOG(logDEBUG1) << "Sending receiver streaming port to receiver " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3102,7 +3105,7 @@ std::string slsDetector::setReceiverStreamingPort(std::string port) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Receiver streaming port: " << retval; + FILE_LOG(logDEBUG1) << "Receiver streaming port: " << retval; thisDetector->receiver_zmqport = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -3132,7 +3135,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { int ret = FAIL; char args[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; - FILE_LOG(logDEBUG5) << "Sending receiver streaming IP to receiver " << sourceIP; + FILE_LOG(logDEBUG1) << "Sending receiver streaming IP to receiver " << sourceIP; // if empty, give rx_hostname if (sourceIP.empty()) { @@ -3163,7 +3166,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { // if zmqip is empty, update it if (! strlen(thisDetector->zmqip)) strcpy(thisDetector->zmqip, args); - FILE_LOG(logDEBUG5) << "Sending receiver streaming IP to receiver " << args; + FILE_LOG(logDEBUG1) << "Sending receiver streaming IP to receiver " << args; // send to receiver if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { @@ -3174,7 +3177,7 @@ std::string slsDetector::setReceiverStreamingIP(std::string sourceIP) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Receiver streaming port: " << retvals; + FILE_LOG(logDEBUG1) << "Receiver streaming port: " << retvals; memset(thisDetector->receiver_zmqip, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiver_zmqip, retvals); if (ret == FORCE_UPDATE) @@ -3191,7 +3194,7 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { char args[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; strcpy(args, jsonheader.c_str()); - FILE_LOG(logDEBUG5) << "Sending additional json header " << args; + FILE_LOG(logDEBUG1) << "Sending additional json header " << args; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -3201,7 +3204,7 @@ std::string slsDetector::setAdditionalJsonHeader(std::string jsonheader) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Additional json header: " << retvals; + FILE_LOG(logDEBUG1) << "Additional json header: " << retvals; memset(thisDetector->receiver_additionalJsonHeader, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiver_additionalJsonHeader, retvals); if (ret == FORCE_UPDATE) @@ -3217,7 +3220,7 @@ std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) { int ret = FAIL; int arg = udpsockbufsize; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending UDP Socket Buffer size to receiver " << arg; + FILE_LOG(logDEBUG1) << "Sending UDP Socket Buffer size to receiver " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3227,7 +3230,7 @@ std::string slsDetector::setReceiverUDPSocketBufferSize(int udpsockbufsize) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULDNOT_SET_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Receiver UDP Socket Buffer size: " << retval; + FILE_LOG(logDEBUG1) << "Receiver UDP Socket Buffer size: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -3241,7 +3244,7 @@ std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int int ret = FAIL; int args[2] = {(int)index, delay}; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting network parameter index " << index << " to " << delay; + FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to " << delay; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -3251,7 +3254,7 @@ std::string slsDetector::setDetectorNetworkParameter(networkParameter index, int if (ret == FAIL) { setErrorMask((getErrorMask())|(DETECTOR_NETWORK_PARAMETER)); } else { - FILE_LOG(logDEBUG5) << "Network Parameter (" << index << "): " << retval; + FILE_LOG(logDEBUG1) << "Network Parameter (" << index << "): " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -3265,11 +3268,11 @@ int slsDetector::setUDPConnection() { int ret = FAIL; char args[3][MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; - FILE_LOG(logDEBUG5) << "Setting UDP Connection"; + FILE_LOG(logDEBUG1) << "Setting UDP Connection"; // called before set up if (!strcmp(thisDetector->receiver_hostname, "none")) { - FILE_LOG(logDEBUG5) << "Receiver hostname not set yet."; + FILE_LOG(logDEBUG1) << "Receiver hostname not set yet."; return FAIL; } // if no udp ip given, use hostname @@ -3296,19 +3299,19 @@ int slsDetector::setUDPConnection() { strcpy(args[0],thisDetector->receiverUDPIP); sprintf(args[1],"%d",thisDetector->receiverUDPPort); sprintf(args[2],"%d",thisDetector->receiverUDPPort2); - FILE_LOG(logDEBUG5) << "Receiver udp ip address: " << thisDetector->receiverUDPIP; - FILE_LOG(logDEBUG5) << "Receiver udp port: " << thisDetector->receiverUDPPort; - FILE_LOG(logDEBUG5) << "Receiver udp port2: " << thisDetector->receiverUDPPort2; + FILE_LOG(logDEBUG1) << "Receiver udp ip address: " << thisDetector->receiverUDPIP; + FILE_LOG(logDEBUG1) << "Receiver udp port: " << thisDetector->receiverUDPPort; + FILE_LOG(logDEBUG1) << "Receiver udp port2: " << thisDetector->receiverUDPPort2; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); - disconnectControl(); + disconnectData(); // handle ret if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Receiver UDP MAC returned : " << retvals; + FILE_LOG(logDEBUG1) << "Receiver UDP MAC returned : " << retvals; memset(thisDetector->receiverUDPMAC, 0, MAX_STR_LENGTH); strcpy(thisDetector->receiverUDPMAC, retvals); if (ret == FORCE_UPDATE) @@ -3320,7 +3323,7 @@ int slsDetector::setUDPConnection() { } } } - printReceiverConfiguration(logDEBUG5); + printReceiverConfiguration(logDEBUG1); return ret; } @@ -3330,7 +3333,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) { int ret = FAIL; int args[2] = {(int)mode, ival}; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending digital test of mode " << mode << ", ival " << ival; + FILE_LOG(logDEBUG1) << "Sending digital test of mode " << mode << ", ival " << ival; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -3340,7 +3343,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Digital Test returned: " << retval; + FILE_LOG(logDEBUG1) << "Digital Test returned: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -3352,7 +3355,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int ival) { int slsDetector::loadImageToDetector(imageType index,std::string const fname) { int ret = FAIL; short int args[thisDetector->nChans * thisDetector->nChips]; - FILE_LOG(logDEBUG5) << "Loading " << (!index ? "Dark" : "Gain") << "image from file " << fname; + FILE_LOG(logDEBUG1) << "Loading " << (!index ? "Dark" : "Gain") << "image from file " << fname; if (readDataFile(fname, args, getTotalNumberOfChannels())) { ret = sendImageToDetector(index,args); @@ -3368,7 +3371,7 @@ int slsDetector::loadImageToDetector(imageType index,std::string const fname) { int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int fnum = F_LOAD_IMAGE; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending image to detector"; + FILE_LOG(logDEBUG1) << "Sending image to detector"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, @@ -3388,7 +3391,7 @@ int slsDetector::sendImageToDetector(imageType index,short int imageVals[]) { int slsDetector::writeCounterBlockFile(std::string const fname,int startACQ) { int ret = FAIL; short int retvals[thisDetector->nChans * thisDetector->nChips]; - FILE_LOG(logDEBUG5) << "Reading Counter to " << fname << + FILE_LOG(logDEBUG1) << "Reading Counter to " << fname << (startACQ ? " and Restarting Acquisition" : "\n"); ret = getCounterBlock(retvals, startACQ); @@ -3404,7 +3407,7 @@ int slsDetector::getCounterBlock(short int image[],int startACQ) { int fnum = F_READ_COUNTER_BLOCK; int ret = FAIL; int arg = startACQ; - FILE_LOG(logDEBUG5) << "Reading Counter block with startacq: " << startACQ; + FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, @@ -3425,7 +3428,7 @@ int slsDetector::resetCounterBlock(int startACQ) { int fnum = F_RESET_COUNTER_BLOCK; int ret = FAIL; int arg = startACQ; - FILE_LOG(logDEBUG5) << "Resetting Counter with startacq: " << startACQ; + FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); @@ -3446,7 +3449,7 @@ int slsDetector::setCounterBit(int i) { int ret = FAIL; int arg = i; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending counter bit " << arg; + FILE_LOG(logDEBUG1) << "Sending counter bit " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3456,7 +3459,7 @@ int slsDetector::setCounterBit(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULD_NOT_SET_COUNTER_BIT)); } else { - FILE_LOG(logDEBUG5) << "Counter bit: " << retval; + FILE_LOG(logDEBUG1) << "Counter bit: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -3515,7 +3518,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { ROI* arg = (roiLimits != NULL) ? roiLimits : thisDetector->roiLimits; int nretval = 0; ROI retval[MAX_ROIS]; - FILE_LOG(logDEBUG5) << "Sending ROI to detector" << narg; + FILE_LOG(logDEBUG1) << "Sending ROI to detector" << narg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { controlSocket->SendDataOnly(&fnum, sizeof(fnum)); @@ -3546,10 +3549,10 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { nrec += controlSocket->ReceiveDataOnly(&retval[i].ymax, sizeof(int)); } thisDetector->nROI = nretval; - FILE_LOG(logDEBUG5) << "nRoi: " << nretval; + FILE_LOG(logDEBUG1) << "nRoi: " << nretval; for (int i = 0; i < nretval; ++i) { thisDetector->roiLimits[i] = retval[i]; - FILE_LOG(logDEBUG5) << "ROI [" << i << "] (" << + FILE_LOG(logDEBUG1) << "ROI [" << i << "] (" << thisDetector->roiLimits[i].xmin << "," << thisDetector->roiLimits[i].xmax << "," << thisDetector->roiLimits[i].ymin << "," << @@ -3573,7 +3576,7 @@ int slsDetector::sendROI(int n, ROI roiLimits[]) { ret = FAIL; narg = thisDetector->nROI; arg = thisDetector->roiLimits; - FILE_LOG(logDEBUG5) << "Sending ROI to receiver " << thisDetector->nROI; + FILE_LOG(logDEBUG1) << "Sending ROI to receiver " << thisDetector->nROI; if (connectData() == OK) { dataSocket->SendDataOnly(&fnum, sizeof(fnum)); @@ -3608,7 +3611,7 @@ int slsDetector::writeAdcRegister(int addr, int val) { int fnum = F_WRITE_ADC_REG; int ret = FAIL; uint32_t args[2] = {(uint32_t)addr, (uint32_t)val}; - FILE_LOG(logDEBUG5) << "Writing to ADC register 0x" << std::hex << + FILE_LOG(logDEBUG1) << "Writing to ADC register 0x" << std::hex << addr << "data: 0x" << std::hex << val << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -3630,7 +3633,7 @@ int slsDetector::activate(int const enable) { int ret = FAIL; int arg = enable; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting activate flag to " << arg; + FILE_LOG(logDEBUG1) << "Setting activate flag to " << arg; // detector if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -3641,7 +3644,7 @@ int slsDetector::activate(int const enable) { if (ret == FAIL) { setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); } else { - FILE_LOG(logDEBUG5) << "Activate: " << retval; + FILE_LOG(logDEBUG1) << "Activate: " << retval; thisDetector->activated = retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -3654,7 +3657,7 @@ int slsDetector::activate(int const enable) { ret = FAIL; arg = thisDetector->activated; retval = -1; - FILE_LOG(logDEBUG5) << "Setting activate flag " << arg << " to receiver"; + FILE_LOG(logDEBUG1) << "Setting activate flag " << arg << " to receiver"; if (connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3676,7 +3679,7 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) { int ret = OK; int arg = padding; int retval = -1; - FILE_LOG(logDEBUG5) << "Deactivated Receiver Padding Enable: " << arg; + FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << arg; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3686,7 +3689,7 @@ int slsDetector::setDeactivatedRxrPaddingMode(int padding) { if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE)); else { - FILE_LOG(logDEBUG5) << "Deactivated Receiver Padding Enable:" << retval; + FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable:" << retval; thisDetector->receiver_deactivatedPaddingEnable = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -3718,7 +3721,7 @@ int slsDetector::setFlippedData(dimension d, int value) { if (value > -1) thisDetector->flippedData[d] = (value > 0) ? 1 : 0; args[1] = thisDetector->flippedData[d]; - FILE_LOG(logDEBUG5) << "Setting flipped data across axis " << d << " with value: " << value; + FILE_LOG(logDEBUG1) << "Setting flipped data across axis " << d << " with value: " << value; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -3728,7 +3731,7 @@ int slsDetector::setFlippedData(dimension d, int value) { if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET)); else { - FILE_LOG(logDEBUG5) << "Flipped data:" << retval; + FILE_LOG(logDEBUG1) << "Flipped data:" << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -3742,7 +3745,7 @@ int slsDetector::setAllTrimbits(int val) { int ret = FAIL; int arg = val; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting all trimbits to " << val; + FILE_LOG(logDEBUG1) << "Setting all trimbits to " << val; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3752,7 +3755,7 @@ int slsDetector::setAllTrimbits(int val) { if (ret == FAIL) { setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "All trimbit value: " << retval; + FILE_LOG(logDEBUG1) << "All trimbit value: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -3767,7 +3770,7 @@ int slsDetector::enableGapPixels(int val) { int ret = OK; int arg = val; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending gap pixels enable to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending gap pixels enable to receiver: " << arg; if (thisDetector->receiverOnlineFlag==ONLINE_FLAG && connectData() == OK) { ret=thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3777,7 +3780,7 @@ int slsDetector::enableGapPixels(int val) { if (ret == FAIL) setErrorMask((getErrorMask())|(RECEIVER_ENABLE_GAPPIXELS_NOT_SET)); else { - FILE_LOG(logDEBUG5) << "Gap pixels enable to receiver:" << retval; + FILE_LOG(logDEBUG1) << "Gap pixels enable to receiver:" << retval; thisDetector->gappixels = retval; // update databytes @@ -3822,7 +3825,7 @@ int slsDetector::pulsePixel(int n, int x, int y) { int fnum = F_PULSE_PIXEL; int ret = FAIL; int args[3] = {n , x, y}; - FILE_LOG(logDEBUG5) << "Pulsing pixel " << n << " number of times at (" << + FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x << "," << y << ")"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -3843,7 +3846,7 @@ int slsDetector::pulsePixelNMove(int n, int x, int y) { int fnum = F_PULSE_PIXEL_AND_MOVE; int ret = FAIL; int args[3] = {n, x, y}; - FILE_LOG(logDEBUG5) << "Pulsing pixel " << n << " number of times and move by delta (" << + FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times and move by delta (" << x << "," << y << ")"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -3864,7 +3867,7 @@ int slsDetector::pulseChip(int n) { int fnum = F_PULSE_CHIP; int ret = FAIL; int arg = n; - FILE_LOG(logDEBUG5) << "Pulsing chip " << n << " number of times"; + FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), NULL, 0); @@ -3885,7 +3888,7 @@ int slsDetector::setThresholdTemperature(int val) { int ret = FAIL; int arg = val; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting threshold temperature to " << val; + FILE_LOG(logDEBUG1) << "Setting threshold temperature to " << val; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3895,7 +3898,7 @@ int slsDetector::setThresholdTemperature(int val) { if (ret == FAIL) { setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } else { - FILE_LOG(logDEBUG5) << "Threshold temperature: " << retval; + FILE_LOG(logDEBUG1) << "Threshold temperature: " << retval; } // no updateDetector as it is stop server } return retval; @@ -3907,7 +3910,7 @@ int slsDetector::setTemperatureControl(int val) { int ret = FAIL; int arg = val; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting temperature control to " << val; + FILE_LOG(logDEBUG1) << "Setting temperature control to " << val; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3917,7 +3920,7 @@ int slsDetector::setTemperatureControl(int val) { if (ret == FAIL) { setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } else { - FILE_LOG(logDEBUG5) << "Temperature control: " << retval; + FILE_LOG(logDEBUG1) << "Temperature control: " << retval; } // no updateDetector as it is stop server } return retval; @@ -3929,7 +3932,7 @@ int slsDetector::setTemperatureEvent(int val) { int ret = FAIL; int arg = val; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting temperature event to " << val; + FILE_LOG(logDEBUG1) << "Setting temperature event to " << val; if (thisDetector->onlineFlag == ONLINE_FLAG && connectStop() == OK) { ret = thisDetectorStop->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3939,7 +3942,7 @@ int slsDetector::setTemperatureEvent(int val) { if (ret == FAIL) { setErrorMask((getErrorMask())|(TEMPERATURE_CONTROL)); } else { - FILE_LOG(logDEBUG5) << "Temperature event: " << retval; + FILE_LOG(logDEBUG1) << "Temperature event: " << retval; } // no updateDetector as it is stop server } return retval; @@ -3951,7 +3954,7 @@ int slsDetector::setStoragecellStart(int pos) { int ret = FAIL; int arg = pos; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting storage cell start to " << pos; + FILE_LOG(logDEBUG1) << "Setting storage cell start to " << pos; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -3961,7 +3964,7 @@ int slsDetector::setStoragecellStart(int pos) { if (ret == FAIL) { setErrorMask((getErrorMask())|(STORAGE_CELL_START)); } else { - FILE_LOG(logDEBUG5) << "Storage cell start: " << retval; + FILE_LOG(logDEBUG1) << "Storage cell start: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -3977,7 +3980,7 @@ int slsDetector::programFPGA(std::string fname) { setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - FILE_LOG(logDEBUG5) << "Programming FPGA with file name:" << fname; + FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname; size_t filesize = 0; char* fpgasrc = NULL; @@ -4010,7 +4013,7 @@ int slsDetector::programFPGA(std::string fname) { } // convert src to dst rawbin - FILE_LOG(logDEBUG5) << "Converting " << fname << " to " << destfname; + FILE_LOG(logDEBUG1) << "Converting " << fname << " to " << destfname; { int filepos, x, y, i; // Remove header (0...11C) @@ -4047,7 +4050,7 @@ int slsDetector::programFPGA(std::string fname) { setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); return FAIL; } - FILE_LOG(logDEBUG5) << "File has been converted to " << destfname; + FILE_LOG(logDEBUG1) << "File has been converted to " << destfname; //loading dst file to memory FILE* fp = fopen(destfname,"r"); @@ -4090,14 +4093,14 @@ int slsDetector::programFPGA(std::string fname) { return FAIL; } unlink(destfname); // delete temporary file - FILE_LOG(logDEBUG5) << "Successfully loaded the rawbin file to program memory"; + FILE_LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory"; } // send program from memory to detector int fnum = F_PROGRAM_FPGA; int ret = FAIL; char mess[MAX_STR_LENGTH] = {0}; - FILE_LOG(logDEBUG5) << "Sending programming binary to detector"; + FILE_LOG(logDEBUG1) << "Sending programming binary to detector"; if (thisDetector->onlineFlag == ONLINE_FLAG) { if (connectControl() == OK) { @@ -4144,7 +4147,7 @@ int slsDetector::programFPGA(std::string fname) { unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb if (unitprogramsize > filesize) //less than 2mb unitprogramsize = filesize; - FILE_LOG(logDEBUG5) << "unitprogramsize:" << unitprogramsize << + FILE_LOG(logDEBUG1) << "unitprogramsize:" << unitprogramsize << "\t filesize:" << filesize; controlSocket->SendDataOnly(fpgasrc + currentPointer, unitprogramsize); @@ -4217,7 +4220,7 @@ int slsDetector::programFPGA(std::string fname) { int slsDetector::resetFPGA() { int fnum = F_RESET_FPGA; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending reset FPGA"; + FILE_LOG(logDEBUG1) << "Sending reset FPGA"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); @@ -4238,7 +4241,7 @@ int slsDetector::powerChip(int ival) { int ret = FAIL; int arg = ival; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting power chip to " << ival; + FILE_LOG(logDEBUG1) << "Setting power chip to " << ival; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4248,7 +4251,7 @@ int slsDetector::powerChip(int ival) { if (ret == FAIL) { setErrorMask((getErrorMask())|(POWER_CHIP)); } else { - FILE_LOG(logDEBUG5) << "Power chip: " << retval; + FILE_LOG(logDEBUG1) << "Power chip: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -4262,7 +4265,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) { int ret = FAIL; int arg = ival; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting auto comp disable mode to " << ival; + FILE_LOG(logDEBUG1) << "Setting auto comp disable mode to " << ival; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4272,7 +4275,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) { if (ret == FAIL) { setErrorMask((getErrorMask())|(AUTO_COMP_DISABLE)); } else { - FILE_LOG(logDEBUG5) << "Auto comp disable: " << retval; + FILE_LOG(logDEBUG1) << "Auto comp disable: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -4300,7 +4303,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) { int fnum = F_SET_MODULE; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting module with tb:" << tb; + FILE_LOG(logDEBUG1) << "Setting module with tb:" << tb; //to exclude trimbits if (!tb) { @@ -4324,7 +4327,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - FILE_LOG(logDEBUG5) << "Set Module returned: " << retval; + FILE_LOG(logDEBUG1) << "Set Module returned: " << retval; disconnectControl(); if (ret == FORCE_UPDATE) @@ -4368,7 +4371,7 @@ int slsDetector::setModule(sls_detector_module module, int tb) { slsDetectorDefs::sls_detector_module *slsDetector::getModule() { int fnum = F_GET_MODULE; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Getting module"; + FILE_LOG(logDEBUG1) << "Getting module"; sls_detector_module *myMod = createModule(); if (myMod == NULL) { @@ -4430,7 +4433,7 @@ int slsDetector::setRateCorrection(int64_t t) { int fnum = F_SET_RATE_CORRECT; int ret = FAIL; int64_t arg = t; - FILE_LOG(logDEBUG5) << "Setting Rate Correction to " << arg; + FILE_LOG(logDEBUG1) << "Setting Rate Correction to " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { char mess[MAX_STR_LENGTH] = {0}; @@ -4456,7 +4459,7 @@ int64_t slsDetector::getRateCorrection() { int fnum = F_GET_RATE_CORRECT; int ret = FAIL; int64_t retval = -1; - FILE_LOG(logDEBUG5) << "Getting rate correction"; + FILE_LOG(logDEBUG1) << "Getting rate correction"; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -4466,7 +4469,7 @@ int64_t slsDetector::getRateCorrection() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Rate correction: " << retval; + FILE_LOG(logDEBUG1) << "Rate correction: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -4478,12 +4481,12 @@ int64_t slsDetector::getRateCorrection() { void slsDetector::printReceiverConfiguration(TLogLevel level) { FILE_LOG(level) << "#Detector " << detId << ":\n" << "Receiver Hostname:\t" << getNetworkParameter(RECEIVER_HOSTNAME) << - "Detector UDP IP (Source):\t\t" << getNetworkParameter(DETECTOR_IP) << - "Detector UDP MAC:\t\t" << getNetworkParameter(DETECTOR_MAC) << - "Receiver UDP IP:\t" << getNetworkParameter(RECEIVER_UDP_IP) << - "Receiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << - "Receiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << - "Receiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2); + "\nDetector UDP IP (Source):\t\t" << getNetworkParameter(DETECTOR_IP) << + "\nDetector UDP MAC:\t\t" << getNetworkParameter(DETECTOR_MAC) << + "\nReceiver UDP IP:\t" << getNetworkParameter(RECEIVER_UDP_IP) << + "\nReceiver UDP MAC:\t" << getNetworkParameter(RECEIVER_UDP_MAC) << + "\nReceiver UDP Port:\t" << getNetworkParameter(RECEIVER_UDP_PORT) << + "\nReceiver UDP Port2:\t" << getNetworkParameter(RECEIVER_UDP_PORT2); } @@ -4525,13 +4528,13 @@ std::string slsDetector::checkReceiverOnline() { thisDetector->receiverOnlineFlag = OFFLINE_FLAG; delete dataSocket; dataSocket = 0; - FILE_LOG(logDEBUG5) << "receiver " << detId << " offline!"; + FILE_LOG(logDEBUG1) << "receiver " << detId << " offline!"; return std::string(thisDetector->receiver_hostname); } else { thisDetector->receiverOnlineFlag = ONLINE_FLAG; dataSocket->SetTimeOut(100); disconnectData(); - FILE_LOG(logDEBUG5) << "receiver " << detId << " online!"; + FILE_LOG(logDEBUG1) << "receiver " << detId << " online!"; } } return retval; @@ -4545,9 +4548,14 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver // rx_hostname if (name.empty()) { + if (!strcmp(thisDetector->receiver_hostname, "none")) { + FILE_LOG(logDEBUG1) << "No rx_hostname given yet"; + thisDetector->receiverOnlineFlag = OFFLINE_FLAG; + return FAIL; + } strcpy(thisName,thisDetector->receiver_hostname); } else { - FILE_LOG(logDEBUG5) << "Setting rx_hostname"; + FILE_LOG(logDEBUG1) << "Setting rx_hostname"; strcpy(thisName, name.c_str()); strcpy(thisDetector->receiver_hostname, thisName); if (dataSocket) { @@ -4560,7 +4568,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver if (receiver_port <= 0) { thisRP = thisDetector->receiverTCPPort; } else { - FILE_LOG(logDEBUG5) << "Setting data port"; + FILE_LOG(logDEBUG1) << "Setting data port"; thisRP = receiver_port; thisDetector->receiverTCPPort = thisRP; if (dataSocket) { @@ -4573,7 +4581,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver if (!dataSocket) { try { dataSocket = new MySocketTCP(thisName, thisRP); - FILE_LOG(logDEBUG5) << "Data socket connected " << thisName << " " << thisRP; + FILE_LOG(logDEBUG1) << "Data socket connected " << thisName << " " << thisRP; } catch(...) { FILE_LOG(logERROR) << "Could not connect Data socket " << thisName << " " << thisRP; dataSocket = 0; @@ -4583,7 +4591,7 @@ int slsDetector::setReceiverTCPSocket(std::string const name, int const receiver if (ret == FAIL) { thisDetector->receiverOnlineFlag = OFFLINE_FLAG; - FILE_LOG(logDEBUG5) << "Receiver offline"; + FILE_LOG(logDEBUG1) << "Receiver offline"; } // check online and version compatibility @@ -4604,7 +4612,7 @@ int slsDetector::lockReceiver(int lock) { int fnum = F_LOCK_RECEIVER; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting receiver server lock to " << lock; + FILE_LOG(logDEBUG1) << "Setting receiver server lock to " << lock; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &lock, sizeof(lock), &retval, sizeof(retval)); @@ -4614,7 +4622,7 @@ int slsDetector::lockReceiver(int lock) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Receiver Lock: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Lock: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4627,7 +4635,7 @@ std::string slsDetector::getReceiverLastClientIP() { int fnum = F_GET_LAST_RECEIVER_CLIENT_IP; int ret = FAIL; char retval[INET_ADDRSTRLEN] = {0}; - FILE_LOG(logDEBUG5) << "Getting last client ip to receiver server"; + FILE_LOG(logDEBUG1) << "Getting last client ip to receiver server"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -4637,7 +4645,7 @@ std::string slsDetector::getReceiverLastClientIP() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Last client IP to receiver: " << retval; + FILE_LOG(logDEBUG1) << "Last client IP to receiver: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4649,7 +4657,7 @@ std::string slsDetector::getReceiverLastClientIP() { int slsDetector::exitReceiver() { int fnum = F_EXIT_RECEIVER; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending exit command to receiver server"; + FILE_LOG(logDEBUG1) << "Sending exit command to receiver server"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); @@ -4667,7 +4675,7 @@ int slsDetector::execReceiverCommand(std::string cmd) { char arg[MAX_STR_LENGTH] = {0}; char retval[MAX_STR_LENGTH] = {0}; strcpy(arg, cmd.c_str()); - FILE_LOG(logDEBUG5) << "Sending command to receiver " << arg; + FILE_LOG(logDEBUG1) << "Sending command to receiver " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, arg, sizeof(arg), retval, sizeof(retval)); @@ -4691,7 +4699,7 @@ int slsDetector::updateReceiverNoWait() { char lastClientIP[INET_ADDRSTRLEN] = {0}; n += dataSocket->ReceiveDataOnly(lastClientIP, sizeof(lastClientIP)); - FILE_LOG(logDEBUG5) << "Updating receiver last modified by " << lastClientIP; + FILE_LOG(logDEBUG1) << "Updating receiver last modified by " << lastClientIP; // filepath n += dataSocket->ReceiveDataOnly(cstring, sizeof(cstring)); @@ -4778,7 +4786,7 @@ int slsDetector::updateReceiverNoWait() { int slsDetector::updateReceiver() { int fnum = F_UPDATE_RECEIVER_CLIENT; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Sending update client to receiver server"; + FILE_LOG(logDEBUG1) << "Sending update client to receiver server"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); @@ -4797,7 +4805,7 @@ void slsDetector::sendMultiDetectorSize() { int ret = FAIL; int args[2] = {thisDetector->multiSize[0], thisDetector->multiSize[1]}; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending multi detector size to Receiver (" << + FILE_LOG(logDEBUG1) << "Sending multi detector size to Receiver (" << thisDetector->multiSize[0] << "," << thisDetector->multiSize[1] << ")"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { @@ -4808,7 +4816,7 @@ void slsDetector::sendMultiDetectorSize() { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_MULTI_DET_SIZE_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver multi size returned: " << retval; + FILE_LOG(logDEBUG1) << "Receiver multi size returned: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4821,7 +4829,7 @@ void slsDetector::setDetectorId() { int ret = FAIL; int arg = detId; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending detector pos id to Receiver " << detId; + FILE_LOG(logDEBUG1) << "Sending detector pos id to Receiver " << detId; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4831,7 +4839,7 @@ void slsDetector::setDetectorId() { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DET_POSID_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver Position Id returned: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Position Id returned: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4845,7 +4853,7 @@ void slsDetector::setDetectorHostname() { char args[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; strcpy(args, thisDetector->hostname); - FILE_LOG(logDEBUG5) << "Sending detector hostname to Receiver " << args; + FILE_LOG(logDEBUG1) << "Sending detector hostname to Receiver " << args; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -4855,7 +4863,7 @@ void slsDetector::setDetectorHostname() { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver set detector hostname: " << retvals; + FILE_LOG(logDEBUG1) << "Receiver set detector hostname: " << retvals; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -4875,7 +4883,7 @@ std::string slsDetector::setFilePath(std::string s) { char args[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; strcpy(args, s.c_str()); - FILE_LOG(logDEBUG5) << "Sending file path to Receiver " << args; + FILE_LOG(logDEBUG1) << "Sending file path to Receiver " << args; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -4889,7 +4897,7 @@ std::string slsDetector::setFilePath(std::string s) { } else setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file path: " << retvals; + FILE_LOG(logDEBUG1) << "Receiver file path: " << retvals; strcpy(thisDetector->receiver_filePath, retvals); if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -4912,7 +4920,7 @@ std::string slsDetector::setFileName(std::string s) { char args[MAX_STR_LENGTH] = {0}; char retvals[MAX_STR_LENGTH] = {0}; strcpy(args, s.c_str()); - FILE_LOG(logDEBUG5) << "Sending file name to Receiver " << args; + FILE_LOG(logDEBUG1) << "Sending file name to Receiver " << args; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, args, sizeof(args), retvals, sizeof(retvals)); @@ -4922,7 +4930,7 @@ std::string slsDetector::setFileName(std::string s) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file name: " << retvals; + FILE_LOG(logDEBUG1) << "Receiver file name: " << retvals; strcpy(thisDetector->receiver_fileName, retvals); if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -4939,7 +4947,7 @@ int slsDetector::setReceiverFramesPerFile(int f) { int ret = FAIL; int arg = f; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting receiver frames per file to " << arg; + FILE_LOG(logDEBUG1) << "Setting receiver frames per file to " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4949,7 +4957,7 @@ int slsDetector::setReceiverFramesPerFile(int f) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver frames per file: " << retval; + FILE_LOG(logDEBUG1) << "Receiver frames per file: " << retval; thisDetector->receiver_framesPerFile = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -4965,7 +4973,7 @@ slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy( int ret = FAIL; int arg = (int)f; frameDiscardPolicy retval = (frameDiscardPolicy)-1; - FILE_LOG(logDEBUG5) << "Setting receiver frames discard policy to " << arg; + FILE_LOG(logDEBUG1) << "Setting receiver frames discard policy to " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -4975,7 +4983,7 @@ slsDetectorDefs::frameDiscardPolicy slsDetector::setReceiverFramesDiscardPolicy( if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver frames discard policy: " << retval; + FILE_LOG(logDEBUG1) << "Receiver frames discard policy: " << retval; thisDetector->receiver_frameDiscardMode = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -4991,7 +4999,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) { int ret = FAIL; int arg = f; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting receiver partial frames enable to " << arg; + FILE_LOG(logDEBUG1) << "Setting receiver partial frames enable to " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5001,7 +5009,7 @@ int slsDetector::setReceiverPartialFramesPadding(int f) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver partial frames enable: " << retval; + FILE_LOG(logDEBUG1) << "Receiver partial frames enable: " << retval; thisDetector->receiver_framePadding = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5018,7 +5026,7 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { int ret = FAIL; int arg = f; fileFormat retval = (fileFormat)-1; - FILE_LOG(logDEBUG5) << "Setting receiver file format to " << arg; + FILE_LOG(logDEBUG1) << "Setting receiver file format to " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5028,7 +5036,7 @@ slsDetectorDefs::fileFormat slsDetector::setFileFormat(fileFormat f) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file format: " << retval; + FILE_LOG(logDEBUG1) << "Receiver file format: " << retval; thisDetector->receiver_fileFormatType = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5055,7 +5063,7 @@ int slsDetector::setFileIndex(int i) { int ret = FAIL; int arg = i; int retval = -1; - FILE_LOG(logDEBUG5) << "Setting file index to " << arg; + FILE_LOG(logDEBUG1) << "Setting file index to " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5065,7 +5073,7 @@ int slsDetector::setFileIndex(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file index: " << retval; + FILE_LOG(logDEBUG1) << "Receiver file index: " << retval; thisDetector->receiver_fileIndex = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5087,7 +5095,7 @@ int slsDetector::startReceiver() { int fnum = F_START_RECEIVER; int ret = FAIL; char mess[MAX_STR_LENGTH] = {0}; - FILE_LOG(logDEBUG5) << "Starting Receiver"; + FILE_LOG(logDEBUG1) << "Starting Receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0, mess); @@ -5111,7 +5119,7 @@ int slsDetector::startReceiver() { int slsDetector::stopReceiver() { int fnum = F_STOP_RECEIVER; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Stopping Receiver"; + FILE_LOG(logDEBUG1) << "Stopping Receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); @@ -5131,7 +5139,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { int fnum = F_GET_RECEIVER_STATUS; int ret = FAIL; runStatus retval = ERROR; - FILE_LOG(logDEBUG5) << "Getting Receiver Status"; + FILE_LOG(logDEBUG1) << "Getting Receiver Status"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -5141,7 +5149,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Receiver Status: " << runStatusType(retval); + FILE_LOG(logDEBUG1) << "Receiver Status: " << runStatusType(retval); if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5154,7 +5162,7 @@ int slsDetector::getFramesCaughtByReceiver() { int fnum = F_GET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Getting Frames Caught by Receiver"; + FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -5164,7 +5172,7 @@ int slsDetector::getFramesCaughtByReceiver() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Frames Caught by Receiver: " << retval; + FILE_LOG(logDEBUG1) << "Frames Caught by Receiver: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5177,7 +5185,7 @@ int slsDetector::getReceiverCurrentFrameIndex() { int fnum = F_GET_RECEIVER_FRAME_INDEX; int ret = FAIL; int retval = -1; - FILE_LOG(logDEBUG5) << "Getting Current Frame Index of Receiver"; + FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, &retval, sizeof(retval)); @@ -5187,7 +5195,7 @@ int slsDetector::getReceiverCurrentFrameIndex() { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Current Frame Index of Receiver: " << retval; + FILE_LOG(logDEBUG1) << "Current Frame Index of Receiver: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5199,7 +5207,7 @@ int slsDetector::getReceiverCurrentFrameIndex() { int slsDetector::resetFramesCaught() { int fnum = F_RESET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Reset Frames Caught by Receiver"; + FILE_LOG(logDEBUG1) << "Reset Frames Caught by Receiver"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); @@ -5221,7 +5229,7 @@ int slsDetector::enableWriteToFile(int enable) { int ret = FAIL; int arg = enable; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending enable file write to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending enable file write to receiver: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5231,7 +5239,7 @@ int slsDetector::enableWriteToFile(int enable) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file write enable: " << retval; + FILE_LOG(logDEBUG1) << "Receiver file write enable: " << retval; thisDetector->receiver_fileWriteEnable = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5248,7 +5256,7 @@ int slsDetector::overwriteFile(int enable) { int ret = FAIL; int arg = enable; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending enable file overwrite to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending enable file overwrite to receiver: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5258,7 +5266,7 @@ int slsDetector::overwriteFile(int enable) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver file overwrite enable: " << retval; + FILE_LOG(logDEBUG1) << "Receiver file overwrite enable: " << retval; thisDetector->receiver_overWriteEnable = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5275,7 +5283,7 @@ int slsDetector::setReceiverStreamingFrequency(int freq) { int ret = FAIL; int arg = freq; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending read frequency to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending read frequency to receiver: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5285,7 +5293,7 @@ int slsDetector::setReceiverStreamingFrequency(int freq) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_STREAMING_FREQUENCY)); } else { - FILE_LOG(logDEBUG5) << "Receiver read frequency: " << retval; + FILE_LOG(logDEBUG1) << "Receiver read frequency: " << retval; thisDetector->receiver_read_freq = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5302,7 +5310,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) { int ret = FAIL; int arg = time_in_ms; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending read timer to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending read timer to receiver: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5312,7 +5320,7 @@ int slsDetector::setReceiverStreamingTimer(int time_in_ms) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_STREAMING_TIMER)); } else { - FILE_LOG(logDEBUG5) << "Receiver read timer: " << retval; + FILE_LOG(logDEBUG1) << "Receiver read timer: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5327,7 +5335,7 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) { int ret = FAIL; int arg = enable; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending Data Streaming to receiver: " << arg; + FILE_LOG(logDEBUG1) << "Sending Data Streaming to receiver: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5337,7 +5345,7 @@ int slsDetector::enableDataStreamingFromReceiver(int enable) { if (ret == FAIL) { setErrorMask((getErrorMask())|(DATA_STREAMING)); } else { - FILE_LOG(logDEBUG5) << "Receiver Data Streaming: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Data Streaming: " << retval; thisDetector->receiver_upstream = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5353,7 +5361,7 @@ int slsDetector::enableTenGigabitEthernet(int i) { int ret = FAIL; int arg = i; int retval = -1; - FILE_LOG(logDEBUG5) << "Enabling / Disabling 10Gbe: " << arg; + FILE_LOG(logDEBUG1) << "Enabling / Disabling 10Gbe: " << arg; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5363,7 +5371,7 @@ int slsDetector::enableTenGigabitEthernet(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(DETECTOR_TEN_GIGA)); } else { - FILE_LOG(logDEBUG5) << "10Gbe: " << retval; + FILE_LOG(logDEBUG1) << "10Gbe: " << retval; thisDetector->tenGigaEnable = retval; if (ret == FORCE_UPDATE) ret = updateDetector(); @@ -5389,7 +5397,7 @@ int slsDetector::enableTenGigabitEthernet(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_TEN_GIGA)); } else { - FILE_LOG(logDEBUG5) << "Receiver 10Gbe enable: " << retval; + FILE_LOG(logDEBUG1) << "Receiver 10Gbe enable: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5404,7 +5412,7 @@ int slsDetector::setReceiverFifoDepth(int i) { int ret = FAIL; int arg = i; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending Receiver Fifo Depth: " << arg; + FILE_LOG(logDEBUG1) << "Sending Receiver Fifo Depth: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5414,7 +5422,7 @@ int slsDetector::setReceiverFifoDepth(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(COULD_NOT_SET_FIFO_DEPTH)); } else { - FILE_LOG(logDEBUG5) << "Receiver Fifo Depth: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Fifo Depth: " << retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); } @@ -5429,7 +5437,7 @@ int slsDetector::setReceiverSilentMode(int i) { int ret = FAIL; int arg = i; int retval = -1; - FILE_LOG(logDEBUG5) << "Sending Receiver Silent Mode: " << arg; + FILE_LOG(logDEBUG1) << "Sending Receiver Silent Mode: " << arg; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, &arg, sizeof(arg), &retval, sizeof(retval)); @@ -5439,7 +5447,7 @@ int slsDetector::setReceiverSilentMode(int i) { if (ret == FAIL) { setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); } else { - FILE_LOG(logDEBUG5) << "Receiver Data Streaming: " << retval; + FILE_LOG(logDEBUG1) << "Receiver Data Streaming: " << retval; thisDetector->receiver_silentMode = retval; if (ret == FORCE_UPDATE) ret = updateReceiver(); @@ -5454,7 +5462,7 @@ int slsDetector::setReceiverSilentMode(int i) { int slsDetector::restreamStopFromReceiver() { int fnum = F_RESTREAM_STOP_FROM_RECEIVER; int ret = FAIL; - FILE_LOG(logDEBUG5) << "Restream stop dummy from Receiver via zmq"; + FILE_LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq"; if (thisDetector->receiverOnlineFlag == ONLINE_FLAG && connectData() == OK) { ret = thisReceiver->Client_Send(fnum, NULL, 0, NULL, 0); @@ -5493,7 +5501,7 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) { int mode = 0; // sets word uint64_t args[3] = {(uint64_t) mode, (uint64_t)addr, word}; uint64_t retval = -1; - FILE_LOG(logDEBUG5) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; + FILE_LOG(logDEBUG1) << "Setting CTB word, addr: 0x" << std::hex << addr << ", word: 0x" << word << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -5503,7 +5511,7 @@ uint64_t slsDetector::setCTBWord(int addr, uint64_t word) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Set CTB word: " << retval; + FILE_LOG(logDEBUG1) << "Set CTB word: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -5518,7 +5526,7 @@ int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { int mode = 1; // sets loop uint64_t args[5] = {(uint64_t) mode, (uint64_t)level, (uint64_t)start, (uint64_t)stop, (uint64_t)n}; uint64_t retvals[3] = {0, 0, 0}; - FILE_LOG(logDEBUG5) << "Setting CTB Pat Loops, " + FILE_LOG(logDEBUG1) << "Setting CTB Pat Loops, " "level: " << level << ", start: " << start << ", stop: " << stop << ", n: " << n; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -5529,7 +5537,7 @@ int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Set CTB Pat Loops: " << + FILE_LOG(logDEBUG1) << "Set CTB Pat Loops: " << retvals[0] << ", " << retvals[1] << ", " << retvals[2]; start = retvals[0]; stop = retvals[1]; @@ -5548,7 +5556,7 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) { int mode = 2; // sets loop uint64_t args[3] = {(uint64_t) mode, (uint64_t)level, (uint64_t)addr}; uint64_t retval = -1; - FILE_LOG(logDEBUG5) << "Setting CTB Wait Addr, " + FILE_LOG(logDEBUG1) << "Setting CTB Wait Addr, " "level: " << level << ", addr: 0x" << std::hex << addr << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { @@ -5559,7 +5567,7 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Set CTB Wait Addr: " << retval; + FILE_LOG(logDEBUG1) << "Set CTB Wait Addr: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -5574,7 +5582,7 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { int mode = 3; // sets loop uint64_t args[3] = {(uint64_t) mode, (uint64_t)level, t}; uint64_t retval = -1; - FILE_LOG(logDEBUG5) << "Setting CTB Wait Time, level: " << level << ", t: " << t; + FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); @@ -5584,7 +5592,7 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { if (ret == FAIL) { setErrorMask((getErrorMask())|(OTHER_ERROR_CODE)); } else { - FILE_LOG(logDEBUG5) << "Set CTB Wait Time: " << retval; + FILE_LOG(logDEBUG1) << "Set CTB Wait Time: " << retval; if (ret == FORCE_UPDATE) ret = updateDetector(); } @@ -5656,7 +5664,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::interpolateTrim( slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string fname, sls_detector_module* myMod, int tb) { - FILE_LOG(logDEBUG5) << "Read settings file " << fname; + FILE_LOG(logDEBUG1) << "Read settings file " << fname; // flag creating module to delete later bool modCreated = false; @@ -5751,9 +5759,9 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string return NULL; } for(int i = 0; i < myMod->ndac; ++i) - FILE_LOG(logDEBUG5) << "dac " << i << ":" << myMod->dacs[i]; - FILE_LOG(logDEBUG5) << "iodelay:" << myMod->iodelay; - FILE_LOG(logDEBUG5) << "tau:" << myMod->tau; + FILE_LOG(logDEBUG1) << "dac " << i << ":" << myMod->dacs[i]; + FILE_LOG(logDEBUG1) << "iodelay:" << myMod->iodelay; + FILE_LOG(logDEBUG1) << "tau:" << myMod->tau; } // gotthard, jungfrau @@ -5762,7 +5770,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string std::string str; while(infile.good()) { getline(infile,str); - FILE_LOG(logDEBUG5) << str; + FILE_LOG(logDEBUG1) << str; std::string sargname; int ival = 0; std::istringstream ssstr(str); @@ -5772,7 +5780,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string if (sargname == names[i]) { myMod->dacs[i] = ival; found = true; - FILE_LOG(logDEBUG5) << names[i] << "(" << i << "): " << ival; + FILE_LOG(logDEBUG1) << names[i] << "(" << i << "): " << ival; ++idac; } } @@ -5803,7 +5811,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(std::string int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) { - FILE_LOG(logDEBUG5) << "Write settings file " << fname; + FILE_LOG(logDEBUG1) << "Write settings file " << fname; std::vector names; switch (thisDetector->myDetectorType) { @@ -5871,7 +5879,7 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod) // gotthard, jungfrau else { for (int i = 0; i < mod.ndac; ++i) { - FILE_LOG(logDEBUG5) << "dac " << i << ": " << mod.dacs[i]; + FILE_LOG(logDEBUG1) << "dac " << i << ": " << mod.dacs[i]; outfile << names[i] << " " << (int)mod.dacs[i] << std::endl; } } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 673876488..fa2797a7b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -2726,7 +2726,7 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int d sscanf(args[1], "%ld",&ival); myDet->setRateCorrection(ival, detPos); } - sprintf(answer,"%lld",myDet->getRateCorrection(detPos)); + sprintf(answer,"%ld",myDet->getRateCorrection(detPos)); return string(answer); } diff --git a/slsReceiverSoftware/include/BinaryFileStatic.h b/slsReceiverSoftware/include/BinaryFileStatic.h index 7d2445f61..b528f8d73 100644 --- a/slsReceiverSoftware/include/BinaryFileStatic.h +++ b/slsReceiverSoftware/include/BinaryFileStatic.h @@ -123,12 +123,14 @@ class BinaryFileStatic { { if(!owenable){ if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ - cprintf(RED,"Error in creating binary master file (without overwrite enable) %s\n",fname.c_str()); + FILE_LOG(logERROR) << "Could not create binary master file " + "(without overwrite enable) " << fname; fd = 0; return 1; } }else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){ - cprintf(RED,"Error in creating binary master file (with overwrite enable) %s\n",fname.c_str()); + FILE_LOG(logERROR) << "Could not create binary master file " + "(with overwrite enable) " << fname; fd = 0; return 1; } @@ -179,8 +181,8 @@ class BinaryFileStatic { (long long int)acquisitionPeriod, ctime(&t)); if (strlen(message) > MAX_MASTER_FILE_LENGTH) { - cprintf(RED,"Master File Size %d is greater than max str size %d\n", - (int)strlen(message), MAX_MASTER_FILE_LENGTH); + FILE_LOG(logERROR) << "Master File Size " << strlen(message) << + " is greater than max str size " << MAX_MASTER_FILE_LENGTH; return 1; } diff --git a/slsReceiverSoftware/include/File.h b/slsReceiverSoftware/include/File.h index afe1a9aba..750c2296e 100644 --- a/slsReceiverSoftware/include/File.h +++ b/slsReceiverSoftware/include/File.h @@ -53,7 +53,7 @@ class File : private virtual slsDetectorDefs { /** * Print all member values */ - virtual void PrintMembers(); + virtual void PrintMembers(TLogLevel level = logDEBUG1); /** * Get Type @@ -85,8 +85,8 @@ class File : private virtual slsDetectorDefs { * @returns OK or FAIL */ virtual int CreateFile(uint64_t fnum){ - cprintf(RED,"This is a generic function CreateFile that should be " - "overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function CreateFile that should be " + "overloaded by a derived class"; return OK; } @@ -94,16 +94,16 @@ class File : private virtual slsDetectorDefs { * Close Current File */ virtual void CloseCurrentFile() { - cprintf(RED,"This is a generic function CloseCurrentFile that should be " - "overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function CloseCurrentFile that should be " + "overloaded by a derived class"; } /** * Close Files */ virtual void CloseAllFiles() { - cprintf(RED,"This is a generic function that should be overloaded " - "by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded " + "by a derived class"; } /** @@ -114,8 +114,8 @@ class File : private virtual slsDetectorDefs { * @param OK or FAIL */ virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) { - cprintf(RED,"This is a generic function WriteToFile that " - "should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function WriteToFile that " + "should be overloaded by a derived class"; return FAIL; } @@ -134,8 +134,8 @@ class File : private virtual slsDetectorDefs { virtual int CreateMasterFile(bool en, uint32_t size, uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp, uint64_t ap) { - cprintf(RED,"This is a generic function CreateMasterFile that " - "should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function CreateMasterFile that " + "should be overloaded by a derived class"; return OK; } @@ -146,8 +146,8 @@ class File : private virtual slsDetectorDefs { * @param ny number of pixels in y direction */ virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) { - cprintf(RED,"This is a generic function SetNumberofPixels that " - "should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function SetNumberofPixels that " + "should be overloaded by a derived class"; } /** @@ -156,8 +156,8 @@ class File : private virtual slsDetectorDefs { * @param numf number of images caught */ virtual void EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { - cprintf(RED,"This is a generic function EndofAcquisition that " - "should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function EndofAcquisition that " + "should be overloaded by a derived class"; } protected: diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index ad97a15f2..0ee8a0ec6 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -161,7 +161,7 @@ public: * @param i ROI */ virtual void SetROI(std::vector i) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; }; /** @@ -171,7 +171,7 @@ public: * @returns adc configured */ virtual const int GetAdcConfigured(int index, std::vector* i) const{ - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; return 0; }; @@ -181,7 +181,7 @@ public: * @param tgEnable true if 10GbE is enabled, else false */ virtual void SetDynamicRange(int dr, bool tgEnable) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; }; /** @@ -190,7 +190,7 @@ public: * @param dr dynamic range */ virtual void SetTenGigaEnable(bool tgEnable, int dr) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; }; /** @@ -199,7 +199,7 @@ public: * @param nroich number of channels in roi */ virtual void setNumberofSamples(const uint64_t ns, uint32_t nroich) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; }; /** @@ -207,38 +207,38 @@ public: * @param enable true if gap pixels enable, else false */ virtual void SetGapPixelsEnable(bool b, int dr) { - cprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + FILE_LOG(logERROR) << "This is a generic function that should be overloaded by a derived class"; }; /** * Print all variables */ - virtual void Print() const { - FILE_LOG(logDEBUG) << "\n\nDetector Data Variables:"; - FILE_LOG(logDEBUG) << "myDetectorType: " << slsDetectorDefs::getDetectorType(myDetectorType); - FILE_LOG(logDEBUG) << "Pixels X: " << nPixelsX; - FILE_LOG(logDEBUG) << "Pixels Y: " << nPixelsY; - FILE_LOG(logDEBUG) << "Empty Header: " << emptyHeader; - FILE_LOG(logDEBUG) << "Header Size in Packet: " << headerSizeinPacket; - FILE_LOG(logDEBUG) << "Data Size: " << dataSize; - FILE_LOG(logDEBUG) << "Packet Size: " << packetSize; - FILE_LOG(logDEBUG) << "Packets per Frame: " << packetsPerFrame; - FILE_LOG(logDEBUG) << "Image Size: " << imageSize; - FILE_LOG(logDEBUG) << "Frame Index Mask: " << frameIndexMask; - FILE_LOG(logDEBUG) << "Frame Index Offset: " << frameIndexOffset; - FILE_LOG(logDEBUG) << "Packet Index Mask: " << packetIndexMask; - FILE_LOG(logDEBUG) << "Packet Index Offset: " << packetIndexOffset; - FILE_LOG(logDEBUG) << "Max Frames Per File: " << maxFramesPerFile; - FILE_LOG(logDEBUG) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize; - FILE_LOG(logDEBUG) << "Default Fifo Depth: " << defaultFifoDepth; - FILE_LOG(logDEBUG) << "Threads Per Receiver: " << threadsPerReceiver; - FILE_LOG(logDEBUG) << "Header Packet Size: " << headerPacketSize; - FILE_LOG(logDEBUG) << "Complete Pixels X: " << nPixelsXComplete; - FILE_LOG(logDEBUG) << "Complete Pixels Y: " << nPixelsYComplete; - FILE_LOG(logDEBUG) << "Complete Image Size: " << imageSizeComplete; - FILE_LOG(logDEBUG) << "Standard Header: " << standardheader; - FILE_LOG(logDEBUG) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize; + virtual void Print(TLogLevel level = logDEBUG1) const { + FILE_LOG(level) << "\n\nDetector Data Variables:"; + FILE_LOG(level) << "myDetectorType: " << slsDetectorDefs::getDetectorType(myDetectorType); + FILE_LOG(level) << "Pixels X: " << nPixelsX; + FILE_LOG(level) << "Pixels Y: " << nPixelsY; + FILE_LOG(level) << "Empty Header: " << emptyHeader; + FILE_LOG(level) << "Header Size in Packet: " << headerSizeinPacket; + FILE_LOG(level) << "Data Size: " << dataSize; + FILE_LOG(level) << "Packet Size: " << packetSize; + FILE_LOG(level) << "Packets per Frame: " << packetsPerFrame; + FILE_LOG(level) << "Image Size: " << imageSize; + FILE_LOG(level) << "Frame Index Mask: " << frameIndexMask; + FILE_LOG(level) << "Frame Index Offset: " << frameIndexOffset; + FILE_LOG(level) << "Packet Index Mask: " << packetIndexMask; + FILE_LOG(level) << "Packet Index Offset: " << packetIndexOffset; + FILE_LOG(level) << "Max Frames Per File: " << maxFramesPerFile; + FILE_LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize; + FILE_LOG(level) << "Default Fifo Depth: " << defaultFifoDepth; + FILE_LOG(level) << "Threads Per Receiver: " << threadsPerReceiver; + FILE_LOG(level) << "Header Packet Size: " << headerPacketSize; + FILE_LOG(level) << "Complete Pixels X: " << nPixelsXComplete; + FILE_LOG(level) << "Complete Pixels Y: " << nPixelsYComplete; + FILE_LOG(level) << "Complete Image Size: " << imageSizeComplete; + FILE_LOG(level) << "Standard Header: " << standardheader; + FILE_LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize; }; }; diff --git a/slsReceiverSoftware/include/HDF5File.h b/slsReceiverSoftware/include/HDF5File.h index dcd1e7760..81390c542 100644 --- a/slsReceiverSoftware/include/HDF5File.h +++ b/slsReceiverSoftware/include/HDF5File.h @@ -55,7 +55,7 @@ class HDF5File : private virtual slsDetectorDefs, public File, public HDF5FileSt /** * Print all member values */ - void PrintMembers(); + void PrintMembers(TLogLevel level = logDEBUG1); /** * Set Number of pixels diff --git a/slsReceiverSoftware/include/HDF5FileStatic.h b/slsReceiverSoftware/include/HDF5FileStatic.h index 38e304c6d..123bda26f 100644 --- a/slsReceiverSoftware/include/HDF5FileStatic.h +++ b/slsReceiverSoftware/include/HDF5FileStatic.h @@ -112,7 +112,7 @@ public: fd = 0; } } catch(Exception error) { - cprintf(RED,"Error in closing HDF5 handles of index %d\n", ind); + FILE_LOG(logERROR) << "Could not close HDF5 handles of index " << ind; error.printErrorStack(); } } @@ -130,7 +130,7 @@ public: fd = 0; } } catch(Exception error) { - cprintf(RED,"Error in closing master HDF5 handles\n"); + FILE_LOG(logERROR) << "Could not close master HDF5 handles"; error.printErrorStack(); } } @@ -144,7 +144,7 @@ public: { if(fd) { if (H5Fclose(fd) < 0 ) - cprintf(RED,"Error in closing virtual HDF5 handles\n"); + FILE_LOG(logERROR) << "Could not close virtual HDF5 handles"; fd = 0; } } @@ -177,7 +177,7 @@ public: memspace.close(); } catch(Exception error){ - cprintf(RED,"Error in writing to file in object %d\n",ind); + FILE_LOG(logERROR) << "Could not write to file in object " << ind; error.printErrorStack(); return 1; } @@ -239,7 +239,7 @@ public: }i=14; } catch(Exception error){ - cprintf(RED,"Error in writing parameters (index:%d) to file in object %d\n", i, ind); + FILE_LOG(logERROR) << "Could not write parameters (index:" << i << ") to file in object " << ind; error.printErrorStack(); return 1; } @@ -282,7 +282,7 @@ public: } catch(Exception error){ - cprintf(RED,"Error in extending dataset in object %d\n",ind); + FILE_LOG(logERROR) << "Could not extend dataset in object " << ind; error.printError(); return 1; } @@ -417,7 +417,7 @@ public: fd->close(); } catch(Exception error) { - cprintf(RED,"Error in creating master HDF5 handles\n"); + FILE_LOG(logERROR) << "Could not create master HDF5 handles"; error.printErrorStack(); if (fd) fd->close(); return 1; @@ -521,7 +521,7 @@ public: } } catch(Exception error){ - cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind); + FILE_LOG(logERROR) << "Could not create HDF5 handles in object " << ind; error.printErrorStack(); if (fd) fd->close(); return 1; @@ -571,36 +571,36 @@ public: hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); if (dfal < 0) return CloseFileOnError(fd, - std::string("Error in creating file access property for virtual file ") + std::string("Could not create file access property for virtual file ") + virtualFileName + std::string("\n")); if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) return CloseFileOnError(fd, - std::string("Error in setting strong file close degree for virtual file ") + std::string("Could not set strong file close degree for virtual file ") + virtualFileName + std::string("\n")); fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal); if (fd < 0) return CloseFileOnError(fd, - std::string("Error in creating virtual file ") + virtualFileName + std::string("\n")); + std::string("Could not create virtual file ") + virtualFileName + std::string("\n")); //attributes - version hid_t dataspace_attr = H5Screate (H5S_SCALAR); if (dataspace_attr < 0) return CloseFileOnError(fd, - std::string("Error in creating dataspace for attribute in virtual file ") + std::string("Could not create dataspace for attribute in virtual file ") + virtualFileName + std::string("\n")); hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT); if (attrid < 0) return CloseFileOnError(fd, - std::string("Error in creating attribute in virtual file ") + std::string("Could not create attribute in virtual file ") + virtualFileName + std::string("\n")); double attr_data = version; if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0) return CloseFileOnError(fd, - std::string("Error in writing attribute in virtual file ") + std::string("Could not write attribute in virtual file ") + virtualFileName + std::string("\n")); if (H5Aclose (attrid) < 0) return CloseFileOnError(fd, - std::string("Error in closing attribute in virtual file ") + std::string("Could not close attribute in virtual file ") + virtualFileName + std::string("\n")); @@ -609,13 +609,13 @@ public: hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL); if (vdsDataspace < 0) return CloseFileOnError(fd, - std::string("Error in creating virtual dataspace in virtual file ") + std::string("Could not create virtual dataspace in virtual file ") + virtualFileName + std::string("\n")); hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz}; hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL); if (vdsDataspace_para < 0) return CloseFileOnError(fd, - std::string("Error in creating virtual dataspace (parameters) in virtual file ") + std::string("Could not create virtual dataspace (parameters) in virtual file ") + virtualFileName + std::string("\n")); @@ -623,23 +623,23 @@ public: hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE); if (dcpl < 0) return CloseFileOnError(fd, - std::string("Error in creating file creation properties in virtual file ") + std::string("Could not create file creation properties in virtual file ") + virtualFileName + std::string("\n")); int fill_value = -1; if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0) return CloseFileOnError(fd, - std::string("Error in creating fill value in virtual file ") + std::string("Could not create fill value in virtual file ") + virtualFileName + std::string("\n")); hid_t dcpl_para[parameterNames.size()]; for (unsigned int i = 0; i < parameterNames.size(); ++i) { dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE); if (dcpl_para[i] < 0) return CloseFileOnError(fd, - std::string("Error in creating file creation properties (parameters) in virtual file ") + std::string("Could not create file creation properties (parameters) in virtual file ") + virtualFileName + std::string("\n")); if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0) return CloseFileOnError(fd, - std::string("Error in creating fill value (parameters) in virtual file ") + std::string("Could not create fill value (parameters) in virtual file ") + virtualFileName + std::string("\n")); } @@ -661,13 +661,13 @@ public: //setect hyperslabs if (H5Sselect_hyperslab (vdsDataspace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) { - cprintf(RED,"could not select hyperslab\n"); + FILE_LOG(logERROR) << "Could not select hyperslab"; error = true; break; } if (H5Sselect_hyperslab (vdsDataspace_para, H5S_SELECT_SET, offset_para, NULL, count_para, NULL) < 0) { - cprintf(RED,"could not select hyperslab for parameters\n"); + FILE_LOG(logERROR) << "Could not select hyperslab for parameters"; error = true; break; } @@ -696,20 +696,20 @@ public: hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax); if (srcDataspace < 0) return CloseFileOnError(fd, - std::string("Error in creating source dataspace in virtual file ") + std::string("Could not create source dataspace in virtual file ") + virtualFileName + std::string("\n")); hsize_t srcdims_para[1] = {nDimx}; hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED}; hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para); if (srcDataspace_para < 0) return CloseFileOnError(fd, - std::string("Error in creating source dataspace (parameters) in virtual file ") + std::string("Could not create source dataspace (parameters) in virtual file ") + virtualFileName + std::string("\n")); //mapping if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(), srcDatasetName.c_str(), srcDataspace) < 0) { - cprintf(RED,"could not set mapping for paramter 1\n"); + FILE_LOG(logERROR) << "Could not set mapping for paramter 1"; error = true; break; } @@ -717,7 +717,7 @@ public: for (unsigned int k = 0; k < parameterNames.size(); ++k) { if (H5Pset_virtual(dcpl_para[k], vdsDataspace_para, relative_srcFileName.c_str(), parameterNames[k], srcDataspace_para) < 0) { - cprintf(RED,"could not set mapping for paramter %d\n", k); + FILE_LOG(logERROR) << "Could not set mapping for paramter " << k; error = true; break; } @@ -736,7 +736,7 @@ public: } if (error) return CloseFileOnError(fd, - std::string("Error in mapping files in virtual file ") + std::string("Could not map files in virtual file ") + virtualFileName + std::string("\n")); //dataset @@ -745,7 +745,7 @@ public: GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); if (vdsdataset < 0) return CloseFileOnError(fd, - std::string("Error in creating virutal dataset in virtual file ") + std::string("Could not create virutal dataset in virtual file ") + virtualFileName + std::string("\n")); @@ -757,7 +757,7 @@ public: H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT); if (vdsdataset_para < 0) return CloseFileOnError(fd, - std::string("Error in creating virutal dataset (parameters) in virtual file ") + std::string("Could not create virutal dataset (parameters) in virtual file ") + virtualFileName + std::string("\n")); } @@ -798,7 +798,7 @@ public: data_out = (T*)malloc(sizeof(T)*(nDimx*nDimy*nDimz)); break; default: - cprintf(RED,"invalid rank. Options: 2 or 3\n"); + FILE_LOG(logERROR) << "Invalid rank. Options: 2 or 3"; return 0; } if (datatype == PredType::STD_U16LE) { @@ -810,7 +810,7 @@ public: } else if (datatype == PredType::STD_U8LE) { FILE_LOG(logINFO) << "datatype:8"; } else { - FILE_LOG(logERROR) << "unknown datatype"; + FILE_LOG(logERROR) << "Unknown datatype: " << datetype; return 1; } FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl @@ -861,7 +861,7 @@ public: newfd->close(); oldfd->close(); } catch(Exception error){ - cprintf(RED,"Error in copying virtual files\n"); + FILE_LOG(logERROR) << "Could not copy virtual files"; error.printErrorStack(); free(data_out); oldfd->close(); @@ -890,20 +890,20 @@ public: hid_t dfal = H5Pcreate (H5P_FILE_ACCESS); if (dfal < 0) - return CloseFileOnError( vfd, std::string("Error in creating file access property for link\n")); + return CloseFileOnError( vfd, std::string("Could not create file access property for link\n")); if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0) - return CloseFileOnError( vfd, std::string("Error in setting strong file close degree for link\n")); + return CloseFileOnError( vfd, std::string("Could not set strong file close degree for link\n")); //open master file hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal); if (mfd < 0) - return CloseFileOnError( vfd, std::string("Error in opening master file\n")); + return CloseFileOnError( vfd, std::string("Could not open master file\n")); //open virtual file vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal); if (vfd < 0) { H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in opening virtual file\n")); + return CloseFileOnError( vfd, std::string("Could not open virtual file\n")); } // find relative path @@ -918,13 +918,13 @@ public: hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT); if (vdset < 0) { H5Fclose(mfd); - return CloseFileOnError( vfd, std::string("Error in opening virtual data dataset\n")); + return CloseFileOnError( vfd, std::string("Could not open virtual data dataset\n")); } sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str()); if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(), mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in creating link to data dataset\n")); + return CloseFileOnError( vfd, std::string("Could not create link to data dataset\n")); } H5Dclose(vdset); @@ -933,14 +933,14 @@ public: hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT); if (vdset_para < 0) { H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in opening virtual parameter dataset to create link\n")); + return CloseFileOnError( vfd, std::string("Could not open virtual parameter dataset to create link\n")); } sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str()); if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(), mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5Fclose(mfd); mfd = 0; - return CloseFileOnError( vfd, std::string("Error in creating link to virtual parameter dataset\n")); + return CloseFileOnError( vfd, std::string("Could not create link to virtual parameter dataset\n")); } } @@ -956,7 +956,7 @@ public: * @returns 1 for fail */ static int CloseFileOnError(hid_t& fd, const std::string msg) { - cprintf(RED, "%s", msg.c_str()); + FILE_LOG(logERROR) << msg; if(fd > 0) H5Fclose(fd); fd = 0; diff --git a/slsReceiverSoftware/src/BinaryFile.cpp b/slsReceiverSoftware/src/BinaryFile.cpp index 639c70328..47af53f20 100644 --- a/slsReceiverSoftware/src/BinaryFile.cpp +++ b/slsReceiverSoftware/src/BinaryFile.cpp @@ -106,8 +106,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_ // if write error if (ret != buffersize) { - cprintf(RED,"%d Error: Write to file failed for image number %lld\n", - index, (long long int)fnum); + FILE_LOG(logERROR) << index << " Error: Write to file failed for image number " << fnum; return FAIL; } return OK; diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index bce6e0379..f2825b5f5 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -166,18 +166,14 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) { firstAcquisitionIndex = fnum; } -#ifdef VERBOSE - cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", - index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); -#endif + FILE_LOG(logDEBUG1) << index << " First Acquisition Index:" << firstAcquisitionIndex << + "\tFirst Measurement Index:" << firstMeasurementIndex; } void DataProcessor::SetGeneralData(GeneralData* g) { generalData = g; -#ifdef VERY_VERBOSE generalData->Print(); -#endif if (file) { if (file->GetFileType() == HDF5) { file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY); @@ -278,16 +274,12 @@ void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) { void DataProcessor::ThreadExecution() { char* buffer=0; fifo->PopAddress(buffer); -#ifdef FIFODEBUG - if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", - index,(void*)(buffer),buffer); -#endif + FILE_LOG(logDEBUG5) << "DataProcessor " << index << ", " + "pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer; //check dummy uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); -#ifdef VERBOSE - if (!index) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes); -#endif + FILE_LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes; if (numBytes == DUMMY_PACKET_VALUE) { StopProcessing(buffer); return; @@ -304,10 +296,8 @@ void DataProcessor::ThreadExecution() { void DataProcessor::StopProcessing(char* buf) { -#ifdef VERBOSE - if (!index) - cprintf(RED,"DataProcessing %d: Dummy\n", index); -#endif + FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy"; + //stream or free if (*dataStreamEnable) fifo->PushAddressToStream(buf); @@ -317,9 +307,7 @@ void DataProcessor::StopProcessing(char* buf) { if (file) file->CloseCurrentFile(); StopRunning(); -#ifdef VERBOSE - FILE_LOG(logINFO) << index << ": Processing Completed"; -#endif + FILE_LOG(logDEBUG1) << index << ": Processing Completed"; } @@ -335,16 +323,9 @@ void DataProcessor::ProcessAnImage(char* buf) { numTotalFramesCaught++; } - -#ifdef VERBOSE - if (!index) - cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); -#endif + FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum; if (!measurementStartedFlag) { -#ifdef VERBOSE - if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum); -#endif RecordFirstIndices(fnum); if (*dataStreamEnable) { @@ -418,11 +399,10 @@ bool DataProcessor::SendToStreamer() { bool DataProcessor::CheckTimer() { struct timespec end; clock_gettime(CLOCK_REALTIME, &end); -#ifdef VERBOSE - cprintf(BLUE,"%d Timer elapsed time:%f seconds\n", index, - ( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) - / 1000000000.0); -#endif + + FILE_LOG(logDEBUG1) << index << " Timer elapsed time:" << + (( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0) + << " seconds"; //still less than streaming timer, keep waiting if((( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0) < ((double)*streamingTimerInMs/1000.00)) @@ -464,9 +444,8 @@ void DataProcessor::PadMissingPackets(char* buf) { uint32_t dsize = generalData->dataSize; uint32_t fifohsize = generalData->fifoBufferHeaderSize; uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize); -#ifdef VERBOSE - cprintf(RED,"bitmask:%s\n", pmask.to_string().c_str()); -#endif + FILE_LOG(logDEBUG1) << "bitmask: " << pmask.to_string(); + for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) { // not missing packet diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index fee9fca24..1f3427f8b 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -108,18 +108,14 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) { firstAcquisitionIndex = fnum; } -#ifdef VERBOSE - cprintf(BLUE,"%d First Acquisition Index:%lld\tFirst Measurement Index:%lld\n", - index, (long long int)firstAcquisitionIndex, (long long int)firstMeasurementIndex); -#endif + FILE_LOG(logDEBUG1) << index << " First Acquisition Index: " << firstAcquisitionIndex << + "\tFirst Measurement Index: " << firstMeasurementIndex; } void DataStreamer::SetGeneralData(GeneralData* g) { generalData = g; -#ifdef VERY_VERBOSE generalData->Print(); -#endif } int DataStreamer::SetThreadPriority(int priority) { @@ -138,7 +134,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci try { zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL)); } catch (...) { - cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index); + FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index; throw; } FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress(); @@ -156,15 +152,13 @@ void DataStreamer::CloseZmqSocket() { void DataStreamer::ThreadExecution() { char* buffer=0; fifo->PopAddressToStream(buffer); -#ifdef FIFODEBUG - if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); -#endif + FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", " + "pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer; + //check dummy uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer)); -#ifdef VERBOSE - cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes); -#endif + FILE_LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes; if (numBytes == DUMMY_PACKET_VALUE) { StopProcessing(buffer); return; @@ -180,20 +174,17 @@ void DataStreamer::ThreadExecution() { void DataStreamer::StopProcessing(char* buf) { -#ifdef VERBOSE - if (!index) - cprintf(RED,"DataStreamer %d: Dummy\n", index); -#endif + FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy"; + sls_receiver_header* header = (sls_receiver_header*) (buf); //send dummy header and data - if (!SendHeader(header, 0, 0, 0, true)) - cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index); + if (!SendHeader(header, 0, 0, 0, true)) { + FILE_LOG(logERROR) << "Could not send zmq dummy header for streamer " << index; + } fifo->FreeAddress(buf); StopRunning(); -#ifdef VERBOSE - FILE_LOG(logINFO) << index << ": Streaming Completed"; -#endif + FILE_LOG(logDEBUG1) << index << ": Streaming Completed"; } /** buf includes only the standard header */ @@ -201,14 +192,9 @@ void DataStreamer::ProcessAnImage(char* buf) { sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); uint64_t fnum = header->detHeader.frameNumber; -#ifdef VERBOSE - cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum); -#endif + FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum; if (!measurementStartedFlag) { -#ifdef VERBOSE - if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index, fnum); -#endif RecordFirstIndices(fnum); } @@ -220,17 +206,16 @@ void DataStreamer::ProcessAnImage(char* buf) { //write imagesize if (!SendHeader(header, generalData->imageSizeComplete, - generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) - cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", - (long long int) fnum, index); - + generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) { + FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index; + } memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); - if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) - cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", - (long long int) fnum, index); + if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) { + FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index; + } } @@ -238,14 +223,13 @@ void DataStreamer::ProcessAnImage(char* buf) { else { if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), - generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback - cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n", - (long long int) fnum, index); - + generalData->nPixelsX, generalData->nPixelsY, false)) {// new size possibly from callback + FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index; + } if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), - (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback - cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n", - (long long int) fnum, index); + (uint32_t)(*((uint32_t*)buf)) )) {// new size possibly from callback + FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index; + } } } diff --git a/slsReceiverSoftware/src/Fifo.cpp b/slsReceiverSoftware/src/Fifo.cpp index a39be358a..2e690ceb5 100644 --- a/slsReceiverSoftware/src/Fifo.cpp +++ b/slsReceiverSoftware/src/Fifo.cpp @@ -21,22 +21,21 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth): fifoDepth(depth), status_fifoBound(0), status_fifoFree(depth){ - FILE_LOG(logDEBUG) << __AT__ << " called"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(CreateFifos(fifoItemSize) == FAIL) throw std::exception(); } Fifo::~Fifo() { - FILE_LOG(logDEBUG) << __AT__ << " called"; - //cprintf(BLUE,"Fifo Object %d: Goodbye\n", index); + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; DestroyFifos(); } int Fifo::CreateFifos(uint32_t fifoItemSize) { - FILE_LOG(logDEBUG) << __AT__ << " called"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; //destroy if not already DestroyFifos(); @@ -69,7 +68,7 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) { void Fifo::DestroyFifos(){ - FILE_LOG(logDEBUG) << __AT__ << " called"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(memory) { free(memory); diff --git a/slsReceiverSoftware/src/File.cpp b/slsReceiverSoftware/src/File.cpp index d7748cb26..b72324e39 100644 --- a/slsReceiverSoftware/src/File.cpp +++ b/slsReceiverSoftware/src/File.cpp @@ -38,8 +38,8 @@ std::string File::GetCurrentFileName() { return currentFileName; } -void File::PrintMembers() { - FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << std::endl +void File::PrintMembers(TLogLevel level) { + FILE_LOG(level) << "\nGeneral Writer Variables:" << std::endl << "Index: " << index << std::endl << "Max Frames Per File: " << *maxFramesPerFile << std::endl << "Number of Detectors in x dir: " << numDetX << std::endl diff --git a/slsReceiverSoftware/src/HDF5File.cpp b/slsReceiverSoftware/src/HDF5File.cpp index f6a4ffe75..f494f48ea 100644 --- a/slsReceiverSoftware/src/HDF5File.cpp +++ b/slsReceiverSoftware/src/HDF5File.cpp @@ -38,9 +38,7 @@ HDF5File::HDF5File(int ind, uint32_t* maxf, dataspace_para(0), extNumImages(0) { -#ifdef VERBOSE PrintMembers(); -#endif dataset_para.clear(); parameterNames.clear(); parameterDataTypes.clear(); @@ -95,15 +93,15 @@ HDF5File::~HDF5File() { CloseAllFiles(); } -void HDF5File::PrintMembers() { +void HDF5File::PrintMembers(TLogLevel level) { File::PrintMembers(); UpdateDataType(); if (datatype == PredType::STD_U8LE) { - FILE_LOG(logINFO) << "Data Type: 4 or 8"; + FILE_LOG(level) << "Data Type: 4 or 8"; } else if (datatype == PredType::STD_U16LE) { - FILE_LOG(logINFO) << "Data Type: 16"; + FILE_LOG(level) << "Data Type: 16"; } else if (datatype == PredType::STD_U32LE) { - FILE_LOG(logINFO) << "Data Type: 32"; + FILE_LOG(level) << "Data Type: 32"; } else { FILE_LOG(logERROR) << "unknown data type"; } @@ -154,8 +152,6 @@ int HDF5File::CreateFile(uint64_t fnum) { return FAIL; } pthread_mutex_unlock(&Mutex); - if (dataspace == NULL) - cprintf(RED,"Got nothing!\n"); if(!(*silentMode)) { FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName; @@ -214,9 +210,8 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t if (HDF5FileStatic::ExtendDataset(index, dataspace, dataset, dataspace_para, dataset_para, *numImages) == OK) { if (!(*silentMode)) { - cprintf(BLUE,"%d Extending HDF5 dataset by %llu, Total x Dimension: %llu\n", - index, (long long unsigned int)extNumImages, - (long long unsigned int)(extNumImages + *numImages)); + FILE_LOG(logINFO) << index << " Extending HDF5 dataset by " << + extNumImages << ", Total x Dimension: " << (extNumImages + *numImages); } extNumImages += *numImages; } @@ -238,7 +233,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t } } pthread_mutex_unlock(&Mutex); - cprintf(RED,"%d Error: Write to file failed\n", index); + FILE_LOG(logERROR) << index << "Write to file failed"; return FAIL; } diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index b28b86377..3508a749d 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -159,19 +159,18 @@ void Listener::RecordFirstIndices(uint64_t fnum) { } if(!(*silentMode)) { - if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n" - "%d First Measurement Index:%lu\n", - index, firstAcquisitionIndex, - index, firstMeasurementIndex); + if (!index) { + FILE_LOG(logINFOBLUE) << index << + " First Acquisition Index: " << firstAcquisitionIndex; + FILE_LOG(logDEBUG1) << index << " First Measurement Index: " << firstMeasurementIndex; + } } } void Listener::SetGeneralData(GeneralData*& g) { generalData = g; -#ifdef VERY_VERBOSE generalData->Print(); -#endif } @@ -300,9 +299,8 @@ void Listener::ThreadExecution() { int rc = 0; fifo->GetNewAddress(buffer); -#ifdef FIFODEBUG - cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer); -#endif + FILE_LOG(logDEBUG5) << "Listener " << index << ", " + "pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer; //udpsocket doesnt exist if (*activated && !udpSocketAlive && !carryOverFlag) { @@ -320,7 +318,6 @@ void Listener::ThreadExecution() { //error check, (should not be here) if not transmitting yet (previous if) rc should be > 0 if (rc == 0) { - //cprintf(RED,"%d Socket shut down while waiting for future packet. udpsocketalive:%d\n",index, udpSocketAlive ); if (!udpSocketAlive) { (*((uint32_t*)buffer)) = 0; StopListening(buffer); @@ -362,10 +359,8 @@ void Listener::StopListening(char* buf) { StopRunning(); sem_post(&semaphore_socket); -#ifdef VERBOSE - cprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); - cprintf(GREEN,"%d: Listening Completed\n", index); -#endif + FILE_LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber << ") : " << numPacketsCaught; + FILE_LOG(logDEBUG1) << index << ": Listening Completed"; } @@ -418,7 +413,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { //look for carry over if (carryOverFlag) { - //cprintf(RED,"%d carry flag\n",index); + FILE_LOG(logDEBUG3) << index << "carry flag"; //check if its the current image packet // -------------------------- new header ---------------------------------------------------------------------- if (standardheader) { @@ -434,7 +429,8 @@ uint32_t Listener::ListenToAnImage(char* buf) { //------------------------------------------------------------------------------------------------------------ if (fnum != currentFrameIndex) { if (fnum < currentFrameIndex) { - cprintf(RED,"Error:(Weird), With carry flag: Frame number %lu less than current frame number %lu\n", fnum, currentFrameIndex); + FILE_LOG(logERROR) << "(Weird), With carry flag: Frame number " << + fnum << " less than current frame number " << currentFrameIndex; return 0; } switch(*frameDiscardMode) { @@ -551,25 +547,22 @@ uint32_t Listener::ListenToAnImage(char* buf) { // Eiger Firmware in a weird state if (myDetectorType == EIGER && fnum == 0) { - cprintf(RED,"[%u]: Got Frame Number Zero from Firmware. Discarding Packet\n", *udpPortNumber); + FILE_LOG(logERROR) << "[" << *udpPortNumber << "]: Got Frame Number " + "Zero from Firmware. Discarding Packet"; numPacketsCaught--; return 0; } lastCaughtFrameIndex = fnum; + FILE_LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex << + ", fnum:" << fnum << ", pnum:" << pnum << ", numpackets:" << numpackets; -#ifdef VERBOSE - //if (!index) - cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n", - index,currentFrameIndex, fnum, pnum, numpackets); -#endif if (!measurementStartedFlag) RecordFirstIndices(fnum); //future packet by looking at image number (all other detectors) if (fnum != currentFrameIndex) { - //cprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets ); carryOverFlag = true; memcpy(carryOverPacket,listeningPacket, generalData->packetSize); @@ -641,19 +634,18 @@ uint32_t Listener::ListenToAnImage(char* buf) { void Listener::PrintFifoStatistics() { -#ifdef VERBOSE - cout << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic << endl; -#endif + FILE_LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic; + //calculate packet loss int64_t loss = -1; loss = (numFramesStatistic*(generalData->packetsPerFrame)) - numPacketsStatistic; numPacketsStatistic = 0; numFramesStatistic = 0; - if (loss) - cprintf(RED,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound() , fifo->GetMinLevelForFifoFree(), currentFrameIndex); - else - cprintf(GREEN,"[%u]: Packet_Loss:%lu Used_Fifo_Max_Level:%d \tFree_Slots_Min_Level:%d \tCurrent_Frame#:%lu\n", - *udpPortNumber,loss, fifo->GetMaxLevelForFifoBound(), fifo->GetMinLevelForFifoFree(), currentFrameIndex); + FILE_LOG(loss ? logINFORED : logINFOGREEN) << "[" << *udpPortNumber << "]: " + "Packet_Loss:" << loss << + " Used_Fifo_Max_Level:" << fifo->GetMaxLevelForFifoBound() << + " \tFree_Slots_Min_Level:" << fifo->GetMinLevelForFifoFree() << + " \tCurrent_Frame#:" << currentFrameIndex; + } diff --git a/slsReceiverSoftware/src/ThreadObject.cpp b/slsReceiverSoftware/src/ThreadObject.cpp index cd381cc21..6c49d191f 100644 --- a/slsReceiverSoftware/src/ThreadObject.cpp +++ b/slsReceiverSoftware/src/ThreadObject.cpp @@ -74,7 +74,8 @@ void* ThreadObject::StartThread(void* thisPointer) { void ThreadObject::RunningThread() { - cprintf(BLUE,"Created [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Created [ " << GetType() << "Thread " << index << ", " + "Tid: " << syscall(SYS_gettid) << "]"; while(true) { while(IsRunning()) { @@ -88,7 +89,8 @@ void ThreadObject::RunningThread() { sem_wait(&semaphore); if(killThread) { - cprintf(BLUE,"Exiting [ %s Thread %d, Tid: %ld ]\n", GetType().c_str(),index, (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Exiting [ " << GetType() << + " Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]"; pthread_exit(NULL); } diff --git a/slsReceiverSoftware/src/main.cpp b/slsReceiverSoftware/src/main.cpp index 500c01748..d301dbb78 100644 --- a/slsReceiverSoftware/src/main.cpp +++ b/slsReceiverSoftware/src/main.cpp @@ -24,18 +24,21 @@ void sigInterruptHandler(int p){ keeprunning = false; } +/** Define Colors to print data call back in different colors for different recievers */ /* -int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ - printf("#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n", - filepath, filename, fileindex, datasize); +#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) - cprintf(BLUE, "--StartAcq: returning 0\n"); +int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){ + FILE_LOG(logINFO) << "#### StartAcq: " + "filepath: " << filepath << "filename: " << filename << + "fileindex: " << fileindex << "datasize: " << datasize << " ####"; + FILE_LOG(logINFO) << "--StartAcq: returning 0"; return 0; } void AcquisitionFinished(uint64_t frames, void*p){ - cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); + FILE_LOG(logINFO) << "#### AcquisitionFinished: frames:" << frames << " ####"; } @@ -45,16 +48,16 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, "#### %d GetData: ####\n" - "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu" - "\t\ttimestamp: %llu\t\tmodId: %u\t\t" - "xCrow%u\t\tcolumn: %u\t\tcolumn: %u\t\tdebug: %u" + "frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu" + "\t\ttimestamp: %lu\t\tmodId: %u\t\t" + "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" //"\t\tpacketsMask:%s" "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId, - detectorHeader.timestamp, detectorHeader.modId, - detectorHeader.row, detectorHeader.column, detectorHeader.column, + detectorHeader.row, (long unsigned int)detectorHeader.frameNumber, + detectorHeader.expLength, detectorHeader.packetNumber, (long unsigned int)detectorHeader.bunchId, + (long unsigned int)detectorHeader.timestamp, detectorHeader.modId, + detectorHeader.row, detectorHeader.column, detectorHeader.reserved, detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.detType, detectorHeader.version, //header->packetsMask.to_string().c_str(), @@ -66,7 +69,7 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ int main(int argc, char *argv[]) { keeprunning = true; - cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]"; // Catch signal SIGINT to close files and call destructors properly struct sigaction sa; @@ -74,7 +77,7 @@ int main(int argc, char *argv[]) { sa.sa_handler=sigInterruptHandler; // handler function sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler if (sigaction(SIGINT, &sa, NULL) == -1) { - cprintf(RED, "Could not set handler function for SIGINT\n"); + FILE_LOG(logERROR) << "Could not set handler function for SIGINT"; } @@ -85,7 +88,7 @@ int main(int argc, char *argv[]) { asa.sa_handler=SIG_IGN; // handler function sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler if (sigaction(SIGPIPE, &asa, NULL) == -1) { - cprintf(RED, "Could not set handler function for SIGPIPE\n"); + FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE"; } @@ -93,7 +96,7 @@ int main(int argc, char *argv[]) { slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret); if(ret==slsDetectorDefs::FAIL){ delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; exit(EXIT_FAILURE); } @@ -142,18 +145,18 @@ int main(int argc, char *argv[]) { //start tcp server thread if (receiver->start() == slsDetectorDefs::FAIL){ delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; exit(EXIT_FAILURE); } FILE_LOG(logINFO) << "Ready ... "; - cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n"); + FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]"; while(keeprunning) pause(); delete receiver; - cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); - FILE_LOG(logINFO) << "Goodbye!"; + FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]"; + FILE_LOG(logINFO) << "Exiting Receiver"; return 0; } diff --git a/slsReceiverSoftware/src/slsReceiverImplementation.cpp b/slsReceiverSoftware/src/slsReceiverImplementation.cpp index 35c6813fc..94a156e76 100644 --- a/slsReceiverSoftware/src/slsReceiverImplementation.cpp +++ b/slsReceiverSoftware/src/slsReceiverImplementation.cpp @@ -24,16 +24,19 @@ /** cosntructor & destructor */ slsReceiverImplementation::slsReceiverImplementation() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; InitializeMembers(); } slsReceiverImplementation::~slsReceiverImplementation() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; DeleteMembers(); } void slsReceiverImplementation::DeleteMembers() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if (generalData) { delete generalData; generalData=0; @@ -58,7 +61,7 @@ void slsReceiverImplementation::DeleteMembers() { void slsReceiverImplementation::InitializeMembers() { - + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; //**detector parameters*** myDetectorType = GENERIC; for (int i = 0; i < MAX_DIMENSIONS; ++i) @@ -113,7 +116,7 @@ void slsReceiverImplementation::InitializeMembers() { dataStreamEnable = false; streamingPort = 0; memset(streamingSrcIP, 0, sizeof(streamingSrcIP)); - memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader)); + memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader)); //** class objects *** generalData = 0; @@ -135,77 +138,77 @@ void slsReceiverImplementation::InitializeMembers() { /**initial parameters***/ int* slsReceiverImplementation::getMultiDetectorSize() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return (int*) numDet; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return (int*) numDet; } int slsReceiverImplementation::getDetectorPositionId() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return detID; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return detID; } std::string slsReceiverImplementation::getDetectorHostname() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return std::string(detHostname); } int slsReceiverImplementation::getFlippedData(int axis) const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(axis<0 || axis > 1) return -1; return flippedData[axis]; } bool slsReceiverImplementation::getGapPixelsEnable() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return gapPixelsEnable; } /***file parameters***/ slsDetectorDefs::fileFormat slsReceiverImplementation::getFileFormat() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileFormatType; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return fileFormatType; } std::string slsReceiverImplementation::getFileName() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return std::string(fileName); } std::string slsReceiverImplementation::getFilePath() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return std::string(filePath); } uint64_t slsReceiverImplementation::getFileIndex() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileIndex; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return fileIndex; } uint32_t slsReceiverImplementation::getFramesPerFile() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return framesPerFile; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return framesPerFile; } slsDetectorDefs::frameDiscardPolicy slsReceiverImplementation::getFrameDiscardPolicy() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return frameDiscardMode; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return frameDiscardMode; } bool slsReceiverImplementation::getFramePaddingEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return framePadding; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return framePadding; } bool slsReceiverImplementation::getFileWriteEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fileWriteEnable; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return fileWriteEnable; } bool slsReceiverImplementation::getOverwriteEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return overwriteEnable; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return overwriteEnable; } @@ -261,130 +264,130 @@ int64_t slsReceiverImplementation::getAcquisitionIndex() const { /***connection parameters***/ uint32_t slsReceiverImplementation::getUDPPortNumber() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpPortNum[0]; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return udpPortNum[0]; } uint32_t slsReceiverImplementation::getUDPPortNumber2() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpPortNum[1]; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return udpPortNum[1]; } std::string slsReceiverImplementation::getEthernetInterface() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return std::string(eth); } /***acquisition parameters***/ std::vector slsReceiverImplementation::getROI() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return roi; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return roi; } uint32_t slsReceiverImplementation::getStreamingFrequency() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return streamingFrequency; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return streamingFrequency; } uint32_t slsReceiverImplementation::getStreamingTimer() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return streamingTimerInMs; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return streamingTimerInMs; } bool slsReceiverImplementation::getDataStreamEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return dataStreamEnable; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return dataStreamEnable; } uint64_t slsReceiverImplementation::getAcquisitionPeriod() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return acquisitionPeriod; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return acquisitionPeriod; } uint64_t slsReceiverImplementation::getAcquisitionTime() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return acquisitionTime; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return acquisitionTime; } uint64_t slsReceiverImplementation::getSubExpTime() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return subExpTime; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return subExpTime; } uint64_t slsReceiverImplementation::getSubPeriod() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return subPeriod; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return subPeriod; } uint64_t slsReceiverImplementation::getNumberOfFrames() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return numberOfFrames; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return numberOfFrames; } uint64_t slsReceiverImplementation::getNumberofSamples() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return numberOfSamples; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return numberOfSamples; } uint32_t slsReceiverImplementation::getDynamicRange() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return dynamicRange;} + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return dynamicRange;} bool slsReceiverImplementation::getTenGigaEnable() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return tengigaEnable; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return tengigaEnable; } uint32_t slsReceiverImplementation::getFifoDepth() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return fifoDepth; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return fifoDepth; } /***receiver status***/ slsDetectorDefs::runStatus slsReceiverImplementation::getStatus() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return status; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return status; } bool slsReceiverImplementation::getSilentMode() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return silentMode; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return silentMode; } bool slsReceiverImplementation::getActivate() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return activated; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return activated; } bool slsReceiverImplementation::getDeactivatedPadding() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return deactivatedPaddingEnable; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return deactivatedPaddingEnable; } uint32_t slsReceiverImplementation::getStreamingPort() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return streamingPort; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return streamingPort; } std::string slsReceiverImplementation::getStreamingSourceIP() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; return std::string(streamingSrcIP); } std::string slsReceiverImplementation::getAdditionalJsonHeader() const{ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return std::string(additionalJsonHeader); + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return std::string(additionalJsonHeader); } uint32_t slsReceiverImplementation::getUDPSocketBufferSize() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return udpSocketBufferSize; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return udpSocketBufferSize; } uint32_t slsReceiverImplementation::getActualUDPSocketBufferSize() const { - FILE_LOG(logDEBUG) << __AT__ << " starting"; - return actualUDPSocketBufferSize; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + return actualUDPSocketBufferSize; } @@ -396,7 +399,7 @@ uint32_t slsReceiverImplementation::getActualUDPSocketBufferSize() const { /**initial parameters***/ void slsReceiverImplementation::setDetectorHostname(const char *c){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(strlen(c)) strcpy(detHostname, c); @@ -405,7 +408,7 @@ void slsReceiverImplementation::setDetectorHostname(const char *c){ void slsReceiverImplementation::setMultiDetectorSize(const int* size) { - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; char message[100]; strcpy(message, "Detector Size: ("); for (int i = 0; i < MAX_DIMENSIONS; ++i) { @@ -423,7 +426,7 @@ void slsReceiverImplementation::setMultiDetectorSize(const int* size) { void slsReceiverImplementation::setFlippedData(int axis, int enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(axis<0 || axis>1) return; flippedData[axis] = enable==0?0:1; FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1]; @@ -469,7 +472,7 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f){ void slsReceiverImplementation::setFileName(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(strlen(c)) strcpy(fileName, c); @@ -478,7 +481,7 @@ void slsReceiverImplementation::setFileName(const char c[]){ void slsReceiverImplementation::setFilePath(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(strlen(c)){ @@ -494,7 +497,7 @@ void slsReceiverImplementation::setFilePath(const char c[]){ void slsReceiverImplementation::setFileIndex(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; fileIndex = i; FILE_LOG(logINFO) << "File Index: " << fileIndex; @@ -502,7 +505,7 @@ void slsReceiverImplementation::setFileIndex(const uint64_t i){ void slsReceiverImplementation::setFramesPerFile(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; framesPerFile = i; FILE_LOG(logINFO) << "Frames per file: " << framesPerFile; @@ -510,7 +513,7 @@ void slsReceiverImplementation::setFramesPerFile(const uint32_t i){ void slsReceiverImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if (i >= 0 && i < NUM_DISCARD_POLICIES) frameDiscardMode = i; @@ -520,7 +523,7 @@ void slsReceiverImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i void slsReceiverImplementation::setFramePaddingEnable(const bool i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; framePadding = i; FILE_LOG(logINFO) << "Frame Padding: " << framePadding; @@ -531,7 +534,7 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b){ if (fileWriteEnable != b){ fileWriteEnable = b; for (unsigned int i = 0; i < dataProcessor.size(); ++i) { - dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, + dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, &framesPerFile, fileName, filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i], generalData); @@ -543,7 +546,7 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b){ void slsReceiverImplementation::setOverwriteEnable(const bool b){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; overwriteEnable = b; FILE_LOG(logINFO) << "Overwrite Enable: " << stringEnable(overwriteEnable); @@ -552,37 +555,37 @@ void slsReceiverImplementation::setOverwriteEnable(const bool b){ /***connection parameters***/ void slsReceiverImplementation::setUDPPortNumber(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; udpPortNum[0] = i; FILE_LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0]; } void slsReceiverImplementation::setUDPPortNumber2(const uint32_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; udpPortNum[1] = i; FILE_LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1]; } void slsReceiverImplementation::setEthernetInterface(const char* c){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; strcpy(eth, c); FILE_LOG(logINFO) << "Ethernet Interface: " << eth; } int slsReceiverImplementation::setUDPSocketBufferSize(const uint32_t s) { - if (listener.size()) - return listener[0]->CreateDummySocketForUDPSocketBufferSize(s); - return FAIL; + if (listener.size()) + return listener[0]->CreateDummySocketForUDPSocketBufferSize(s); + return FAIL; } /***acquisition parameters***/ int slsReceiverImplementation::setROI(const std::vector i) { if (myDetectorType != GOTTHARD) { - cprintf(RED, "Error: Can not set ROI for this detector\n"); + FILE_LOG(logERROR) << "Can not set ROI for this detector"; return FAIL; } @@ -651,7 +654,7 @@ int slsReceiverImplementation::setStreamingFrequency(const uint32_t freq) { } void slsReceiverImplementation::setStreamingTimer(const uint32_t time_in_ms){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; streamingTimerInMs = time_in_ms; FILE_LOG(logINFO) << "Streamer Timer: " << streamingTimerInMs; @@ -669,23 +672,23 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) { dataStreamer.clear(); if (enable) { - for ( int i = 0; i < numThreads; ++i ) { - try { - DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, - &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode); - dataStreamer.push_back(s); - dataStreamer[i]->SetGeneralData(generalData); - dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP); - } - catch(...) { - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - delete(*it); - dataStreamer.clear(); - dataStreamEnable = false; - return FAIL; - } - } - SetThreadPriorities(); + for ( int i = 0; i < numThreads; ++i ) { + try { + DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, + &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode); + dataStreamer.push_back(s); + dataStreamer[i]->SetGeneralData(generalData); + dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP); + } + catch(...) { + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) + delete(*it); + dataStreamer.clear(); + dataStreamEnable = false; + return FAIL; + } + } + SetThreadPriorities(); } } FILE_LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable; @@ -701,21 +704,21 @@ void slsReceiverImplementation::setStreamingPort(const uint32_t i) { void slsReceiverImplementation::setStreamingSourceIP(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; strcpy(streamingSrcIP, c); FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP; } void slsReceiverImplementation::setAdditionalJsonHeader(const char c[]){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; - strcpy(additionalJsonHeader, c); - FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + strcpy(additionalJsonHeader, c); + FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; } int slsReceiverImplementation::setAcquisitionPeriod(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; acquisitionPeriod = i; FILE_LOG(logINFO) << "Acquisition Period: " << (double)acquisitionPeriod/(1E9) << "s"; @@ -725,7 +728,7 @@ int slsReceiverImplementation::setAcquisitionPeriod(const uint64_t i){ } int slsReceiverImplementation::setAcquisitionTime(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; acquisitionTime = i; FILE_LOG(logINFO) << "Acquisition Time: " << (double)acquisitionTime/(1E9) << "s"; @@ -735,21 +738,21 @@ int slsReceiverImplementation::setAcquisitionTime(const uint64_t i){ } void slsReceiverImplementation::setSubExpTime(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; subExpTime = i; FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subExpTime/(1E9) << "s"; } void slsReceiverImplementation::setSubPeriod(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; subPeriod = i; FILE_LOG(logINFO) << "Sub Exposure Period: " << (double)subPeriod/(1E9) << "s"; } int slsReceiverImplementation::setNumberOfFrames(const uint64_t i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; numberOfFrames = i; FILE_LOG(logINFO) << "Number of Frames: " << numberOfFrames; @@ -824,7 +827,7 @@ int slsReceiverImplementation::setFifoDepth(const uint32_t i) { /***receiver parameters***/ bool slsReceiverImplementation::setActivate(bool enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; activated = enable; FILE_LOG(logINFO) << "Activation: " << stringEnable(activated); return activated; @@ -832,14 +835,14 @@ bool slsReceiverImplementation::setActivate(bool enable){ bool slsReceiverImplementation::setDeactivatedPadding(bool enable){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; deactivatedPaddingEnable = enable; FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable); return deactivatedPaddingEnable; } void slsReceiverImplementation::setSilentMode(const bool i){ - FILE_LOG(logDEBUG) << __AT__ << " starting"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; silentMode = i; FILE_LOG(logINFO) << "Silent Mode: " << i; @@ -854,7 +857,7 @@ void slsReceiverImplementation::setSilentMode(const bool i){ /***initial functions***/ int slsReceiverImplementation::setDetectorType(const detectorType d) { - FILE_LOG(logDEBUG) << "Setting receiver type"; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; DeleteMembers(); InitializeMembers(); myDetectorType = d; @@ -897,30 +900,30 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) { //create threads for ( int i = 0; i < numThreads; ++i ) { - try { - Listener* l = new Listener(i, myDetectorType, fifo[i], &status, - &udpPortNum[i], eth, &numberOfFrames, &dynamicRange, - &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, + try { + Listener* l = new Listener(i, myDetectorType, fifo[i], &status, + &udpPortNum[i], eth, &numberOfFrames, &dynamicRange, + &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode); - listener.push_back(l); + listener.push_back(l); - DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, - fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, - &dynamicRange, &streamingFrequency, &streamingTimerInMs, + DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, + fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, + &dynamicRange, &streamingFrequency, &streamingTimerInMs, &framePadding, &activated, &deactivatedPaddingEnable, &silentMode, - rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); - dataProcessor.push_back(p); - } - catch (...) { - FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - delete(*it); - listener.clear(); - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - delete(*it); - dataProcessor.clear(); - return FAIL; - } + rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); + dataProcessor.push_back(p); + } + catch (...) { + FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; + for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) + delete(*it); + listener.clear(); + for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) + delete(*it); + dataProcessor.clear(); + return FAIL; + } } //set up writer and callbacks @@ -931,8 +934,8 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) { SetThreadPriorities(); - // check udp socket buffer size - setUDPSocketBufferSize(udpSocketBufferSize); + // check udp socket buffer size + setUDPSocketBufferSize(udpSocketBufferSize); FILE_LOG(logDEBUG) << " Detector type set to " << getDetectorType(d); return OK; @@ -942,6 +945,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) { void slsReceiverImplementation::setDetectorPositionId(const int i){ + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; detID = i; FILE_LOG(logINFO) << "Detector Position Id:" << detID; for (unsigned int i = 0; i < dataProcessor.size(); ++i) { @@ -962,6 +966,7 @@ void slsReceiverImplementation::setDetectorPositionId(const int i){ /***acquisition functions***/ void slsReceiverImplementation::resetAcquisitionCount() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) (*it)->ResetParametersforNewAcquisition(); @@ -977,7 +982,7 @@ void slsReceiverImplementation::resetAcquisitionCount() { int slsReceiverImplementation::startReceiver(char *c) { - cprintf(RESET,"\n"); + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logINFO) << "Starting Receiver"; ResetParametersforNewMeasurement(); @@ -1023,6 +1028,7 @@ int slsReceiverImplementation::startReceiver(char *c) { void slsReceiverImplementation::stopReceiver(){ + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logINFO) << "Stopping Receiver"; //set status to transmitting @@ -1031,14 +1037,14 @@ void slsReceiverImplementation::stopReceiver(){ //wait for the processes (Listener and DataProcessor) to be done bool running = true; while(running) { - running = false; - for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) - if ((*it)->IsRunning()) - running = true; - for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) - if ((*it)->IsRunning()) - running = true; - usleep(5000); + running = false; + for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) + if ((*it)->IsRunning()) + running = true; + for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) + if ((*it)->IsRunning()) + running = true; + usleep(5000); } @@ -1057,13 +1063,13 @@ void slsReceiverImplementation::stopReceiver(){ //wait for the processes (DataStreamer) to be done running = true; - while(running) { - running = false; - for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) - if ((*it)->IsRunning()) - running = true; - usleep(5000); - } + while(running) { + running = false; + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) + if ((*it)->IsRunning()) + running = true; + usleep(5000); + } status = RUN_FINISHED; FILE_LOG(logINFO) << "Status: " << runStatusType(status); @@ -1075,20 +1081,15 @@ void slsReceiverImplementation::stopReceiver(){ tot += dataProcessor[i]->GetNumFramesCaught(); uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught(); - if ((int)missingpackets > 0) { - cprintf(RED, "\n[Port %d]\n",udpPortNum[i]); - cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - cprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - cprintf(RED, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); - }else{ - cprintf(GREEN, "\n[Port %d]\n",udpPortNum[i]); - cprintf(GREEN, "Missing Packets\t\t: %lld\n",(long long int)missingpackets); - cprintf(GREEN, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught()); - cprintf(GREEN, "Last Frame Caught\t: %lld\n",(long long int)listener[i]->GetLastFrameIndexCaught()); - } + FILE_LOG(((int)missingpackets > 0) ? logINFORED : logINFOGREEN) << + "Summary of Port " << udpPortNum[i] << + "\n\tMissing Packets\t\t: " << missingpackets << + "\n\tComplete Frames\t\t: " << dataProcessor[i]->GetNumFramesCaught() << + "\n\tLast Frame Caught\t: " << listener[i]->GetLastFrameIndexCaught(); + } + if(!activated) { + FILE_LOG(logINFORED) << "Deactivated Receiver"; } - if(!activated) - cprintf(RED,"Note: Deactivated Receiver\n"); //callback if (acquisitionFinishedCallBack) acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished); @@ -1104,6 +1105,7 @@ void slsReceiverImplementation::stopReceiver(){ void slsReceiverImplementation::startReadout(){ + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; if(status == RUNNING){ // wait for incoming delayed packets @@ -1117,11 +1119,8 @@ void slsReceiverImplementation::startReadout(){ //wait as long as there is change from prev totalP, while(prev != totalP){ -#ifdef VERY_VERBOSE - cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n", - prev,totalP); - -#endif + FILE_LOG(logDEBUG3) << "waiting for all packets prevP:" << prev << + " totalP: " << totalP; //usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000); usleep(5*1000);/* Need to find optimal time **/ @@ -1130,9 +1129,7 @@ void slsReceiverImplementation::startReadout(){ for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) totalP += (*it)->GetPacketsCaught(); -#ifdef VERY_VERBOSE - cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP); -#endif + FILE_LOG(logDEBUG3) << "\tupdated: totalP:" << totalP; } } @@ -1147,6 +1144,7 @@ void slsReceiverImplementation::startReadout(){ void slsReceiverImplementation::shutDownUDPSockets() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) (*it)->ShutDownUDPSocket(); } @@ -1154,6 +1152,7 @@ void slsReceiverImplementation::shutDownUDPSockets() { void slsReceiverImplementation::closeFiles() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; uint64_t maxIndexCaught = 0; bool anycaught = false; for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) { @@ -1168,6 +1167,7 @@ void slsReceiverImplementation::closeFiles() { int slsReceiverImplementation::restreamStop() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; bool ret = OK; for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) { if ((*it)->RestreamStop() == FAIL) @@ -1202,40 +1202,41 @@ void slsReceiverImplementation::registerCallBackRawDataReady(void (*func)(char* } void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(char* , - char*, uint32_t&, void*),void *arg){ - rawDataModifyReadyCallBack=func; - pRawDataReady=arg; + char*, uint32_t&, void*),void *arg){ + rawDataModifyReadyCallBack=func; + pRawDataReady=arg; } void slsReceiverImplementation::SetLocalNetworkParameters() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; // to increase Max length of input packet queue int max_back_log; const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog"; { - std::ifstream proc_file(proc_file_name); - proc_file >> max_back_log; + std::ifstream proc_file(proc_file_name); + proc_file >> max_back_log; } if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) { - std::ofstream proc_file(proc_file_name); - if (proc_file.good()) { - proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl; - cprintf(GREEN, "Max length of input packet queue " - "[/proc/sys/net/core/netdev_max_backlog] modified to %d\n", - MAX_SOCKET_INPUT_PACKET_QUEUE); - } else { - const char *msg = "Could not change max length of " - "input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)"; - FILE_LOG(logWARNING) << msg; - } + std::ofstream proc_file(proc_file_name); + if (proc_file.good()) { + proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl; + FILE_LOG(logINFOBLUE) << "Max length of input packet queue " + "[/proc/sys/net/core/netdev_max_backlog] modified to " << + MAX_SOCKET_INPUT_PACKET_QUEUE; + } else { + FILE_LOG(logWARNING) << "Could not change max length of " + "input packet queue [net.core.netdev_max_backlog]. (No Root Privileges?)"; + } } } void slsReceiverImplementation::SetThreadPriorities() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it){ if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { @@ -1252,7 +1253,8 @@ void slsReceiverImplementation::SetThreadPriorities() { int slsReceiverImplementation::SetupFifoStructure() { - numberofJobs = 1; + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; + numberofJobs = 1; for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) @@ -1261,18 +1263,18 @@ int slsReceiverImplementation::SetupFifoStructure() { for ( int i = 0; i < numThreads; ++i ) { //create fifo structure - try { - Fifo* f = new Fifo (i, - (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), - fifoDepth); - fifo.push_back(f); - } catch (...) { - cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i); - for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) - delete(*it); - fifo.clear(); - return FAIL; - } + try { + Fifo* f = new Fifo (i, + (generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize), + fifoDepth); + fifo.push_back(f); + } catch (...) { + FILE_LOG(logERROR) << "Could not allocate memory for fifo structure of index " << i; + for (std::vector::const_iterator it = fifo.begin(); it != fifo.end(); ++it) + delete(*it); + fifo.clear(); + return FAIL; + } //set the listener & dataprocessor threads to point to the right fifo if(listener.size())listener[i]->SetFifo(fifo[i]); if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]); @@ -1287,6 +1289,7 @@ int slsReceiverImplementation::SetupFifoStructure() { void slsReceiverImplementation::ResetParametersforNewMeasurement() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) (*it)->ResetParametersforNewMeasurement(); for (std::vector::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) @@ -1303,6 +1306,7 @@ void slsReceiverImplementation::ResetParametersforNewMeasurement() { int slsReceiverImplementation::CreateUDPSockets() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; bool error = false; for (unsigned int i = 0; i < listener.size(); ++i) if (listener[i]->CreateUDPSockets() == FAIL) { @@ -1320,6 +1324,7 @@ int slsReceiverImplementation::CreateUDPSockets() { int slsReceiverImplementation::SetupWriter() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; bool error = false; for (unsigned int i = 0; i < dataProcessor.size(); ++i) if (dataProcessor[i]->CreateNewFile(tengigaEnable, @@ -1338,6 +1343,7 @@ int slsReceiverImplementation::SetupWriter() { void slsReceiverImplementation::StartRunning() { + FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; //set running mask and post semaphore to start the inner loop in execution thread for (std::vector::const_iterator it = listener.begin(); it != listener.end(); ++it) { (*it)->StartRunning(); diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 92645edb0..67503f615 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -141,7 +141,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){ void slsReceiverTCPIPInterface::startTCPServer(){ - cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid) << "]";; FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl; int ret = OK; @@ -159,7 +159,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){ } mySock->exitServer(); - cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]"; pthread_exit(NULL); } @@ -170,7 +170,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){ receiver->shutDownUDPSockets(); } } - cprintf(BLUE,"Exiting [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid)); + FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) <<"]"; pthread_exit(NULL); } } @@ -229,7 +229,7 @@ int slsReceiverTCPIPInterface::function_table(){ flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable; for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { - FILE_LOG(logDEBUG5) << "function fnum: " << i << " (" << + FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" << getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i]; } @@ -243,28 +243,29 @@ int slsReceiverTCPIPInterface::decode_function(){ ret = FAIL; int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); if (n <= 0) { - FILE_LOG(logDEBUG5) << "Could not read socket. " + FILE_LOG(logDEBUG3) << "Could not read socket. " "Received " << n << " bytes," << "fnum:" << fnum << " " "(" << getFunctionNameFromEnum((enum detFuncs)fnum) << ")"; return FAIL; } else - FILE_LOG(logDEBUG5) << "Received " << n << " bytes"; + FILE_LOG(logDEBUG3) << "Received " << n << " bytes"; if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) { FILE_LOG(logERROR) << "Unknown function enum " << fnum; ret = (this->M_nofunc)(); } else{ - FILE_LOG(logDEBUG5) << "calling function fnum: "<< fnum << " " + FILE_LOG(logDEBUG1) << "calling function fnum: "<< fnum << " " "(" << getFunctionNameFromEnum((enum detFuncs)fnum) << ") " "located at " << flist[fnum]; ret = (this->*flist[fnum])(); if (ret == FAIL) { - FILE_LOG(logDEBUG5) << "Failed to execute function = " << fnum << " (" + FILE_LOG(logDEBUG1) << "Failed to execute function = " << fnum << " (" << getFunctionNameFromEnum((enum detFuncs)fnum) << ")"; - } + } else FILE_LOG(logDEBUG1) << "Function " << + getFunctionNameFromEnum((enum detFuncs)fnum) << " executed OK"; } return ret; } @@ -352,7 +353,7 @@ int slsReceiverTCPIPInterface::exec_command() { int slsReceiverTCPIPInterface::exit_server() { - cprintf(BG_RED, "Closing server\n"); + FILE_LOG(logINFO) << "Closing server"; ret = OK; memset(mess, 0, sizeof(mess)); interface->Server_SendResult(false, ret, NULL, 0); @@ -369,7 +370,7 @@ int slsReceiverTCPIPInterface::lock_receiver() { // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, &lock, sizeof(lock)) == FAIL) return FAIL; - FILE_LOG(logDEBUG5) << "Locking Server to " << lock; + FILE_LOG(logDEBUG1) << "Locking Server to " << lock; // execute action if (lock >= 0) { @@ -642,7 +643,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() { // get std::string s = receiver->getDetectorHostname(); strcpy(retval, s.c_str()); - if (s.length()) { + if (!s.length()) { ret = FAIL; sprintf(mess, "hostname not set\n"); FILE_LOG(logERROR) << mess; @@ -675,9 +676,9 @@ int slsReceiverTCPIPInterface::set_roi() { return interface->Server_SocketCrash(); arg.push_back(temp); } - FILE_LOG(logDEBUG5) << "Set ROI narg: " << narg; + FILE_LOG(logDEBUG1) << "Set ROI narg: " << narg; for (int iloop = 0; iloop < narg; ++iloop) { - FILE_LOG(logDEBUG5) << "(" << arg[iloop].xmin << ", " << + FILE_LOG(logDEBUG1) << "(" << arg[iloop].xmin << ", " << arg[iloop].xmax << ", " << arg[iloop].ymin << ", " << arg[iloop].ymax << ")"; } @@ -705,7 +706,7 @@ int slsReceiverTCPIPInterface::setup_udp(){ ret = OK; memset(mess, 0, sizeof(mess)); char args[3][MAX_STR_LENGTH] = {0}; - char retval[MAX_STR_LENGTH] = {0}; + char retvals[MAX_STR_LENGTH] = {0}; // get args, return if socket crashed, ret is fail if receiver is not null if (interface->Server_ReceiveArg(ret, mess, args, sizeof(args), true, receiver) == FAIL) @@ -755,13 +756,13 @@ int slsReceiverTCPIPInterface::setup_udp(){ FILE_LOG(logERROR) << mess; } else { - strcpy(retval,temp.c_str()); - FILE_LOG(logINFO) << "Reciever MAC Address: " << retval; + strcpy(retvals,temp.c_str()); + FILE_LOG(logINFO) << "Reciever MAC Address: " << retvals; } } } } - return interface->Server_SendResult(true, ret, retval, sizeof(retval), mess); + return interface->Server_SendResult(true, ret, retvals, sizeof(retvals), mess); } @@ -778,7 +779,7 @@ int slsReceiverTCPIPInterface::set_timer() { // base object not null if (ret == OK) { - FILE_LOG(logDEBUG5) << "Setting timer index " << index[0] << " to " << index[1]; + FILE_LOG(logDEBUG1) << "Setting timer index " << index[0] << " to " << index[1]; // set if (index[1] >= 0) { @@ -848,7 +849,7 @@ int slsReceiverTCPIPInterface::set_timer() { break; } validate((int)index[1], (int)retval, std::string("set timer"), 0); - FILE_LOG(logDEBUG5) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; + FILE_LOG(logDEBUG1) << slsDetectorDefs::getTimerType((timerIndex)(index[0])) << ":" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -871,7 +872,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { if (dr >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting dynamic range: " << dr; + FILE_LOG(logDEBUG1) << "Setting dynamic range: " << dr; bool exists = false; switch (dr) { case 16: @@ -903,7 +904,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() { // get retval = receiver->getDynamicRange(); validate(dr, retval, std::string("set dynamic range"), 0); - FILE_LOG(logDEBUG5) << "dynamic range: " << retval; + FILE_LOG(logDEBUG1) << "dynamic range: " << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -926,7 +927,7 @@ int slsReceiverTCPIPInterface::set_streaming_frequency() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting streaming frequency: " << index; + FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index; ret = receiver->setStreamingFrequency(index); if(ret == FAIL) { strcpy(mess, "Could not allocate memory for listening fifo\n"); @@ -952,9 +953,9 @@ int slsReceiverTCPIPInterface::get_status(){ interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); if (ret == OK) { - FILE_LOG(logDEBUG5) << "Getting Status"; + FILE_LOG(logDEBUG1) << "Getting Status"; retval = receiver->getStatus(); - FILE_LOG(logDEBUG5) << "Status:" << runStatusType(retval); + FILE_LOG(logDEBUG1) << "Status:" << runStatusType(retval); } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -980,7 +981,7 @@ int slsReceiverTCPIPInterface::start_receiver(){ sprintf(mess,"Cannot start Receiver as it is in %s state\n",runStatusType(s).c_str()); FILE_LOG(logERROR) << mess; }else { - FILE_LOG(logDEBUG5) << "Starting Reciever"; + FILE_LOG(logDEBUG1) << "Starting Reciever"; ret = receiver->startReceiver(mess); if (ret == FAIL) { FILE_LOG(logERROR) << mess; @@ -1006,7 +1007,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){ // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { if(receiver->getStatus() != IDLE) { - FILE_LOG(logDEBUG5) << "Stopping Reciever"; + FILE_LOG(logDEBUG1) << "Stopping Reciever"; receiver->stopReceiver(); } enum runStatus s = receiver->getStatus(); @@ -1038,18 +1039,18 @@ int slsReceiverTCPIPInterface::set_file_dir() { if (ret == OK) { // set if (strlen(fPath)) { - FILE_LOG(logDEBUG5) << "Setting file path: " << fPath; + FILE_LOG(logDEBUG1) << "Setting file path: " << fPath; receiver->setFilePath(fPath); } // get std::string s = receiver->getFilePath(); strcpy(retval, s.c_str()); - if ((s.length()) || (strlen(fPath) && strcasecmp(fPath, retval))) { + if ((!s.length()) || (strlen(fPath) && strcasecmp(fPath, retval))) { ret = FAIL; strcpy(mess,"receiver file path does not exist\n"); FILE_LOG(logERROR) << mess; } else - FILE_LOG(logDEBUG5) << "file path:" << retval; + FILE_LOG(logDEBUG1) << "file path:" << retval; } return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1070,18 +1071,18 @@ int slsReceiverTCPIPInterface::set_file_name() { if (ret == OK) { // set if (strlen(fName)) { - FILE_LOG(logDEBUG5) << "Setting file name: " << fName; + FILE_LOG(logDEBUG1) << "Setting file name: " << fName; receiver->setFileName(fName); } // get std::string s = receiver->getFileName(); strcpy(retval, s.c_str()); - if (s.length()) { + if (!s.length()) { ret = FAIL; strcpy(mess, "file name is empty\n"); FILE_LOG(logERROR) << mess; } else - FILE_LOG(logDEBUG5) << "file name:" << retval; + FILE_LOG(logDEBUG1) << "file name:" << retval; } return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1104,14 +1105,14 @@ int slsReceiverTCPIPInterface::set_file_index() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting file index: " << index; + FILE_LOG(logDEBUG1) << "Setting file index: " << index; receiver->setFileIndex(index); } } // get retval=receiver->getFileIndex(); validate(index, retval, std::string("set file index"), 0); - FILE_LOG(logDEBUG5) << "file index:" << retval; + FILE_LOG(logDEBUG1) << "file index:" << retval; } return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1127,9 +1128,9 @@ int slsReceiverTCPIPInterface::get_frame_index(){ interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); if (ret == OK) { - FILE_LOG(logDEBUG5) << "Getting frame index"; + FILE_LOG(logDEBUG1) << "Getting frame index"; retval = receiver->getAcquisitionIndex(); - FILE_LOG(logDEBUG5) << "frame index:" << retval; + FILE_LOG(logDEBUG1) << "frame index:" << retval; } return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1145,9 +1146,9 @@ int slsReceiverTCPIPInterface::get_frames_caught(){ interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); if (ret == OK) { - FILE_LOG(logDEBUG5) << "Getting frames caught"; + FILE_LOG(logDEBUG1) << "Getting frames caught"; retval = receiver->getTotalFramesCaught(); - FILE_LOG(logDEBUG5) << "frames caught:" << retval; + FILE_LOG(logDEBUG1) << "frames caught:" << retval; } return interface->Server_SendResult(true, ret, &retval,sizeof(retval), mess); } @@ -1166,7 +1167,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){ // only set // verify if receiver is unlocked if (interface->Server_VerifyLock(ret, mess, lockStatus) == OK) { - FILE_LOG(logDEBUG5) << "Reset frames caught"; + FILE_LOG(logDEBUG1) << "Reset frames caught"; receiver->resetAcquisitionCount(); } } @@ -1191,14 +1192,14 @@ int slsReceiverTCPIPInterface::enable_file_write(){ if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting File write enable:" << enable; + FILE_LOG(logDEBUG1) << "Setting File write enable:" << enable; receiver->setFileWriteEnable(enable); } } // get retval = receiver->getFileWriteEnable(); validate(enable, retval, std::string("set file write enable"), 0); - FILE_LOG(logDEBUG5) << "file write enable:" << retval; + FILE_LOG(logDEBUG1) << "file write enable:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1221,14 +1222,14 @@ int slsReceiverTCPIPInterface::enable_overwrite() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting File overwrite enable:" << index; + FILE_LOG(logDEBUG1) << "Setting File overwrite enable:" << index; receiver->setOverwriteEnable(index); } } // get retval = receiver->getOverwriteEnable(); validate(index, retval, std::string("set file overwrite enable"), 0); - FILE_LOG(logDEBUG5) << "file overwrite enable:" << retval; + FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1254,14 +1255,14 @@ int slsReceiverTCPIPInterface::enable_tengiga() { if (val >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting 10GbE:" << val; + FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val; ret = receiver->setTenGigaEnable(val); } } // get retval = receiver->getTenGigaEnable(); validate(val, retval, std::string("set 10GbE"), 0); - FILE_LOG(logDEBUG5) << "10Gbe:" << retval; + FILE_LOG(logDEBUG1) << "10Gbe:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1284,7 +1285,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { if (value >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting fifo depth:" << value; + FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value; ret = receiver->setFifoDepth(value); if (ret == FAIL) { strcpy(mess,"Could not set fifo depth"); @@ -1295,7 +1296,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() { // get retval = receiver->getFifoDepth(); validate(value, retval, std::string("set fifo depth"), 0); - FILE_LOG(logDEBUG5) << "fifo depth:" << retval; + FILE_LOG(logDEBUG1) << "fifo depth:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1321,14 +1322,14 @@ int slsReceiverTCPIPInterface::set_activate() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting activate:" << enable; + FILE_LOG(logDEBUG1) << "Setting activate:" << enable; receiver->setActivate(enable > 0 ? true : false); } } // get retval = (int)receiver->getActivate(); validate(enable, retval, std::string("set activate"), 0); - FILE_LOG(logDEBUG5) << "Activate: " << retval; + FILE_LOG(logDEBUG1) << "Activate: " << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1351,14 +1352,14 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){ if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting data stream enable:" << index; + FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index; ret = receiver->setDataStreamEnable(index); } } // get retval = receiver->getDataStreamEnable(); validate(index, retval, std::string("set data stream enable"), 0); - FILE_LOG(logDEBUG5) << "data streaming enable:" << retval; + FILE_LOG(logDEBUG1) << "data streaming enable:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1381,14 +1382,14 @@ int slsReceiverTCPIPInterface::set_streaming_timer(){ if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting streaming timer:" << index; + FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index; receiver->setStreamingTimer(index); } } // get retval=receiver->getStreamingTimer(); validate(index, retval, std::string("set data stream timer"), 0); - FILE_LOG(logDEBUG5) << "Streaming timer:" << retval; + FILE_LOG(logDEBUG1) << "Streaming timer:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1414,14 +1415,14 @@ int slsReceiverTCPIPInterface::set_flipped_data(){ if (args[1] >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting flipped data:" << args[1]; + FILE_LOG(logDEBUG1) << "Setting flipped data:" << args[1]; receiver->setFlippedData(args[0],args[1]); } } // get retval=receiver->getFlippedData(args[0]); validate(args[1], retval, std::string("set flipped data"), 0); - FILE_LOG(logDEBUG5) << "Flipped Data:" << retval; + FILE_LOG(logDEBUG1) << "Flipped Data:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1444,14 +1445,14 @@ int slsReceiverTCPIPInterface::set_file_format() { if (f >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting file format:" << f; + FILE_LOG(logDEBUG1) << "Setting file format:" << f; receiver->setFileFormat(f); } } // get retval = receiver->getFileFormat(); validate(f, retval, std::string("set file format"), 0); - FILE_LOG(logDEBUG5) << "File Format: " << retval; + FILE_LOG(logDEBUG1) << "File Format: " << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1474,14 +1475,14 @@ int slsReceiverTCPIPInterface::set_detector_posid() { if (arg >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting detector position id:" << arg; + FILE_LOG(logDEBUG1) << "Setting detector position id:" << arg; receiver->setDetectorPositionId(arg); } } // get retval = receiver->getDetectorPositionId(); validate(arg, retval, std::string("set detector position id"), 0); - FILE_LOG(logDEBUG5) << "Position Id:" << retval; + FILE_LOG(logDEBUG1) << "Position Id:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1504,7 +1505,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { if((arg[0] > 0) && (arg[1] > 0)) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting multi detector size:" << arg[0] << "," << arg[1]; + FILE_LOG(logDEBUG1) << "Setting multi detector size:" << arg[0] << "," << arg[1]; receiver->setMultiDetectorSize(arg); } } @@ -1516,7 +1517,7 @@ int slsReceiverTCPIPInterface::set_multi_detector_size() { else retval *= temp[i]; } - FILE_LOG(logDEBUG5) << "Multi Detector Size:" << retval; + FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1539,14 +1540,14 @@ int slsReceiverTCPIPInterface::set_streaming_port() { if (port >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting streaming port:" << port; + FILE_LOG(logDEBUG1) << "Setting streaming port:" << port; receiver->setStreamingPort(port); } } // get retval = receiver->getStreamingPort(); validate(port, retval, std::string("set streaming port"), 0); - FILE_LOG(logDEBUG5) << "streaming port:" << retval; + FILE_LOG(logDEBUG1) << "streaming port:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1568,12 +1569,12 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { // only set // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting streaming source ip:" << arg; + FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg; receiver->setStreamingSourceIP(arg); } // get strcpy(retval, receiver->getStreamingSourceIP().c_str()); - FILE_LOG(logDEBUG5) << "streaming source ip:" << retval; + FILE_LOG(logDEBUG1) << "streaming source ip:" << retval; } return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1596,14 +1597,14 @@ int slsReceiverTCPIPInterface::set_silent_mode() { if (value >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting silent mode:" << value; + FILE_LOG(logDEBUG1) << "Setting silent mode:" << value; receiver->setSilentMode(value); } } // get retval = (int)receiver->getSilentMode(); validate(value, retval, std::string("set silent mode"), 0); - FILE_LOG(logDEBUG5) << "silent mode:" << retval; + FILE_LOG(logDEBUG1) << "silent mode:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1629,14 +1630,14 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting gap pixels enable:" << enable; + FILE_LOG(logDEBUG1) << "Setting gap pixels enable:" << enable; receiver->setGapPixelsEnable(enable); } } // get retval = receiver->getGapPixelsEnable(); validate(enable, retval, std::string("set gap pixels enable"), 0); - FILE_LOG(logDEBUG5) << "Gap Pixels Enable: " << retval; + FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1660,7 +1661,7 @@ int slsReceiverTCPIPInterface::restream_stop(){ sprintf(mess,"Could not restream stop packet as data Streaming is disabled.\n"); FILE_LOG(logERROR) << mess; } else { - FILE_LOG(logDEBUG5) << "Restreaming stop"; + FILE_LOG(logDEBUG1) << "Restreaming stop"; ret = receiver->restreamStop(); if (ret == FAIL) { sprintf(mess,"Could not restream stop packet.\n"); @@ -1689,12 +1690,12 @@ int slsReceiverTCPIPInterface::set_additional_json_header() { // only set // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting additional json header: " << arg; + FILE_LOG(logDEBUG1) << "Setting additional json header: " << arg; receiver->setAdditionalJsonHeader(arg); } // get strcpy(retval, receiver->getAdditionalJsonHeader().c_str()); - FILE_LOG(logDEBUG5) << "additional json header:" << retval; + FILE_LOG(logDEBUG1) << "additional json header:" << retval; } return interface->Server_SendResult(true, ret, retval, MAX_STR_LENGTH, mess); } @@ -1717,7 +1718,7 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting UDP Socket Buffer size: " << index; + FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index; if (receiver->setUDPSocketBufferSize(index) == FAIL) { ret = FAIL; strcpy(mess, "Could not create dummy UDP Socket to test buffer size\n"); @@ -1728,7 +1729,7 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() { // get retval = receiver->getUDPSocketBufferSize(); validate(index, retval, std::string("set udp socket buffer size (No CAP_NET_ADMIN privileges?)"), 0); - FILE_LOG(logDEBUG5) << "UDP Socket Buffer Size:" << retval; + FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1744,7 +1745,7 @@ int slsReceiverTCPIPInterface::get_real_udp_socket_buffer_size(){ interface->Server_ReceiveArg(ret, mess, NULL, 0, true, receiver); if (ret == OK) { - FILE_LOG(logDEBUG5) << "Getting actual UDP buffer size"; + FILE_LOG(logDEBUG1) << "Getting actual UDP buffer size"; retval = receiver->getActualUDPSocketBufferSize(); } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); @@ -1768,14 +1769,14 @@ int slsReceiverTCPIPInterface::set_frames_per_file() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting frames per file: " << index; + FILE_LOG(logDEBUG1) << "Setting frames per file: " << index; receiver->setFramesPerFile(index); } } // get retval = receiver->getFramesPerFile(); validate(index, retval, std::string("set frames per file"), 0); - FILE_LOG(logDEBUG5) << "frames per file:" << retval; + FILE_LOG(logDEBUG1) << "frames per file:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1790,7 +1791,7 @@ int slsReceiverTCPIPInterface::check_version_compatibility() { // get args, return if socket crashed if (interface->Server_ReceiveArg(ret, mess, &arg, sizeof(arg)) == FAIL) return FAIL; - FILE_LOG(logDEBUG5) << "Checking versioning compatibility with value " << arg; + FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value " << arg; int64_t client_requiredVersion = arg; int64_t rx_apiVersion = APIRECEIVER; int64_t rx_version = getReceiverVersion(); @@ -1838,14 +1839,14 @@ int slsReceiverTCPIPInterface::set_discard_policy() { if (index >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting frames discard policy: " << index; + FILE_LOG(logDEBUG1) << "Setting frames discard policy: " << index; receiver->setFrameDiscardPolicy((frameDiscardPolicy)index); } } // get retval = receiver->getFrameDiscardPolicy(); validate(index, retval, std::string("set discard policy"), 0); - FILE_LOG(logDEBUG5) << "frame discard policy:" << retval; + FILE_LOG(logDEBUG1) << "frame discard policy:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1869,14 +1870,14 @@ int slsReceiverTCPIPInterface::set_padding_enable() { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { index = (index == 0) ? 0 : 1; - FILE_LOG(logDEBUG5) << "Setting frames padding enable: " << index; + FILE_LOG(logDEBUG1) << "Setting frames padding enable: " << index; receiver->setFramePaddingEnable(index); } } // get retval = (int)receiver->getFramePaddingEnable(); validate(index, retval, std::string("set frame padding enable"), 0); - FILE_LOG(logDEBUG5) << "Frame Padding Enable:" << retval; + FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } @@ -1902,14 +1903,14 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { if (enable >= 0) { // verify if receiver is unlocked and idle if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) { - FILE_LOG(logDEBUG5) << "Setting deactivated padding enable: " << enable; + FILE_LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable; receiver->setDeactivatedPadding(enable > 0 ? true : false); } } // get retval = (int)receiver->getDeactivatedPadding(); validate(enable, retval, std::string("set deactivated padding enable"), 0); - FILE_LOG(logDEBUG5) << "Deactivated Padding Enable: " << retval; + FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval; } return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess); } diff --git a/slsSupportLib/include/logger.h b/slsSupportLib/include/logger.h index a7b99eefe..e1a75ab51 100644 --- a/slsSupportLib/include/logger.h +++ b/slsSupportLib/include/logger.h @@ -36,8 +36,9 @@ inline std::string NowTime(); - -enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; +// 1 normal debug, 3 function names, 5 fifodebug +enum TLogLevel {logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO, + logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; template class Log{ public: @@ -63,20 +64,11 @@ public: static void Output(const std::string& msg, TLogLevel level); }; -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) -# if defined (BUILDING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllexport) -# elif defined (USING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllimport) -# else -# define FILELOG_DECLSPEC -# endif // BUILDING_DBSIMPLE_DLL -#else -# define FILELOG_DECLSPEC -#endif // _WIN32 + +#define FILELOG_DECLSPEC class FILELOG_DECLSPEC FILELog : public Log {}; -//typedef Log FILELog; + #define FILE_LOG(level) \ if (level > FILELOG_MAX_LEVEL) ; \ @@ -84,29 +76,6 @@ class FILELOG_DECLSPEC FILELog : public Log {}; else FILELog().Get(level) -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - -#include - - - -inline std::string NowTime() - -{ - const int MAX_LEN = 200; - char buffer[MAX_LEN]; - if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, - "HH':'mm':'ss", buffer, MAX_LEN) == 0) - return "Error in NowTime()"; - - char result[100] = {0}; - static DWORD first = GetTickCount(); - sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); - return result; -} - -#else - #include inline std::string NowTime() @@ -127,8 +96,6 @@ inline std::string NowTime() return result; } -#endif //WIN32 - template Log::Log():lev(logDEBUG){} @@ -138,7 +105,7 @@ template std::ostringstream& Log::Get(TLogLevel level) os << "- " << NowTime(); os << " " << ToString(level) << ": "; if (level > logDEBUG) - os << std::string(level - logDEBUG, '\t'); + os << std::string(level - logDEBUG, ' '); return os; } @@ -156,7 +123,9 @@ template TLogLevel& Log::ReportingLevel() template std::string Log::ToString(TLogLevel level) { - static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"}; + static const char* const buffer[] = { + "ERROR", "WARNING", "INFO", "INFO", "INFO", "INFO", + "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"}; return buffer[level]; } @@ -211,21 +180,10 @@ inline void Output2FILE::Output(const std::string& msg, TLogLevel level) case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break; case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break; case logINFO: cprintf(RESET,"%s",msg.c_str()); break; + case logINFOBLUE: cprintf(BLUE,"%s",msg.c_str()); break; + case logINFORED: cprintf(RED,"%s",msg.c_str()); break; + case logINFOGREEN: cprintf(GREEN,"%s",msg.c_str()); break; default: fprintf(pStream,"%s",msg.c_str()); out = false; break; } fflush(out ? stdout : pStream); } - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) -# if defined (BUILDING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllexport) -# elif defined (USING_FILELOG_DLL) -# define FILELOG_DECLSPEC __declspec (dllimport) -# else -# define FILELOG_DECLSPEC -# endif // BUILDING_DBSIMPLE_DLL -#else -# define FILELOG_DECLSPEC -#endif // _WIN32 - -