diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index b114aff7a..9f51b1922 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -15,19 +15,31 @@ qTabSettings::~qTabSettings() {} void qTabSettings::SetupWidgetWindow() { // enabling according to det type - switch (det->getDetectorType().squash()) { - case slsDetectorDefs::MYTHEN3: + slsDetectorDefs::detectorType detType = det->getDetectorType().squash(); + if (detType == slsDetectorDefs::MYTHEN3) { lblSettings->setEnabled(false); comboSettings->setEnabled(false); - break; - case slsDetectorDefs::EIGER: + + lblDynamicRange->setEnabled(true); + comboDynamicRange->setEnabled(true); + // disable dr + QStandardItemModel *model = + qobject_cast(comboDynamicRange->model()); + if (model) { + QModelIndex index; + QStandardItem *item; + index = + model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(), + comboDynamicRange->rootModelIndex()); + item = model->itemFromIndex(index); + item->setEnabled(false); + } + + } else if (detType == slsDetectorDefs::EIGER) { lblDynamicRange->setEnabled(true); comboDynamicRange->setEnabled(true); lblThreshold->setEnabled(true); spinThreshold->setEnabled(true); - break; - default: - break; } // default settings for the disabled diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index e192e8bd1..3b39650a9 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index af624fc05..3a7620fbc 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1614,7 +1614,6 @@ int enableTenGigabitEthernet(int val) { } else { bus_w(addr, bus_r(addr) & (~CONFIG_GB10_SND_UDP_MSK)); } - // configuremac called from client } return ((bus_r(addr) & CONFIG_GB10_SND_UDP_MSK) >> CONFIG_GB10_SND_UDP_OFST); diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 9d25b9682..8a28acb04 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index fd5a8e656..25fa60526 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1528,7 +1528,6 @@ int enableTenGigabitEthernet(int val) { send_to_ten_gig = 1; else send_to_ten_gig = 0; - // configuremac called from client } return send_to_ten_gig; } diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 2f063c16e..4166c3b46 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 6728a6204..6f815d9d4 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index a4d9ae934..2ab30d3cc 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 092fba13a..69e95f9ef 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ 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/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 537a4d6ea..7401da623 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 219819826..d95875dfd 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -21,6 +21,7 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; +extern int checkModuleFlag; extern udpStruct udpDetails; extern const enum detectorType myDetectorType; @@ -426,6 +427,42 @@ void setupDetector() { setGateDelay(i, DEFAULT_GATE_DELAY); } setInitialExtSignals(); + // 10G UDP + enableTenGigabitEthernet(1); + + // check module type attached if not in debug mode + { + int ret = checkDetectorType(); + if (checkModuleFlag) { + switch (ret) { + case -1: + sprintf(initErrorMessage, + "Could not get the module type attached.\n"); + initError = FAIL; + LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); + return; + case -2: + sprintf(initErrorMessage, + "No Module attached! Run server with -nomodule.\n"); + initError = FAIL; + LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); + return; + case FAIL: + sprintf(initErrorMessage, + "Wrong Module (Not Mythen3) attached!\n"); + initError = FAIL; + LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage)); + return; + default: + break; + } + } else { + LOG(logINFOBLUE, + ("In No-Module mode: Ignoring module type. Continuing.\n")); + } + } + + powerChip(1); loadDefaultPattern(DEFAULT_PATTERN_FILE); } @@ -496,16 +533,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; @@ -520,10 +556,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: @@ -1459,6 +1495,26 @@ int setDetectorPosition(int pos[]) { int *getDetectorPosition() { return detPos; } +int enableTenGigabitEthernet(int val) { + uint32_t addr = PKT_CONFIG_REG; + + // set + if (val != -1) { + LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0)); + // 1g + if (val == 0) { + bus_w(addr, bus_r(addr) | PKT_CONFIG_1G_INTERFACE_MSK); + } + // 10g + else { + bus_w(addr, bus_r(addr) & (~PKT_CONFIG_1G_INTERFACE_MSK)); + } + } + int oneG = ((bus_r(addr) & PKT_CONFIG_1G_INTERFACE_MSK) >> + PKT_CONFIG_1G_INTERFACE_OFST); + return oneG ? 0 : 1; +} + /* pattern */ void startPattern() { @@ -2003,7 +2059,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); @@ -2011,8 +2066,33 @@ void *start_timer(void *arg) { // Generate data char imageData[imagesize]; memset(imageData, 0, imagesize); - for (int i = 0; i < imagesize; i += sizeof(uint8_t)) { - *((uint8_t *)(imageData + i)) = i; + { + 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; + } } // Send data @@ -2247,13 +2327,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/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 2fd715409..c9953263b 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -377,7 +377,8 @@ int getInterruptSubframe(); int setReadNLines(int value); int getReadNLines(); #endif -#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) +#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \ + defined(MYTHEN3D) int enableTenGigabitEthernet(int val); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index db33ca039..5c93c83a4 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: @@ -2847,14 +2855,14 @@ int enable_ten_giga(int file_des) { return printSocketReadError(); LOG(logINFOBLUE, ("Setting 10GbE: %d\n", arg)); -#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(MYTHEN3D) || \ - defined(GOTTHARD2D) +#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D) functionNotImplemented(); #else // set & get if ((arg == GET_FLAG) || (Server_VerifyLock() == OK)) { if (arg >= 0 && enableTenGigabitEthernet(GET_FLAG) != arg) { enableTenGigabitEthernet(arg); +#ifdef EIGERD uint64_t hardwaremac = getDetectorMAC(); if (udpDetails.srcmac != hardwaremac) { LOG(logINFOBLUE, ("Updating udp source mac\n")); @@ -2865,6 +2873,7 @@ int enable_ten_giga(int file_des) { LOG(logINFOBLUE, ("Updating udp source ip\n")); udpDetails.srcip = hardwareip; } +#endif configure_mac(); } retval = enableTenGigabitEthernet(GET_FLAG); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 042e6e0bf..894c12237 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; /** @@ -501,10 +511,10 @@ class Detector { Result printRxConfiguration(Positions pos = {}) const; - /** [Eiger][CTB][Moench] */ + /** [Eiger][CTB][Moench][Mythen3] */ Result getTenGiga(Positions pos = {}) const; - /** [Eiger][CTB][Moench] */ + /** [Eiger][CTB][Moench][Mythen3] */ void setTenGiga(bool value, Positions pos = {}); /** [Eiger, Jungfrau] */ @@ -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..f3e85893c 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); @@ -1648,7 +1648,7 @@ class CmdProxy { "\n\tPrints the receiver configuration."); INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, StringTo, - "[0, 1]\n\t[Eiger][Ctb][Moench] 10GbE Enable."); + "[0, 1]\n\t[Eiger][Ctb][Moench][Mythen3] 10GbE Enable."); INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl, setTenGigaFlowControl, StringTo, @@ -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..309bc30ab 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); @@ -1523,7 +1565,7 @@ TEST_CASE("tengiga", "[.cmd][.new]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD || - det_type == defs::MOENCH) { + det_type == defs::MOENCH || det_type == defs::MYTHEN3) { auto tengiga = det.getTenGiga(); det.setTenGiga(false); diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 483c6134f..ac45ae0c2 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -430,7 +430,7 @@ int ClientInterface::setup_receiver(Interface &socket) { } impl()->setTimingMode(arg.timMode); if (myDetectorType == EIGER || myDetectorType == MOENCH || - myDetectorType == CHIPTESTBOARD) { + myDetectorType == CHIPTESTBOARD || myDetectorType == MYTHEN3) { try { impl()->setTenGigaEnable(arg.tenGiga); } catch (const RuntimeError &e) { @@ -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) { @@ -980,7 +987,7 @@ int ClientInterface::get_overwrite(Interface &socket) { int ClientInterface::enable_tengiga(Interface &socket) { auto val = socket.Receive(); if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD && - myDetectorType != MOENCH) + myDetectorType != MOENCH && myDetectorType != MYTHEN3) functionNotImplemented(); if (val >= 0) { @@ -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..09eb56364 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(); @@ -1661,6 +1662,9 @@ void Implementation::setTenGigaEnable(const bool b) { case EIGER: generalData->SetTenGigaEnable(b, dynamicRange); break; + case MYTHEN3: + generalData->SetDynamicRange(dynamicRange, b); + break; case MOENCH: case CHIPTESTBOARD: ctbAnalogDataBytes = generalData->setImageSize(