From afc08f8c304631f0f16647e46bd674f2f643b042 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 29 Sep 2017 16:43:19 +0200 Subject: [PATCH] double* changed to char* in gui data call back, decoding to be done by caller. enablegappixels skeleton created --- .../multiSlsDetector/multiSlsDetector.cpp | 54 ++----------------- .../multiSlsDetector/multiSlsDetector.h | 12 +---- .../slsDetectorAnalysis/detectorData.h | 21 ++++---- .../slsDetectorAnalysis/postProcessing.h | 2 +- 4 files changed, 17 insertions(+), 72 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 8945faba9..726a2da63 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -282,8 +282,6 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) threadpool = 0; if(createThreadPool() == FAIL) exit(-1); - gainDataEnable = false; - } multiSlsDetector::~multiSlsDetector() { @@ -5711,7 +5709,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){ -int multiSlsDetector::getData(const int isocket, int* image, const int size, +int multiSlsDetector::getData(const int isocket, char* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) { //fail is on parse error or end of acquisition @@ -5786,18 +5784,6 @@ void multiSlsDetector::readFrameFromReceiver(){ } int expectedslssize = slsdatabytes/numSocketsPerSLSDetector; - /*int* image = new int[(expectedslssize/sizeof(int))](); - int nel=(thisMultiDetector->dataBytes)/sizeof(int); - if(nel <= 0){ - cprintf(RED,"Error: Multislsdetector databytes not valid : %d\n", thisMultiDetector->dataBytes); - return; - } - int* multiframe=new int[nel](); - int* multiframegain=NULL; - if (jungfrau) - multiframegain = new int[nel](); - */ - char* image = new char[expectedslssize](); char* multiframe = new char[thisMultiDetector->dataBytes](); char* multiframegain = NULL; @@ -5822,7 +5808,7 @@ void multiSlsDetector::readFrameFromReceiver(){ //exit when last message for each socket received while(running){ - memset(multiframe,0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors);/*memset(((char*)multiframe),0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors);*/ //reset frame memory + memset(multiframe,0xFF,slsdatabytes*thisMultiDetector->numberOfDetectors); //reset frame memory //get each frame for(int isocket=0; isocket> 14) | ((multiframe[i] & 0x0000C000) >> 14) ; - multiframe[i] = (multiframe[i] & 0x3FFF3FFF); - } - gdata = decodeData(multiframegain,nch); - } - // without gain data - else { - for(unsigned int i=0;idataBytes, NULL,NULL,getCurrentProgress(),currentFileName.c_str(),maxX,maxY); + thisData = new detectorData(NULL,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),maxX,maxY,multiframe, thisMultiDetector->dataBytes); dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg); delete thisData; + //cout<<"Send frame #"<< currentFrameIndex << " to gui"<externalgui; } - -void multiSlsDetector::setGainDataEnableinDataCallback(bool e) { - gainDataEnable = e; -} diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 005e37572..08552e0e7 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1477,13 +1477,6 @@ class multiSlsDetector : public slsDetectorUtils { */ bool getExternalGuiFlag(); - /** - * Set Gain Data enable for gain plot - * in data call back - * @param e enable - */ - void setGainDataEnableinDataCallback(bool e); - private: @@ -1498,7 +1491,7 @@ private: * @param subframeIndex address of subframe index * @param filename address of file name */ - int getData(const int isocket, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename); + int getData(const int isocket, char* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename); /** Ensures if sockets created successfully */ @@ -1522,9 +1515,6 @@ private: private: ThreadPool* threadpool; - /** Gain Data enabled in data call back */ - bool gainDataEnable; - }; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h index f120ade1d..8e5c8a07d 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h @@ -18,28 +18,27 @@ class detectorData { \param ny dimension in y (1D detector) \param gval pointer to gain data (for jungfrau) */ - detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, double* gval=NULL) : cvalues(NULL), databytes(-1), values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), gvalues(gval){ + detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), cvalues(cval), databytes(dbytes), dgainvalues(NULL) { strcpy(fileName,fname); }; - detectorData(char *val=NULL, int db=0, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1, double* gval=NULL) : cvalues(val), databytes(db), values(NULL), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny), gvalues(gval){ - strcpy(fileName,fname); - }; - /** + + /** @short The destructor deletes also the arrays pointing to data/errors/angles if not NULL - */ - ~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if (gvalues) delete [] gvalues;}; + cvalues are deleted by caller + */ + ~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if(dgainvalues) delete [] dgainvalues;}; //private: - char* cvalues; - int databytes; - double *values; /**< @short pointer to the data */ + double *values; /**< @short pointer to the data as double array */ double *errors; /**< @short pointer to the errors */ double *angles;/**< @short pointer to the angles (NULL if no angular conversion) */ double progressIndex;/**< @short file index */ char fileName[1000];/**< @short file name */ int npoints;/**< @short number of points */ int npy;/**< @short dimensions in y coordinate*/ - double *gvalues; /**< @short pointer to the gain data */ + char* cvalues; /**< @short pointer to the data as char arary */ + int databytes; /**< @short number of bytes of data. Used with cvalues */ + double* dgainvalues; /**< @short pointer to gain data as double array */ }; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h index 02e305f4f..d2e87722c 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.h @@ -332,7 +332,7 @@ s double *fdata; - int (*dataReady)(detectorData*,int, int,void*); + int (*dataReady)(detectorData*,int, int, void*); void *pCallbackArg; detectorData *thisData;