diff --git a/slsDetectorServers/eigerDetectorServer/Beb.c b/slsDetectorServers/eigerDetectorServer/Beb.c index 13901392d..b2bd86a28 100644 --- a/slsDetectorServers/eigerDetectorServer/Beb.c +++ b/slsDetectorServers/eigerDetectorServer/Beb.c @@ -479,19 +479,21 @@ int Beb_SetDataStream(int left, int enable) { (left ? XPAR_GPIO_LFT_STRM_DSBL_MSK : XPAR_GPIO_RGHT_STRM_DSBL_MSK); u_int32_t value = Beb_Read32(csp0base, reg); - LOG(logDEBUG, ("data streaming register value before:%d\n", value)); - if (enable) + LOG(logINFO, ("data streaming register value before:0x%x\n", value)); + // disabling in firmware + if (!enable) value |= mask; else value &= ~mask; + LOG(logINFO, ("Going to set data streaming register value:0x%x\n", value)); u_int32_t retval = Beb_Write32(csp0base, reg, value); - if (retval != value) { + /*if (retval != value) { LOG(logERROR, ("Could not %s %s fpga datastream. Wrote 0x%x, read 0x%x\n", (enable ? "enable" : "disable"), (left ? "left" : "right"), value, retval)); Beb_close(fd, csp0base); - } + }*/ } Beb_close(fd, csp0base); return 1; @@ -516,7 +518,8 @@ int Beb_GetDataStream(int left, int *retval) { (left ? XPAR_GPIO_LFT_STRM_DSBL_MSK : XPAR_GPIO_RGHT_STRM_DSBL_MSK); u_int32_t value = Beb_Read32(csp0base, reg); - *retval = (value & mask) ? 1 : 0; + // disabling in firmware + *retval = (value & mask) ? 0 : 1; } Beb_close(fd, csp0base); return 1; diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index d527282e9..96d9c38cd 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 39918fbcc..c61fe6eea 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -7055,6 +7055,28 @@ int get_receiver_parameters(int file_des) { if (n < 0) return printSocketReadError(); + // data stream left +#ifdef EIGERD + i32 = 0; + getDataStream(1, &i32); +#else + i32 = 0; +#endif + n += sendData(file_des, &i32, sizeof(i32), INT32); + if (n < 0) + return printSocketReadError(); + + // data stream right +#ifdef EIGERD + i32 = 0; + getDataStream(0, &i32); +#else + i32 = 0; +#endif + n += sendData(file_des, &i32, sizeof(i32), INT32); + if (n < 0) + return printSocketReadError(); + // quad #ifdef EIGERD i32 = getQuad(); @@ -8300,7 +8322,7 @@ int set_datastream(int file_des) { if (ret == FAIL) { sprintf(mess, "Could not %s\n", msg); LOG(logERROR, (mess)); - } else { + } /*else { int retval = -1; ret = getDataStream(leftFpga, &retval); LOG(logDEBUG1, ("%s retval: %u\n", msg, retval)); @@ -8310,7 +8332,7 @@ int set_datastream(int file_des) { LOG(logERROR, (mess)); } validate(&ret, mess, enable, retval, msg, DEC); - } + }*/ } } #endif diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 6fcf5c123..677374930 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1516,6 +1516,9 @@ bool Module::getDataStream(const bool left) const { void Module::setDataStream(const bool left, const bool enable) { int args[]{static_cast(left), static_cast(enable)}; sendToDetector(F_SET_DATASTREAM, args, nullptr); + if (shm()->useReceiverFlag) { + sendToReceiver(F_RECEIVER_SET_DATASTREAM, args, nullptr); + } } // Jungfrau Specific diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 8f644000e..c35209314 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -209,6 +209,8 @@ int ClientInterface::functionTable(){ flist[F_GET_RECEIVER_STREAMING_HWM] = &ClientInterface::get_streaming_hwm; flist[F_SET_RECEIVER_STREAMING_HWM] = &ClientInterface::set_streaming_hwm; flist[F_RECEIVER_SET_ALL_THRESHOLD] = &ClientInterface::set_all_threshold; + flist[F_RECEIVER_SET_DATASTREAM] = &ClientInterface::set_detector_datastream; + for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { LOG(logDEBUG1) << "function fnum: " << i << " (" << @@ -401,6 +403,8 @@ int ClientInterface::setup_receiver(Interface &socket) { impl()->setSubPeriod(std::chrono::nanoseconds(arg.subExpTimeNs) + std::chrono::nanoseconds(arg.subDeadTimeNs)); impl()->setActivate(static_cast(arg.activate)); + impl()->setDetectorDataStream(1, arg.dataStreamLeft); + impl()->setDetectorDataStream(0, arg.dataStreamRight); try { impl()->setQuad(arg.quad == 0 ? false : true); } catch (const RuntimeError &e) { @@ -1695,3 +1699,18 @@ int ClientInterface::set_all_threshold(Interface &socket) { impl()->setThresholdEnergy(eVs); return socket.Send(OK); } + +int ClientInterface::set_detector_datastream(Interface &socket) { + int args[2]{-1, -1}; + socket.Receive(args); + bool left = static_cast(args[0]); + bool enable = static_cast(args[1]); + LOG(logDEBUG1) << "Setting datstream " << (left ? "left" : "right") + << ") to " << sls::ToString(enable); + if (myDetectorType != EIGER) + functionNotImplemented(); + verifyIdle(socket); + impl()->setDetectorDataStream(left, enable); + return socket.Send(OK); +} + diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index fa3d3b683..64ed796c0 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -162,6 +162,8 @@ class ClientInterface : private virtual slsDetectorDefs { int get_streaming_hwm(sls::ServerInterface &socket); int set_streaming_hwm(sls::ServerInterface &socket); int set_all_threshold(sls::ServerInterface &socket); + int set_detector_datastream(sls::ServerInterface &socket); + Implementation *impl() { if (receiver != nullptr) { diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 6b4c8467f..a506e02fb 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -151,7 +151,7 @@ void DataProcessor::CreateFirstFiles( const bool overWriteEnable, const bool silentMode, const int modulePos, const int numUnitsPerReadout, const uint32_t udpPortNumber, const uint32_t maxFramesPerFile, const uint64_t numImages, - const uint32_t dynamicRange) { + const uint32_t dynamicRange, const bool detectorDataStream) { if (dataFile_ == nullptr) { throw sls::RuntimeError("file object not contstructed"); } @@ -163,6 +163,16 @@ void DataProcessor::CreateFirstFiles( overWriteEnable, silentMode, attr); } + // deactivated with padding enabled, dont write file + if (!*activated_ && !*deactivatedPaddingEnable_) { + return; + } + + // deactivated port, dont write file + if (!detectorDataStream) { + return; + } + switch (dataFile_->GetFileFormat()) { #ifdef HDF5C case HDF5: diff --git a/slsReceiverSoftware/src/DataProcessor.h b/slsReceiverSoftware/src/DataProcessor.h index aca8eb6e1..c05af8784 100644 --- a/slsReceiverSoftware/src/DataProcessor.h +++ b/slsReceiverSoftware/src/DataProcessor.h @@ -60,7 +60,9 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { const uint32_t udpPortNumber, const uint32_t maxFramesPerFile, const uint64_t numImages, - const uint32_t dynamicRange); + const uint32_t dynamicRange, + const bool detectorDataStream + ); #ifdef HDF5C uint32_t GetFilesInAcquisition() const; void CreateVirtualFile(const std::string filePath, diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 1e6462e5a..436ea5644 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -167,7 +167,7 @@ void Implementation::setDetectorType(const detectorType d) { i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i], &numberOfTotalFrames, &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, - &activated, &deactivatedPaddingEnable, &silentMode)); + &activated, &detectorDataStream[i], &deactivatedPaddingEnable, &silentMode)); dataProcessor.push_back(sls::make_unique( i, detType, fifo_ptr, &activated, &deactivatedPaddingEnable, &dataStreamEnable, &streamingFrequency, &streamingTimerInMs, @@ -610,6 +610,12 @@ void Implementation::stopReceiver() { if (!activated) { LOG(logINFORED) << "Deactivated Receiver"; } + if (!detectorDataStream[0]) { + LOG(logINFORED) << "Deactivated Left Port"; + } + if (!detectorDataStream[1]) { + LOG(logINFORED) << "Deactivated Right Port"; + } // callback if (acquisitionFinishedCallBack) { try { @@ -796,7 +802,7 @@ void Implementation::SetupWriter() { masterAttributes.get(), filePath, fileName, fileIndex, overwriteEnable, silentMode, modulePos, numThreads, udpPortNum[i], framesPerFile, numberOfTotalFrames, - dynamicRange); + dynamicRange, detectorDataStream[i]); } } catch (const sls::RuntimeError &e) { shutDownUDPSockets(); @@ -867,7 +873,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) { i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i], &numberOfTotalFrames, &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, - &frameDiscardMode, &activated, &deactivatedPaddingEnable, + &frameDiscardMode, &activated, &detectorDataStream[i], &deactivatedPaddingEnable, &silentMode)); listener[i]->SetGeneralData(generalData); @@ -1497,10 +1503,20 @@ void Implementation::setQuad(const bool b) { bool Implementation::getActivate() const { return activated; } -bool Implementation::setActivate(bool enable) { +void Implementation::setActivate(bool enable) { activated = enable; LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled"); - return activated; +} + +bool Implementation::getDetectorDataStream(const bool leftPort) const { + int index = (leftPort ? 0 : 1); + return detectorDataStream[index]; +} + +void Implementation::setDetectorDataStream(const bool leftPort, const bool enable) { + int index = (leftPort ? 0 : 1); + detectorDataStream[index] = enable; + LOG(logINFO) << "Detector datastream (" << (leftPort ? "Left" : "Right") << " Port): " << sls::ToString(detectorDataStream[index]); } bool Implementation::getDeactivatedPadding() const { diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index fa54837d7..ac2a1cf10 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -210,7 +210,11 @@ class Implementation : private virtual slsDetectorDefs { bool getActivate() const; /** [Eiger] If deactivated, receiver will create dummy data if deactivated * padding is enabled (as it will receive nothing from detector) */ - bool setActivate(const bool enable); + void setActivate(const bool enable); + bool getDetectorDataStream(const bool leftPort) const; + /** [Eiger] If datastream is disabled, receiver will create dummy data if deactivated + * padding for that port is enabled (as it will receive nothing from detector) */ + void setDetectorDataStream(const bool leftPort, const bool enable); bool getDeactivatedPadding() const; /* [Eiger] */ void setDeactivatedPadding(const bool enable); @@ -346,6 +350,7 @@ class Implementation : private virtual slsDetectorDefs { int flippedDataX{0}; bool quadEnable{false}; bool activated{true}; + std::array detectorDataStream = {{true, true}}; bool deactivatedPaddingEnable{true}; int numLinesReadout{MAX_EIGER_ROWS_PER_READOUT}; int thresholdEnergyeV{-1}; diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index f1b1bcee1..9b0aaed55 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -22,11 +22,11 @@ const std::string Listener::TypeName = "Listener"; Listener::Listener(int ind, detectorType dtype, Fifo *f, std::atomic *s, uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as, uint32_t *fpf, - frameDiscardPolicy *fdp, bool *act, bool *depaden, bool *sm) + frameDiscardPolicy *fdp, bool *act, bool* detds, bool *depaden, bool *sm) : ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s), udpPortNumber(portno), eth(e), numImages(nf), udpSocketBufferSize(us), actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp), - activated(act), deactivatedPaddingEnable(depaden), silentMode(sm) { + activated(act), detectorDataStream(detds), deactivatedPaddingEnable(depaden), silentMode(sm) { LOG(logDEBUG) << "Listener " << ind << " created"; } @@ -94,7 +94,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) { void Listener::SetGeneralData(GeneralData *g) { generalData = g; } void Listener::CreateUDPSockets() { - if (!(*activated)) { + if (!(*activated) || !(*detectorDataStream)) { return; } @@ -144,7 +144,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) { LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber; - if (!(*activated)) { + if (!(*activated) || !(*detectorDataStream)) { *actualUDPSocketBufferSize = (s * 2); return; } @@ -201,7 +201,7 @@ void Listener::ThreadExecution() { << std::hex << (void *)(buffer) << std::dec << ":" << buffer; // udpsocket doesnt exist - if (*activated && !udpSocketAlive && !carryOverFlag) { + if (*activated && *detectorDataStream && !udpSocketAlive && !carryOverFlag) { // LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not // created or shut down earlier"; (*((uint32_t *)buffer)) = 0; @@ -210,7 +210,7 @@ void Listener::ThreadExecution() { } // get data - if ((*status != TRANSMITTING && (!(*activated) || udpSocketAlive)) || + if ((*status != TRANSMITTING && (!(*activated) || !(*detectorDataStream) || udpSocketAlive)) || carryOverFlag) { rc = ListenToAnImage(buffer); } @@ -293,6 +293,10 @@ uint32_t Listener::ListenToAnImage(char *buf) { memset(buf, 0, fifohsize); new_header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); + // deactivated port (eiger) + if (!(*detectorDataStream)) { + return 0; + } // deactivated (eiger) if (!(*activated)) { // no padding diff --git a/slsReceiverSoftware/src/Listener.h b/slsReceiverSoftware/src/Listener.h index 5f6bdc46e..eff5800dc 100644 --- a/slsReceiverSoftware/src/Listener.h +++ b/slsReceiverSoftware/src/Listener.h @@ -37,12 +37,13 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { * @param fpf pointer to frames per file * @param fdp frame discard policy * @param act pointer to activated + * @param detds pointer to detector data stream * @param depaden pointer to deactivated padding enable * @param sm pointer to silent mode */ Listener(int ind, detectorType dtype, Fifo *f, std::atomic *s, uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as, - uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool *depaden, + uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool* detds, bool *depaden, bool *sm); /** @@ -187,6 +188,9 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { /** Activated/Deactivated */ bool *activated; + /** detector data stream */ + bool* detectorDataStream; + /** Deactivated padding enable */ bool *deactivatedPaddingEnable; diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 28a6403a9..5b15b0630 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -459,6 +459,8 @@ typedef struct { int64_t subExpTimeNs{0}; int64_t subDeadTimeNs{0}; int activate{0}; + int dataStreamLeft{0}; + int dataStreamRight{0}; int quad{0}; int numLinesReadout{0}; int thresholdEnergyeV[3]{0, 0, 0}; diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 061964010..e0f46f96a 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -330,6 +330,7 @@ enum detFuncs { F_GET_RECEIVER_STREAMING_HWM, F_SET_RECEIVER_STREAMING_HWM, F_RECEIVER_SET_ALL_THRESHOLD, + F_RECEIVER_SET_DATASTREAM, NUM_REC_FUNCTIONS }; @@ -658,7 +659,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_RECEIVER_STREAMING_HWM: return "F_GET_RECEIVER_STREAMING_HWM"; case F_SET_RECEIVER_STREAMING_HWM: return "F_SET_RECEIVER_STREAMING_HWM"; case F_RECEIVER_SET_ALL_THRESHOLD: return "F_RECEIVER_SET_ALL_THRESHOLD"; - + case F_RECEIVER_SET_DATASTREAM: return "F_RECEIVER_SET_DATASTREAM"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; default: return "Unknown Function"; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 2fcef8069..b8fc94ae9 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -10,4 +10,4 @@ #define APIMYTHEN3 0x210621 #define APIMOENCH 0x210621 -#define APIEIGER 0x210702 +#define APIEIGER 0x210705 diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 3d5b92de5..8593d4fb8 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -52,6 +52,8 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) { << "subDeadTime:" << ToString(std::chrono::nanoseconds(r.subDeadTimeNs)) << std::endl << "activate:" << r.activate << std::endl + << "leftDataStream:" << r.dataStreamLeft << std::endl + << "rightDataStream:" << r.dataStreamRight << std::endl << "quad:" << r.quad << std::endl << "numLinesReadout:" << r.numLinesReadout << std::endl << "thresholdEnergyeV:" << ToString(r.thresholdEnergyeV) << std::endl