From 660ed4c1773820cd0c30f12eb84bb803ffa45ef4 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 25 Oct 2018 14:11:40 +0200 Subject: [PATCH] changed users set/getDetectorsize API to include a single ROI --- .../slsDetector/slsDetectorCommand.cpp | 7 +++- .../slsDetector/slsDetectorUsers.cpp | 38 ++++++++++++++----- .../slsDetector/slsDetectorUsers.h | 6 +-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 398c937f9..82b358700 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -4533,7 +4533,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { myDet->setReceiverOnline(ONLINE_FLAG); ret=myDet->setDynamicRange(val); } else if (cmd=="roi") { - myDet->getROI(ret); + ROI* r = myDet->getROI(ret); + if (myDet->isMultiSlsDetectorClass() && r != NULL) + delete [] r; } else if (cmd=="detsizechan") { sprintf(ans,"%d %d",myDet->getMaxNumberOfChannelsPerDetector(X),myDet->getMaxNumberOfChannelsPerDetector(Y)); return string(ans); @@ -6995,7 +6997,8 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { } } os << hex << reg << dec; - + if (myDet->isMultiSlsDetectorClass() && aa != NULL) + delete [] aa; //os <<" "<< hex << myDet->readRegister(120) << dec; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index b76d9da18..e4bb9026c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -115,17 +115,37 @@ int slsDetectorUsers::getPositions(double *pos){ } int slsDetectorUsers::setDetectorSize(int x0, int y0, int nx, int ny){ - if(myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y)>1) - return 1; - int nmod=nx/(myDetector->getChansPerMod(0)); - cout << myDetector->getChansPerMod(0) << " " << nx << " " << nmod << endl; - return myDetector->setNumberOfModules(nmod)*myDetector->getChansPerMod(0);} + // only one roi + slsDetectorDefs::ROI roi[1]; + roi[0].xmin = x0; + roi[0].ymin = y0; + roi[0].xmax = x0 + nx; + roi[0].ymax = y0 + ny; + return myDetector->setROI(1, roi); +} int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){ - y0=0; - x0=0; - nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X); - ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y); + int n = 0; + slsDetectorDefs::ROI* roi = myDetector->getROI(n); + + // roi + if (roi != NULL && n > 0) { + x0 = roi[0].xmin; + y0 = roi[0].ymin; + nx = roi[0].xmax - roi[0].xmin; + ny = roi[0].ymax - roi[0].ymin; + } + // no roi + else { + y0=0; + x0=0; + nx=myDetector->getTotalNumberOfChannels(slsDetectorDefs::X); + ny=myDetector->getTotalNumberOfChannels(slsDetectorDefs::Y); + } + + if (roi != NULL) + delete [] roi; + return nx*ny; } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index f9976a70b..9a0f1a5a8 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -247,7 +247,7 @@ class slsDetectorUsers int getPositions(double *pos=NULL); /** - @short sets the detector size + @short sets the detector size (only 1 ROI) (not Mythen supported anymore) \param x0 horizontal position origin in channel number (-1 unchanged) \param y0 vertical position origin in channel number (-1 unchanged) \param nx number of channels in horiziontal (-1 unchanged) @@ -258,12 +258,12 @@ class slsDetectorUsers /** - @short gets detector size + @short gets detector size (not Mythen supported anymore) \param x0 horizontal position origin in channel number \param y0 vertical position origin in channel number \param nx number of channels in horiziontal \param ny number of channels in vertical - \returns OK/FAIL + \returns total number of channels */ int getDetectorSize(int &x0, int &y0, int &nx, int &ny); /**