mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
Merge branch 'apidhanya' of github.com:slsdetectorgroup/slsDetectorPackage into apidhanya
This commit is contained in:
commit
7721787748
@ -252,6 +252,51 @@ class Detector {
|
|||||||
*/
|
*/
|
||||||
void setMaxNumberOfChannels(const defs::coordinates value);
|
void setMaxNumberOfChannels(const defs::coordinates value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Detector offset from shared memory (Gotthard only)
|
||||||
|
* @param pos detector position
|
||||||
|
* @returns offset in both dimensions
|
||||||
|
*/
|
||||||
|
Result<defs::coordinates> getDetectorOffsets(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Detector offset in shared memory for each module
|
||||||
|
* @param value offset for detector in both dimensions
|
||||||
|
* @param pos detector position
|
||||||
|
*/
|
||||||
|
void setDetectorOffsets(defs::coordinates value, Positions pos = {});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Quad Type (Only for Eiger Quad detector hardware)
|
||||||
|
* @param pos detector position
|
||||||
|
* @returns quad type
|
||||||
|
*/
|
||||||
|
Result<bool> getQuad(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Quad Type (Only for Eiger Quad detector hardware)
|
||||||
|
* @param enable true if quad type set, else false
|
||||||
|
* @param pos detector position
|
||||||
|
*/
|
||||||
|
void setQuad(const bool enable, Positions pos = {});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of rows to read out (Only for Eiger)
|
||||||
|
* @param pos detector position
|
||||||
|
* @returns number of lines
|
||||||
|
*/
|
||||||
|
Result<int> getReadNLines(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set number of rows to read out (Only for Eiger)
|
||||||
|
* @param value number of lines
|
||||||
|
* @param pos detector position
|
||||||
|
*/
|
||||||
|
void setReadNLines(const int value, Positions pos = {});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Erik
|
// Erik
|
||||||
|
|
||||||
Result<int> getFramesCaughtByReceiver(Positions pos = {}) const;
|
Result<int> getFramesCaughtByReceiver(Positions pos = {}) const;
|
||||||
@ -334,7 +379,7 @@ class Detector {
|
|||||||
* @param start start address for level 0-2
|
* @param start start address for level 0-2
|
||||||
* @param stop stop address for level 0-2
|
* @param stop stop address for level 0-2
|
||||||
* @param n number of loops for level 0-2
|
* @param n number of loops for level 0-2
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param pos detector position
|
||||||
*/
|
*/
|
||||||
void setPatternLoops(int level, int start, int stop, int n,
|
void setPatternLoops(int level, int start, int stop, int n,
|
||||||
Positions pos = {});
|
Positions pos = {});
|
||||||
|
@ -475,34 +475,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
void setMaxNumberOfChannels(const slsDetectorDefs::coordinates c); //
|
void setMaxNumberOfChannels(const slsDetectorDefs::coordinates c); //
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Quad Type (Only for Eiger Quad detector hardware)
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
* @returns quad type
|
|
||||||
*/
|
|
||||||
int getQuad(int detPos = -1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Quad Type (Only for Eiger Quad detector hardware)
|
|
||||||
* @param enable true if quad type set, else false
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
*/
|
|
||||||
void setQuad(const bool enable, int detPos = -1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set number of rows to read out (Only for Eiger)
|
|
||||||
* @param value number of lines
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
*/
|
|
||||||
void setReadNLines(const int value, int detPos = -1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get number of rows to read out (Only for Eiger)
|
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
|
||||||
* @returns number of lines
|
|
||||||
*/
|
|
||||||
int getReadNLines(int detPos = -1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Detector offset from shared memory in dimension d
|
* Get Detector offset from shared memory in dimension d
|
||||||
* @param d dimension d
|
* @param d dimension d
|
||||||
@ -510,7 +482,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
* @returns offset in dimension d, -1 if pos is not an actual position in
|
* @returns offset in dimension d, -1 if pos is not an actual position in
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
int getDetectorOffset(dimension d, int detPos = -1);
|
int getDetectorOffset(dimension d, int detPos = -1); //
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Detector offset in shared memory in dimension d
|
* Set Detector offset in shared memory in dimension d
|
||||||
@ -518,13 +490,35 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
* @param off offset for detector
|
* @param off offset for detector
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
*/
|
*/
|
||||||
void setDetectorOffset(dimension d, int off, int detPos = -1);
|
void setDetectorOffset(dimension d, int off, int detPos = -1);//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the channel offsets in X and Y dimension for all the sls
|
* Get Quad Type (Only for Eiger Quad detector hardware)
|
||||||
* detectors It is required for decodeNMod and setting ROI
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
* @returns quad type
|
||||||
*/
|
*/
|
||||||
void updateOffsets();
|
int getQuad(int detPos = -1);//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Quad Type (Only for Eiger Quad detector hardware)
|
||||||
|
* @param enable true if quad type set, else false
|
||||||
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
*/
|
||||||
|
void setQuad(const bool enable, int detPos = -1);//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set number of rows to read out (Only for Eiger)
|
||||||
|
* @param value number of lines
|
||||||
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
*/
|
||||||
|
void setReadNLines(const int value, int detPos = -1);//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get number of rows to read out (Only for Eiger)
|
||||||
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
* @returns number of lines
|
||||||
|
*/
|
||||||
|
int getReadNLines(int detPos = -1);//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if each of the detectors are online/offline
|
* Checks if each of the detectors are online/offline
|
||||||
@ -2302,6 +2296,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY);
|
int decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the channel offsets in X and Y dimension for all the sls
|
||||||
|
* detectors It is required for decodeNMod and setting ROI
|
||||||
|
*/
|
||||||
|
void updateOffsets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute in command line and return result
|
* Execute in command line and return result
|
||||||
* @param cmd command
|
* @param cmd command
|
||||||
|
@ -403,7 +403,7 @@ class slsDetector : public virtual slsDetectorDefs {
|
|||||||
* Get Quad Type (Only for Eiger Quad detector hardware)
|
* Get Quad Type (Only for Eiger Quad detector hardware)
|
||||||
* @returns quad type
|
* @returns quad type
|
||||||
*/
|
*/
|
||||||
int getQuad();
|
bool getQuad();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Quad Type (Only for Eiger Quad detector hardware)
|
* Set Quad Type (Only for Eiger Quad detector hardware)
|
||||||
@ -430,12 +430,24 @@ class slsDetector : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int getDetectorOffset(dimension d) const;
|
int getDetectorOffset(dimension d) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Detector offset from shared memory in dimension d
|
||||||
|
* @returns offset
|
||||||
|
*/
|
||||||
|
slsDetectorDefs::coordinates getDetectorOffsets() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Detector offset in shared memory in dimension d
|
* Set Detector offset in shared memory in dimension d
|
||||||
* @param d dimension d
|
* @param d dimension d
|
||||||
* @param off offset for detector
|
* @param off offset for detector
|
||||||
*/
|
*/
|
||||||
void setDetectorOffset(dimension d, int off);
|
void setDetectorOffset(dimension d, int off);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Detector offset in shared memory
|
||||||
|
* @param value offset for detector
|
||||||
|
*/
|
||||||
|
void setDetectorOffsets(slsDetectorDefs::coordinates value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Detector offset in shared memory in dimension d
|
* Set Detector offset in shared memory in dimension d
|
||||||
|
@ -204,9 +204,32 @@ void Detector::setMaxNumberOfChannels(const defs::coordinates value) {
|
|||||||
pimpl->setMaxNumberOfChannels(value);
|
pimpl->setMaxNumberOfChannels(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
Result<defs::coordinates> Detector::getDetectorOffsets(Positions pos) const {
|
||||||
//
|
return pimpl->Parallel(&slsDetector::getDetectorOffsets, pos);
|
||||||
//
|
}
|
||||||
|
|
||||||
|
void Detector::setDetectorOffsets(defs::coordinates value, Positions pos) {
|
||||||
|
return pimpl->Parallel(&slsDetector::setDetectorOffsets, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getQuad(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&slsDetector::getQuad, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setQuad(const bool value, Positions pos) {
|
||||||
|
pimpl->setQuad(value, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<int> Detector::getReadNLines(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&slsDetector::getReadNLines, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setReadNLines(const int value, Positions pos) {
|
||||||
|
pimpl->Parallel(&slsDetector::setReadNLines, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Erik
|
// Erik
|
||||||
Result<int> Detector::getFramesCaughtByReceiver(Positions pos) const {
|
Result<int> Detector::getFramesCaughtByReceiver(Positions pos) const {
|
||||||
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);
|
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);
|
||||||
|
@ -370,6 +370,167 @@ int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int &channelX,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void multiSlsDetector::updateOffsets() {
|
||||||
|
FILE_LOG(logDEBUG1) << "Updating Multi-Detector Offsets";
|
||||||
|
|
||||||
|
int offsetX = 0, offsetY = 0, numX = 0, numY = 0;
|
||||||
|
int maxChanX = multi_shm()->maxNumberOfChannelsPerDetector[X];
|
||||||
|
int maxChanY = multi_shm()->maxNumberOfChannelsPerDetector[Y];
|
||||||
|
int prevChanX = 0;
|
||||||
|
int prevChanY = 0;
|
||||||
|
bool firstTime = true;
|
||||||
|
|
||||||
|
multi_shm()->numberOfChannel[X] = 0;
|
||||||
|
multi_shm()->numberOfChannel[Y] = 0;
|
||||||
|
multi_shm()->numberOfDetector[X] = 0;
|
||||||
|
multi_shm()->numberOfDetector[Y] = 0;
|
||||||
|
|
||||||
|
// gap pixels
|
||||||
|
int offsetX_gp = 0, offsetY_gp = 0, numX_gp = 0, numY_gp = 0;
|
||||||
|
int prevChanX_gp = 0, prevChanY_gp = 0;
|
||||||
|
multi_shm()->numberOfChannelInclGapPixels[X] = 0;
|
||||||
|
multi_shm()->numberOfChannelInclGapPixels[Y] = 0;
|
||||||
|
|
||||||
|
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
||||||
|
FILE_LOG(logDEBUG1)
|
||||||
|
<< "offsetX:" << offsetX << " prevChanX:" << prevChanX
|
||||||
|
<< " offsetY:" << offsetY << " prevChanY:" << prevChanY
|
||||||
|
<< " offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp
|
||||||
|
<< " offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp;
|
||||||
|
|
||||||
|
// incrementing in both direction
|
||||||
|
if (firstTime) {
|
||||||
|
// incrementing in both directions
|
||||||
|
firstTime = false;
|
||||||
|
if ((maxChanX > 0) &&
|
||||||
|
((offsetX + detectors[idet]->getTotalNumberOfChannels(X)) >
|
||||||
|
maxChanX)) {
|
||||||
|
FILE_LOG(logWARNING)
|
||||||
|
<< "\nDetector[" << idet
|
||||||
|
<< "] exceeds maximum channels "
|
||||||
|
"allowed for complete detector set in X dimension!";
|
||||||
|
}
|
||||||
|
if ((maxChanY > 0) &&
|
||||||
|
((offsetY + detectors[idet]->getTotalNumberOfChannels(Y)) >
|
||||||
|
maxChanY)) {
|
||||||
|
FILE_LOG(logERROR)
|
||||||
|
<< "\nDetector[" << idet
|
||||||
|
<< "] exceeds maximum channels "
|
||||||
|
"allowed for complete detector set in Y dimension!";
|
||||||
|
}
|
||||||
|
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
||||||
|
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||||
|
prevChanX_gp =
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||||
|
prevChanY_gp =
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||||
|
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
||||||
|
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
||||||
|
numX_gp +=
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||||
|
numY_gp +=
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||||
|
++multi_shm()->numberOfDetector[X];
|
||||||
|
++multi_shm()->numberOfDetector[Y];
|
||||||
|
FILE_LOG(logDEBUG1) << "incrementing in both direction";
|
||||||
|
}
|
||||||
|
|
||||||
|
// incrementing in y direction
|
||||||
|
else if ((maxChanY == -1) ||
|
||||||
|
((maxChanY > 0) && ((offsetY + prevChanY +
|
||||||
|
detectors[idet]->getTotalNumberOfChannels(
|
||||||
|
Y)) <= maxChanY))) {
|
||||||
|
offsetY += prevChanY;
|
||||||
|
offsetY_gp += prevChanY_gp;
|
||||||
|
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||||
|
prevChanY_gp =
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||||
|
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
||||||
|
numY_gp +=
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||||
|
// increment in y again only in the first column (else you double
|
||||||
|
// increment)
|
||||||
|
if (multi_shm()->numberOfDetector[X] == 1)
|
||||||
|
++multi_shm()->numberOfDetector[Y];
|
||||||
|
FILE_LOG(logDEBUG1) << "incrementing in y direction";
|
||||||
|
}
|
||||||
|
|
||||||
|
// incrementing in x direction
|
||||||
|
else {
|
||||||
|
if ((maxChanX > 0) &&
|
||||||
|
((offsetX + prevChanX +
|
||||||
|
detectors[idet]->getTotalNumberOfChannels(X)) > maxChanX)) {
|
||||||
|
FILE_LOG(logDEBUG1)
|
||||||
|
<< "\nDetector[" << idet
|
||||||
|
<< "] exceeds maximum channels "
|
||||||
|
"allowed for complete detector set in X dimension!";
|
||||||
|
}
|
||||||
|
offsetY = 0;
|
||||||
|
offsetY_gp = 0;
|
||||||
|
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
||||||
|
prevChanY_gp =
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
||||||
|
numY = 0; // assuming symmetry with this statement.
|
||||||
|
// whats on 1st column should be on 2nd column
|
||||||
|
numY_gp = 0;
|
||||||
|
offsetX += prevChanX;
|
||||||
|
offsetX_gp += prevChanX_gp;
|
||||||
|
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
||||||
|
prevChanX_gp =
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||||
|
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
||||||
|
numX_gp +=
|
||||||
|
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
||||||
|
++multi_shm()->numberOfDetector[X];
|
||||||
|
FILE_LOG(logDEBUG1) << "incrementing in x direction";
|
||||||
|
}
|
||||||
|
|
||||||
|
double bytesperchannel =
|
||||||
|
(double)detectors[idet]->getDataBytes() /
|
||||||
|
(double)(detectors[idet]->getTotalNumberOfChannels(X) *
|
||||||
|
detectors[idet]->getTotalNumberOfChannels(Y));
|
||||||
|
detectors[idet]->setDetectorOffset(
|
||||||
|
X, (bytesperchannel >= 1.0) ? offsetX_gp : offsetX);
|
||||||
|
detectors[idet]->setDetectorOffset(
|
||||||
|
Y, (bytesperchannel >= 1.0) ? offsetY_gp : offsetY);
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG1) << "Detector[" << idet << "] has offsets ("
|
||||||
|
<< detectors[idet]->getDetectorOffset(X) << ", "
|
||||||
|
<< detectors[idet]->getDetectorOffset(Y) << ")";
|
||||||
|
// offsetY has been reset sometimes and offsetX the first time,
|
||||||
|
// but remember the highest values
|
||||||
|
if (numX > multi_shm()->numberOfChannel[X]) {
|
||||||
|
multi_shm()->numberOfChannel[X] = numX;
|
||||||
|
}
|
||||||
|
if (numY > multi_shm()->numberOfChannel[Y]) {
|
||||||
|
multi_shm()->numberOfChannel[Y] = numY;
|
||||||
|
}
|
||||||
|
if (numX_gp > multi_shm()->numberOfChannelInclGapPixels[X]) {
|
||||||
|
multi_shm()->numberOfChannelInclGapPixels[X] = numX_gp;
|
||||||
|
}
|
||||||
|
if (numY_gp > multi_shm()->numberOfChannelInclGapPixels[Y]) {
|
||||||
|
multi_shm()->numberOfChannelInclGapPixels[Y] = numY_gp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FILE_LOG(logDEBUG1)
|
||||||
|
<< "\n\tNumber of Channels in X direction:"
|
||||||
|
<< multi_shm()->numberOfChannel[X]
|
||||||
|
<< "\n\tNumber of Channels in Y direction:"
|
||||||
|
<< multi_shm()->numberOfChannel[Y]
|
||||||
|
<< "\n\tNumber of Channels in X direction with Gap Pixels:"
|
||||||
|
<< multi_shm()->numberOfChannelInclGapPixels[X]
|
||||||
|
<< "\n\tNumber of Channels in Y direction with Gap Pixels:"
|
||||||
|
<< multi_shm()->numberOfChannelInclGapPixels[Y];
|
||||||
|
|
||||||
|
multi_shm()->numberOfChannels =
|
||||||
|
multi_shm()->numberOfChannel[0] * multi_shm()->numberOfChannel[1];
|
||||||
|
|
||||||
|
for (auto &d : detectors) {
|
||||||
|
d->updateMultiSize(multi_shm()->numberOfDetector[0],
|
||||||
|
multi_shm()->numberOfDetector[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string multiSlsDetector::exec(const char *cmd) {
|
std::string multiSlsDetector::exec(const char *cmd) {
|
||||||
int bufsize = 128;
|
int bufsize = 128;
|
||||||
char buffer[bufsize];
|
char buffer[bufsize];
|
||||||
@ -580,6 +741,14 @@ void multiSlsDetector::setMaxNumberOfChannels(const slsDetectorDefs::coordinates
|
|||||||
multi_shm()->maxNumberOfChannelsPerDetector[Y] = c.y;
|
multi_shm()->maxNumberOfChannelsPerDetector[Y] = c.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int multiSlsDetector::getDetectorOffset(dimension d, int detPos) {
|
||||||
|
return detectors[detPos]->getDetectorOffset(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void multiSlsDetector::setDetectorOffset(dimension d, int off, int detPos) {
|
||||||
|
detectors[detPos]->setDetectorOffset(d, off);
|
||||||
|
}
|
||||||
|
|
||||||
int multiSlsDetector::getQuad(int detPos) {
|
int multiSlsDetector::getQuad(int detPos) {
|
||||||
int retval = detectors[0]->getQuad();
|
int retval = detectors[0]->getQuad();
|
||||||
if (retval && getNumberOfDetectors() > 1) {
|
if (retval && getNumberOfDetectors() > 1) {
|
||||||
@ -619,175 +788,6 @@ int multiSlsDetector::getReadNLines(int detPos) {
|
|||||||
return sls::minusOneIfDifferent(r);
|
return sls::minusOneIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int multiSlsDetector::getDetectorOffset(dimension d, int detPos) {
|
|
||||||
return detectors[detPos]->getDetectorOffset(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
void multiSlsDetector::setDetectorOffset(dimension d, int off, int detPos) {
|
|
||||||
detectors[detPos]->setDetectorOffset(d, off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void multiSlsDetector::updateOffsets() {
|
|
||||||
FILE_LOG(logDEBUG1) << "Updating Multi-Detector Offsets";
|
|
||||||
|
|
||||||
int offsetX = 0, offsetY = 0, numX = 0, numY = 0;
|
|
||||||
int maxChanX = multi_shm()->maxNumberOfChannelsPerDetector[X];
|
|
||||||
int maxChanY = multi_shm()->maxNumberOfChannelsPerDetector[Y];
|
|
||||||
int prevChanX = 0;
|
|
||||||
int prevChanY = 0;
|
|
||||||
bool firstTime = true;
|
|
||||||
|
|
||||||
multi_shm()->numberOfChannel[X] = 0;
|
|
||||||
multi_shm()->numberOfChannel[Y] = 0;
|
|
||||||
multi_shm()->numberOfDetector[X] = 0;
|
|
||||||
multi_shm()->numberOfDetector[Y] = 0;
|
|
||||||
|
|
||||||
// gap pixels
|
|
||||||
int offsetX_gp = 0, offsetY_gp = 0, numX_gp = 0, numY_gp = 0;
|
|
||||||
int prevChanX_gp = 0, prevChanY_gp = 0;
|
|
||||||
multi_shm()->numberOfChannelInclGapPixels[X] = 0;
|
|
||||||
multi_shm()->numberOfChannelInclGapPixels[Y] = 0;
|
|
||||||
|
|
||||||
for (size_t idet = 0; idet < detectors.size(); ++idet) {
|
|
||||||
FILE_LOG(logDEBUG1)
|
|
||||||
<< "offsetX:" << offsetX << " prevChanX:" << prevChanX
|
|
||||||
<< " offsetY:" << offsetY << " prevChanY:" << prevChanY
|
|
||||||
<< " offsetX_gp:" << offsetX_gp << " prevChanX_gp:" << prevChanX_gp
|
|
||||||
<< " offsetY_gp:" << offsetY_gp << " prevChanY_gp:" << prevChanY_gp;
|
|
||||||
|
|
||||||
// incrementing in both direction
|
|
||||||
if (firstTime) {
|
|
||||||
// incrementing in both directions
|
|
||||||
firstTime = false;
|
|
||||||
if ((maxChanX > 0) &&
|
|
||||||
((offsetX + detectors[idet]->getTotalNumberOfChannels(X)) >
|
|
||||||
maxChanX)) {
|
|
||||||
FILE_LOG(logWARNING)
|
|
||||||
<< "\nDetector[" << idet
|
|
||||||
<< "] exceeds maximum channels "
|
|
||||||
"allowed for complete detector set in X dimension!";
|
|
||||||
}
|
|
||||||
if ((maxChanY > 0) &&
|
|
||||||
((offsetY + detectors[idet]->getTotalNumberOfChannels(Y)) >
|
|
||||||
maxChanY)) {
|
|
||||||
FILE_LOG(logERROR)
|
|
||||||
<< "\nDetector[" << idet
|
|
||||||
<< "] exceeds maximum channels "
|
|
||||||
"allowed for complete detector set in Y dimension!";
|
|
||||||
}
|
|
||||||
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
|
||||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
|
||||||
prevChanX_gp =
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
|
||||||
prevChanY_gp =
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
|
||||||
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
|
||||||
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
|
||||||
numX_gp +=
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
|
||||||
numY_gp +=
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
|
||||||
++multi_shm()->numberOfDetector[X];
|
|
||||||
++multi_shm()->numberOfDetector[Y];
|
|
||||||
FILE_LOG(logDEBUG1) << "incrementing in both direction";
|
|
||||||
}
|
|
||||||
|
|
||||||
// incrementing in y direction
|
|
||||||
else if ((maxChanY == -1) ||
|
|
||||||
((maxChanY > 0) && ((offsetY + prevChanY +
|
|
||||||
detectors[idet]->getTotalNumberOfChannels(
|
|
||||||
Y)) <= maxChanY))) {
|
|
||||||
offsetY += prevChanY;
|
|
||||||
offsetY_gp += prevChanY_gp;
|
|
||||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
|
||||||
prevChanY_gp =
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
|
||||||
numY += detectors[idet]->getTotalNumberOfChannels(Y);
|
|
||||||
numY_gp +=
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
|
||||||
// increment in y again only in the first column (else you double
|
|
||||||
// increment)
|
|
||||||
if (multi_shm()->numberOfDetector[X] == 1)
|
|
||||||
++multi_shm()->numberOfDetector[Y];
|
|
||||||
FILE_LOG(logDEBUG1) << "incrementing in y direction";
|
|
||||||
}
|
|
||||||
|
|
||||||
// incrementing in x direction
|
|
||||||
else {
|
|
||||||
if ((maxChanX > 0) &&
|
|
||||||
((offsetX + prevChanX +
|
|
||||||
detectors[idet]->getTotalNumberOfChannels(X)) > maxChanX)) {
|
|
||||||
FILE_LOG(logDEBUG1)
|
|
||||||
<< "\nDetector[" << idet
|
|
||||||
<< "] exceeds maximum channels "
|
|
||||||
"allowed for complete detector set in X dimension!";
|
|
||||||
}
|
|
||||||
offsetY = 0;
|
|
||||||
offsetY_gp = 0;
|
|
||||||
prevChanY = detectors[idet]->getTotalNumberOfChannels(Y);
|
|
||||||
prevChanY_gp =
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(Y);
|
|
||||||
numY = 0; // assuming symmetry with this statement.
|
|
||||||
// whats on 1st column should be on 2nd column
|
|
||||||
numY_gp = 0;
|
|
||||||
offsetX += prevChanX;
|
|
||||||
offsetX_gp += prevChanX_gp;
|
|
||||||
prevChanX = detectors[idet]->getTotalNumberOfChannels(X);
|
|
||||||
prevChanX_gp =
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
|
||||||
numX += detectors[idet]->getTotalNumberOfChannels(X);
|
|
||||||
numX_gp +=
|
|
||||||
detectors[idet]->getTotalNumberOfChannelsInclGapPixels(X);
|
|
||||||
++multi_shm()->numberOfDetector[X];
|
|
||||||
FILE_LOG(logDEBUG1) << "incrementing in x direction";
|
|
||||||
}
|
|
||||||
|
|
||||||
double bytesperchannel =
|
|
||||||
(double)detectors[idet]->getDataBytes() /
|
|
||||||
(double)(detectors[idet]->getTotalNumberOfChannels(X) *
|
|
||||||
detectors[idet]->getTotalNumberOfChannels(Y));
|
|
||||||
detectors[idet]->setDetectorOffset(
|
|
||||||
X, (bytesperchannel >= 1.0) ? offsetX_gp : offsetX);
|
|
||||||
detectors[idet]->setDetectorOffset(
|
|
||||||
Y, (bytesperchannel >= 1.0) ? offsetY_gp : offsetY);
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) << "Detector[" << idet << "] has offsets ("
|
|
||||||
<< detectors[idet]->getDetectorOffset(X) << ", "
|
|
||||||
<< detectors[idet]->getDetectorOffset(Y) << ")";
|
|
||||||
// offsetY has been reset sometimes and offsetX the first time,
|
|
||||||
// but remember the highest values
|
|
||||||
if (numX > multi_shm()->numberOfChannel[X]) {
|
|
||||||
multi_shm()->numberOfChannel[X] = numX;
|
|
||||||
}
|
|
||||||
if (numY > multi_shm()->numberOfChannel[Y]) {
|
|
||||||
multi_shm()->numberOfChannel[Y] = numY;
|
|
||||||
}
|
|
||||||
if (numX_gp > multi_shm()->numberOfChannelInclGapPixels[X]) {
|
|
||||||
multi_shm()->numberOfChannelInclGapPixels[X] = numX_gp;
|
|
||||||
}
|
|
||||||
if (numY_gp > multi_shm()->numberOfChannelInclGapPixels[Y]) {
|
|
||||||
multi_shm()->numberOfChannelInclGapPixels[Y] = numY_gp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FILE_LOG(logDEBUG1)
|
|
||||||
<< "\n\tNumber of Channels in X direction:"
|
|
||||||
<< multi_shm()->numberOfChannel[X]
|
|
||||||
<< "\n\tNumber of Channels in Y direction:"
|
|
||||||
<< multi_shm()->numberOfChannel[Y]
|
|
||||||
<< "\n\tNumber of Channels in X direction with Gap Pixels:"
|
|
||||||
<< multi_shm()->numberOfChannelInclGapPixels[X]
|
|
||||||
<< "\n\tNumber of Channels in Y direction with Gap Pixels:"
|
|
||||||
<< multi_shm()->numberOfChannelInclGapPixels[Y];
|
|
||||||
|
|
||||||
multi_shm()->numberOfChannels =
|
|
||||||
multi_shm()->numberOfChannel[0] * multi_shm()->numberOfChannel[1];
|
|
||||||
|
|
||||||
for (auto &d : detectors) {
|
|
||||||
d->updateMultiSize(multi_shm()->numberOfDetector[0],
|
|
||||||
multi_shm()->numberOfDetector[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string multiSlsDetector::checkOnline(int detPos) {
|
std::string multiSlsDetector::checkOnline(int detPos) {
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
return detectors[detPos]->checkOnline();
|
return detectors[detPos]->checkOnline();
|
||||||
|
@ -654,12 +654,12 @@ int slsDetector::getNChips() const { return shm()->nChips; }
|
|||||||
|
|
||||||
int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; }
|
int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; }
|
||||||
|
|
||||||
int slsDetector::getQuad() {
|
bool slsDetector::getQuad() {
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Getting Quad Type";
|
FILE_LOG(logDEBUG1) << "Getting Quad Type";
|
||||||
sendToDetector(F_GET_QUAD, nullptr, retval);
|
sendToDetector(F_GET_QUAD, nullptr, retval);
|
||||||
FILE_LOG(logDEBUG1) << "Quad Type :" << retval;
|
FILE_LOG(logDEBUG1) << "Quad Type :" << retval;
|
||||||
return retval;
|
return (retval == 0 ? false : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsDetector::setQuad(const bool enable) {
|
void slsDetector::setQuad(const bool enable) {
|
||||||
@ -693,12 +693,24 @@ int slsDetector::getDetectorOffset(dimension d) const {
|
|||||||
return shm()->offset[d];
|
return shm()->offset[d];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slsDetectorDefs::coordinates slsDetector::getDetectorOffsets() const {
|
||||||
|
slsDetectorDefs::coordinates coord;
|
||||||
|
coord.x = shm()->offset[X];
|
||||||
|
coord.y = shm()->offset[Y];
|
||||||
|
return coord;
|
||||||
|
}
|
||||||
|
|
||||||
void slsDetector::setDetectorOffset(dimension d, int off) {
|
void slsDetector::setDetectorOffset(dimension d, int off) {
|
||||||
if (off >= 0) {
|
if (off >= 0) {
|
||||||
shm()->offset[d] = off;
|
shm()->offset[d] = off;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slsDetector::setDetectorOffsets(slsDetectorDefs::coordinates value) {
|
||||||
|
shm()->offset[X] = value.x;
|
||||||
|
shm()->offset[Y] = value.y;
|
||||||
|
}
|
||||||
|
|
||||||
void slsDetector::updateMultiSize(int detx, int dety) {
|
void slsDetector::updateMultiSize(int detx, int dety) {
|
||||||
shm()->multiSize[0] = detx;
|
shm()->multiSize[0] = detx;
|
||||||
shm()->multiSize[1] = dety;
|
shm()->multiSize[1] = dety;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user