From c5d6dd0dd480d3ec9e8029c65d079e21bd3a2594 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 12:39:04 +0200 Subject: [PATCH 1/4] flippeddatax for jungfrau server --- RELEASE.txt | 1 + python/src/detector.cpp | 9 +-- .../jungfrauDetectorServer/RegisterDefs.h | 2 +- .../slsDetectorFunctionList.c | 20 ++++++ .../include/slsDetectorFunctionList.h | 2 + .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 65 ++++++++++++++++++- slsDetectorSoftware/include/sls/Detector.h | 15 +++-- slsDetectorSoftware/src/CmdProxy.h | 19 +++--- slsDetectorSoftware/src/Detector.cpp | 16 ++--- slsDetectorSoftware/src/Module.cpp | 24 ++++--- slsDetectorSoftware/src/Module.h | 4 +- .../tests/test-CmdProxy-eiger.cpp | 21 ------ slsDetectorSoftware/tests/test-CmdProxy.cpp | 28 ++++++++ .../include/sls/sls_detector_funcs.h | 4 ++ 15 files changed, 174 insertions(+), 60 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index c5b81f899..8bc41c6fe 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -63,6 +63,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases. getAutoCompDisable->getAutoComparatorDisable +setBottom->setFlippedDataAcrossXAxis 3. Firmware Requirements ======================== diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 6980fc55f..93cc262af 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -848,12 +848,13 @@ void init_det(py::module &m) { (void (Detector::*)(bool, sls::Positions)) & Detector::setOverFlowMode, py::arg(), py::arg() = Positions{}) - .def("getBottom", + .def("getFlippedDataAcrossXAxis", (Result(Detector::*)(sls::Positions) const) & - Detector::getBottom, + Detector::getFlippedDataAcrossXAxis, py::arg() = Positions{}) - .def("setBottom", - (void (Detector::*)(bool, sls::Positions)) & Detector::setBottom, + .def("setFlippedDataAcrossXAxis", + (void (Detector::*)(bool, sls::Positions)) & + Detector::setFlippedDataAcrossXAxis, py::arg(), py::arg() = Positions{}) .def("getRateCorrection", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h index 5ea830d1b..df4a6e63f 100644 --- a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h @@ -190,7 +190,7 @@ #define CONFIG_TDMA_TIMESLOT_OFST (25) // 1ms #define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST) #define CONFIG_BOTTOM_INVERT_STREAM_OFST (30) -#define CONFIG_BOTTOM_INVERT_STREAM_MSK (0x0000001F << CONFIG_BOTTOM_INVERT_STREAM_OFST) +#define CONFIG_BOTTOM_INVERT_STREAM_MSK (0x00000001 << CONFIG_BOTTOM_INVERT_STREAM_OFST) #define CONFIG_ETHRNT_FLW_CNTRL_OFST (31) #define CONFIG_ETHRNT_FLW_CNTRL_MSK (0x00000001 << CONFIG_ETHRNT_FLW_CNTRL_OFST) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 0665f053e..609e3694c 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -474,6 +474,7 @@ void setupDetector() { // temp threshold and reset event setThresholdTemperature(DEFAULT_TMP_THRSHLD); setTemperatureEvent(0); + setFlippedDataAcrossXAxis(0); } int resetToDefaultDacs(int hardReset) { @@ -2002,6 +2003,25 @@ void alignDeserializer() { bus_r(ADC_DSRLZR_3_REG) & (~(ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK))); } +int getFlippedDataAcrossXAxis() { + return ((bus_r(CONFIG_REG) & CONFIG_BOTTOM_INVERT_STREAM_MSK) >> + CONFIG_BOTTOM_INVERT_STREAM_OFST); +} + +void setFlippedDataAcrossXAxis(int arg) { + if (arg >= 0) { + if (arg == 0) { + LOG(logINFO, ("Switching off bottom flipping\n")); + bus_w(CONFIG_REG, + bus_r(CONFIG_REG) & ~CONFIG_BOTTOM_INVERT_STREAM_MSK); + } else { + LOG(logINFO, ("Switching on bottom flipping\n")); + bus_w(CONFIG_REG, + bus_r(CONFIG_REG) | CONFIG_BOTTOM_INVERT_STREAM_MSK); + } + } +} + int getTenGigaFlowControl() { return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >> CONFIG_ETHRNT_FLW_CNTRL_OFST); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 95a1c2249..0e1d60ad7 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -460,6 +460,8 @@ int setThresholdTemperature(int val); int setTemperatureControl(int val); int setTemperatureEvent(int val); void alignDeserializer(); +int getFlippedDataAcrossXAxis(); +void setFlippedDataAcrossXAxis(int arg); // eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter #elif EIGERD diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 594de8402..e5550db60 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -260,4 +260,6 @@ int set_default_dac(int); int get_gain_mode(int); int set_gain_mode(int); int get_comp_disable_time(int); -int set_comp_disable_time(int); \ No newline at end of file +int set_comp_disable_time(int); +int get_flipped_data_x(int); +int set_flipped_data_x(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index faa4b0ff4..d0d3e3fa6 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -386,6 +386,8 @@ void function_table() { flist[F_SET_GAIN_MODE] = &set_gain_mode; flist[F_GET_COMP_DISABLE_TIME] = &get_comp_disable_time; flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time; + flist[F_GET_FLIPPED_DATA_X] = &get_flipped_data_x; + flist[F_SET_FLIPPED_DATA_X] = &set_flipped_data_x; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8675,4 +8677,65 @@ int set_comp_disable_time(int file_des) { } #endif return Server_SendResult(file_des, INT64, NULL, 0); -} \ No newline at end of file +} + +int get_flipped_data_x(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + + LOG(logDEBUG1, ("Getting flipped data x\n")); + +#ifndef JUNGFRAUD + functionNotImplemented(); +#else + // get only + retval = getFlippedDataAcrossXAxis(); + LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval)); +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} + +int set_flipped_data_x(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = -1; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + LOG(logINFO, ("Setting flipped data x: %u\n", (int)arg)); + +#ifndef JUNGFRAUD + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + + if (arg != 0 && arg != 1) { + ret = FAIL; + sprintf(mess, + "Could not set flipped data x. Invalid argument %d.\n", + arg); + LOG(logERROR, (mess)); + } + // only for HW 2.0 (version = 3) + else if (isHardwareVersion2()) { + ret = FAIL; + strcpy(mess, "Could not set flipped data x. Only available for " + "Hardware Board version 2.0.\n"); + LOG(logERROR, (mess)); + } else if (getNumberofUDPInterfaces() == 1) { + ret = FAIL; + strcpy(mess, "Could not set flipped data x. Number of udp " + "interfaces is still 1.\n"); + LOG(logERROR, (mess)); + } else { + setFlippedDataAcrossXAxis(arg); + int retval = getFlippedDataAcrossXAxis(); + LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval)); + validate(&ret, mess, arg, retval, "set flipped data x", DEC); + } + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 8ad4c5338..a2b0074ac 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -172,6 +172,15 @@ class Detector { */ void setGapPixelsinCallback(const bool enable); + /** [Eiger][Jungfrau] */ + Result getFlippedDataAcrossXAxis(Positions pos = {}) const; + + /** [Eiger] flips across x Axis paramater sent to slsreceiver to send to gui + * (via zmq) to flip bottom [Jungfrau] flips data across x Axis in the + * detector itself. slsReceiver and slsDetectorGui does not handle. + */ + void setFlippedDataAcrossXAxis(bool value, Positions pos = {}); + Result isVirtualDetectorServer(Positions pos = {}) const; ///@{ @@ -995,12 +1004,6 @@ class Detector { /** [Eiger] Overflow in 32 bit mode. Default is disabled.*/ void setOverFlowMode(bool value, Positions pos = {}); - /** [Eiger] */ - Result getBottom(Positions pos = {}) const; - - /** [Eiger] for client call back (gui) purposes to flip bottom image */ - void setBottom(bool value, Positions pos = {}); - /** [Eiger] deadtime in ns, 0 = disabled */ Result getRateCorrection(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index f501a6f99..bed86280f 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -769,6 +769,7 @@ class CmdProxy { {"trimval", &CmdProxy::trimval}, {"trimen", &CmdProxy::TrimEnergies}, {"gappixels", &CmdProxy::GapPixels}, + {"flippeddatax", &CmdProxy::flippeddatax}, /* acquisition parameters */ {"acquire", &CmdProxy::Acquire}, @@ -906,7 +907,6 @@ class CmdProxy { {"subexptime", &CmdProxy::subexptime}, {"subdeadtime", &CmdProxy::subdeadtime}, {"overflow", &CmdProxy::overflow}, - {"flippeddatax", &CmdProxy::flippeddatax}, {"ratecorr", &CmdProxy::RateCorrection}, {"readnlines", &CmdProxy::readnlines}, {"interruptsubframe", &CmdProxy::interruptsubframe}, @@ -1233,6 +1233,16 @@ class CmdProxy { "[n_trimval]\n\t[Eiger][Mythen3] All trimbits set to this " "value. Returns -1 if all trimbits are different values."); + INTEGER_COMMAND_VEC_ID( + flippeddatax, getFlippedDataAcrossXAxis, setFlippedDataAcrossXAxis, + StringTo, + "[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 " + "is top. Used to let Gui (via zmq from receiver) know to flip the " + "bottom image over the x axis. Files are not written without the flip " + "however.\n\t[Jungfrau] If enabled, the bottom is flipped across the x " + "axis from the detector. The slsReceiver nor the Gui handles this " + "parameter."); + /* acquisition parameters */ INTEGER_COMMAND_SET_NOID_GET_ID( @@ -1778,13 +1788,6 @@ class CmdProxy { "[0, 1]\n\t[Eiger] Enable or disable show overflow flag in " "32 bit mode. Default is disabled."); - INTEGER_COMMAND_VEC_ID( - flippeddatax, getBottom, setBottom, StringTo, - "[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 " - "is top. Used to let Gui (via zmq from receiver) know to flip the " - "bottom image over the x axis. Files are not written without the flip " - "however."); - INTEGER_COMMAND_VEC_ID( readnlines, getPartialReadout, setPartialReadout, StringTo, "[1 - 256]\n\t[Eiger] Number of rows to readout per half module " diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 427950689..536d8305f 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -279,6 +279,14 @@ void Detector::setGapPixelsinCallback(bool enable) { pimpl->setGapPixelsinCallback(enable); } +Result Detector::getFlippedDataAcrossXAxis(Positions pos) const { + return pimpl->Parallel(&Module::getFlippedDataAcrossXAxis, pos); +} + +void Detector::setFlippedDataAcrossXAxis(bool value, Positions pos) { + pimpl->Parallel(&Module::setFlippedDataAcrossXAxis, pos, value); +} + Result Detector::isVirtualDetectorServer(Positions pos) const { return pimpl->Parallel(&Module::isVirtualDetectorServer, pos); } @@ -1304,14 +1312,6 @@ void Detector::setOverFlowMode(bool value, Positions pos) { pimpl->Parallel(&Module::setOverFlowMode, pos, value); } -Result Detector::getBottom(Positions pos) const { - return pimpl->Parallel(&Module::getFlippedDataX, pos); -} - -void Detector::setBottom(bool value, Positions pos) { - pimpl->Parallel(&Module::setFlippedDataX, pos, value); -} - Result Detector::getRateCorrection(Positions pos) const { return pimpl->Parallel(&Module::getRateCorrection, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index cac7590ea..71ba8e277 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -458,6 +458,22 @@ int Module::setTrimEn(const std::vector &energies) { return shm()->trimEnergies.size(); } +bool Module::getFlippedDataAcrossXAxis() const { + if (shm()->myDetectorType == EIGER) { + return sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, GET_FLAG); + } + return sendToDetector(F_GET_FLIPPED_DATA_X); +} + +void Module::setFlippedDataAcrossXAxis(bool value) { + if (shm()->myDetectorType == EIGER) { + sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, + static_cast(value)); + } else { + sendToDetector(F_SET_FLIPPED_DATA_X, static_cast(value), nullptr); + } +} + bool Module::isVirtualDetectorServer() const { return sendToDetector(F_IS_VIRTUAL); } @@ -1398,14 +1414,6 @@ void Module::setOverFlowMode(const bool enable) { sendToDetector(F_SET_OVERFLOW_MODE, static_cast(enable), nullptr); } -bool Module::getFlippedDataX() const { - return sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, GET_FLAG); -} - -void Module::setFlippedDataX(bool value) { - sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, static_cast(value)); -} - int64_t Module::getRateCorrection() const { return sendToDetector(F_GET_RATE_CORRECT); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 6855d91b5..3f3252e75 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -114,6 +114,8 @@ class Module : public virtual slsDetectorDefs { void setAllTrimbits(int val); std::vector getTrimEn() const; int setTrimEn(const std::vector &energies = {}); + bool getFlippedDataAcrossXAxis() const; + void setFlippedDataAcrossXAxis(bool value); bool isVirtualDetectorServer() const; /************************************************** @@ -323,8 +325,6 @@ class Module : public virtual slsDetectorDefs { void setSubDeadTime(int64_t value); bool getOverFlowMode() const; void setOverFlowMode(const bool enable); - bool getFlippedDataX() const; - void setFlippedDataX(bool value); int64_t getRateCorrection() const; void setDefaultRateCorrection(); void setRateCorrection(int64_t t = 0); diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index d47c0a75b..0e5ff1e38 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -340,27 +340,6 @@ TEST_CASE("overflow", "[.cmd]") { } } -TEST_CASE("flippeddatax", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - auto previous = det.getBottom(); - std::ostringstream oss1, oss2, oss3; - proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "flippeddatax 1\n"); - proxy.Call("flippeddatax", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "flippeddatax 1\n"); - proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3); - REQUIRE(oss3.str() == "flippeddatax 0\n"); - for (int i = 0; i != det.size(); ++i) { - det.setBottom(previous[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET)); - } -} - TEST_CASE("ratecorr", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 77b70a795..0de2c4449 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -510,6 +510,34 @@ TEST_CASE("gappixels", "[.cmd]") { } } +TEST_CASE("flippeddatax", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { + auto previous = det.getFlippedDataAcrossXAxis(); + auto previous_numudp = det.getNumberofUDPInterfaces(); + if (det_type == defs::JUNGFRAU) { + det.setNumberofUDPInterfaces(2); + } + std::ostringstream oss1, oss2, oss3; + proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "flippeddatax 1\n"); + proxy.Call("flippeddatax", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "flippeddatax 1\n"); + proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "flippeddatax 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setFlippedDataAcrossXAxis(previous[i], {i}); + if (det_type == defs::JUNGFRAU) { + det.setNumberofUDPInterfaces(previous_numudp[i], {i}); + } + } + } else { + REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET)); + } +} + /* acquisition parameters */ // acquire: not testing diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 952843f21..5ab13be4b 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -237,6 +237,8 @@ enum detFuncs { F_SET_GAIN_MODE, F_GET_COMP_DISABLE_TIME, F_SET_COMP_DISABLE_TIME, + F_GET_FLIPPED_DATA_X, + F_SET_FLIPPED_DATA_X, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -580,6 +582,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_GAIN_MODE: return "F_SET_GAIN_MODE"; case F_GET_COMP_DISABLE_TIME: return "F_GET_COMP_DISABLE_TIME"; case F_SET_COMP_DISABLE_TIME: return "F_SET_COMP_DISABLE_TIME"; + case F_GET_FLIPPED_DATA_X: return "F_GET_FLIPPED_DATA_X"; + case F_SET_FLIPPED_DATA_X: return "F_SET_FLIPPED_DATA_X"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; From 619f3b71c1df2ae523d3b15c2f7ce640399b62f9 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 14:44:25 +0200 Subject: [PATCH 2/4] flippeddataoverxaxis changed to flipRows --- RELEASE.txt | 2 +- python/src/detector.cpp | 8 ++-- .../slsDetectorFunctionList.c | 10 ++--- .../include/slsDetectorFunctionList.h | 4 +- .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 30 +++++++------- slsDetectorSoftware/include/sls/Detector.h | 12 +++--- slsDetectorSoftware/src/CmdProxy.h | 17 ++++---- slsDetectorSoftware/src/Detector.cpp | 8 ++-- slsDetectorSoftware/src/DetectorImpl.cpp | 9 ++--- slsDetectorSoftware/src/Module.cpp | 13 +++--- slsDetectorSoftware/src/Module.h | 4 +- slsDetectorSoftware/tests/test-CmdProxy.cpp | 20 +++++----- slsReceiverSoftware/src/ClientInterface.cpp | 33 ++++++++++----- slsReceiverSoftware/src/ClientInterface.h | 3 +- slsReceiverSoftware/src/DataStreamer.cpp | 8 ++-- slsReceiverSoftware/src/DataStreamer.h | 14 +++---- slsReceiverSoftware/src/Implementation.cpp | 40 ++++++++++--------- slsReceiverSoftware/src/Implementation.h | 6 +-- slsSupportLib/include/sls/ZmqSocket.h | 4 +- .../include/sls/sls_detector_funcs.h | 14 ++++--- slsSupportLib/src/ZmqSocket.cpp | 6 +-- 22 files changed, 143 insertions(+), 126 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index 8bc41c6fe..cd798a21d 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -63,7 +63,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases. getAutoCompDisable->getAutoComparatorDisable -setBottom->setFlippedDataAcrossXAxis +setBottom->setFlipRows 3. Firmware Requirements ======================== diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 93cc262af..7a5807a1d 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -848,13 +848,13 @@ void init_det(py::module &m) { (void (Detector::*)(bool, sls::Positions)) & Detector::setOverFlowMode, py::arg(), py::arg() = Positions{}) - .def("getFlippedDataAcrossXAxis", + .def("getFlipRows", (Result(Detector::*)(sls::Positions) const) & - Detector::getFlippedDataAcrossXAxis, + Detector::getFlipRows, py::arg() = Positions{}) - .def("setFlippedDataAcrossXAxis", + .def("setFlipRows", (void (Detector::*)(bool, sls::Positions)) & - Detector::setFlippedDataAcrossXAxis, + Detector::setFlipRows, py::arg(), py::arg() = Positions{}) .def("getRateCorrection", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 609e3694c..a48ffabd0 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -474,7 +474,7 @@ void setupDetector() { // temp threshold and reset event setThresholdTemperature(DEFAULT_TMP_THRSHLD); setTemperatureEvent(0); - setFlippedDataAcrossXAxis(0); + setFlipRows(0); } int resetToDefaultDacs(int hardReset) { @@ -2003,19 +2003,19 @@ void alignDeserializer() { bus_r(ADC_DSRLZR_3_REG) & (~(ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK))); } -int getFlippedDataAcrossXAxis() { +int getFlipRows() { return ((bus_r(CONFIG_REG) & CONFIG_BOTTOM_INVERT_STREAM_MSK) >> CONFIG_BOTTOM_INVERT_STREAM_OFST); } -void setFlippedDataAcrossXAxis(int arg) { +void setFlipRows(int arg) { if (arg >= 0) { if (arg == 0) { - LOG(logINFO, ("Switching off bottom flipping\n")); + LOG(logINFO, ("Switching off bottom row flipping\n")); bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_BOTTOM_INVERT_STREAM_MSK); } else { - LOG(logINFO, ("Switching on bottom flipping\n")); + LOG(logINFO, ("Switching on bottom row flipping\n")); bus_w(CONFIG_REG, bus_r(CONFIG_REG) | CONFIG_BOTTOM_INVERT_STREAM_MSK); } diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 0e1d60ad7..77dc873f7 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -460,8 +460,8 @@ int setThresholdTemperature(int val); int setTemperatureControl(int val); int setTemperatureEvent(int val); void alignDeserializer(); -int getFlippedDataAcrossXAxis(); -void setFlippedDataAcrossXAxis(int arg); +int getFlipRows(); +void setFlipRows(int arg); // eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter #elif EIGERD diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index e5550db60..52b924528 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -261,5 +261,5 @@ int get_gain_mode(int); int set_gain_mode(int); int get_comp_disable_time(int); int set_comp_disable_time(int); -int get_flipped_data_x(int); -int set_flipped_data_x(int); \ No newline at end of file +int get_flip_rows(int); +int set_flip_rows(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index d0d3e3fa6..6a83ebc55 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -386,8 +386,8 @@ void function_table() { flist[F_SET_GAIN_MODE] = &set_gain_mode; flist[F_GET_COMP_DISABLE_TIME] = &get_comp_disable_time; flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time; - flist[F_GET_FLIPPED_DATA_X] = &get_flipped_data_x; - flist[F_SET_FLIPPED_DATA_X] = &set_flipped_data_x; + flist[F_GET_FLIP_ROWS] = &get_flip_rows; + flist[F_SET_FLIP_ROWS] = &set_flip_rows; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8679,31 +8679,31 @@ int set_comp_disable_time(int file_des) { return Server_SendResult(file_des, INT64, NULL, 0); } -int get_flipped_data_x(int file_des) { +int get_flip_rows(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int retval = -1; - LOG(logDEBUG1, ("Getting flipped data x\n")); + LOG(logDEBUG1, ("Getting flip rows\n")); #ifndef JUNGFRAUD functionNotImplemented(); #else // get only - retval = getFlippedDataAcrossXAxis(); - LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval)); + retval = getFlipRows(); + LOG(logDEBUG1, ("flip rows retval: %u\n", retval)); #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } -int set_flipped_data_x(int file_des) { +int set_flip_rows(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int arg = -1; if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - LOG(logINFO, ("Setting flipped data x: %u\n", (int)arg)); + LOG(logINFO, ("Setting flip rows: %u\n", (int)arg)); #ifndef JUNGFRAUD functionNotImplemented(); @@ -8714,26 +8714,26 @@ int set_flipped_data_x(int file_des) { if (arg != 0 && arg != 1) { ret = FAIL; sprintf(mess, - "Could not set flipped data x. Invalid argument %d.\n", + "Could not set flip rows. Invalid argument %d.\n", arg); LOG(logERROR, (mess)); } // only for HW 2.0 (version = 3) else if (isHardwareVersion2()) { ret = FAIL; - strcpy(mess, "Could not set flipped data x. Only available for " + strcpy(mess, "Could not set flip rows. Only available for " "Hardware Board version 2.0.\n"); LOG(logERROR, (mess)); } else if (getNumberofUDPInterfaces() == 1) { ret = FAIL; - strcpy(mess, "Could not set flipped data x. Number of udp " + strcpy(mess, "Could not set flip rows. Number of udp " "interfaces is still 1.\n"); LOG(logERROR, (mess)); } else { - setFlippedDataAcrossXAxis(arg); - int retval = getFlippedDataAcrossXAxis(); - LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval)); - validate(&ret, mess, arg, retval, "set flipped data x", DEC); + setFlipRows(arg); + int retval = getFlipRows(); + LOG(logDEBUG1, ("flip rows retval: %u\n", retval)); + validate(&ret, mess, arg, retval, "set flip rows", DEC); } } #endif diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index a2b0074ac..e3511a622 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -173,13 +173,15 @@ class Detector { void setGapPixelsinCallback(const bool enable); /** [Eiger][Jungfrau] */ - Result getFlippedDataAcrossXAxis(Positions pos = {}) const; + Result getFlipRows(Positions pos = {}) const; - /** [Eiger] flips across x Axis paramater sent to slsreceiver to send to gui - * (via zmq) to flip bottom [Jungfrau] flips data across x Axis in the - * detector itself. slsReceiver and slsDetectorGui does not handle. + /** [Eiger] flips rows paramater sent to slsreceiver to stream as json + * parameter to flip rows in gui \n[Jungfrau] flips rows in the detector + * itself. For bottom module and number of interfaces must be set to 2. + * slsReceiver and slsDetectorGui does not handle.slsReceiver and + * slsDetectorGui does not handle */ - void setFlippedDataAcrossXAxis(bool value, Positions pos = {}); + void setFlipRows(bool value, Positions pos = {}); Result isVirtualDetectorServer(Positions pos = {}) const; ///@{ diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index bed86280f..30b466e25 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -584,6 +584,7 @@ class CmdProxy { {"detsizechan", "detsize"}, {"trimdir", "settingspath"}, {"settingsdir", "settingspath"}, + {"flippeddatax", "fliprows"}, /* acquisition parameters */ {"cycles", "triggers"}, @@ -769,7 +770,7 @@ class CmdProxy { {"trimval", &CmdProxy::trimval}, {"trimen", &CmdProxy::TrimEnergies}, {"gappixels", &CmdProxy::GapPixels}, - {"flippeddatax", &CmdProxy::flippeddatax}, + {"fliprows", &CmdProxy::fliprows}, /* acquisition parameters */ {"acquire", &CmdProxy::Acquire}, @@ -1234,14 +1235,12 @@ class CmdProxy { "value. Returns -1 if all trimbits are different values."); INTEGER_COMMAND_VEC_ID( - flippeddatax, getFlippedDataAcrossXAxis, setFlippedDataAcrossXAxis, - StringTo, - "[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 " - "is top. Used to let Gui (via zmq from receiver) know to flip the " - "bottom image over the x axis. Files are not written without the flip " - "however.\n\t[Jungfrau] If enabled, the bottom is flipped across the x " - "axis from the detector. The slsReceiver nor the Gui handles this " - "parameter."); + fliprows, getFlipRows, setFlipRows, StringTo, + "[0, 1]\n\t[Eiger] flips rows paramater sent to slsreceiver " + "to stream as json parameter to flip rows in gui \n\t[Jungfrau] flips " + "rows in the detector itself. For bottom module and number of " + "interfaces must be set to 2. slsReceiver and slsDetectorGui " + "does not handle."); /* acquisition parameters */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 536d8305f..4929a3ead 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -279,12 +279,12 @@ void Detector::setGapPixelsinCallback(bool enable) { pimpl->setGapPixelsinCallback(enable); } -Result Detector::getFlippedDataAcrossXAxis(Positions pos) const { - return pimpl->Parallel(&Module::getFlippedDataAcrossXAxis, pos); +Result Detector::getFlipRows(Positions pos) const { + return pimpl->Parallel(&Module::getFlipRows, pos); } -void Detector::setFlippedDataAcrossXAxis(bool value, Positions pos) { - pimpl->Parallel(&Module::setFlippedDataAcrossXAxis, pos, value); +void Detector::setFlipRows(bool value, Positions pos) { + pimpl->Parallel(&Module::setFlipRows, pos, value); } Result Detector::isVirtualDetectorServer(Positions pos) const { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index e6af420f1..20b159875 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -490,8 +490,7 @@ void DetectorImpl::readFrameFromReceiver() { uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, currentFileIndex = -1; double currentProgress = 0.00; - uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, - flippedDataX = -1; + uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, flipRows = -1; while (numZmqRunning != 0) { // reset data @@ -571,7 +570,7 @@ void DetectorImpl::readFrameFromReceiver() { if (eiger) { coordY = (nY - 1) - coordY; } - flippedDataX = zHeader.flippedDataX; + flipRows = zHeader.flipRows; if (zHeader.completeImage == 0) { completeImage = false; } @@ -585,7 +584,7 @@ void DetectorImpl::readFrameFromReceiver() { << "\n\tcurrentSubFrameIndex: " << currentSubFrameIndex << "\n\tcurrentProgress: " << currentProgress << "\n\tcoordX: " << coordX << "\n\tcoordY: " << coordY - << "\n\tflippedDataX: " << flippedDataX + << "\n\tflipRows: " << flipRows << "\n\tcompleteImage: " << completeImage; } @@ -609,7 +608,7 @@ void DetectorImpl::readFrameFromReceiver() { << "\n\tsingledetrowoffset: " << singledetrowoffset << "\n\trowoffset: " << rowoffset; - if (eiger && (flippedDataX != 0U)) { + if (eiger && (flipRows != 0U)) { for (uint32_t i = 0; i < nPixelsY; ++i) { memcpy((multiframe.get()) + ((yoffset + (nPixelsY - 1 - i)) * diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 71ba8e277..70bb408fb 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -458,19 +458,18 @@ int Module::setTrimEn(const std::vector &energies) { return shm()->trimEnergies.size(); } -bool Module::getFlippedDataAcrossXAxis() const { +bool Module::getFlipRows() const { if (shm()->myDetectorType == EIGER) { - return sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, GET_FLAG); + return sendToReceiver(F_GET_FLIP_ROWS_RECEIVER); } - return sendToDetector(F_GET_FLIPPED_DATA_X); + return sendToDetector(F_GET_FLIP_ROWS); } -void Module::setFlippedDataAcrossXAxis(bool value) { +void Module::setFlipRows(bool value) { if (shm()->myDetectorType == EIGER) { - sendToReceiver(F_SET_FLIPPED_DATA_RECEIVER, - static_cast(value)); + sendToReceiver(F_SET_FLIP_ROWS_RECEIVER, static_cast(value)); } else { - sendToDetector(F_SET_FLIPPED_DATA_X, static_cast(value), nullptr); + sendToDetector(F_SET_FLIP_ROWS, static_cast(value), nullptr); } } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 3f3252e75..3a9250d36 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -114,8 +114,8 @@ class Module : public virtual slsDetectorDefs { void setAllTrimbits(int val); std::vector getTrimEn() const; int setTrimEn(const std::vector &energies = {}); - bool getFlippedDataAcrossXAxis() const; - void setFlippedDataAcrossXAxis(bool value); + bool getFlipRows() const; + void setFlipRows(bool value); bool isVirtualDetectorServer() const; /************************************************** diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 0de2c4449..1da4eedff 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -510,31 +510,31 @@ TEST_CASE("gappixels", "[.cmd]") { } } -TEST_CASE("flippeddatax", "[.cmd]") { +TEST_CASE("fliprows", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { - auto previous = det.getFlippedDataAcrossXAxis(); + auto previous = det.getFlipRows(); auto previous_numudp = det.getNumberofUDPInterfaces(); if (det_type == defs::JUNGFRAU) { det.setNumberofUDPInterfaces(2); } std::ostringstream oss1, oss2, oss3; - proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "flippeddatax 1\n"); - proxy.Call("flippeddatax", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "flippeddatax 1\n"); - proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3); - REQUIRE(oss3.str() == "flippeddatax 0\n"); + proxy.Call("fliprows", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "fliprows 1\n"); + proxy.Call("fliprows", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "fliprows 1\n"); + proxy.Call("fliprows", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "fliprows 0\n"); for (int i = 0; i != det.size(); ++i) { - det.setFlippedDataAcrossXAxis(previous[i], {i}); + det.setFlipRows(previous[i], {i}); if (det_type == defs::JUNGFRAU) { det.setNumberofUDPInterfaces(previous_numudp[i], {i}); } } } else { - REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("fliprows", {}, -1, GET)); } } diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index d882ba1d8..4dc63e33f 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -156,7 +156,8 @@ int ClientInterface::functionTable(){ flist[F_SET_RECEIVER_STREAMING] = &ClientInterface::set_streaming; flist[F_GET_RECEIVER_STREAMING] = &ClientInterface::get_streaming; flist[F_RECEIVER_STREAMING_TIMER] = &ClientInterface::set_streaming_timer; - flist[F_SET_FLIPPED_DATA_RECEIVER] = &ClientInterface::set_flipped_data; + flist[F_GET_FLIP_ROWS_RECEIVER] = &ClientInterface::get_flip_rows; + flist[F_SET_FLIP_ROWS_RECEIVER] = &ClientInterface::set_flip_rows; flist[F_SET_RECEIVER_FILE_FORMAT] = &ClientInterface::set_file_format; flist[F_GET_RECEIVER_FILE_FORMAT] = &ClientInterface::get_file_format; flist[F_SET_RECEIVER_STREAMING_PORT] = &ClientInterface::set_streaming_port; @@ -1020,21 +1021,33 @@ int ClientInterface::set_streaming_timer(Interface &socket) { return socket.sendResult(retval); } -int ClientInterface::set_flipped_data(Interface &socket) { +int ClientInterface::get_flip_rows(Interface &socket) { + if (myDetectorType != EIGER) + functionNotImplemented(); + + int retval = impl()->getFlipRows(); + LOG(logDEBUG1) << "Flip rows:" << retval; + return socket.sendResult(retval); +} + +int ClientInterface::set_flip_rows(Interface &socket) { auto arg = socket.Receive(); if (myDetectorType != EIGER) functionNotImplemented(); - if (arg >= 0) { - verifyIdle(socket); - LOG(logDEBUG1) << "Setting flipped data:" << arg; - impl()->setFlippedDataX(arg); + if (arg != 0 && arg != 1) { + throw RuntimeError("Could not set flip rows. Invalid argument: " + + std::to_string(arg)); } - int retval = impl()->getFlippedDataX(); - validate(arg, retval, std::string("set flipped data"), DEC); - LOG(logDEBUG1) << "Flipped Data:" << retval; - return socket.sendResult(retval); + verifyIdle(socket); + LOG(logDEBUG1) << "Setting flip rows:" << arg; + impl()->setFlipRows(static_cast(arg)); + + int retval = impl()->getFlipRows(); + validate(arg, retval, std::string("set flip rows"), DEC); + LOG(logDEBUG1) << "Flip rows:" << retval; + return socket.sendResult(retval); } int ClientInterface::set_file_format(Interface &socket) { diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 64ed796c0..113bc77a8 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -107,7 +107,8 @@ class ClientInterface : private virtual slsDetectorDefs { int set_streaming(sls::ServerInterface &socket); int get_streaming(sls::ServerInterface &socket); int set_streaming_timer(sls::ServerInterface &socket); - int set_flipped_data(sls::ServerInterface &socket); + int get_flip_rows(sls::ServerInterface &socket); + int set_flip_rows(sls::ServerInterface &socket); int set_file_format(sls::ServerInterface &socket); int get_file_format(sls::ServerInterface &socket); int set_streaming_port(sls::ServerInterface &socket); diff --git a/slsReceiverSoftware/src/DataStreamer.cpp b/slsReceiverSoftware/src/DataStreamer.cpp index 86b41112f..d5ad9763e 100644 --- a/slsReceiverSoftware/src/DataStreamer.cpp +++ b/slsReceiverSoftware/src/DataStreamer.cpp @@ -15,9 +15,9 @@ const std::string DataStreamer::TypeName = "DataStreamer"; DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, - int fd, int *nm, bool *qe, uint64_t *tot) + bool fr, int *nm, bool *qe, uint64_t *tot) : ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r), - fileIndex(fi), flippedDataX(fd), quadEnable(qe), totalNumFrames(tot) { + fileIndex(fi), flipRows(fr), quadEnable(qe), totalNumFrames(tot) { numMods[0] = nm[0]; numMods[1] = nm[1]; @@ -65,7 +65,7 @@ void DataStreamer::SetNumberofModules(int *nm) { numMods[1] = nm[1]; } -void DataStreamer::SetFlippedDataX(int fd) { flippedDataX = fd; } +void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; } void DataStreamer::SetAdditionalJsonHeader( const std::map &json) { @@ -240,7 +240,7 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size, zHeader.roundRNumber = header.roundRNumber; zHeader.detType = header.detType; zHeader.version = header.version; - zHeader.flippedDataX = flippedDataX; + zHeader.flipRows = static_cast(flipRows); zHeader.quad = *quadEnable; zHeader.completeImage = (header.packetNumber < generalData->packetsPerFrame ? false : true); diff --git a/slsReceiverSoftware/src/DataStreamer.h b/slsReceiverSoftware/src/DataStreamer.h index 45d4c0839..da598ebd3 100644 --- a/slsReceiverSoftware/src/DataStreamer.h +++ b/slsReceiverSoftware/src/DataStreamer.h @@ -30,12 +30,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { * @param dr pointer to dynamic range * @param r roi * @param fi pointer to file index - * @param fd flipped data enable for x dimension + * @param fr flip rows * @param nm pointer to number of modules in each dimension * @param qe pointer to quad Enable * @param tot pointer to total number of frames */ - DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, int fd, + DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr, int *nm, bool *qe, uint64_t *tot); /** @@ -68,10 +68,10 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { void SetNumberofModules(int *nm); /** - * Set Flipped data enable across x dimension - * @param fd data enable in x dimension + * Set Flipped rows + * @param fd flip rows enable */ - void SetFlippedDataX(int fd); + void SetFlipRows(bool fd); /** * Set additional json header @@ -165,8 +165,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject { /** Pointer to file index */ uint64_t *fileIndex; - /** flipped data across x axis */ - int flippedDataX; + /** flip rows */ + bool flipRows; /** additional json header */ std::map additionalJsonHeader; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 1a8bdbefc..719ca8eb7 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -893,15 +893,15 @@ void Implementation::setNumberofUDPInterfaces(const int n) { // streamer threads if (dataStreamEnable) { try { - int fd = flippedDataX; + bool flip = flipRows; int nm[2] = {numMods[0], numMods[1]}; if (quadEnable) { - fd = i; + flip = (i == 1 ? true : false); nm[0] = 1; nm[1] = 2; } dataStreamer.push_back(sls::make_unique( - i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, fd, + i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip, (int *)nm, &quadEnable, &numberOfTotalFrames)); dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->CreateZmqSockets( @@ -1022,15 +1022,15 @@ void Implementation::setDataStreamEnable(const bool enable) { if (enable) { for (int i = 0; i < numThreads; ++i) { try { - int fd = flippedDataX; + bool flip = flipRows; int nm[2] = {numMods[0], numMods[1]}; if (quadEnable) { - fd = i; + flip = (i == 1 ? true : false); nm[0] = 1; nm[1] = 2; } dataStreamer.push_back(sls::make_unique( - i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, fd, + i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip, (int *)nm, &quadEnable, &numberOfTotalFrames)); dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->CreateZmqSockets( @@ -1458,22 +1458,24 @@ void Implementation::setTenGigaEnable(const bool b) { LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); } -int Implementation::getFlippedDataX() const { return flippedDataX; } +bool Implementation::getFlipRows() const { return flipRows; } -void Implementation::setFlippedDataX(int enable) { - flippedDataX = (enable == 0) ? 0 : 1; +void Implementation::setFlipRows(bool enable) { + flipRows = enable; if (!quadEnable) { for (const auto &it : dataStreamer) { - it->SetFlippedDataX(flippedDataX); - } - } else { - if (dataStreamer.size() == 2) { - dataStreamer[0]->SetFlippedDataX(0); - dataStreamer[1]->SetFlippedDataX(1); + it->SetFlipRows(flipRows); } } - LOG(logINFO) << "Flipped Data X: " << flippedDataX; + // quad + else { + if (dataStreamer.size() == 2) { + dataStreamer[0]->SetFlipRows(false); + dataStreamer[1]->SetFlipRows(true); + } + } + LOG(logINFO) << "Flip Rows: " << flipRows; } bool Implementation::getQuad() const { return quadEnable; } @@ -1485,7 +1487,7 @@ void Implementation::setQuad(const bool b) { if (!quadEnable) { for (const auto &it : dataStreamer) { it->SetNumberofModules(numMods); - it->SetFlippedDataX(flippedDataX); + it->SetFlipRows(flipRows); } } else { int size[2] = {1, 2}; @@ -1493,8 +1495,8 @@ void Implementation::setQuad(const bool b) { it->SetNumberofModules(size); } if (dataStreamer.size() == 2) { - dataStreamer[0]->SetFlippedDataX(0); - dataStreamer[1]->SetFlippedDataX(1); + dataStreamer[0]->SetFlipRows(false); + dataStreamer[1]->SetFlipRows(true); } } } diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 5a1650705..b711c68d2 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -202,8 +202,8 @@ class Implementation : private virtual slsDetectorDefs { bool getTenGigaEnable() const; /* [Eiger][Ctb] */ void setTenGigaEnable(const bool b); - int getFlippedDataX() const; - void setFlippedDataX(int enable = -1); + bool getFlipRows() const; + void setFlipRows(bool enable); bool getQuad() const; /* [Eiger] */ void setQuad(const bool b); @@ -347,7 +347,7 @@ class Implementation : private virtual slsDetectorDefs { uint32_t dynamicRange{16}; ROI roi{}; bool tengigaEnable{false}; - int flippedDataX{0}; + bool flipRows{false}; bool quadEnable{false}; bool activated{true}; std::array detectorDataStream = {{true, true}}; diff --git a/slsSupportLib/include/sls/ZmqSocket.h b/slsSupportLib/include/sls/ZmqSocket.h index 713f59a73..e6914f5b5 100644 --- a/slsSupportLib/include/sls/ZmqSocket.h +++ b/slsSupportLib/include/sls/ZmqSocket.h @@ -58,8 +58,8 @@ struct zmqHeader { uint16_t roundRNumber{0}; uint8_t detType{0}; uint8_t version{0}; - /** if image should be flipped across x axis */ - int flippedDataX{0}; + /** if rows of image should be flipped */ + int flipRows{0}; /** quad type (eiger hardware specific) */ uint32_t quad{0}; /** true if complete image, else missing packets */ diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 5ab13be4b..08927974e 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -237,8 +237,8 @@ enum detFuncs { F_SET_GAIN_MODE, F_GET_COMP_DISABLE_TIME, F_SET_COMP_DISABLE_TIME, - F_GET_FLIPPED_DATA_X, - F_SET_FLIPPED_DATA_X, + F_GET_FLIP_ROWS, + F_SET_FLIP_ROWS, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -289,7 +289,8 @@ enum detFuncs { F_SET_RECEIVER_STREAMING, F_GET_RECEIVER_STREAMING, F_RECEIVER_STREAMING_TIMER, - F_SET_FLIPPED_DATA_RECEIVER, + F_GET_FLIP_ROWS_RECEIVER, + F_SET_FLIP_ROWS_RECEIVER, F_SET_RECEIVER_FILE_FORMAT, F_GET_RECEIVER_FILE_FORMAT, F_SET_RECEIVER_STREAMING_PORT, @@ -582,8 +583,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_GAIN_MODE: return "F_SET_GAIN_MODE"; case F_GET_COMP_DISABLE_TIME: return "F_GET_COMP_DISABLE_TIME"; case F_SET_COMP_DISABLE_TIME: return "F_SET_COMP_DISABLE_TIME"; - case F_GET_FLIPPED_DATA_X: return "F_GET_FLIPPED_DATA_X"; - case F_SET_FLIPPED_DATA_X: return "F_SET_FLIPPED_DATA_X"; + case F_GET_FLIP_ROWS: return "F_GET_FLIP_ROWS"; + case F_SET_FLIP_ROWS: return "F_SET_FLIP_ROWS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; @@ -633,7 +634,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_RECEIVER_STREAMING: return "F_SET_RECEIVER_STREAMING"; case F_GET_RECEIVER_STREAMING: return "F_GET_RECEIVER_STREAMING"; case F_RECEIVER_STREAMING_TIMER: return "F_RECEIVER_STREAMING_TIMER"; - case F_SET_FLIPPED_DATA_RECEIVER: return "F_SET_FLIPPED_DATA_RECEIVER"; + case F_GET_FLIP_ROWS_RECEIVER: return "F_GET_FLIP_ROWS_RECEIVER"; + case F_SET_FLIP_ROWS_RECEIVER: return "F_SET_FLIP_ROWS_RECEIVER"; case F_SET_RECEIVER_FILE_FORMAT: return "F_SET_RECEIVER_FILE_FORMAT"; case F_GET_RECEIVER_FILE_FORMAT: return "F_GET_RECEIVER_FILE_FORMAT"; case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT"; diff --git a/slsSupportLib/src/ZmqSocket.cpp b/slsSupportLib/src/ZmqSocket.cpp index f044eb48a..58b9de525 100644 --- a/slsSupportLib/src/ZmqSocket.cpp +++ b/slsSupportLib/src/ZmqSocket.cpp @@ -160,7 +160,7 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) { "\"version\":%u, " // additional stuff - "\"flippedDataX\":%u, " + "\"flipRows\":%u, " "\"quad\":%u" ; //"}\n"; @@ -177,7 +177,7 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) { header.detType, header.version, // additional stuff - header.flippedDataX, header.quad); + header.flipRows, header.quad); if (!header.addJsonHeader.empty()) { strcat(header_buffer.get(), ", "); @@ -303,7 +303,7 @@ int ZmqSocket::ParseHeader(const int index, int length, char *buff, zHeader.detType = document["detType"].GetUint(); zHeader.version = document["version"].GetUint(); - zHeader.flippedDataX = document["flippedDataX"].GetUint(); + zHeader.flipRows = document["flipRows"].GetUint(); zHeader.quad = document["quad"].GetUint(); zHeader.completeImage = document["completeImage"].GetUint(); From 7bf6cc3995fbfec80ef402fbc72d807c4370f6b3 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 6 Aug 2021 13:25:55 +0200 Subject: [PATCH 3/4] wip --- python/slsdet/detector.py | 19 ++++++++++++++++++- python/src/detector.cpp | 7 +++++++ slsDetectorSoftware/src/Detector.cpp | 8 ++++++++ slsDetectorSoftware/src/Module.h | 4 +++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 383c2265c..4e4471316 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2242,7 +2242,9 @@ class Detector(CppDetectorApi): """[Gotthard2] Set filter resistor. Note ---- - Default is 0. Options: 0-3. + Advanced user command. + [Gotthard2] Default is 0. Options: 0-3. + [Jungfrau] Default is 1. Options: 0-1. """ return self.getFilter() @@ -2250,6 +2252,21 @@ class Detector(CppDetectorApi): def filter(self, value): ut.set_using_dict(self.setFilter, value) + @property + @element + def filtercell(self): + """ + [Jungfrau] Set filter capacitor. + Note + ---- + [Jungfrau] Options: 0-12. Default: 0. Advanced user command. + """ + return self.getFilterCell() + + @filtercell.setter + def filtercell(self, value): + ut.set_using_dict(self.setFilterCell, value) + @property def maxclkphaseshift(self): """ diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 7a5807a1d..7f0f71ea3 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1104,6 +1104,13 @@ void init_det(py::module &m) { .def("setFilter", (void (Detector::*)(int, sls::Positions)) & Detector::setFilter, py::arg(), py::arg() = Positions{}) + .def("getFilterCell", + (Result(Detector::*)(sls::Positions) const) & + Detector::getFilterCell, + py::arg() = Positions{}) + .def("setFilterCell", + (void (Detector::*)(int, sls::Positions)) & Detector::setFilterCell, + py::arg(), py::arg() = Positions{}) .def("getCurrentSource", (Result(Detector::*)(sls::Positions) const) & Detector::getCurrentSource, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 4929a3ead..b8f77c0eb 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1513,6 +1513,14 @@ void Detector::setGainMode(const defs::gainMode mode, Positions pos) { pimpl->Parallel(&Module::setGainMode, pos, mode); } +Result Detector::getFilterCell(Positions pos) const { + return pimpl->Parallel(&Module::getFilterCell, pos); +} + +void Detector::setFilterCell(int cell, Positions pos) { + pimpl->Parallel(&Module::setFilterCell, pos, cell); +} + // Gotthard Specific Result Detector::getROI(Positions pos) const { diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 3a9250d36..73fdb215a 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -373,7 +373,9 @@ class Module : public virtual slsDetectorDefs { void setStorageCellDelay(int64_t value); gainMode getGainMode() const; void setGainMode(const gainMode mode); - + int getStorageCellStart() const; + void setStorageCellStart(int pos); + /************************************************** * * * Gotthard Specific * From bd7af286019e94d0c545c73edf7d042e4b396f0f Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 6 Aug 2021 15:13:10 +0200 Subject: [PATCH 4/4] minor --- slsDetectorSoftware/src/Module.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 73fdb215a..e44a97d28 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -373,8 +373,6 @@ class Module : public virtual slsDetectorDefs { void setStorageCellDelay(int64_t value); gainMode getGainMode() const; void setGainMode(const gainMode mode); - int getStorageCellStart() const; - void setStorageCellStart(int pos); /************************************************** * *