From 272167435d5627e3e544a5a4a4af199ee9bf9859 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 1 Sep 2017 12:04:04 +0200 Subject: [PATCH] gainplot added, masking done separately before converting to double --- .../multiSlsDetector/multiSlsDetector.cpp | 43 ++++++++++++++----- .../multiSlsDetector/multiSlsDetector.h | 13 +++++- .../slsDetectorAnalysis/detectorData.h | 6 ++- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 3652d3a80..26de3b26e 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -279,6 +279,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1) threadpool = 0; if(createThreadPool() == FAIL) exit(-1); + gainDataEnable = false; } @@ -5436,7 +5437,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){ -int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, +int multiSlsDetector::getData(const int isocket, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) { //fail is on parse error or end of acquisition @@ -5446,14 +5447,6 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image, //receiving incorrect size is replaced by 0xFF zmqSocket[isocket]->ReceiveData(isocket, image, size); - //jungfrau masking adcval - if(masking){ - unsigned int snel = size/sizeof(int); - for(unsigned int i=0;inumberOfDetectors; int numSocketsPerSLSDetector = 1; bool jungfrau = false; + double* gdata = NULL; switch(getDetectorsType()){ case EIGER: numSocketsPerSLSDetector = 2; @@ -5526,6 +5520,9 @@ void multiSlsDetector::readFrameFromReceiver(){ return; } int* multiframe=new int[nel](); + int* multiframegain=NULL; + if (jungfrau) + multiframegain = new int[nel](); int nch; bool runningList[numSockets]; @@ -5552,7 +5549,7 @@ void multiSlsDetector::readFrameFromReceiver(){ //if running if (runningList[isocket]) { //get individual images - if(FAIL == getData(isocket, jungfrau, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){ + if(FAIL == getData(isocket, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){ runningList[isocket] = false; numRunning--; continue; @@ -5606,12 +5603,29 @@ void multiSlsDetector::readFrameFromReceiver(){ //send data to callback if(running){ + if (jungfrau) { + // with gain data + if (gainDataEnable) { + memcpy(multiframegain, multiframe, nel * sizeof(int)); + for(unsigned int i=0;i> 14) | ((multiframe[i] & 0x0000C000) >> 14) ; + multiframe[i] = (multiframe[i] & 0x3FFF3FFF); + } + gdata = decodeData(multiframegain,nch); + } + // without gain data + else { + for(unsigned int i=0;iexternalgui; } + + +void multiSlsDetector::setGainDataEnableinDataCallback(bool e) { + gainDataEnable = e; +} diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 258bfa933..5a1fc4139 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1457,6 +1457,13 @@ 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: @@ -1464,7 +1471,6 @@ private: /** * Gets data from socket * @param isocket socket index - * @param masking if masking required (jungfrau) * @param image image buffer * @param size size of image * @param acqIndex address of acquisition index @@ -1472,7 +1478,7 @@ private: * @param subframeIndex address of subframe index * @param filename address of file name */ - int getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename); + int getData(const int isocket, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename); /** Ensures if sockets created successfully */ @@ -1496,6 +1502,9 @@ 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 888993fa0..f0d238b4e 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h @@ -16,15 +16,16 @@ class detectorData { \param fname file name to which the data are saved \param np number of points in x coordinate defaults to the number of detector channels (1D detector) \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) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){ + 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) : values(val), 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;}; + ~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles; if (gvalues) delete [] gvalues;}; //private: double *values; /**< @short pointer to the data */ double *errors; /**< @short pointer to the errors */ @@ -33,6 +34,7 @@ class detectorData { 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 */ };