Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
Gemma Tinti 2018-06-29 13:47:48 +02:00
commit 7e16f3ebeb
4 changed files with 86 additions and 37 deletions

View File

@ -285,20 +285,20 @@ int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int& channelX, in
channelY = -1;
//loop over
for (int i = 0; i < detectors.size(); ++i) {
int x = detectors[i]->getDetectorOffset(X);
int y = detectors[i]->getDetectorOffset(Y);
//check x offset range
if ((offsetX >= thisMultiDetector->offsetX[i]) &&
(offsetX < (thisMultiDetector->offsetX[i] +
detectors[i]->getMaxNumberOfChannelsInclGapPixels(X)))) {
if ((offsetX >= x) &&
(offsetX < (x + detectors[i]->getMaxNumberOfChannelsInclGapPixels(X)))) {
if (offsetY == -1) {
channelX = offsetX - thisMultiDetector->offsetX[i];
channelX = offsetX - x;
return i;
} else {
//check y offset range
if ((offsetY >= thisMultiDetector->offsetY[i]) &&
(offsetY < (thisMultiDetector->offsetY[i] +
detectors[i]->getMaxNumberOfChannelsInclGapPixels(Y)))) {
channelX = offsetX - thisMultiDetector->offsetX[i];
channelY = offsetY - thisMultiDetector->offsetY[i];
if ((offsetY >= y) &&
(offsetY < (y + detectors[i]->getMaxNumberOfChannelsInclGapPixels(Y)))) {
channelX = offsetX - x;
channelY = offsetY - y;
return i;
}
}
@ -752,10 +752,6 @@ void multiSlsDetector::initializeDetectorStructure() {
thisMultiDetector->stoppedFlag = 0;
thisMultiDetector->masterPosition = -1;
thisMultiDetector->syncMode = GET_SYNCHRONIZATION_MODE;
for(int i = 0; i < MAXDET; ++i) {
thisMultiDetector->offsetX[i] = 0;
thisMultiDetector->offsetY[i] = 0;
}
thisMultiDetector->dataBytes = 0;
thisMultiDetector->dataBytesInclGapPixels = 0;
thisMultiDetector->numberOfChannels = 0;
@ -967,6 +963,8 @@ void multiSlsDetector::addMultipleDetectors(const char* name) {
// a get to update shared memory online flag
setOnline();
updateOffsets();
createThreadPool();
}
void multiSlsDetector::addSlsDetector (std::string s) {
@ -1006,9 +1004,6 @@ void multiSlsDetector::addSlsDetector (std::string s) {
thisMultiDetector->dataBytesInclGapPixels += detectors[pos]->getDataBytesInclGapPixels();
thisMultiDetector->numberOfChannels += detectors[pos]->getTotalNumberOfChannels();
thisMultiDetector->maxNumberOfChannels += detectors[pos]->getMaxNumberOfChannels();
updateOffsets();
createThreadPool();
}
@ -1214,6 +1209,18 @@ int multiSlsDetector::setMaxNumberOfChannelsPerDetector(dimension d,int i) {
return thisMultiDetector->maxNumberOfChannelsPerDetector[d];
}
int multiSlsDetector::getDetectorOffset(dimension d, int pos) {
if (pos < 0 || pos >= detectors.size())
return -1;
return detectors[pos]->getDetectorOffset(d);
}
void multiSlsDetector::setDetectorOffset(dimension d, int off, int pos) {
if (pos < 0 || pos >= detectors.size())
detectors[pos]->setDetectorOffset(d, off);
}
void multiSlsDetector::updateOffsets() {
//cannot paralllize due to slsdetector calling this via parentdet->
@ -1336,10 +1343,13 @@ void multiSlsDetector::updateOffsets() {
double bytesperchannel = (double)detectors[idet]->getDataBytes() /
(double)(detectors[idet]->getMaxNumberOfChannels(X)
* detectors[idet]->getMaxNumberOfChannels(Y));
detectors[idet]->setDetectorOffset(X, (bytesperchannel >= 1.0) ? offsetX_gp : offsetX);
detectors[idet]->setDetectorOffset(Y, (bytesperchannel >= 1.0) ? offsetY_gp : offsetY);
#ifdef VERBOSE
cout << "Detector[" << idet << "] has offsets (" <<
thisMultiDetector->offsetX[idet] << ", " <<
thisMultiDetector->offsetY[idet] << ")" << endl;
detectors[idet]->getDetectorOffset(X) << ", " <<
detectors[idet]->getDetectorOffset(Y) << ")" << endl;
#endif
//offsetY has been reset sometimes and offsetX the first time,
//but remember the highest values
@ -3199,8 +3209,8 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) {
lastChannelX = (detectors[idet]->getMaxNumberOfChannelsInclGapPixels(X)) - 1;
lastChannelY = (detectors[idet]->getMaxNumberOfChannelsInclGapPixels(Y)) - 1;
offsetX = thisMultiDetector->offsetX[idet];
offsetY = thisMultiDetector->offsetY[idet];
offsetX = detectors[idet]->getDetectorOffset(X);
offsetY = detectors[idet]->getDetectorOffset(Y);
//at the end in x dir
if ((offsetX + lastChannelX) >= xmax)
lastChannelX = xmax - offsetX;
@ -3296,10 +3306,12 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) {
cout << temp[j].xmin << "\t" << temp[j].xmax << "\t"
<< temp[j].ymin << "\t" << temp[j].ymax << endl;
//#endif
roiLimits[n].xmin = temp[j].xmin + thisMultiDetector->offsetX[i];
roiLimits[n].xmax = temp[j].xmax + thisMultiDetector->offsetX[i];
roiLimits[n].ymin = temp[j].ymin + thisMultiDetector->offsetY[i];
roiLimits[n].ymax = temp[j].ymin + thisMultiDetector->offsetY[i];
int x = detectors[i]->getDetectorOffset(X);
int y = detectors[i]->getDetectorOffset(Y);
roiLimits[n].xmin = temp[j].xmin + x;
roiLimits[n].xmax = temp[j].xmax + x;
roiLimits[n].ymin = temp[j].ymin + y;
roiLimits[n].ymax = temp[j].ymin + y;
++n;
}
}

View File

@ -19,7 +19,7 @@ class ZmqSocket;
#include <string>
#define MULTI_SHMVERSION 0x180628
#define MULTI_SHMVERSION 0x180629
#define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30
@ -72,12 +72,6 @@ private:
/** type of synchronization between detectors */
synchronizationMode syncMode;
/** Detectors offset in the X direction (in number of channels)*/
int offsetX[MAXDET];
/** Detectors offsets in the Y direction (in number of channels) */
int offsetY[MAXDET];
/** size of the data that are transfered from all detectors */
int dataBytes;
@ -721,6 +715,22 @@ public:
*/
int setMaxNumberOfChannelsPerDetector(dimension d,int i);
/**
* Get Detector offset from shared memory in dimension d
* @param d dimension d
* @param pos detector position in multi detector list
* @returns offset in dimension d, -1 if pos is not an actual position in list
*/
int getDetectorOffset(dimension d, int pos);
/**
* Set Detector offset in shared memory in dimension d
* @param d dimension d
* @param off offset for detector
* @param pos detector position in multi detector list
*/
void setDetectorOffset(dimension d, int off, int pos);
/**
* Updates the channel offsets in X and Y dimension for all the sls detectors
* It is required for decodeNMod and setting ROI

View File

@ -636,6 +636,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->stoppedFlag = 0;
strncpy(thisDetector->hostname, DEFAULT_HOSTNAME, MAX_STR_LENGTH-1);
thisDetector->hostname[MAX_STR_LENGTH-1] = 0;
thisDetector->offset[X] = 0;
thisDetector->offset[Y] = 0;
thisDetector->controlPort = DEFAULT_PORTNO;
thisDetector->stopPort = DEFAULT_PORTNO + 1;
thisDetector->myDetectorType = type;
@ -1692,6 +1694,14 @@ int slsDetector::getNChips(dimension d) {
return thisDetector->nChip[d];
}
int slsDetector::getDetectorOffset(dimension d) {
return thisDetector->offset[d];
}
void slsDetector::setDetectorOffset(dimension d, int off) {
if (off >= 0)
thisDetector->offset[d] = off;
}
int slsDetector::setOnline(int off) {
int old=thisDetector->onlineFlag;

View File

@ -19,7 +19,7 @@ class multiSlsDetector;
class SharedMemory;
class receiverInterface;
#define SLS_SHMVERSION 0x180628
#define SLS_SHMVERSION 0x180629
#define NMODMAXX 24
#define NMODMAXY 24
#define NCHIPSMAX 10
@ -57,11 +57,6 @@ private:
/** shared memory version */
int shmversion;
/** END OF FIXED PATTERN -----------------------------------------------*/
/** online flag - is set if the detector is connected, unset if socket
* connection is not possible */
int onlineFlag;
@ -74,6 +69,14 @@ private:
* before starting the communication */
char hostname[MAX_STR_LENGTH];
/** END OF FIXED PATTERN -----------------------------------------------*/
/** Detector offset in the X & Y direction in the multi detector structure */
int offset[2];
/** is the port used for control functions */
int controlPort;
@ -719,6 +722,20 @@ public:
*/
int getNChips(dimension d);
/**
* Get Detector offset from shared memory in dimension d
* @param d dimension d
* @returns offset in dimension d
*/
int getDetectorOffset(dimension d);
/**
* Set Detector offset in shared memory in dimension d
* @param d dimension d
* @param off offset for detector
*/
void setDetectorOffset(dimension d, int off);
/**
* Checks if the detector is online and sets the online flag
* @param online if GET_ONLINE_FLAG, only returns shared memory online flag,