diff --git a/RELEASE.txt b/RELEASE.txt index fd176c10e..c934c3cb2 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -17,6 +17,7 @@ This document describes the differences between 4.0.3 and 4.0.2 releases. 1. Topics Concerning ==================== + - software for eiger quad hardware integrated - command line framesl, cyclesl was printing in float @@ -27,13 +28,24 @@ This document describes the differences between 4.0.3 and 4.0.2 releases. Client ------ - 1. Command line commands framesl, cyclesl, fatesl, problesl and nframes was + 1. Command line quad integrates Eiger quad hardware + + 2. Command line commands framesl, cyclesl, fatesl, problesl and nframes was printing the result in decimals. It is now fixed to print as whole numbers. - Detector Server - --------------- - + Detector Server (Eiger) + ----------------------- + + 1. Command line quad integrates Eiger quad hardware + + + Receiver + -------- + + 1. Command line quad integrates Eiger quad hardware + + 3. Known Issues =============== diff --git a/serverBin/eigerDetectorServerv4.0.1.22.1 b/serverBin/eigerDetectorServerv4.0.1.22.1 deleted file mode 120000 index 04312328b..000000000 --- a/serverBin/eigerDetectorServerv4.0.1.22.1 +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.1.22.1 \ No newline at end of file diff --git a/serverBin/eigerDetectorServerv4.0.3.23.0 b/serverBin/eigerDetectorServerv4.0.3.23.0 new file mode 120000 index 000000000..df9505dd7 --- /dev/null +++ b/serverBin/eigerDetectorServerv4.0.3.23.0 @@ -0,0 +1 @@ +../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.3.23.0 \ No newline at end of file diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 87492eeea..c21b2f586 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -121,12 +121,21 @@ void qDrawPlot::SetupWidgetWindow(){ nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); - if (detType == slsDetectorDefs::JUNGFRAUCTB) { - npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES_JCTB, -1) * 2)/25;// for moench 03 - nPixelsX = npixelsx_jctb; - nPixelsY = npixelsy_jctb; + switch(detType) { + case slsDetectorDefs::JUNGFRAUCTB: + npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES_JCTB, -1) * 2)/25;// for moench 03 + nPixelsX = npixelsx_jctb; + nPixelsY = npixelsy_jctb; + break; + case slsDetectorDefs::EIGER: + if (myDet->setQuad()) { + nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; + nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; + } + break; + default: + break; } - cout<<"nPixelsX:"<getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); - if (detType == slsDetectorDefs::JUNGFRAUCTB) { - npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES_JCTB, -1) * 2)/25; // for moench 03 - nPixelsX = npixelsx_jctb; - nPixelsY = npixelsy_jctb; + switch(detType) { + case slsDetectorDefs::JUNGFRAUCTB: + npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES_JCTB, -1) * 2)/25;// for moench 03 + nPixelsX = npixelsx_jctb; + nPixelsY = npixelsy_jctb; + break; + case slsDetectorDefs::EIGER: + if (myDet->setQuad()) { + nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2; + nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2; + } + break; + default: + break; } + cout<<"nPixelsX:"<= 0) { + Beb_quadEnable = (val == 0 ? 0 : 1); + Beb_SetDetectorPosition(Beb_positions); + } + return Beb_quadEnable; +} int Beb_SetDetectorPosition(int pos[]) { if(!Beb_activated) return OK; - cprintf(BLUE,"Got Position values %d %d %d...\n", pos[0],pos[1], pos[2]); - pos[0] = Beb_swap_uint16(pos[0]); - //pos[1] = Beb_swap_uint16(pos[1]); - pos[2] = Beb_swap_uint16(pos[2]); + cprintf(BLUE,"Got Position values [%d %d %d]\n", pos[0], pos[1], pos[2]); + + + // save positions + Beb_positions[0] = pos[0]; + Beb_positions[1] = pos[1]; + Beb_positions[2] = pos[2]; + + // get left and right + int posLeft[3] = {pos[0], pos[1], pos[2]}; + int posRight[3] = {pos[0], pos[1] + 1, pos[2]}; + + if (Beb_quadEnable) { + posRight[0] = 1; // right is next row + posRight[1] = 0; // right same first column + } int ret = FAIL; //mapping new memory to read master top module configuration @@ -1233,26 +1253,28 @@ int Beb_SetDetectorPosition(int pos[]) { uint32_t value = 0; ret = OK; // x left + int posval = Beb_swap_uint16(posLeft[0]); value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); value &= UDP_HEADER_ID_MSK; // to keep previous id value - Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); + Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); - if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) + if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) ret = FAIL; // x right + posval = Beb_swap_uint16(posRight[0]); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); value &= UDP_HEADER_ID_MSK; // to keep previous id value - Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); + Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); - if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) + if((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) ret = FAIL; // y left (column) // overwriting z anyway, so no need to look at previous z value - int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1)); + posval = Beb_swap_uint16(posLeft[1]); Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST); if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) @@ -1260,7 +1282,7 @@ int Beb_SetDetectorPosition(int pos[]) { // y right // overwriting z anyway, so no need to look at previous z value - posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]); + posval = Beb_swap_uint16(posRight[1]); Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST); if(value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) @@ -1269,19 +1291,21 @@ int Beb_SetDetectorPosition(int pos[]) { // z left + posval = Beb_swap_uint16(posLeft[2]); value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST); value &= UDP_HEADER_Y_MSK; // to keep previous y value - Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); + Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST); - if((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) + if((value & UDP_HEADER_Z_MSK) != ((posval << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) ret = FAIL; // z right + posval = Beb_swap_uint16(posRight[2]); value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST); value &= UDP_HEADER_Y_MSK; // to keep previous y value - Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); + Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)); value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST); - if((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) + if((value & UDP_HEADER_Z_MSK) != ((posval << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK)) ret = FAIL; @@ -1292,8 +1316,7 @@ int Beb_SetDetectorPosition(int pos[]) { cprintf(BLUE, "Position set to...\n" "Left: [%d, %d, %d]\n" "Right:[%d, %d, %d]\n", - Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]), - Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2])); + posLeft[0], posLeft[1], posLeft[2], posRight[0], posRight[1], posRight[2]); } return ret; diff --git a/slsDetectorSoftware/eigerDetectorServer/Beb.h b/slsDetectorSoftware/eigerDetectorServer/Beb.h index 73718db03..7f5be0088 100644 --- a/slsDetectorSoftware/eigerDetectorServer/Beb.h +++ b/slsDetectorSoftware/eigerDetectorServer/Beb.h @@ -91,6 +91,7 @@ struct BebInfo{ int Beb_GetBebFPGATemp(); void Beb_SetDetectorNumber(uint32_t detid); + int Beb_SetQuad(int val); int Beb_SetDetectorPosition(int pos[]); uint16_t Beb_swap_uint16( uint16_t val); diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.1.22.1 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.1.22.1 deleted file mode 100755 index 63e32f9fc..000000000 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.1.22.1 and /dev/null differ diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt index b442b6b9a..1ea1d1f8b 100644 --- a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt +++ b/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: ef3e01b9bdf3a6a08367e2448bcc92bd13cf73ad -Revision: 351 -Branch: 4.0.1-rc +Repsitory UUID: 3e2b471ee1e6bbbd0fbce6292c30e4403a4f4b2f +Revision: 352 +Branch: quad Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4068 -Last Changed Date: 2019-02-06 14:44:47.000000002 +0100 ./xparameters.h +Last Changed Rev: 4117 +Last Changed Date: 2019-07-10 17:22:28.000000002 +0200 ./Beb.c diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h index cef8cc341..84bfa4364 100644 --- a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h +++ b/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "ef3e01b9bdf3a6a08367e2448bcc92bd13cf73ad" +#define GITREPUUID "3e2b471ee1e6bbbd0fbce6292c30e4403a4f4b2f" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4068 -#define GITDATE 0x20190206 -#define GITBRANCH "4.0.1-rc" +#define GITREV 0x4117 +#define GITDATE 0x20190710 +#define GITBRANCH "quad" diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c index ddfd53164..d695b583e 100644 --- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c @@ -1219,6 +1219,10 @@ int setDetectorPosition(int pos[]) { } +int setQuad(int val) { + return Beb_SetQuad(val); +} + diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index e17df3533..206bae13f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4983,17 +4983,12 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) { } void multiSlsDetector::readFrameFromReceiver() { - - int nX = thisMultiDetector->numberOfDetector[X]; // to copy data in multi module - int nY = thisMultiDetector->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 (getDetectorsType() == EIGER) { - eiger = true; - nX *= 2; - gappixelsenable = detectors[0]->enableGapPixels(-1) >= 1 ? true : false; - } - + bool eiger = false; bool runningList[zmqSocket.size()], connectList[zmqSocket.size()]; int numRunning = 0; for (unsigned int i = 0; i < zmqSocket.size(); ++i) { @@ -5068,6 +5063,15 @@ 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(); + nDetPixelsX = nX * nPixelsX; + nDetPixelsY = nY * nPixelsY; + // det type + eiger = (doc["detType"].GetUint() == (int)EIGER) ? true : false; + // gap pixels enable + gappixelsenable = (doc["gappixels"].GetUint() == 0) ? false : true; #ifdef VERBOSE cprintf(BLUE, "(Debug) One Time Header Info:\n" @@ -5076,9 +5080,13 @@ void multiSlsDetector::readFrameFromReceiver() { "dynamicRange: %u\n" "bytesPerPixel: %f\n" "nPixelsX: %u\n" - "nPixelsY: %u\n", + "nPixelsY: %u\n" + "nX: %u\n" + "nY: %u\n" + "eiger: %d\n" + "gappixelsenable: %d\n", size, multisize, dynamicRange, bytesPerPixel, - nPixelsX, nPixelsY); + nPixelsX, nPixelsY, nX, nY, eiger, gappixelsenable); #endif } // each time, parse rest of header @@ -5148,21 +5156,18 @@ void multiSlsDetector::readFrameFromReceiver() { } //send data to callback - if (data) { - int nCompletePixelsX = thisMultiDetector->numberOfChannelInclGapPixels[X]; - int nCompletePixelsY = thisMultiDetector->numberOfChannelInclGapPixels[Y]; - + if (data) { // 4bit gap pixels if (dynamicRange == 4 && gappixelsenable) { int n = processImageWithGapPixels(multiframe, multigappixels); thisData = new detectorData(NULL, NULL, NULL, getCurrentProgress(), - currentFileName.c_str(), nCompletePixelsX, nCompletePixelsY, + currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multigappixels, n, dynamicRange, currentFileIndex); } // normal pixels else { thisData = new detectorData(NULL, NULL, NULL, getCurrentProgress(), - currentFileName.c_str(), nCompletePixelsX, nCompletePixelsY, + currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multiframe, multisize, dynamicRange, currentFileIndex); } dataReady(thisData, currentFrameIndex, @@ -5429,3 +5434,9 @@ int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) { int multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t) { return callDetectorMember(&slsDetector::setCTBPatWaitTime, level, t); } + +int multiSlsDetector::setQuad(int val) { + if (getNumberOfDetectors() > 1) + val = 0; + return callDetectorMember(&slsDetector::setQuad, val); +} diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 6bc712ea9..1f11e1b1f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1869,6 +1869,13 @@ public: */ int setCTBPatWaitTime(int level, uint64_t t=-1); + /** + * Set or Get Quad Type (Only for Eiger Quad detector hardware) + * @param val 1 if quad type set, else 0, -1 gets + * @returns 1 if quad type set, else 0 + */ + int setQuad(int val = -1); + private: /** diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 73c30960d..91dd35fb3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -9756,5 +9756,50 @@ int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { } +int slsDetector::setQuad(int val) { + int fnum = F_QUAD, fnum2 = F_RECEIVER_QUAD; + int ret = FAIL; + int retval = -1; + // set row column header in detector + if (val >= 0) { + if (thisDetector->onlineFlag==ONLINE_FLAG) { + if (connectControl() == OK){ + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&val,sizeof(val)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + char mess[MAX_STR_LENGTH] = {}; + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + setErrorMask((getErrorMask())|(SOME_ERROR)); + } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + disconnectControl(); + if (ret==FORCE_UPDATE) + updateDetector(); + } + } + } else + ret = OK; + // set quad type to receiver (flipped data and detector shape, numdet) + if (ret != FAIL) { + ret = FAIL; + if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ +#ifdef VERBOSE + if(val ==-1) + std::cout<< "Getting Receiver Quad mode" << endl; + else + std::cout<< "Setting Receiver Quad Mode to " << val << endl; +#endif + if (connectData() == OK){ + ret=thisReceiver->sendInt(fnum2,retval,val); + disconnectData(); + } + if(ret==FAIL) + setErrorMask((getErrorMask())|(RECEIVER_PARAMETER_NOT_SET)); + } + } + return retval; +} diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 779ad78e7..36b719595 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -2274,6 +2274,13 @@ public: */ int setCTBPatWaitTime(int level, uint64_t t=-1); + /** + * Set or Get Quad Type (Only for Eiger Quad detector hardware) + * @param val 1 if quad type set, else 0, -1 gets + * @returns 1 if quad type set, else 0 + */ + int setQuad(int val = -1); + private: /** diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index f7b0f0b1a..ced8c8d3b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -378,6 +378,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize; ++i; + /*! \page config + - quad [i] 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 - roimask [i] ?? \c Returns \c (int) in hexadecimal */ @@ -4458,7 +4465,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { myDet->setOnline(ONLINE_FLAG); - if (cmd == "roi") + if (cmd == "roi" || cmd == "quad") myDet->setReceiverOnline(ONLINE_FLAG); if (action==PUT_ACTION) { @@ -4494,6 +4501,13 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { myDet->setMaxNumberOfChannelsPerDetector(Y,val); } + if(cmd=="quad"){ + if (val >=0 ) { + sprintf(ans, "%d", myDet->setQuad(val)); + return string(ans); + } + } + if(cmd=="flippeddatax"){ if ((!sscanf(args[1],"%d",&val)) || (val!=0 && val != 1)) return string ("cannot scan flippeddata x mode: must be 0 or 1"); @@ -4533,7 +4547,13 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { } else if (cmd=="detsizechan") { sprintf(ans,"%d %d",myDet->getMaxNumberOfChannelsPerDetector(X),myDet->getMaxNumberOfChannelsPerDetector(Y)); return string(ans); + } + + else if (cmd=="quad") { + sprintf(ans, "%d", myDet->setQuad()); + return string(ans); } + else if(cmd=="flippeddatax"){ myDet->setReceiverOnline(ONLINE_FLAG); ret = myDet->getFlippedData(X); @@ -4571,6 +4591,7 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], 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; @@ -4581,6 +4602,7 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], 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; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 13988d42c..76a397c9d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -1021,6 +1021,13 @@ virtual int setReceiverSilentMode(int i = -1)=0; */ virtual int checkVersionCompatibility(portType t) = 0; + /** + * Set or Get Quad Type (Only for Eiger Quad detector hardware) + * @param val 1 if quad type set, else 0, -1 gets + * @returns 1 if quad type set, else 0 + */ + virtual int setQuad(int val = -1) = 0; + protected: diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h index b10be6845..35be5c9ea 100644 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h @@ -194,6 +194,9 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32 #if defined(JUNGFRAUD) || defined(EIGERD) int setDetectorPosition(int pos[]); #endif +#ifdef EIGERD +int setQuad(int val); +#endif // very detector specific diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index 8cd09f2b1..e906f1bea 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -211,6 +211,7 @@ const char* getFunctionName(enum detFuncs func) { case F_STORAGE_CELL_START: return "F_STORAGE_CELL_START"; case F_CHECK_VERSION: return "F_CHECK_VERSION"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; + case F_QUAD: return "F_QUAD"; default: return "Unknown Function"; } @@ -297,6 +298,7 @@ void function_table() { flist[F_STORAGE_CELL_START] = &storage_cell_start; flist[F_CHECK_VERSION] = &check_version; flist[F_SOFTWARE_TRIGGER] = &software_trigger; + flist[F_QUAD] = &set_quad; // check if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { @@ -5926,3 +5928,60 @@ int software_trigger(int file_des) { return ret; } +int set_quad(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"Setting quad failed\n"); + + // execute action +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (set_quad) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Setting Quad :%d \n",arg); +#endif + retval=setQuad(arg); + if((arg != -1) && (retval != arg)) { + ret=FAIL; + cprintf(RED, "Warning: %s", mess); + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h index a4bbaeb64..210a5636d 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h @@ -97,5 +97,6 @@ int auto_comp_disable(int); int storage_cell_start(int); int check_version(int); int software_trigger(int); +int set_quad(int); #endif diff --git a/slsReceiverSoftware/include/DataStreamer.h b/slsReceiverSoftware/include/DataStreamer.h index 8857102c7..e48a4a65a 100644 --- a/slsReceiverSoftware/include/DataStreamer.h +++ b/slsReceiverSoftware/include/DataStreamer.h @@ -30,9 +30,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { * @param fd flipped data enable for x and y dimensions * @param ajh additional json header * @param sm pointer to silent mode + * @param nd pointer to number of detectors in each dimension + * @param gpEnable pointer to gap pixels enable */ DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector* r, - uint64_t* fi, int* fd, char* ajh, bool* sm); + uint64_t* fi, int* fd, char* ajh, bool* sm, int* nd, bool* gpEnable); /** * Destructor @@ -88,6 +90,18 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { */ int SetThreadPriority(int priority); + /** + * Set number of detectors + * @param number of detectors in both dimensions + */ + void SetNumberofDetectors(int* nd); + + /** + * Set Flipped data enable across both dimensions + * @param flipped data enable in both dimensions + */ + void SetFlippedData(int* fd); + /** * Creates Zmq Sockets * (throws an exception if it couldnt create zmq sockets) @@ -184,7 +198,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { uint64_t* fileIndex; /** flipped data across both dimensions enable */ - int* flippedData; + int flippedData[2]; /** additional json header */ char* additionJsonHeader; @@ -207,5 +221,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject { /** Complete buffer used for roi, eg. shortGotthard */ char* completeBuffer; + /** Number of Detectors in X and Y dimension */ + int numDet[2]; + + /** Gap Pixels Enable */ + bool* gapPixelsEnable; + }; diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 695caa96a..381315519 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -72,6 +72,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ bool getGapPixelsEnable() const; + /** + * Get Quad type Enable (eiger and hardware specific) + * @return true if quad enabled, else false + */ + bool getQuad() const; + //***file parameters*** /** @@ -341,7 +347,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter void setMultiDetectorSize(const int* size); /* - * Get flipped data across 'axis' + * Set flipped data across 'axis' * @return if data is flipped across 'axis' */ void setFlippedData(int axis=0, int enable=-1); @@ -353,6 +359,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ int setGapPixelsEnable(const bool b); + /** + * Set Quad type Enable (eiger and hardware specific) + * @param true if quad enabled, else false + */ + void setQuad(const bool b); + //***file parameters*** /** @@ -739,6 +751,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter int flippedData[2]; /** gap pixels enable */ bool gapPixelsEnable; + /** quad type enable */ + bool quadEnable; //***receiver parameters*** /** Maximum Number of Listening Threads/ UDP Ports */ diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 55e0d2cb6..40c37ac70 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -162,6 +162,12 @@ class UDPInterface { */ virtual bool getGapPixelsEnable() const = 0; + /** + * Get Quad type Enable (eiger and hardware specific) + * @return true if quad enabled, else false + */ + virtual bool getQuad() const = 0; + //***file parameters*** /** @@ -444,6 +450,12 @@ class UDPInterface { */ virtual int setGapPixelsEnable(const bool b) = 0; + /** + * Set Quad type Enable (eiger and hardware specific) + * @param true if quad enabled, else false + */ + virtual void setQuad(const bool b) = 0; + //***file parameters*** /** diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index 506aeb698..4215c5e2e 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -53,6 +53,18 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase */ int64_t getAcquisitionIndex() const; + /* + * Set multi detector size + * @param pointer to array of multi detector size in every dimension + */ + void setMultiDetectorSize(const int* size); + + /* + * Set flipped data across 'axis' + * @return if data is flipped across 'axis' + */ + void setFlippedData(int axis=0, int enable=-1); + /** * Set Gap Pixels Enable (eiger specific) * @param b true for gap pixels enable, else false @@ -60,6 +72,12 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase */ int setGapPixelsEnable(const bool b); + /** + * Set Quad type Enable (eiger and hardware specific) + * @param true if quad enabled, else false + */ + void setQuad(const bool b); + /** * Set File Format * @param f fileformat binary or hdf5 diff --git a/slsReceiverSoftware/include/ZmqSocket.h b/slsReceiverSoftware/include/ZmqSocket.h index e58419a1e..2063239f6 100644 --- a/slsReceiverSoftware/include/ZmqSocket.h +++ b/slsReceiverSoftware/include/ZmqSocket.h @@ -238,19 +238,42 @@ public: /** * Send Message Header - * @param buf message - * @param length length of message - * @param dummy true if end of acquistion else false + * @param index self index for debugging + * @param dummy true if a dummy message for end of acquisition + * @param jsonversion json version + * @param dynamicrange dynamic range + * @param fileIndex file or acquisition index + * @param ndetx number of detectors in x axis + * @param ndety number of detectors in y axis + * @param npixelsx number of pixels/channels in x axis for this zmq socket + * @param npixelsy number of pixels/channels in y axis for this zmq socket + * @param imageSize number of bytes for an image in this socket + * @param frameNumber current frame number + * @param expLength exposure length or subframe index if eiger + * @param packetNumber number of packets caught for this frame + * @param bunchId bunch id + * @param timestamp time stamp + * @param modId module Id + * @param row row index in complete detector + * @param column column index in complete detector + * @param reserved reserved + * @param debug debug + * @param roundRNumber not used yet + * @param detType detector enum + * @param version detector header version + * @param gapPixelsEnable gap pixels enable (exception: if gap pixels enable for 4 bit mode, data is not yet gap pixel enabled in receiver) + * @param flippedData int array of 2 elements for x and y, if it is flipped across x or y axis + * @param additionalJsonHeader additional json header * @returns 0 if error, else 1 */ int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0, - uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, + uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL, uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, uint64_t bunchId = 0, uint64_t timestamp = 0, uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0, uint32_t debug = 0, uint16_t roundRNumber = 0, - uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0, + uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int* flippedData = 0, char* additionalJsonHeader = 0) { @@ -261,6 +284,7 @@ public: "\"jsonversion\":%u, " "\"bitmode\":%u, " "\"fileIndex\":%llu, " + "\"detshape\":[%u, %u], " "\"shape\":[%u, %u], " "\"size\":%u, " "\"acqIndex\":%llu, " @@ -283,11 +307,12 @@ public: "\"version\":%u, " //additional stuff + "\"gappixels\":%u, " "\"flippedDataX\":%u" ;//"}\n"; int length = sprintf(buf, jsonHeaderFormat, - jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize, + jsonversion, dynamicrange, fileIndex, ndetx, ndety, npixelsx, npixelsy, imageSize, acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1, frameNumber, expLength, packetNumber, bunchId, timestamp, @@ -295,6 +320,7 @@ public: detType, version, //additional stuff + gapPixelsEnable, ((flippedData == 0 ) ? 0 :flippedData[0]) ); if (additionalJsonHeader && strlen(additionalJsonHeader)) { diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index 1b28c2ed4..3c0bf3b9d 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -284,6 +284,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { /** set deactivated receiver padding enable */ int set_deactivated_receiver_padding_enable(); + /** set quad type */ + int set_quad_type(); + /** detector type */ detectorType myDetectorType; diff --git a/slsReceiverSoftware/include/sls_receiver_funcs.h b/slsReceiverSoftware/include/sls_receiver_funcs.h index 281088f19..5d3636e8c 100644 --- a/slsReceiverSoftware/include/sls_receiver_funcs.h +++ b/slsReceiverSoftware/include/sls_receiver_funcs.h @@ -71,6 +71,7 @@ enum recFuncs{ F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */ F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */ F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */ + F_RECEIVER_QUAD, /* Always append functions hereafter!!! */ diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index 47689f48e..49a75579c 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -16,7 +16,7 @@ const std::string DataStreamer::TypeName = "DataStreamer"; DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector* r, - uint64_t* fi, int* fd, char* ajh, bool* sm) : + uint64_t* fi, int* fd, char* ajh, bool* sm, int* nd, bool* gpEnable) : ThreadObject(ind), runningFlag(0), generalData(0), @@ -26,14 +26,19 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector* r, roi(r), adcConfigured(-1), fileIndex(fi), - flippedData(fd), additionJsonHeader(ajh), acquisitionStartedFlag(false), measurementStartedFlag(false), firstAcquisitionIndex(0), firstMeasurementIndex(0), - completeBuffer(0) + completeBuffer(0), + gapPixelsEnable(gpEnable) { + flippedData[0] = fd[0]; + flippedData[1] = fd[1]; + numDet[0] = nd[0]; + numDet[1] = nd[1]; + if(ThreadObject::CreateThread() == FAIL) throw std::exception(); @@ -130,6 +135,16 @@ int DataStreamer::SetThreadPriority(int priority) { return OK; } +void DataStreamer::SetNumberofDetectors(int* nd) { + numDet[0] = nd[0]; + numDet[1] = nd[1]; +} + +void DataStreamer::SetFlippedData(int* fd) { + flippedData[0] = fd[0]; + flippedData[1] = fd[1]; +} + void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) { uint32_t portnum = port + index; @@ -261,13 +276,13 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32 uint64_t acquisitionIndex = header.frameNumber - firstAcquisitionIndex; return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex, - nx, ny, size, + numDet[0], numDet[1], nx, ny, size, acquisitionIndex, frameIndex, fileNametoStream, header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp, header.modId, header.row, header.column, header.reserved, header.debug, header.roundRNumber, header.detType, header.version, - flippedData, + gapPixelsEnable ? 1 : 0, flippedData, additionJsonHeader ); } diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index fb7e15054..154f591d8 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -53,6 +53,7 @@ void UDPBaseImplementation::initializeMembers(){ flippedData[0] = 0; flippedData[1] = 0; gapPixelsEnable = false; + quadEnable = false; //***receiver parameters*** status = IDLE; @@ -137,6 +138,11 @@ bool UDPBaseImplementation::getGapPixelsEnable() const { return gapPixelsEnable; } +bool UDPBaseImplementation::getQuad() const { + FILE_LOG(logDEBUG) << __AT__ << " starting"; + return quadEnable; +} + /***file parameters***/ slsReceiverDefs::fileFormat UDPBaseImplementation::getFileFormat() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; @@ -392,6 +398,8 @@ void UDPBaseImplementation::setMultiDetectorSize(const int* size) { } strcat(message,")"); FILE_LOG(logINFO) << message; + + // overridden } void UDPBaseImplementation::setFlippedData(int axis, int enable){ @@ -399,6 +407,8 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){ if(axis<0 || axis>1) return; flippedData[axis] = enable==0?0:1; FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1]; + + // overridden } int UDPBaseImplementation::setGapPixelsEnable(const bool b) { @@ -410,6 +420,14 @@ int UDPBaseImplementation::setGapPixelsEnable(const bool b) { return OK; } +void UDPBaseImplementation::setQuad(const bool b) { + FILE_LOG(logDEBUG) << __AT__ << " starting"; + quadEnable = b; + FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; + + // overridden +} + /***file parameters***/ void UDPBaseImplementation::setFileFormat(const fileFormat f){ FILE_LOG(logDEBUG) << __AT__ << " starting"; diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index d7ea6122e..2564f0349 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -111,6 +111,55 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const { } +void UDPStandardImplementation::setMultiDetectorSize(const int* size) { + char message[100]; + strcpy(message, "Detector Size: ("); + for (int i = 0; i < MAX_DIMENSIONS; ++i) { + if (myDetectorType == EIGER && (!i)) + numDet[i] = size[i]*2; + else + numDet[i] = size[i]; + sprintf(message,"%s%d",message,numDet[i]); + if (i < MAX_DIMENSIONS-1 ) + strcat(message,","); + } + strcat(message,")"); + + int sz[2] = {numDet[0], numDet[1]}; + if (quadEnable) { + sz[0] = 1; + sz[1] = 2; + } + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ + (*it)->SetNumberofDetectors(sz); + } + + FILE_LOG(logINFO) << message; +} + +void UDPStandardImplementation::setFlippedData(int axis, int enable){ + if(axis<0 || axis>1) return; + flippedData[axis] = enable==0?0:1; + + if (!quadEnable) { + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ + (*it)->SetFlippedData(flippedData); + } + } + else { + int fd[2] = {flippedData[0], flippedData[1]}; + if (dataStreamer.size() == 2) { + fd[0] = 0; + dataStreamer[0]->SetFlippedData(fd); + fd[0] = 1; + dataStreamer[1]->SetFlippedData(fd); + } + } + + FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1]; +} + + int UDPStandardImplementation::setGapPixelsEnable(const bool b) { if (gapPixelsEnable != b) { @@ -130,6 +179,32 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) { return OK; } +void UDPStandardImplementation::setQuad(const bool b) { + if (quadEnable != b) { + quadEnable = b; + + if (!quadEnable) { + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ + (*it)->SetNumberofDetectors(numDet); + (*it)->SetFlippedData(flippedData); + } + } else { + int size[2] = {1, 2}; + for (std::vector::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ + (*it)->SetNumberofDetectors(size); + } + int fd[2] = {flippedData[0], flippedData[1]}; + if (dataStreamer.size() == 2) { + fd[0] = 0; + dataStreamer[0]->SetFlippedData(fd); + fd[0] = 1; + dataStreamer[1]->SetFlippedData(fd); + } + } + } + FILE_LOG(logINFO) << "Quad Enable: " << quadEnable; +} + void UDPStandardImplementation::setFileFormat(const fileFormat f){ switch(f){ @@ -252,7 +327,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) { for ( int i = 0; i < numThreads; ++i ) { try { DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange, - &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode); + &roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode, (int*)numDet, &gapPixelsEnable); dataStreamer.push_back(s); dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP); diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 4536bbbb4..87b8851b0 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -246,6 +246,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) { case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY"; case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE"; case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE"; + case F_RECEIVER_QUAD: return "F_RECEIVER_QUAD"; default: return "Unknown Function"; } @@ -303,7 +304,7 @@ int slsReceiverTCPIPInterface::function_table(){ flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy; flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable; flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable; - + flist[F_RECEIVER_QUAD] = &slsReceiverTCPIPInterface::set_quad_type; #ifdef VERYVERBOSE for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { @@ -2982,3 +2983,53 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() { // return ok/fail return ret; } + + + +int slsReceiverTCPIPInterface::set_quad_type() { + ret = OK; + memset(mess, 0, sizeof(mess)); + int value = -1; + int retval = -1; + + // receive arguments + if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 ) + return printSocketReadError(); + + // execute action +#ifdef SLS_RECEIVER_UDP_FUNCTIONS + if (receiverBase == NULL) + invalidReceiverObject(); + else { + // set + if(value >= 0) { + if (mySock->differentClients && lockStatus) + receiverlocked(); + else if (receiverBase->getStatus() != IDLE) + receiverNotIdle(); + else { + receiverBase->setQuad(value); // no check required + } + } + //get + retval = (int)receiverBase->getQuad(); // no check required + } +#endif +#ifdef VERYVERBOSE + FILE_LOG(logINFO) << "Quad mode:" << retval; +#endif + + if (ret == OK && mySock->differentClients) + ret = FORCE_UPDATE; + + // send answer + mySock->SendDataOnly(&ret,sizeof(ret)); + if (ret == FAIL) + mySock->SendDataOnly(mess,sizeof(mess)); + mySock->SendDataOnly(&retval,sizeof(retval)); + + // return ok/fail + return ret; +} + +