From 3802f22ebedff4841d05a28b9fcb59da15e10a74 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 4 Aug 2021 14:03:27 +0200 Subject: [PATCH] wip --- python/scripts/test_virtual.py | 4 ++-- python/slsdet/detector.py | 2 +- python/src/enums.cpp | 2 +- .../jungfrauDetectorServer/slsDetectorFunctionList.c | 9 +++++++-- .../jungfrauDetectorServer/slsDetectorServer_defs.h | 2 +- .../slsDetectorServer/src/slsDetectorServer_funcs.c | 4 ++-- slsDetectorSoftware/include/sls/Detector.h | 2 +- slsDetectorSoftware/src/Detector.cpp | 9 ++++++--- slsSupportLib/include/sls/sls_detector_defs.h | 3 +-- slsSupportLib/src/ToString.cpp | 4 ++-- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/python/scripts/test_virtual.py b/python/scripts/test_virtual.py index 2d24bf1d7..eec0da90b 100644 --- a/python/scripts/test_virtual.py +++ b/python/scripts/test_virtual.py @@ -161,7 +161,7 @@ def test_gainmode(virtual_jf_detectors): assert d.gainMode == gainMode.NORMAL_GAIN_MODE gain_list = [ - gainMode.DYNAMIC_GAIN, + gainMode.DYNAMIC_GAIN_MODE, gainMode.FORCE_SWITCH_G1, gainMode.FORCE_SWITCH_G2, gainMode.FIX_G1, @@ -176,7 +176,7 @@ def test_gainmode(virtual_jf_detectors): d.setGainMode(gainMode.FORCE_SWITCH_G1, [1]) assert d.gainMode == [ - gainMode.DYNAMIC_GAIN, + gainMode.DYNAMIC_GAIN_MODE, gainMode.FORCE_SWITCH_G1, gainMode.FORCE_SWITCH_G2, gainMode.FIX_G1, diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 26f7c0896..ae9566968 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2201,7 +2201,7 @@ class Detector(CppDetectorApi): [Jungfrau] Detector gain mode. Enum: gainMode Note ----- - [Jungfrau] DYNAMIC_GAIN, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n + [Jungfrau] DYNAMIC_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 \n CAUTION: Do not use FIX_G0 blindly, you can damage the detector!!! """ return element_if_equal(self.getGainMode()) diff --git a/python/src/enums.cpp b/python/src/enums.cpp index 75e490349..f3d381a51 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -308,7 +308,7 @@ void init_enums(py::module &m) { .export_values(); py::enum_(Defs, "gainMode") - .value("DYNAMIC_GAIN", slsDetectorDefs::gainMode::DYNAMIC_GAIN) + .value("DYNAMIC_GAIN_MODE", slsDetectorDefs::gainMode::DYNAMIC_GAIN_MODE) .value("FORCE_SWITCH_G1", slsDetectorDefs::gainMode::FORCE_SWITCH_G1) .value("FORCE_SWITCH_G2", slsDetectorDefs::gainMode::FORCE_SWITCH_G2) .value("FIX_G1", slsDetectorDefs::gainMode::FIX_G1) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 40446e875..5b94b45fe 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -793,6 +793,11 @@ int selectStoragecellStart(int pos) { LOG(logINFO, ("Setting storage cell start: %d\n", pos)); bus_w(addr, bus_r(addr) & ~mask); bus_w(addr, bus_r(addr) | ((value << offset) & mask)); + // should not do a get to verify (status register does not update + // immediately during acquisition) + if (getChipVersion() == 11) { + return pos; + } } // read value back @@ -1098,7 +1103,7 @@ enum gainMode getGainMode() { switch (retval_force) { case DAQ_FRCE_GAIN_STG_0_VAL: - return DYNAMIC_GAIN; + return DYNAMIC_GAIN_MODE; case DAQ_FRCE_GAIN_STG_1_VAL: return FORCE_SWITCH_G1; case DAQ_FRCE_GAIN_STG_2_VAL: @@ -1128,7 +1133,7 @@ void setGainMode(enum gainMode mode) { uint32_t value = bus_r(addr); switch (mode) { - case DYNAMIC_GAIN: + case DYNAMIC_GAIN_MODE: value &= ~(DAQ_GAIN_MODE_MASK); bus_w(addr, value); LOG(logINFO, diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index dc23238a9..6f222b746 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -98,7 +98,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_SETTINGS (GAIN0) -#define DEFAULT_GAINMODE (DYNAMIC_GAIN) +#define DEFAULT_GAINMODE (DYNAMIC_GAIN_MODE) #define DEFAULT_TX_UDP_PORT (0x7e9a) #define DEFAULT_TMP_THRSHLD (65 * 1000) // milli degree Celsius #define DEFAULT_NUM_STRG_CLLS (0) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 9bbbe16c3..faa4b0ff4 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -8560,7 +8560,7 @@ int set_default_dac(int file_des) { int get_gain_mode(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - enum gainMode retval = NORMAL_GAIN_MODE; + enum gainMode retval = DYNAMIC_GAIN_MODE; LOG(logDEBUG1, ("Getting gain mode\n")); #ifndef JUNGFRAUD @@ -8593,7 +8593,7 @@ int set_gain_mode(int file_des) { // only set if (Server_VerifyLock() == OK) { switch (gainmode) { - case DYNAMIC_GAIN: + case DYNAMIC_GAIN_MODE: case FORCE_SWITCH_G1: case FORCE_SWITCH_G2: case FIX_G1: diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 1bdb62b73..09f7e74fd 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: DYNAMIC_GAIN, FORCE_SWITCH_G1, FORCE_SWITCH_G2, + /** [Jungfrau] Options: DYNAMIC_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2, * FIX_G1, FIX_G2, FIX_G0 \n\CAUTION: Do not use FIX_G0 blindly, you can * damage the detector!!!\n */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 413eb3d1c..ac9db0e84 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1494,9 +1494,12 @@ void Detector::setStorageCellDelay(ns value, Positions pos) { std::vector Detector::getGainModeList() const { switch (getDetectorType().squash()) { case defs::JUNGFRAU: - return std::vector{ - defs::DYNAMIC_GAIN, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2, - defs::FIX_G1, defs::FIX_G2, defs::FIX_G0}; + return std::vector{defs::DYNAMIC_GAIN_MODE, + defs::FORCE_SWITCH_G1, + defs::FORCE_SWITCH_G2, + defs::FIX_G1, + defs::FIX_G2, + defs::FIX_G0}; break; default: throw RuntimeError("Gain mode is not implemented for this detector."); diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index c0ae55bb3..348b36648 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -416,12 +416,11 @@ typedef struct { enum vetoAlgorithm { DEFAULT_ALGORITHM }; enum gainMode { - DYNAMIC_GAIN, + DYNAMIC_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, - FIX_G0, FIX_G0 }; diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index a14cfa291..2755f320d 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -583,7 +583,7 @@ std::string ToString(const defs::vetoAlgorithm s) { std::string ToString(const defs::gainMode s) { switch (s) { - case defs::DYNAMIC_GAIN: + case defs::DYNAMIC_GAIN_MODE: return std::string("dynamicgain"); case defs::FORCE_SWITCH_G1: return std::string("forceswitchg1"); @@ -987,7 +987,7 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) { template <> defs::gainMode StringTo(const std::string &s) { if (s == "dynamicgain") - return defs::DYNAMIC_GAIN; + return defs::DYNAMIC_GAIN_MODE; if (s == "forceswitchg1") return defs::FORCE_SWITCH_G1; if (s == "forceswitchg2")