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

View File

@ -19,7 +19,7 @@ class ZmqSocket;
#include <string> #include <string>
#define MULTI_SHMVERSION 0x180628 #define MULTI_SHMVERSION 0x180629
#define SHORT_STRING_LENGTH 50 #define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30 #define DATE_LENGTH 30
@ -72,12 +72,6 @@ private:
/** type of synchronization between detectors */ /** type of synchronization between detectors */
synchronizationMode syncMode; 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 */ /** size of the data that are transfered from all detectors */
int dataBytes; int dataBytes;
@ -721,6 +715,22 @@ public:
*/ */
int setMaxNumberOfChannelsPerDetector(dimension d,int i); 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 * Updates the channel offsets in X and Y dimension for all the sls detectors
* It is required for decodeNMod and setting ROI * It is required for decodeNMod and setting ROI

View File

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

View File

@ -19,7 +19,7 @@ class multiSlsDetector;
class SharedMemory; class SharedMemory;
class receiverInterface; class receiverInterface;
#define SLS_SHMVERSION 0x180628 #define SLS_SHMVERSION 0x180629
#define NMODMAXX 24 #define NMODMAXX 24
#define NMODMAXY 24 #define NMODMAXY 24
#define NCHIPSMAX 10 #define NCHIPSMAX 10
@ -57,11 +57,6 @@ private:
/** shared memory version */ /** shared memory version */
int shmversion; int shmversion;
/** END OF FIXED PATTERN -----------------------------------------------*/
/** online flag - is set if the detector is connected, unset if socket /** online flag - is set if the detector is connected, unset if socket
* connection is not possible */ * connection is not possible */
int onlineFlag; int onlineFlag;
@ -74,6 +69,14 @@ private:
* before starting the communication */ * before starting the communication */
char hostname[MAX_STR_LENGTH]; 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 */ /** is the port used for control functions */
int controlPort; int controlPort;
@ -719,6 +722,20 @@ public:
*/ */
int getNChips(dimension d); 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 * Checks if the detector is online and sets the online flag
* @param online if GET_ONLINE_FLAG, only returns shared memory online flag, * @param online if GET_ONLINE_FLAG, only returns shared memory online flag,