* making quad work in developer branch

* binary added

* minor changes

* bug fix to set quad to 0 when more than 1 detector
This commit is contained in:
Dhanya Thattil
2019-07-22 16:41:03 +02:00
committed by GitHub
parent 0fa63f8be2
commit e7a76ccea1
23 changed files with 432 additions and 70 deletions

View File

@ -514,6 +514,22 @@ int multiSlsDetector::setMaxNumberOfChannelsPerDetector(dimension d, int i) {
return multi_shm()->maxNumberOfChannelsPerDetector[d];
}
int multiSlsDetector::getQuad(int detPos) {
int retval = detectors[0]->getQuad();
if (retval && getNumberOfDetectors() > 1) {
throw RuntimeError("Quad type is available only for 1 Eiger Quad Half module, but it Quad is enabled for 1st readout");
}
return retval;
}
void multiSlsDetector::setQuad(const bool enable, int detPos) {
if (enable && getNumberOfDetectors() > 1) {
throw RuntimeError("Cannot set Quad type as it is available only for 1 Eiger Quad Half module.");
}
detectors[0]->setQuad(enable);
}
int multiSlsDetector::getDetectorOffset(dimension d, int detPos) {
return detectors[detPos]->getDetectorOffset(d);
}
@ -3256,18 +3272,13 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
void multiSlsDetector::readFrameFromReceiver() {
int nX = multi_shm()->numberOfDetector[X]; // to copy data in multi module
int nY = multi_shm()->numberOfDetector[Y]; // for eiger, to reverse the data
int nX = 0;
int nY = 0;
int nDetPixelsX = 0;
int nDetPixelsY = 0;
bool gappixelsenable = false;
bool eiger = false;
if (getDetectorTypeAsEnum() == EIGER) {
eiger = true;
nX *= 2;
gappixelsenable = detectors[0]->enableGapPixels(-1) > 0;
}
if (getNumberofUDPInterfaces() == 2) {
nY *= 2;
}
bool numInterfaces = getNumberofUDPInterfaces(); // cannot pick up from zmq
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
int numRunning = 0;
@ -3344,14 +3355,29 @@ void multiSlsDetector::readFrameFromReceiver() {
// shape
nPixelsX = doc["shape"][0].GetUint();
nPixelsY = doc["shape"][1].GetUint();
// detector shape
nX = doc["detshape"][0].GetUint();
nY = doc["detshape"][1].GetUint();
nY *= numInterfaces;
nDetPixelsX = nX * nPixelsX;
nDetPixelsY = nY * nPixelsY;
// det type
eiger = (doc["detType"].GetUint() == static_cast<int>(3)) ? true : false; // to be changed to EIGER when firmware updates its header data
// gap pixels enable
gappixelsenable = (doc["gappixels"].GetUint() == 0) ? false : true;
FILE_LOG(logDEBUG1)
<< "One Time Header Info:"
"\n\tsize: "
<< size << "\n\tmultisize: " << multisize
<< "\n\tdynamicRange: " << dynamicRange
<< "\n\tbytesPerPixel: " << bytesPerPixel
<< "\n\tnPixelsX: " << nPixelsX << "\n\tnPixelsY: " << nPixelsY;
<< "\n\tnPixelsX: " << nPixelsX
<< "\n\tnPixelsY: " << nPixelsY
<< "\n\tnX: " << nX
<< "\n\tnY: " << nY
<< "\n\teiger: " << eiger
<< "\n\tgappixelsenable: " << gappixelsenable;
}
// each time, parse rest of header
currentFileName = doc["fname"].GetString();
@ -3414,20 +3440,16 @@ void multiSlsDetector::readFrameFromReceiver() {
// send data to callback
if (data) {
int nCompletePixelsX = multi_shm()->numberOfChannelInclGapPixels[X];
int nCompletePixelsY = multi_shm()->numberOfChannelInclGapPixels[Y];
setCurrentProgress(currentAcquisitionIndex + 1);
// 4bit gap pixels
if (dynamicRange == 4 && gappixelsenable) {
int n = processImageWithGapPixels(multiframe, multigappixels);
thisData =
new detectorData(getCurrentProgress(), currentFileName.c_str(), nCompletePixelsX,
nCompletePixelsY, multigappixels, n, dynamicRange, currentFileIndex);
new detectorData(getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multigappixels, n, dynamicRange, currentFileIndex);
}
// normal pixels
else {
thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nCompletePixelsX,
nCompletePixelsY, multiframe, multisize, dynamicRange,
thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multiframe, multisize, dynamicRange,
currentFileIndex);
}
dataReady(thisData, currentFrameIndex,

View File

@ -629,6 +629,28 @@ int slsDetector::getNChips() const { return shm()->nChips; }
int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; }
int slsDetector::getQuad() {
int retval = -1;
FILE_LOG(logDEBUG1) << "Getting Quad Type";
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_GET_QUAD, nullptr, retval);
FILE_LOG(logDEBUG1) << "Quad Type :" << retval;
}
return retval;
}
void slsDetector::setQuad(const bool enable) {
int value = enable ? 1 : 0;
FILE_LOG(logDEBUG1) << "Setting Quad type to " << value;
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_SET_QUAD, value, nullptr);
}
FILE_LOG(logDEBUG1) << "Setting Quad type to " << value << " in Receiver";
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr);
}
}
int slsDetector::getDetectorOffset(dimension d) const {
return shm()->offset[d];
}

