diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 8d0e67711..0aa4529f4 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -3261,7 +3261,10 @@ void multiSlsDetector::verifyMinMaxROI(int n, ROI r[]) { } } -int multiSlsDetector::setROI(int n, ROI roiLimits[]) { +int multiSlsDetector::setROI(int n, ROI roiLimits[], int imod) { + if (imod > 0 && imod < (int)detectors.size()) { + return detectors[imod]->setROI(n, roiLimits, imod); + } int ret1 = -100, ret; int i, xmin, xmax, ymin, ymax, channelX, channelY, idet, lastChannelX, lastChannelY, index, offsetX, offsetY; @@ -3393,8 +3396,10 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) { } -slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) { - +slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n, int imod) { + if (imod > 0 && imod < (int)detectors.size()) { + return detectors[imod]->getROI(n, imod); + } n = 0; int num = 0, i, j; int ndet = detectors.size(); diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index dd6afede9..6bc712ea9 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1222,16 +1222,18 @@ public: * At the moment only one set allowed * @param n number of rois * @param roiLimits array of roi + * @param imod module number (-1 for all) * @returns OK or FAIL */ - int setROI(int n=-1,ROI roiLimits[]=NULL); + int setROI(int n=-1,ROI roiLimits[]=NULL, int imod = -1); /** * Get ROI from each detector and convert it to the multi detector scale (Gotthard) * @param n number of rois - * @returns OK or FAIL + * @param imod module number (-1 for all) + * @returns pointer to array of ROI structure */ - ROI* getROI(int &n); + ROI* getROI(int &n, int imod = -1); /** * Write to ADC register (Gotthard, Jungfrau, ChipTestBoard). For expert users diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 80f4ecc0a..1277a3788 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -6017,7 +6017,7 @@ int slsDetector::setCounterBit(int i) { -int slsDetector::setROI(int n,ROI roiLimits[]) { +int slsDetector::setROI(int n,ROI roiLimits[], int imod) { int ret = FAIL; //sort ascending order int temp; @@ -6053,7 +6053,7 @@ int slsDetector::setROI(int n,ROI roiLimits[]) { } -slsDetectorDefs::ROI* slsDetector::getROI(int &n) { +slsDetectorDefs::ROI* slsDetector::getROI(int &n, int imod) { sendROI(-1,NULL); n=thisDetector->nROI; if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels(); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 2562d7d0a..7e8e1e80d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1500,16 +1500,18 @@ public: * At the moment only one set allowed * @param n number of rois * @param roiLimits array of roi + * @param imod module number (ignored) * @returns OK or FAIL */ - int setROI(int n=-1,ROI roiLimits[]=NULL); + int setROI(int n=-1,ROI roiLimits[]=NULL, int imod = -1); - /** - * Get ROI from each detector and convert it to the multi detector scale (Gotthard) - * @param n number of rois - * @returns OK or FAIL - */ - slsDetectorDefs::ROI* getROI(int &n); + /** + * Get ROI from each detector and convert it to the multi detector scale (Gotthard) + * @param n number of rois + * @param imod module number (ignored) + * @returns pointer to array of ROI structure + */ + ROI* getROI(int &n, int imod = -1); /** * Returns number of rois diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 73e6451a6..5ef912f1c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -4534,7 +4534,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { ret=myDet->setDynamicRange(val); } else if (cmd=="roi") { ROI* r = myDet->getROI(ret); - if (r != NULL) + if (myDet->isMultiSlsDetectorClass() && r != NULL) delete [] r; } else if (cmd=="detsizechan") { sprintf(ans,"%d %d",myDet->getMaxNumberOfChannelsPerDetector(X),myDet->getMaxNumberOfChannelsPerDetector(Y)); @@ -6997,7 +6997,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { } } os << hex << reg << dec; - if (aa != NULL) + if (myDet->isMultiSlsDetectorClass() && aa != NULL) delete [] aa; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index c55826799..556777db1 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -135,7 +135,7 @@ int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){ slsDetectorDefs::ROI* roi = myDetector->getROI(n); // roi - if (roi != NULL && n > 0) { + if (roi != NULL && n == 1) { x0 = roi[0].xmin; y0 = roi[0].ymin; nx = roi[0].xmax - roi[0].xmin; @@ -513,3 +513,11 @@ int64_t slsDetectorUsers::setNumberOfStorageCells(int64_t t, int imod) { int slsDetectorUsers::setStoragecellStart(int pos) { return myDetector->setStoragecellStart(pos); } + +int slsDetectorUsers::setROI(int n, slsDetectorDefs::ROI roiLimits[], int imod) { + return myDetector->setROI(n, roiLimits, imod); +} + +slsDetectorDefs::ROI* slsDetectorUsers::getROI(int &n, int imod) { + return myDetector->getROI(n, imod); +} diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index 44fd5ebad..cabc9de66 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -17,6 +17,8 @@ class detectorData; class multiSlsDetector; class multiSlsDetectorCommand; +#include "sls_detector_defs.h" + #include #include @@ -256,9 +258,8 @@ class slsDetectorUsers */ int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1); - /** - @short gets detector size + @short gets detector size (roi size if only one roi) \param x0 horizontal position origin in channel number \param y0 vertical position origin in channel number \param nx number of channels in horiziontal @@ -818,6 +819,25 @@ class slsDetectorUsers */ int setStoragecellStart(int pos=-1); + /** + * Set ROI (Gotthard) (>= 1 roi, but max 1 roi per module) + * At the moment only one set allowed + * @param n number of rois + * @param roiLimits array of roi + * @param imod module number (-1 for all) + * @returns OK or FAIL + */ + int setROI(int n=-1, slsDetectorDefs::ROI roiLimits[]=NULL, int imod = -1); + + /** + * Get ROI from each detector and convert it to the multi detector scale (Gotthard) + * >= 1 roi, but max 1 roi per module + * @param n number of rois + * @param imod module number (ignored) + * @returns pointer to array of ROI structure + */ + slsDetectorDefs::ROI* getROI(int &n, int imod = -1); + /************************************************************************ STATIC FUNCTIONS diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 68fb13179..13988d42c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -869,16 +869,18 @@ virtual int calibratePedestal(int frames = 0)=0; set roi \param n number of rois \param roiLimits array of roi + \param imod module number (-1 for all) \returns success or failure */ -virtual int setROI(int n=-1,ROI roiLimits[]=NULL)=0; +virtual int setROI(int n=-1,ROI roiLimits[]=NULL, int imod = -1)=0; /** get roi from each detector and convert it to the multi detector scale \param n number of rois - \returns an array of multidetector's rois + \param imod module number (-1 for all) + \returns pointer to array of ROI structure */ -virtual ROI* getROI(int &n)=0; +virtual ROI* getROI(int &n, int imod = -1)=0; /** Sets the read receiver frequency if data required from receiver randomly readRxrFrequency=0,