From 666c73c98887ad156b5be6bd5ba20f2b51e7eb63 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Mon, 27 May 2013 09:11:26 +0000 Subject: [PATCH] edited call backs in receiver, got rid of uhrix callback, expose receiver read freq to user, got rid of wait for receiver t finish git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@577 951219d9-93cf-4727-9268-0efd64621fa3 --- .../eigerDetectorServer/Makefile | 2 +- .../slsDetectorServer_defs.h | 31 ++++ .../gotthardDetectorServer/svnInfoGotthard.h | 6 +- .../moenchDetectorServer/svnInfoMoench.h | 6 +- .../multiSlsDetector/multiSlsDetector.cpp | 5 - .../multiSlsDetector/multiSlsDetector.h | 4 - .../mythenDetectorServer/svnInfoMythen.h | 6 +- .../slsDetector/slsDetector.cpp | 7 - slsDetectorSoftware/slsDetector/slsDetector.h | 4 - .../slsDetector/slsDetectorUsers.cpp | 4 +- .../slsDetector/slsDetectorUsers.h | 7 + .../slsDetector/slsDetectorUtils.h | 5 - slsDetectorSoftware/slsDetector/svnInfoLib.h | 6 +- .../slsDetectorServer/Makefile | 2 +- .../slsDetectorFunctionList.h | 39 ++-- .../slsDetectorServer_funcs.c | 171 +++++++++--------- slsDetectorSoftware/slsReceiver/Makefile | 6 +- .../slsReceiver/UHRIXCallback.cpp | 28 --- .../slsReceiver/UHRIXCallback.h | 3 - .../slsReceiver/slsReceiverFunctionList.cpp | 25 +-- .../slsReceiver/slsReceiverFunctionList.h | 21 +-- .../slsReceiver/slsReceiverUsers.cpp | 2 +- .../slsReceiver/slsReceiverUsers.h | 4 +- .../slsReceiver/slsReceiver_funcs.h | 3 +- .../slsReceiver/svnInfoReceiver.h | 6 +- 25 files changed, 179 insertions(+), 224 deletions(-) create mode 100644 slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h delete mode 100644 slsDetectorSoftware/slsReceiver/UHRIXCallback.cpp delete mode 100644 slsDetectorSoftware/slsReceiver/UHRIXCallback.h diff --git a/slsDetectorSoftware/eigerDetectorServer/Makefile b/slsDetectorSoftware/eigerDetectorServer/Makefile index d3cea6d22..db4249325 100644 --- a/slsDetectorSoftware/eigerDetectorServer/Makefile +++ b/slsDetectorSoftware/eigerDetectorServer/Makefile @@ -1,5 +1,5 @@ CC = g++#powerpc-4xx-softfloat-g++ -CLAGS += -Wall -DDACS_INT -DSLS_DETECTOR_FUNCTION_LIST -DEIGERD #-DVIRTUAL +CLAGS += -Wall -DDACS_INT -DEIGERD #-DSLS_DETECTOR_FUNCTION_LIST #-DVIRTUAL LDLIBS += -lm -lstdc++ PROGS = eigerDetectorServer diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h new file mode 100644 index 000000000..4efd49838 --- /dev/null +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h @@ -0,0 +1,31 @@ +/* + * slsDetectorServer_defs.h + * + * Created on: Jan 24, 2013 + * Author: l_maliakal_d + */ + +#ifndef SLSDETECTORSERVER_DEFS_H_ +#define SLSDETECTORSERVER_DEFS_H_ + +#include "sls_detector_defs.h" +#include + +#define GOODBYE -200 + + +/* examples +#define NCHAN 1 +#define NCHIP 1 +#define NDAC 1 +#define NADC 1 +#define NMAXMODX 1 +#define NMAXMODY 1 +#define NMAXMOD NMAXMODX*NMAXMODY +#define NCHANS NCHAN*NCHIP*NMAXMOD +#define NDACS NDAC*NMAXMOD +*/ + + + +#endif /* SLSDETECTORSERVER_DEFS_H_ */ diff --git a/slsDetectorSoftware/gotthardDetectorServer/svnInfoGotthard.h b/slsDetectorSoftware/gotthardDetectorServer/svnInfoGotthard.h index 5135ac9f2..2187d6799 100644 --- a/slsDetectorSoftware/gotthardDetectorServer/svnInfoGotthard.h +++ b/slsDetectorSoftware/gotthardDetectorServer/svnInfoGotthard.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/gotthardDetectorServer" //#define SVNREPPATH "" #define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x557 +//#define SVNREV 0x565 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x557 -#define SVNDATE 0x20130516 +#define SVNREV 0x565 +#define SVNDATE 0x20130517 // diff --git a/slsDetectorSoftware/moenchDetectorServer/svnInfoMoench.h b/slsDetectorSoftware/moenchDetectorServer/svnInfoMoench.h index ce93a7156..15ed00e31 100644 --- a/slsDetectorSoftware/moenchDetectorServer/svnInfoMoench.h +++ b/slsDetectorSoftware/moenchDetectorServer/svnInfoMoench.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/moenchDetectorServer" //#define SVNREPPATH "" #define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x563 +//#define SVNREV 0x572 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x563 -#define SVNDATE 0x20130517 +#define SVNREV 0x572 +#define SVNDATE 0x20130521 // diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 85f1ea288..9da873a12 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4684,8 +4684,3 @@ int multiSlsDetector::setReadReceiverFrequency(int getFromReceiver,int i){ -void multiSlsDetector::waitForReceiverReadToFinish(){ - for (int idet=0; idetnumberOfDetectors; idet++) - if (detectors[idet]) - detectors[idet]->waitForReceiverReadToFinish(); -} diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 39790ad54..bdd465f32 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1203,10 +1203,6 @@ class multiSlsDetector : public slsDetectorUtils { /** updates the multidetector offsets */ void updateOffsets(); - /** - * Waits for receiver read to finish after stopping acquisition - */ - void waitForReceiverReadToFinish(); protected: diff --git a/slsDetectorSoftware/mythenDetectorServer/svnInfoMythen.h b/slsDetectorSoftware/mythenDetectorServer/svnInfoMythen.h index 126e18931..539c64f94 100644 --- a/slsDetectorSoftware/mythenDetectorServer/svnInfoMythen.h +++ b/slsDetectorSoftware/mythenDetectorServer/svnInfoMythen.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/mythenDetectorServer" //#define SVNREPPATH "" #define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x557 +//#define SVNREV 0x565 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x557 -#define SVNDATE 0x20130516 +#define SVNREV 0x565 +#define SVNDATE 0x20130517 // diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 83398bb7d..495a40195 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -6360,10 +6360,3 @@ int slsDetector::setReadReceiverFrequency(int getFromReceiver,int i){ } -void slsDetector::waitForReceiverReadToFinish(){ - if(dataSocket){ - while(dataSocket->Connect() < 0) - usleep(1000); - dataSocket->Disconnect(); - } -} diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 2d4f8b37c..d288574e4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1603,10 +1603,6 @@ class slsDetector : public slsDetectorUtils, public energyConversion { */ int setReadReceiverFrequency(int getFromReceiver, int i=-1); - /** - * Waits for receiver read to finish after stopping acquisition - */ - void waitForReceiverReadToFinish(); protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 629bedf0b..567af254b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -230,7 +230,9 @@ void slsDetectorUsers::finalizeDataset(double *a, double *v, double *e, int &np) - +int slsDetectorUsers::setReceiverMode(int n){ + return myDetector->setReadReceiverFrequency(1,n); +} diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index 115a62162..ee6ba64ea 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -415,6 +415,13 @@ class slsDetectorUsers */ string getDetectorType(); + /** + @short sets the mode by which gui requests data from receiver + \param n is 0 for random requests for fast acquisitions and greater than 0 for nth read requests + \returns the mode set in the receiver + */ + int setReceiverMode(int n=-1); + /** @short register calbback for accessing detector final data \param userCallback function for plotting/analyzing the data. Its arguments are the data structure d and the frame number f. diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 3411632cb..e80d8deed 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -683,11 +683,6 @@ virtual ROI* getROI(int &n)=0; virtual int setReadReceiverFrequency(int getFromReceiver, int i=-1)=0; -/** - * Waits for receiver read to finish after stopping acquisition -*/ -virtual void waitForReceiverReadToFinish()=0; - protected: diff --git a/slsDetectorSoftware/slsDetector/svnInfoLib.h b/slsDetectorSoftware/slsDetector/svnInfoLib.h index 34117f0d9..f7ad49572 100644 --- a/slsDetectorSoftware/slsDetector/svnInfoLib.h +++ b/slsDetectorSoftware/slsDetector/svnInfoLib.h @@ -2,10 +2,10 @@ #define SVNURLLIB "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware" //#define SVNREPPATH "" #define SVNREPUUIDLIB "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x564 +//#define SVNREV 0x576 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTHLIB "l_maliakal_d" -#define SVNREVLIB 0x564 -#define SVNDATELIB 0x20130517 +#define SVNREVLIB 0x576 +#define SVNDATELIB 0x20130523 // diff --git a/slsDetectorSoftware/slsDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServer/Makefile index 8f7039037..9f8c63c8b 100644 --- a/slsDetectorSoftware/slsDetectorServer/Makefile +++ b/slsDetectorSoftware/slsDetectorServer/Makefile @@ -1,5 +1,5 @@ CC = gcc -CLAGS += -Wall -DVIRTUAL -DDACS_INT -DSLS_DETECTOR_FUNCTION_LIST -DGENERIC +CLAGS += -Wall -DVIRTUAL -DDACS_INT -DGENERIC # -DSLS_DETECTOR_FUNCTION_LIST LDLIBS += -lm PROGS = genericDetectorServer diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h index 0da50207f..1f2d3de8f 100644 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h @@ -32,14 +32,19 @@ Here are the definitions, but the actual implementation should be done for each ****************************************************/ - +int mapCSP0(void); int initializeDetector(); - +enum masterFlags setMaster(enum masterFlags arg); +enum synchronizationMode setSynchronization(enum synchronizationMode arg); int setNMod(int nm, enum dimension dim); int getNModBoard(enum dimension arg); +enum externalSignalFlag getExtSignal(int signalindex); +enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag); +enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); + int64_t getModuleId(enum idMode arg, int imod); int64_t getDetectorId(enum idMode arg); int moduleTest( enum digitalTestMode arg, int imod); @@ -48,42 +53,46 @@ int detectorTest( enum digitalTestMode arg); double setDAC(enum dacIndex ind, double val, int imod); double getADC(enum dacIndex ind, int imod); +bus_w() +bus_r() int setChannel(sls_detector_channel myChan); int getChannel(sls_detector_channel *myChan); int setChip(sls_detector_chip myChip); int getChip(sls_detector_chip *myChip); int setModule(sls_detector_module myChan); int getModule(sls_detector_module *myChan); + +enum detectorSettings setSettings(enum detectorSettings sett, int imod); int getThresholdEnergy(int imod); int setThresholdEnergy(int thr, int imod); -enum detectorSettings setSettings(enum detectorSettings sett, int imod); - int startStateMachine(); int stopStateMachine(); int startReadOut(); enum runStatus getRunStatus(); char *readFrame(int *ret, char *mess); + + int64_t setTimer(enum timerIndex ind, int64_t val); int64_t getTimeLeft(enum timerIndex ind); + int setDynamicRange(int dr); - - -int setROI(int mask); //////????????????????? -int getROI(int *mask); //////////????????????????????? -int setSpeed(enum speedVariable arg, int val); enum readOutFlags setReadOutFlags(enum readOutFlags val); +int setROI(int mask); +int setSpeed(enum speedVariable arg, int val); int executeTrimming(enum trimMode mode, int par1, int par2, int imod); - - +#ifdef GOTTHARDD int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb); int loadImage(enum imageType index, char *imageVals); int readCounterBlock(int startACQ, char *counterVals); int resetCounterBlock(int startACQ); +int startReceiver(int d); +int calibratePedestal(int frames); +#endif + int calculateDataBytes(); - int getTotalNumberOfChannels(); int getTotalNumberOfChips(); int getTotalNumberOfModules(); @@ -94,12 +103,6 @@ int getNumberOfDACsPerModule(); int getNumberOfADCsPerModule(); -enum externalSignalFlag getExtSignal(int signalindex); -enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag); -enum externalCommunicationMode setTiming( enum externalCommunicationMode arg); -enum masterFlags setMaster(enum masterFlags arg); -enum synchronizationMode setSynchronization(enum synchronizationMode arg); - #endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index 77f097131..136569cc7 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -13,7 +13,8 @@ #include - +//#if defined(EIGERD) || defined(GOTHARDD) break; +//#endif // Global variables @@ -36,11 +37,12 @@ const enum detectorType myDetectorType=GENERIC; //define in communication_funcs +/* extern int lockStatus; extern char lastClientIP[INET_ADDRSTRLEN]; extern char thisClientIP[INET_ADDRSTRLEN]; extern int differentClients; - +*/ /* global variables for optimized readout */ @@ -57,17 +59,16 @@ int init_detector(int b) { printf("This is a VIRTUAL detector\n"); #endif - //mapCSP0(); + mapCSP0(); //only for control server if(b){ #ifdef SLS_DETECTOR_FUNCTION_LIST - //initializeDetector(); + initializeDetector(); //testFpga(); //testRAM(); - //setSettings(GET_SETTINGS,-1); //Initialization - + //setSettings(GET_SETTINGS,-1); //setFrames(1); //setTrains(1); //setExposureTime(1e6); @@ -90,7 +91,7 @@ int init_detector(int b) { int decode_function(int file_des) { int fnum,n; - int retval=FAIL; + int ret=FAIL; #ifdef VERBOSE printf( "receive data\n"); #endif @@ -109,10 +110,10 @@ int decode_function(int file_des) { #endif if (fnum<0 || fnum>255) fnum=255; - retval=(*flist[fnum])(file_des); - if (retval==FAIL) + ret=(*flist[fnum])(file_des); + if (ret==FAIL) printf( "Error executing the function = %d \n",fnum); - return retval; + return ret; } @@ -194,18 +195,18 @@ int function_table() { int M_nofunc(int file_des){ - int retval=FAIL; + int ret=FAIL; sprintf(mess,"Unrecognized Function\n"); printf(mess); - sendDataOnly(file_des,&retval,sizeof(retval)); + sendDataOnly(file_des,&ret,sizeof(ret)); sendDataOnly(file_des,mess,sizeof(mess)); return GOODBYE; } int exit_server(int file_des) { - int retval=FAIL; - sendDataOnly(file_des,&retval,sizeof(retval)); + int ret=FAIL; + sendDataOnly(file_des,&ret,sizeof(ret)); printf("closing server."); sprintf(mess,"closing server"); sendDataOnly(file_des,mess,sizeof(mess)); @@ -215,7 +216,7 @@ int exit_server(int file_des) { int exec_command(int file_des) { char cmd[MAX_STR_LENGTH]; char answer[MAX_STR_LENGTH]; - int retval=OK; + int ret=OK; int sysret=0; int n=0; @@ -223,11 +224,11 @@ int exec_command(int file_des) { n = receiveDataOnly(file_des,cmd,MAX_STR_LENGTH); if (n < 0) { sprintf(mess,"Error reading from socket\n"); - retval=FAIL; + ret=FAIL; } /* execute action if the arguments correctly arrived*/ - if (retval==OK) { + if (ret==OK) { #ifdef VERBOSE printf("executing command %s\n", cmd); #endif @@ -241,23 +242,23 @@ int exec_command(int file_des) { sprintf(answer,"Detector locked by %s\n", lastClientIP); } else { sprintf(answer,"Failed\n"); - retval=FAIL; + ret=FAIL; } } else { sprintf(answer,"Could not receive the command\n"); } /* send answer */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); + n = sendDataOnly(file_des,&ret,sizeof(ret)); n = sendDataOnly(file_des,answer,MAX_STR_LENGTH); if (n < 0) { sprintf(mess,"Error writing to socket"); - retval=FAIL; + ret=FAIL; } /*return ok/fail*/ - return retval; + return ret; } @@ -468,6 +469,7 @@ int set_master(int file_des) { printf("setting master flags to %d\n",arg); #endif +#ifdef SLS_DETECTOR_FUNCTION_LIST if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { ret=FAIL; sprintf(mess,"Detector locked by %s\n",lastClientIP); @@ -475,9 +477,11 @@ int set_master(int file_des) { retval=setMaster(arg); } +#endif if (retval==GET_MASTER) { ret=FAIL; } + n = sendDataOnly(file_des,&ret,sizeof(ret)); if (ret==FAIL) { n = sendDataOnly(file_des,mess,sizeof(mess)); @@ -513,15 +517,19 @@ int set_synchronization(int file_des) { printf("setting master flags to %d\n",arg); #endif +#ifdef SLS_DETECTOR_FUNCTION_LIST if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { ret=FAIL; sprintf(mess,"Detector locked by %s\n",lastClientIP); } else { retval=setSynchronization(arg); } +#endif + if (retval==GET_SYNCHRONIZATION_MODE) { ret=FAIL; } + n = sendDataOnly(file_des,&ret,sizeof(ret)); if (ret==FAIL) { n = sendDataOnly(file_des,mess,sizeof(mess)); @@ -539,15 +547,15 @@ int set_synchronization(int file_des) { int get_detector_type(int file_des) { int n=0; - enum detectorType ret; - int retval=OK; + enum detectorType retval; + int ret=OK; sprintf(mess,"Can't return detector type\n"); /* receive arguments */ /* execute action */ - ret=myDetectorType; + retval=myDetectorType; #ifdef VERBOSE printf("Returning detector type %d\n",ret); @@ -558,15 +566,15 @@ int get_detector_type(int file_des) { if (differentClients==1) retval=FORCE_UPDATE; - n += sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { + n += sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret!=FAIL) { /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); + n += sendDataOnly(file_des,&retval,sizeof(retval)); } else { n += sendDataOnly(file_des,mess,sizeof(mess)); } /*return ok/fail*/ - return retval; + return ret; } @@ -574,8 +582,8 @@ int get_detector_type(int file_des) { int set_number_of_modules(int file_des) { int n; - int arg[2], ret=0; - int retval=OK; + int arg[2], retval=0; + int ret=OK; enum dimension dim; int nm; @@ -585,9 +593,9 @@ int set_number_of_modules(int file_des) { n = receiveDataOnly(file_des,&arg,sizeof(arg)); if (n < 0) { sprintf(mess,"Error reading from socket %d", n); - retval=GOODBYE; + ret=GOODBYE; } - if (retval==OK) { + if (ret==OK) { dim=arg[0]; nm=arg[1]; @@ -596,43 +604,42 @@ int set_number_of_modules(int file_des) { printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); #endif - +#ifdef SLS_DETECTOR_FUNCTION_LIST if (lockStatus==1 && differentClients==1 && nm!=GET_FLAG) { sprintf(mess,"Detector locked by %s\n", lastClientIP); - retval=FAIL; - } else { - ret=setNMod(nm, dim); - if (ret==nm || nm==GET_FLAG) { - retval=OK; - if (differentClients==1) - retval=FORCE_UPDATE; - } else - retval=FAIL; - } + ret=FAIL; + } else + retval=setNMod(nm, dim); } - - dataBytes=calculateDataBytes(); +#endif + + if (retval==nm || nm==GET_FLAG) { + ret=OK; + if (differentClients==1) + ret=FORCE_UPDATE; + } else + ret=FAIL; /* send answer */ /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret!=FAIL) { /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); + n += sendDataOnly(file_des,&retval,sizeof(retval)); } else { n += sendDataOnly(file_des,mess,sizeof(mess)); } - /*return ok/fail*/ - return retval; + /*return ok/fail*/ + return ret; } int get_max_number_of_modules(int file_des) { int n; - int ret; - int retval=OK; + int retval; + int ret=OK; enum dimension arg; sprintf(mess,"Can't get max number of modules\n"); @@ -640,39 +647,37 @@ int get_max_number_of_modules(int file_des) { n = receiveDataOnly(file_des,&arg,sizeof(arg)); if (n < 0) { sprintf(mess,"Error reading from socket\n"); - retval=FAIL; + ret=FAIL; } /* execute action */ #ifdef VERBOSE printf("Getting the max number of modules in dimension %d \n",arg); #endif +#ifdef SLS_DETECTOR_FUNCTION_LIST - ret=getNModBoard(arg); + retval=getNModBoard(arg); +#endif #ifdef VERBOSE - printf("Max number of module in dimension %d is %d\n",arg,ret ); + printf("Max number of module in dimension %d is %d\n",arg,retval ); #endif - - - if (differentClients==1 && retval==OK) { - retval=FORCE_UPDATE; + if (differentClients==1 && ret==OK) { + ret=FORCE_UPDATE; } /* send answer */ /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret!=FAIL) { /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); + n += sendDataOnly(file_des,&retval,sizeof(retval)); } else { n += sendDataOnly(file_des,mess,sizeof(mess)); } - - /*return ok/fail*/ - return retval; + return ret; } @@ -686,7 +691,7 @@ int set_external_signal_flag(int file_des) { int arg[2]; int ret=OK; int signalindex; - enum externalSignalFlag flag, retval; + enum externalSignalFlag flag, retval=SIGNAL_OFF; sprintf(mess,"Can't set external signal flag\n"); @@ -696,7 +701,7 @@ int set_external_signal_flag(int file_des) { sprintf(mess,"Error reading from socket\n"); ret=FAIL; } - retval=SIGNAL_OFF; +#ifdef SLS_DETECTOR_FUNCTION_LIST if (ret==OK) { signalindex=arg[0]; flag=arg[1]; @@ -705,7 +710,6 @@ int set_external_signal_flag(int file_des) { case GET_EXTERNAL_SIGNAL_FLAG: retval=getExtSignal(signalindex); break; - default: if (differentClients==0 || lockStatus==0) { retval=setExtSignal(signalindex,flag); @@ -714,24 +718,20 @@ int set_external_signal_flag(int file_des) { sprintf(mess,"External signal %d flag should be 0x%04x but is 0x%04x\n", signalindex, flag, retval); } - } else { - if (lockStatus!=0) { + } else if (lockStatus!=0) { ret=FAIL; sprintf(mess,"Detector locked by %s\n", lastClientIP); - } } - break; } - #ifdef VERBOSE printf("Setting external signal %d to flag %d\n",signalindex,flag ); printf("Set to flag %d\n",retval); #endif - } else { ret=FAIL; } +#endif if (ret==OK && differentClients!=0) ret=FORCE_UPDATE; @@ -756,8 +756,8 @@ int set_external_signal_flag(int file_des) { int set_external_communication_mode(int file_des) { int n; - enum externalCommunicationMode arg, ret=GET_EXTERNAL_COMMUNICATION_MODE; - int retval=OK; + enum externalCommunicationMode arg, retval=GET_EXTERNAL_COMMUNICATION_MODE; + int ret=OK; sprintf(mess,"Can't set external communication mode\n"); @@ -766,7 +766,7 @@ int set_external_communication_mode(int file_des) { n = receiveDataOnly(file_des,&arg,sizeof(arg)); if (n < 0) { sprintf(mess,"Error reading from socket\n"); - retval=FAIL; + ret=FAIL; } /* enum externalCommunicationMode{ @@ -782,15 +782,16 @@ enum externalCommunicationMode{ GATE_COINCIDENCE_WITH_INTERNAL_ENABLE }; */ - if (retval==OK) { +#ifdef SLS_DETECTOR_FUNCTION_LIST + if (ret==OK) { /* execute action */ - ret=setTiming(arg); + retval=setTiming(arg); /* switch(arg) { */ /* default: */ /* sprintf(mess,"The meaning of single signals should be set\n"); */ - /* retval=FAIL; */ + /* ret=FAIL; */ /* } */ @@ -799,19 +800,20 @@ enum externalCommunicationMode{ #endif } else ret=FAIL; +#endif /* send answer */ /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret!=FAIL) { /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); + n += sendDataOnly(file_des,&retval,sizeof(retval)); } else { n += sendDataOnly(file_des,mess,sizeof(mess)); } /*return ok/fail*/ - return retval; + return ret; } @@ -2929,7 +2931,6 @@ int reset_counter_block(int file_des) { - int start_receiver(int file_des) { int ret=OK; int n=0; diff --git a/slsDetectorSoftware/slsReceiver/Makefile b/slsDetectorSoftware/slsReceiver/Makefile index 5d3a52641..31680bb33 100644 --- a/slsDetectorSoftware/slsReceiver/Makefile +++ b/slsDetectorSoftware/slsReceiver/Makefile @@ -1,14 +1,14 @@ CC = g++ -CLAGS += -DSLS_RECEIVER_FUNCTION_LIST #-DUHRIXCALLBACK #-DTESTWRITE +CLAGS += -DSLS_RECEIVER_FUNCTION_LIST LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ #LDLIBS += -lm -lstdc++ -lpthread LIBS?= -L$(LIBDIR) -lSlsDetector -INCLUDES ?= -I ../MySocketTCP -I ../commonFiles -I ../usersFunctions -I ../slsDetectorAnalysis -I . +INCLUDES ?= -I ../MySocketTCP -I ../commonFiles -I -I ../slsDetectorAnalysis -I . SRC_CLNT = slsReceiver.cpp -#../MySocketTCP/MySocketTCP.cpp slsReceiver_funcs.cpp UHRIXCallback.cpp slsReceiverFunctionList.cpp ../usersFunctions/usersFunctions.cpp slsReceiverUsers.cpp +#../MySocketTCP/MySocketTCP.cpp slsReceiver_funcs.cpp UHRIXCallback.cpp slsReceiverFunctionList.cpp slsReceiverUsers.cpp DESTDIR ?= bin INSTMODE = 0777 diff --git a/slsDetectorSoftware/slsReceiver/UHRIXCallback.cpp b/slsDetectorSoftware/slsReceiver/UHRIXCallback.cpp deleted file mode 100644 index e45115a06..000000000 --- a/slsDetectorSoftware/slsReceiver/UHRIXCallback.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -#include "UHRIXCallback.h" - - -int UHRIXCallbackDataFunc(char* d, int np, FILE* fd, void* p){ - int i,j,jmax=6; - u_int16_t da; - - - //#ifdef VERBOSE - //printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Receiver Data received \n"); - if (d==NULL) - printf("no data received\n"); - else{ - // printf("received %d bytes of data\n",np); - // printf("index:%d\n",(int)(*(int*)d)); - for ( i=0; i<(np-4)/2-jmax+1; i++) - { - //((int16_t *)d)[i+2] -= ((int16_t *)d)[i+3]; - //((int16_t *)d)[i+2] *= ((int16_t *)d)[i+2]; - for (j=1; j - -int UHRIXCallbackDataFunc(char* d, int np, FILE* fd, void* p); diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index eb9b290d4..95b8b3341 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -7,14 +7,6 @@ #include "slsReceiverFunctionList.h" -#ifdef TESTWRITE -#include "usersFunctions.h" -#endif - -#ifdef UHRIXCALLBACK -#include "UHRIXCallback.h" -#endif - #include // SIGINT #include // stat #include // socket(), bind(), listen(), accept(), shut down @@ -58,8 +50,6 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit guiFileName(NULL), currframenum(0), nFrameToGui(0), - writeReceiverData(0), - pwriteReceiverDataArg(0), startAcquisitionCallBack(NULL), pStartAcquisition(NULL), acquisitionFinishedCallBack(NULL), @@ -111,14 +101,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit if(withGotthard) cout << "Testing MOENCH Receiver with GOTTHARD Detector" << endl; -#ifdef TESTWRITE - //to test write receiver data call back - registerWriteReceiverDataCallback(&defaultWriteReceiverDataFunc, NULL); -#endif -#ifdef UHRIXCALLBACK - registerWriteReceiverDataCallback(&UHRIXCallbackDataFunc, latestData); -#endif } @@ -443,7 +426,7 @@ int slsReceiverFunctionList::startWriting(){ strcpy(guiFileName,""); cout << "Max Frames Per File:" << maxFramesPerFile << endl; - if (writeReceiverData) + if (rawDataReadyCallBack) cout << "Note: Data Write has been defined exernally" << endl; if(nFrameToGui) cout << "Sending every " << nFrameToGui << "th frame to gui" << endl; @@ -510,13 +493,9 @@ int slsReceiverFunctionList::startWriting(){ //cout<<"**************curreframenm:"<=0) nFrameToGui = i; return nFrameToGui;}; - /** - * Register call back function to write receiver data - */ - void registerWriteReceiverDataCallback(int( *userCallback)(char*, int, FILE*, void*), void *pArg) {writeReceiverData = userCallback; pwriteReceiverDataArg = pArg;}; - - private: /** detector type */ @@ -314,11 +304,6 @@ private: int nFrameToGui; - - /** register for call back to get data */ - int (*writeReceiverData)(char*,int,FILE*,void*); - void *pwriteReceiverDataArg; - /** callback arguments are filepath @@ -348,10 +333,11 @@ private: args to raw data ready callback are framenum datapointer + datasize in bytes file descriptor guidatapointer (NULL, no data required) */ - void (*rawDataReadyCallBack)(int, char*, FILE*, char*, void*); + void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*); void *pRawDataReady; /** The action which decides what the user and default responsibilites to save data are @@ -407,10 +393,11 @@ public: args to raw data ready callback are framenum datapointer + datasize in bytes file descriptor guidatapointer (NULL, no data required) */ - void registerCallBackRawDataReady(void (*func)(int, char*, FILE*, char*, void*),void *arg){rawDataReadyCallBack=func; pRawDataReady=arg;}; + void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){rawDataReadyCallBack=func; pRawDataReady=arg;}; }; diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp index 98faab77e..b3ce2c824 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp @@ -30,7 +30,7 @@ void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(int, voi } -void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(int, char*, FILE*, char*, void*),void *arg){ +void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){ receiver->registerCallBackRawDataReady(func,arg); } diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h index 52b911276..2c3f5ce96 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h @@ -64,11 +64,11 @@ public: /** @sort register callback to be called when data are available (to process and/or save the data). - \param func raw data ready callback. arguments are framenum datapointer file descriptor guidatapointer (NULL, no data required) + \param func raw data ready callback. arguments are framenum datapointer datasize file descriptor guidatapointer (NULL, no data required) \returns nothing */ - void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, FILE* filedescriptor, char* guidatapointer, void*),void *arg); + void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, int datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg); private: diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h index d5ba684e7..4b75cfa20 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h @@ -71,11 +71,12 @@ public: args to raw data ready callback are framenum datapointer + datasize in bytes file descriptor guidatapointer (NULL, no data required) */ - void registerCallBackRawDataReady(void (*func)(int, char*, FILE*, char*, void*),void *arg){slsReceiverList->registerCallBackRawDataReady(func,arg);}; + void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){slsReceiverList->registerCallBackRawDataReady(func,arg);}; private: diff --git a/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h b/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h index 02f18f2fa..c932fabef 100644 --- a/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h +++ b/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/slsReceiver" //#define SVNREPPATH "" #define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x561 +//#define SVNREV 0x568 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x561 -#define SVNDATE 0x20130516 +#define SVNREV 0x568 +#define SVNDATE 0x20130521 //