View File

@ -348,6 +348,14 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDetectorSize;
++i;
/*! \page config
- <b>quad [i] </b> if 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="quad"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
++i;
/*! \page config
- <b>flippeddatax [i]</b> enables/disables data being flipped across x axis. 1 enables, 0 disables. Used for EIGER only. 1 for bottom half-module, 0 for top-half module. \c Returns \c (int)
*/
@ -3391,7 +3399,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
myDet->setOnline(ONLINE_FLAG, detPos);
if (cmd == "roi")
if (cmd == "roi" || cmd == "quad")
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
@ -3421,6 +3429,12 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
myDet->setMaxNumberOfChannelsPerDetector(Y, val);
}
if(cmd=="quad"){
if (val >=0 ) {
myDet->setQuad(val);
}
}
if (cmd == "flippeddatax") {
if ((!sscanf(args[1], "%d", &val)) || (val != 0 && val != 1))
return std::string("cannot scan flippeddata x mode: must be 0 or 1");
@ -3455,6 +3469,8 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
} else if (cmd == "detsizechan") {
sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y));
return std::string(ans);
} else if (cmd=="quad") {
return std::to_string(myDet->getQuad());
} else if (cmd == "flippeddatax") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
ret = myDet->getFlippedData(X, detPos);
@ -3468,6 +3484,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
return std::string("Cannot execute this command from slsDetector level. Please use multiSlsDetector level.\n");
ret = myDet->enableGapPixels(-1, detPos);
}
else
return std::string("unknown command ") + cmd;
@ -3484,6 +3501,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
os << "dr i \n sets the dynamic range of the detector" << std::endl;
os << "roi i xmin xmax ymin ymax \n sets region of interest where i is number of rois;i=0 to clear rois" << std::endl;
os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl;
os << "quad i \n if i = 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl;
os << "flippeddatax x \n sets if the data should be flipped on the x axis" << std::endl;
os << "flippeddatay y \n sets if the data should be flipped on the y axis" << std::endl;
os << "gappixels i \n enables/disables gap pixels in system (detector & receiver). 1 sets, 0 unsets. Used in EIGER only and multidetector level." << std::endl;
@ -3492,6 +3510,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
os << "dr \n gets the dynamic range of the detector" << std::endl;
os << "roi \n gets region of interest" << std::endl;
os << "detsizechan \n gets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl;
os << "quad \n returns 1 if the detector size is a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl;
os << "flippeddatax\n gets if the data will be flipped on the x axis" << std::endl;
os << "flippeddatay\n gets if the data will be flipped on the y axis" << std::endl;
os << "gappixels\n gets if gap pixels is enabled in system. Used in EIGER only and multidetector level." << std::endl;