diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index f126d8024..184485b8e 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -112,7 +112,7 @@ #define CONFIG_DYNAMIC_RANGE_OFST (4) #define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST) #define CONFIG_DYNAMIC_RANGE_1_VAL ((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) -#define CONFIG_DYNAMIC_RANGE_4_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) +#define CONFIG_DYNAMIC_RANGE_8_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) #define CONFIG_DYNAMIC_RANGE_16_VAL ((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) #define CONFIG_DYNAMIC_RANGE_24_VAL ((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK) @@ -149,6 +149,8 @@ #define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST) #define PKT_CONFIG_RXR_START_ID_OFST (8) #define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST) +#define PKT_CONFIG_1G_INTERFACE_OFST (16) +#define PKT_CONFIG_1G_INTERFACE_MSK (0x00000001 << PKT_CONFIG_1G_INTERFACE_OFST) /* Module Coordinates Register */ #define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT) diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 2b9cd2f04..da0b7305b 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -531,16 +531,15 @@ int setDynamicRange(int dr) { if (dr > 0) { uint32_t regval = 0; switch (dr) { - case 1: + /*case 1: TODO:Not implemented in firmware yet regval = CONFIG_DYNAMIC_RANGE_1_VAL; - break; - case 4: - regval = CONFIG_DYNAMIC_RANGE_4_VAL; + break;*/ + case 8: + regval = CONFIG_DYNAMIC_RANGE_8_VAL; break; case 16: regval = CONFIG_DYNAMIC_RANGE_16_VAL; break; - case 24: case 32: regval = CONFIG_DYNAMIC_RANGE_24_VAL; break; @@ -555,10 +554,10 @@ int setDynamicRange(int dr) { uint32_t regval = bus_r(CONFIG_REG) & CONFIG_DYNAMIC_RANGE_MSK; switch (regval) { - case CONFIG_DYNAMIC_RANGE_1_VAL: - return 1; - case CONFIG_DYNAMIC_RANGE_4_VAL: - return 4; + /*case CONFIG_DYNAMIC_RANGE_1_VAL: TODO:Not implemented in firmware yet + return 1;*/ + case CONFIG_DYNAMIC_RANGE_8_VAL: + return 8; case CONFIG_DYNAMIC_RANGE_16_VAL: return 16; case CONFIG_DYNAMIC_RANGE_24_VAL: @@ -2038,7 +2037,6 @@ void *start_timer(void *arg) { int numFrames = (getNumFrames() * getNumTriggers()); int64_t expUs = getGatePeriod() / 1000; - // int dr = setDynamicRange(-1); int imagesize = calculateDataBytes(); int dataSize = imagesize / PACKETS_PER_FRAME; int packetSize = dataSize + sizeof(sls_detector_header); @@ -2046,6 +2044,34 @@ void *start_timer(void *arg) { // Generate data char imageData[imagesize]; memset(imageData, 0, imagesize); + { + int dr = setDynamicRange(-1); + int numCounters = __builtin_popcount(getCounterMask()); + int nchannels = NCHAN_1_COUNTER * NCHIP * numCounters; + + switch (dr) { + /*case 1: // TODO: Not implemented in firmware yet + break;*/ + case 8: + for (int i = 0; i < nchannels; ++i) { + *((uint8_t *)(imageData + i)) = (uint8_t)i; + } + break; + case 16: + for (int i = 0; i < nchannels; ++i) { + *((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i; + } + break; + case 32: + for (int i = 0; i < nchannels; ++i) { + *((uint32_t *)(imageData + i * sizeof(uint32_t))) = + ((uint32_t)i & 0xFFFFFF); // 24 bit + } + break; + default: + break; + } + } for (int i = 0; i < imagesize; i += sizeof(uint8_t)) { *((uint8_t *)(imageData + i)) = i; } @@ -2282,13 +2308,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { int calculateDataBytes() { int numCounters = __builtin_popcount(getCounterMask()); int dr = setDynamicRange(-1); - int databytes = NCHAN_1_COUNTER * NCHIP * numCounters * - ((dr > 16) ? 4 : // 32 bit - ((dr > 8) ? 2 : // 16 bit - ((dr > 4) ? 0.5 : // 4 bit - 0.125))); // 1 bit - - return databytes; + return (NCHAN_1_COUNTER * NCHIP * numCounters * ((double)dr / 8.00)); } int getTotalNumberOfChannels() { diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 805cdb553..b85d01578 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -27,7 +27,7 @@ #define DEFAULT_PATTERN_FILE ("DefaultPattern.txt") #define DEFAULT_INTERNAL_GATES (1) #define DEFAULT_EXTERNAL_GATES (1) -#define DEFAULT_DYNAMIC_RANGE (24) +#define DEFAULT_DYNAMIC_RANGE (32) #define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_CYCLES (1) #define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index db33ca039..1b1d15a3d 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -2684,10 +2684,13 @@ int set_dynamic_range(int file_des) { // check dr switch (dr) { case GET_FLAG: -#ifdef MYTHEN3D - case 32: -#elif EIGERD +/*#ifdef MYTHEN3D TODO:Not implemented in firmware yet + case 1: +#endif*/ +#ifdef EIGERD case 4: +#endif +#if defined(EIGERD) || defined(MYTHEN3D) case 8: case 16: case 32: @@ -2698,6 +2701,11 @@ int set_dynamic_range(int file_des) { #endif retval = setDynamicRange(dr); LOG(logDEBUG1, ("Dynamic range: %d\n", retval)); + if (retval == -1) { + ret = FAIL; + sprintf(mess, "Could not get dynamic range.\n"); + LOG(logERROR, (mess)); + } validate(dr, retval, "set dynamic range", DEC); break; default: diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 042e6e0bf..96e3dfc02 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -203,6 +203,16 @@ class Detector { * [Gotthard2] only in continuous mode */ Result getDelayAfterTriggerLeft(Positions pos = {}) const; + Result getDynamicRange(Positions pos = {}) const; + + /** + * [Eiger] Options: 4, 8, 16, 32 + * [Mythen3] Options: 8, 16, 32 + * [Eiger] If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to + * 1 + */ + void setDynamicRange(int value); + Result getTimingMode(Positions pos = {}) const; /** @@ -698,8 +708,8 @@ class Detector { Result getRxZmqStartingFrame(Positions pos = {}) const; /** - * The starting frame index to stream out. 0 by default, which streams - * the first frame in an acquisition, and then depending on the rx zmq + * The starting frame index to stream out. 0 by default, which streams + * the first frame in an acquisition, and then depending on the rx zmq * frequency/ timer. */ void setRxZmqStartingFrame(int fnum, Positions pos = {}); @@ -736,15 +746,6 @@ class Detector { * * * ************************************************/ - Result getDynamicRange(Positions pos = {}) const; - - /** - * [Eiger] - * Options: 4, 8, 16, 32 - * If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1 - */ - void setDynamicRange(int value); - /** [Eiger] in 32 bit mode */ Result getSubExptime(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index f9834215e..63d26b103 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -487,6 +487,37 @@ std::string CmdProxy::Exptime(int action) { return os.str(); } +std::string CmdProxy::DynamicRange(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + os << "[value]\n\tDynamic Range or number of bits per " + "pixel in detector.\n\t" + "[Eiger] Options: 4, 8, 16, 32\n\t" + "[Mythen3] Options: 8, 16, 32" + << '\n'; + } else if (action == defs::GET_ACTION) { + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto t = det->getDynamicRange({det_id}); + os << OutString(t) << '\n'; + } else if (action == defs::PUT_ACTION) { + if (det_id != -1) { + throw sls::RuntimeError( + "Cannot execute dynamic range at module level"); + } + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + det->setDynamicRange(StringTo(args[0])); + os << args.front() << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + std::string CmdProxy::Speed(int action) { std::ostringstream os; os << cmd << ' '; @@ -1196,35 +1227,6 @@ std::string CmdProxy::ReceiveHostname(int action) { /* ZMQ Streaming Parameters (Receiver<->Client) */ /* Eiger Specific */ -std::string CmdProxy::DynamicRange(int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == defs::HELP_ACTION) { - os << "[4|8|16|32]\n\t[Eiger] Dynamic Range or number of bits per " - "pixel in detector." - << '\n'; - } else if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getDynamicRange({det_id}); - os << OutString(t) << '\n'; - } else if (action == defs::PUT_ACTION) { - if (det_id != -1) { - throw sls::RuntimeError( - "Cannot execute dynamic range at module level"); - } - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - det->setDynamicRange(StringTo(args[0])); - os << args.front() << '\n'; - } else { - throw sls::RuntimeError("Unknown action"); - } - return os.str(); -} - std::string CmdProxy::Threshold(int action) { std::ostringstream os; os << cmd << ' '; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index ce4012f0d..36cd2672d 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -643,6 +643,7 @@ class CmdProxy { {"triggersl", &CmdProxy::triggersl}, {"delayl", &CmdProxy::delayl}, {"periodl", &CmdProxy::periodl}, + {"dr", &CmdProxy::DynamicRange}, {"timing", &CmdProxy::timing}, {"speed", &CmdProxy::Speed}, {"adcphase", &CmdProxy::Adcphase}, @@ -814,7 +815,6 @@ class CmdProxy { {"zmqip", &CmdProxy::zmqip}, /* Eiger Specific */ - {"dr", &CmdProxy::DynamicRange}, {"subexptime", &CmdProxy::subexptime}, {"subdeadtime", &CmdProxy::subdeadtime}, {"threshold", &CmdProxy::Threshold}, @@ -996,6 +996,7 @@ class CmdProxy { /* acquisition parameters */ std::string Acquire(int action); std::string Exptime(int action); + std::string DynamicRange(int action); std::string Speed(int action); std::string Adcphase(int action); std::string Dbitphase(int action); @@ -1021,7 +1022,6 @@ class CmdProxy { /* File */ /* ZMQ Streaming Parameters (Receiver<->Client) */ /* Eiger Specific */ - std::string DynamicRange(int action); std::string Threshold(int action); std::string ThresholdNoTb(int action); std::string TrimEnergies(int action); @@ -1785,9 +1785,11 @@ class CmdProxy { "[nth frame]\n\tStream out every nth frame. Default is 1. 0 means " "streaming every 200 ms and discarding frames in this interval."); - INTEGER_COMMAND( - rx_zmqstartfnum, getRxZmqStartingFrame, setRxZmqStartingFrame, StringTo, - "[fnum]\n\tThe starting frame index to stream out. 0 by default, which streams the first frame in an acquisition, and then depending on the rx zmq frequency/ timer"); + INTEGER_COMMAND(rx_zmqstartfnum, getRxZmqStartingFrame, + setRxZmqStartingFrame, StringTo, + "[fnum]\n\tThe starting frame index to stream out. 0 by " + "default, which streams the first frame in an acquisition, " + "and then depending on the rx zmq frequency/ timer"); INTEGER_COMMAND( rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 5c7a71123..9f90e9ee8 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -273,6 +273,14 @@ Result Detector::getPeriodLeft(Positions pos) const { return pimpl->Parallel(&Module::getPeriodLeft, pos); } +Result Detector::getDynamicRange(Positions pos) const { + return pimpl->Parallel(&Module::getDynamicRange, pos); +} + +void Detector::setDynamicRange(int value) { + pimpl->Parallel(&Module::setDynamicRange, {}, value); +} + Result Detector::getTimingMode(Positions pos) const { return pimpl->Parallel(&Module::getTimingMode, pos); } @@ -1022,14 +1030,6 @@ void Detector::setClientZmqIp(const IpAddr ip, Positions pos) { // Eiger Specific -Result Detector::getDynamicRange(Positions pos) const { - return pimpl->Parallel(&Module::getDynamicRange, pos); -} - -void Detector::setDynamicRange(int value) { - pimpl->Parallel(&Module::setDynamicRange, {}, value); -} - Result Detector::getSubExptime(Positions pos) const { return pimpl->Parallel(&Module::getSubExptime, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 9ffa20173..12dfd9c8a 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -259,6 +259,38 @@ int64_t Module::getPeriodLeft() const { return sendToDetectorStop(F_GET_PERIOD_LEFT); } +int Module::getDynamicRange() { + return sendToDetector(F_SET_DYNAMIC_RANGE, GET_FLAG); +} + +void Module::setDynamicRange(int n) { + int prev_val = n; + if (shm()->myDetectorType == EIGER) { + prev_val = getDynamicRange(); + } + + auto retval = sendToDetector(F_SET_DYNAMIC_RANGE, n); + if (shm()->useReceiverFlag) { + int arg = retval; + sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, arg); + } + + // changes in dr + if (n != prev_val) { + // update speed for usability + if (n == 32) { + LOG(logINFO) << "Setting Clock to Quarter Speed to cope with " + "Dynamic Range of 32"; + setClockDivider(RUN_CLOCK, 2); + } else if (prev_val == 32) { + LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of " + << n; + setClockDivider(RUN_CLOCK, 0); + } + updateRateCorrection(); + } +} + slsDetectorDefs::timingMode Module::getTimingMode() { return sendToDetector(F_SET_TIMING_MODE, GET_FLAG); } @@ -1017,38 +1049,6 @@ void Module::setClientStreamingIP(const sls::IpAddr ip) { // Eiger Specific -int Module::getDynamicRange() { - return sendToDetector(F_SET_DYNAMIC_RANGE, GET_FLAG); -} - -void Module::setDynamicRange(int n) { - int prev_val = n; - if (shm()->myDetectorType == EIGER) { - prev_val = getDynamicRange(); - } - - auto retval = sendToDetector(F_SET_DYNAMIC_RANGE, n); - if (shm()->useReceiverFlag) { - int arg = retval; - sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, arg); - } - - // changes in dr - if (n != prev_val) { - // update speed for usability - if (n == 32) { - LOG(logINFO) << "Setting Clock to Quarter Speed to cope with " - "Dynamic Range of 32"; - setClockDivider(RUN_CLOCK, 2); - } else if (prev_val == 32) { - LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of " - << n; - setClockDivider(RUN_CLOCK, 0); - } - updateRateCorrection(); - } -} - int64_t Module::getSubExptime() { return sendToDetector(F_GET_SUB_EXPTIME); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index bcef6975f..bd8046d45 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -125,6 +125,8 @@ class Module : public virtual slsDetectorDefs { int64_t getNumberOfTriggersLeft() const; int64_t getDelayAfterTriggerLeft() const; int64_t getPeriodLeft() const; + int getDynamicRange(); + void setDynamicRange(int n); timingMode getTimingMode(); void setTimingMode(timingMode value); int getClockDivider(int clkIndex); @@ -290,8 +292,6 @@ class Module : public virtual slsDetectorDefs { * Eiger Specific * * * * ************************************************/ - int getDynamicRange(); - void setDynamicRange(int n); int64_t getSubExptime(); void setSubExptime(int64_t value); int64_t getSubDeadTime(); diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index 1014bcc60..2fe0633ab 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -315,47 +315,6 @@ TEST_CASE("txndelay_right", "[.cmd][.new]") { /* Eiger Specific */ -TEST_CASE("dr", "[.cmd][.new]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - auto dr = det.getDynamicRange().squash(); - std::array vals{4, 8, 16, 32}; - for (const auto val : vals) { - std::ostringstream oss1, oss2; - proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); - proxy.Call("dr", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); - } - det.setDynamicRange(dr); - } else if (det_type == defs::MYTHEN3) { - // not updated in firmware to support anything other than 32 at the - // moment - std::ostringstream oss1, oss2; - proxy.Call("dr", {"32"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr 32\n"); - proxy.Call("dr", {"32"}, -1, PUT, oss2); - REQUIRE(oss2.str() == "dr 32\n"); - REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("dr", {"16"}, -1, PUT)); - } else { - // For the other detectors we should get an error message - // except for dr 16 - REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT)); - - std::ostringstream oss1, oss2; - proxy.Call("dr", {"16"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dr 16\n"); - proxy.Call("dr", {"16"}, -1, PUT, oss2); - REQUIRE(oss2.str() == "dr 16\n"); - } -} - TEST_CASE("subexptime", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 6cbb18c64..3ddc90c0c 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -451,6 +451,48 @@ TEST_CASE("periodl", "[.cmd][.new]") { } } +TEST_CASE("dr", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto dr = det.getDynamicRange().squash(); + std::array vals{4, 8, 16, 32}; + for (const auto val : vals) { + std::ostringstream oss1, oss2; + proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); + proxy.Call("dr", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); + } + det.setDynamicRange(dr); + } else if (det_type == defs::MYTHEN3) { + auto dr = det.getDynamicRange().squash(); + // not updated in firmware to support dr 1 + std::array vals{8, 16, 32}; + for (const auto val : vals) { + std::ostringstream oss1, oss2; + proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n'); + proxy.Call("dr", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); + } + det.setDynamicRange(dr); + } else { + // For the other detectors we should get an error message + // except for dr 16 + REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT)); + + std::ostringstream oss1, oss2; + proxy.Call("dr", {"16"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr 16\n"); + proxy.Call("dr", {"16"}, -1, PUT, oss2); + REQUIRE(oss2.str() == "dr 16\n"); + } +} + TEST_CASE("timing", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 483c6134f..deef9b569 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -727,21 +727,28 @@ int ClientInterface::set_dynamic_range(Interface &socket) { verifyIdle(socket); LOG(logDEBUG1) << "Setting dynamic range: " << dr; bool exists = false; - switch (myDetectorType) { - case EIGER: - if (dr == 4 || dr == 8 || dr == 16 || dr == 32) { + switch (dr) { + case 16: + exists = true; + break; + /*case 1: //TODO: Not yet implemented in firmware + if (myDetectorType == MYTHEN3) { exists = true; } break; - case MYTHEN3: - if (dr == 1 || dr == 4 || dr == 16 || dr == 32) { + */ + case 4: + if (myDetectorType == EIGER) { + exists = true; + } + break; + case 8: + case 32: + if (myDetectorType == EIGER || myDetectorType == MYTHEN3) { exists = true; } break; default: - if (dr == 16) { - exists = true; - } break; } if (!exists) { @@ -1718,7 +1725,7 @@ int ClientInterface::get_streaming_start_fnum(Interface &socket) { } int ClientInterface::set_streaming_start_fnum(Interface &socket) { - auto index = socket.Receive(); + auto index = socket.Receive(); if (index < 0) { throw RuntimeError("Invalid streaming start frame number: " + std::to_string(index)); diff --git a/slsReceiverSoftware/src/GeneralData.h b/slsReceiverSoftware/src/GeneralData.h index 585df7e4a..687a6f065 100644 --- a/slsReceiverSoftware/src/GeneralData.h +++ b/slsReceiverSoftware/src/GeneralData.h @@ -449,11 +449,7 @@ class Mythen3Data : public GeneralData { ncounters = n; nPixelsX = NCHAN * ncounters; LOG(logINFO) << "nPixelsX: " << nPixelsX; - imageSize = nPixelsX * nPixelsY * - ((dr > 16) ? 4 : // 32 bit - ((dr > 8) ? 2 : // 16 bit - ((dr > 4) ? 0.5 : // 4 bit - 0.125))); // 1 bit + imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00); dataSize = imageSize / packetsPerFrame; packetSize = headerSizeinPacket + dataSize; LOG(logINFO) << "PacketSize: " << packetSize; @@ -465,11 +461,7 @@ class Mythen3Data : public GeneralData { * @param tgEnable (discarded, of no value to mythen3) */ void SetDynamicRange(int dr, bool tgEnable) { - imageSize = nPixelsX * nPixelsY * - ((dr > 16) ? 4 : // 32 bit - ((dr > 8) ? 2 : // 16 bit - ((dr > 4) ? 0.5 : // 4 bit - 0.125))); // 1 bit + imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00); dataSize = imageSize / packetsPerFrame; packetSize = headerSizeinPacket + dataSize; LOG(logINFO) << "PacketSize: " << packetSize; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index c461de731..32be51dba 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -293,9 +293,10 @@ void Implementation::setDetectorType(const detectorType d) { dataProcessor.push_back(sls::make_unique( i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, &dynamicRange, - &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &framePadding, - &activated, &deactivatedPaddingEnable, &silentMode, &quadEnable, - &ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes)); + &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, + &framePadding, &activated, &deactivatedPaddingEnable, + &silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset, + &ctbAnalogDataBytes)); } catch (...) { listener.clear(); dataProcessor.clear(); @@ -1018,10 +1019,10 @@ void Implementation::setNumberofUDPInterfaces(const int n) { dataProcessor.push_back(sls::make_unique( i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, - &dynamicRange, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum, - &framePadding, &activated, &deactivatedPaddingEnable, - &silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset, - &ctbAnalogDataBytes)); + &dynamicRange, &streamingFrequency, &streamingTimerInMs, + &streamingStartFnum, &framePadding, &activated, + &deactivatedPaddingEnable, &silentMode, &quadEnable, + &ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes)); dataProcessor[i]->SetGeneralData(generalData); } catch (...) { listener.clear();