diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index ce79b1c9e..9941fdadb 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1098,7 +1098,7 @@ enum gainMode getGainMode() { switch (retval_force) { case DAQ_FRCE_GAIN_STG_0_VAL: - return NORMAL_GAIN_MODE; + return DYNAMICGAIN; case DAQ_FRCE_GAIN_STG_1_VAL: return FORCE_SWITCH_G1; case DAQ_FRCE_GAIN_STG_2_VAL: @@ -1131,7 +1131,7 @@ void setGainMode(enum gainMode mode) { uint32_t value = bus_r(addr); switch (mode) { - case NORMAL_GAIN_MODE: + case DYNAMICGAIN: value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK); bus_w(addr, value); LOG(logINFO, ("Set gain mode - Normal Gain Mode [DAQ Reg:0x%x]\n", @@ -1151,6 +1151,27 @@ void setGainMode(enum gainMode mode) { LOG(logINFO, ("Set gain mode - Force Switch G2 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); break; + case FIX_G1: + value &= ~(DAQ_FIX_GAIN_MSK); + value |= DAQ_FIX_GAIN_STG_1_VAL; + bus_w(addr, value); + LOG(logINFO, + ("Set gain mode - Fix G1 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); + break; + case FIX_G2: + value &= ~(DAQ_FIX_GAIN_MSK); + value |= DAQ_FIX_GAIN_STG_2_VAL; + bus_w(addr, value); + LOG(logINFO, + ("Set gain mode - Fix G2 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); + break; + case FIX_G0: //???? + value &= ~(DAQ_FIX_GAIN_MSK); + value |= DAQ_FIX_GAIN_STG_2_VAL; + bus_w(addr, value); + LOG(logINFO, + ("Set gain mode - Fix G2 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); + break; default: LOG(logERROR, ("This gain mode %d is not defined\n", (int)mode)); } diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index f69225778..38550100a 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1179,7 +1179,7 @@ class Detector { /** [Jungfrau]*/ Result getGainMode(Positions pos = {}) const; - /** [Jungfrau] Options: NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2, + /** [Jungfrau] Options: DYNAMICGAIN, FORCE_SWITCH_G1, FORCE_SWITCH_G2, * FIX_G1, FIX_G2, FIX_G0, FIX_HG0 \n\CAUTION: Do not use FIX_G0 and FIX_HG0 * blindly, you can damage the detector!!!\n */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index ddd7253f2..9e5937ea6 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1494,9 +1494,10 @@ void Detector::setStorageCellDelay(ns value, Positions pos) { std::vector Detector::getGainModeList() const { switch (getDetectorType().squash()) { case defs::JUNGFRAU: - return std::vector{defs::NORMAL_GAIN_MODE, - defs::FORCE_SWITCH_G1, - defs::FORCE_SWITCH_G2}; + return std::vector{ + defs::DYNAMICGAIN, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2, + defs::FIX_G1, defs::FIX_G2, defs::FIX_G0, + defs::FIX_HG0}; break; default: throw RuntimeError("Gain mode is not implemented for this detector."); diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index 521b0faee..75b2a78b7 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -463,8 +463,18 @@ TEST_CASE("gainmode", "[.cmd]") { } { std::ostringstream oss; - proxy.Call("gainmode", {"normal"}, -1, PUT, oss); - REQUIRE(oss.str() == "gainmode normal\n"); + proxy.Call("gainmode", {"fixg1"}, -1, PUT, oss); + REQUIRE(oss.str() == "gainmode fixg1\n"); + } + { + std::ostringstream oss; + proxy.Call("gainmode", {"fixg2"}, -1, PUT, oss); + REQUIRE(oss.str() == "gainmode fixg2\n"); + } + { + std::ostringstream oss; + proxy.Call("gainmode", {"dynamic"}, -1, PUT, oss); + REQUIRE(oss.str() == "gainmode dynamic\n"); } for (int i = 0; i != det.size(); ++i) { det.setGainMode(prev_val[i], {i}); diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 65472c488..872d17c66 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -415,7 +415,7 @@ typedef struct { enum vetoAlgorithm { DEFAULT_ALGORITHM }; enum gainMode { - NORMAL_GAIN_MODE, + DYNAMICGAIN, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 95fb57f1f..0f18afd86 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -581,8 +581,8 @@ std::string ToString(const defs::vetoAlgorithm s) { std::string ToString(const defs::gainMode s) { switch (s) { - case defs::NORMAL_GAIN_MODE: - return std::string("normal"); + case defs::DYNAMICGAIN: + return std::string("dynamicgain"); case defs::FORCE_SWITCH_G1: return std::string("forceswitchg1"); case defs::FORCE_SWITCH_G2: @@ -984,8 +984,8 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) { } template <> defs::gainMode StringTo(const std::string &s) { - if (s == "normal") - return defs::NORMAL_GAIN_MODE; + if (s == "dynamicgain") + return defs::DYNAMICGAIN; if (s == "forceswitchg1") return defs::FORCE_SWITCH_G1; if (s == "forceswitchg2")