diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index dcf335bf8..d4fa76679 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -10,6 +10,7 @@ #include "sls_receiver_defs.h" #include "receiver_defs.h" +#define NUM_BITS_IN_ONE_BYTE 8 class GeneralData { @@ -171,6 +172,15 @@ public: bprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); }; + /** + * Enable Gap Pixels changes member variables + * @param enable true if gap pixels enable, else false + */ + virtual void SetGapPixelsEnable(bool b, int dr) { + bprintf(RED,"This is a generic function that should be overloaded by a derived class\n"); + }; + + /** * Print all variables */ @@ -544,6 +554,26 @@ class EigerData : public GeneralData { imageSize = dataSize*packetsPerFrame; }; + /** + * Enable Gap Pixels changes member variables + * @param enable true if gap pixels enable, else false + */ + void SetGapPixelsEnable(bool b, int dr) { + switch((int)b) { + case 1: + nPixelsX_Streamer = (256*2) + 3; + nPixelsY_Streamer = 256 + 1; + imageSize_Streamer = nPixelsX_Streamer * imageSize_Streamer * + ((double)dr/(double)NUM_BITS_IN_ONE_BYTE); + break; + default: + nPixelsX_Streamer = (256*2); + nPixelsY_Streamer = 256; + imageSize_Streamer = dataSize*packetsPerFrame; + break; + } + }; + }; diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index f5af43d68..8e4a54b6b 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -66,6 +66,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ int getFlippedData(int axis=0) const; + /** + * Get Gap Pixels Enable (eiger specific) + * @return true if gap pixels enabled, else false + */ + bool getGapPixelsEnable() const; + //***file parameters*** /** @@ -284,6 +290,13 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ void setFlippedData(int axis=0, int enable=-1); + /** + * Set Gap Pixels Enable (eiger specific) + * @param b true for gap pixels enable, else false + * @return OK or FAIL + */ + int setGapPixelsEnable(const bool b); + //***file parameters*** /** @@ -609,6 +622,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter uint32_t fifoDepth; /** enable for flipping data across both axes */ int flippedData[2]; + /** gap pixels enable */ + bool gapPixelsEnable; //***receiver parameters*** /** Maximum Number of Listening Threads/ UDP Ports */ diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 3e48d765f..d12b60032 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -48,6 +48,7 @@ class UDPInterface { * -setFlippedData (if eiger) * -setActivate (if eiger) * -setTenGigaEnable (if eiger) + * -setGapPixelsEnable * -setStreamingPort * -setStreamingSourceIP * -setDataStreamEnable @@ -151,6 +152,12 @@ class UDPInterface { */ virtual int getFlippedData(int axis=0) const = 0; + /** + * Get Gap Pixels Enable (eiger specific) + * @return true if gap pixels enabled, else false + */ + virtual bool getGapPixelsEnable() const = 0; + //***file parameters*** /** @@ -370,6 +377,14 @@ class UDPInterface { virtual void setFlippedData(int axis=0, int enable=-1) = 0; + /** + * Set Gap Pixels Enable (eiger specific) + * @param b true for gap pixels enable, else false + * @return OK or FAIL + */ + virtual int setGapPixelsEnable(const bool b) = 0; + + //***file parameters*** /** * Set File Format diff --git a/slsReceiverSoftware/include/UDPStandardImplementation.h b/slsReceiverSoftware/include/UDPStandardImplementation.h index a5fe533ab..4136f91f2 100644 --- a/slsReceiverSoftware/include/UDPStandardImplementation.h +++ b/slsReceiverSoftware/include/UDPStandardImplementation.h @@ -53,6 +53,13 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase */ int64_t getAcquisitionIndex() const; + /** + * Set Gap Pixels Enable (eiger specific) + * @param b true for gap pixels enable, else false + * @return OK or FAIL + */ + int setGapPixelsEnable(const bool b); + /** * Set File Format * @param f fileformat binary or hdf5 diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index aa44f00ad..885c7ef90 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -261,6 +261,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { /** set streaming source ip */ int set_streaming_source_ip(); + /** enable gap pixels */ + int enable_gap_pixels(); + /** detector type */ diff --git a/slsReceiverSoftware/include/sls_receiver_funcs.h b/slsReceiverSoftware/include/sls_receiver_funcs.h index 48d41679f..cd29bfe8c 100644 --- a/slsReceiverSoftware/include/sls_receiver_funcs.h +++ b/slsReceiverSoftware/include/sls_receiver_funcs.h @@ -60,6 +60,7 @@ enum recFuncs{ F_SEND_RECEIVER_MULTIDETSIZE, /** < sets the multi detector size to the receiver */ F_SET_RECEIVER_STREAMING_PORT, /** < sets the receiver streaming port */ F_RECEIVER_STREAMING_SRC_IP, /** < sets the receiver streaming source IP */ + F_ENABLE_GAPPIXELS_IN_RECEIVER, /** < sets gap pixels in the receiver */ /* Always append functions hereafter!!! */ diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 5fbb5d00e..ae29ae7f3 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -53,6 +53,7 @@ void UDPBaseImplementation::initializeMembers(){ fifoDepth = 0; flippedData[0] = 0; flippedData[1] = 0; + gapPixelsEnable = false; //***receiver parameters*** status = IDLE; @@ -115,6 +116,10 @@ int UDPBaseImplementation::getFlippedData(int axis) const{ return flippedData[axis]; } +bool UDPBaseImplementation::getGapPixelsEnable() const { + FILE_LOG(logDEBUG) << __AT__ << " starting"; + return gapPixelsEnable; +} /***file parameters***/ slsReceiverDefs::fileFormat UDPBaseImplementation::getFileFormat() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileFormatType;} @@ -255,6 +260,14 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){ FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1]; } +int UDPBaseImplementation::setGapPixelsEnable(const bool b) { + FILE_LOG(logDEBUG) << __AT__ << " starting"; + gapPixelsEnable = b; + FILE_LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable; + + // overridden + return OK; +} /***file parameters***/ void UDPBaseImplementation::setFileFormat(const fileFormat f){ diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 16b68067c..46a1985e4 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -112,6 +112,21 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const { } +int UDPStandardImplementation::setGapPixelsEnable(const bool b) { + if (gapPixelsEnable != b) { + gapPixelsEnable = b; + + // side effects + + numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure + if (SetupFifoStructure() == FAIL) + return FAIL; + } + FILE_LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable; + return OK; +} + + void UDPStandardImplementation::setFileFormat(const fileFormat f){ switch(f){ #ifdef HDF5C diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index f7e31472f..647c60342 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -280,6 +280,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) { case F_SEND_RECEIVER_DETPOSID: return "F_SEND_RECEIVER_DETPOSID"; case F_SEND_RECEIVER_MULTIDETSIZE: return "F_SEND_RECEIVER_MULTIDETSIZE"; case F_RECEIVER_STREAMING_SRC_IP: return "F_RECEIVER_STREAMING_SRC_IP"; + case F_ENABLE_GAPPIXELS_IN_RECEIVER:return "F_ENABLE_GAPPIXELS_IN_RECEIVER"; default: return "Unknown Function"; } @@ -326,6 +327,7 @@ int slsReceiverTCPIPInterface::function_table(){ flist[F_SEND_RECEIVER_MULTIDETSIZE] = &slsReceiverTCPIPInterface::set_multi_detector_size; flist[F_SET_RECEIVER_STREAMING_PORT] = &slsReceiverTCPIPInterface::set_streaming_port; flist[F_RECEIVER_STREAMING_SRC_IP] = &slsReceiverTCPIPInterface::set_streaming_source_ip; + flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &slsReceiverTCPIPInterface::enable_gap_pixels; #ifdef VERYVERBOSE for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { FILE_LOG(logINFO) << "function fnum: " << i << " (" << getFunctionName((enum recFuncs)i) << ") located at " << (unsigned int)flist[i]; @@ -687,6 +689,11 @@ int slsReceiverTCPIPInterface::send_update() { if (path != NULL) delete[] path; + // gap pixels enable +#ifdef SLS_RECEIVER_UDP_FUNCTIONS + ind = (int)receiverBase->getGapPixelsEnable(); +#endif + mySock->SendDataOnly(&ind,sizeof(ind)); if (!lockStatus) strcpy(mySock->lastClientIP,mySock->thisClientIP); @@ -2367,3 +2374,63 @@ int slsReceiverTCPIPInterface::set_streaming_source_ip() { // return ok/fail return ret; } + + + + + +int slsReceiverTCPIPInterface::enable_gap_pixels() { + ret = OK; + memset(mess, 0, sizeof(mess)); + int enable = -1; + int retval = -1; + + // receive arguments + if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ) + return printSocketReadError(); + + if (myDetectorType != EIGER) + functionNotImplemented(); + + // execute action +#ifdef SLS_RECEIVER_UDP_FUNCTIONS + else { + if (receiverBase == NULL) + invalidReceiverObject(); + else { + // set + if(enable >= 0) { + if (mySock->differentClients && lockStatus) + receiverlocked(); + else if (receiverBase->getStatus() != IDLE) + receiverNotIdle(); + else { + receiverBase->setGapPixelsEnable(enable); + } + } + //get + retval = receiverBase->getGapPixelsEnable(); + if(enable >= 0 && retval != enable){ + ret = FAIL; + sprintf(mess,"Could not set gap pixels to %d, returned %d\n",enable,retval); + FILE_LOG(logERROR) << "Warning: " << mess; + } + } + } +#endif +#ifdef VERYVERBOSE + FILE_LOG(logDEBUG1) << "Activate: " << 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; +}