From 0e5e0f346b3354b4059cede0ba19f08ec2048b02 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 4 Aug 2021 13:07:48 +0200 Subject: [PATCH] rewrote settings enums, gainmode enums --- python/scripts/test_virtual.py | 26 +++++--- python/slsdet/detector.py | 6 +- python/src/enums.cpp | 8 ++- slsDetectorGui/include/qTabSettings.h | 24 ------- slsDetectorGui/src/qTabSettings.cpp | 9 +-- .../jungfrauDetectorServer/RegisterDefs.h | 1 + .../slsDetectorFunctionList.c | 65 +++++++++---------- .../slsDetectorServer_defs.h | 3 +- .../src/slsDetectorServer_funcs.c | 9 ++- slsDetectorSoftware/include/sls/Detector.h | 8 +-- slsDetectorSoftware/src/CmdProxy.h | 12 ++-- slsDetectorSoftware/src/Detector.cpp | 9 ++- .../tests/test-CmdProxy-jungfrau.cpp | 9 ++- slsDetectorSoftware/tests/test-CmdProxy.cpp | 7 +- slsSupportLib/include/sls/sls_detector_defs.h | 7 +- slsSupportLib/src/ToString.cpp | 20 +++--- 16 files changed, 109 insertions(+), 114 deletions(-) diff --git a/python/scripts/test_virtual.py b/python/scripts/test_virtual.py index f5dc302cd..2d24bf1d7 100644 --- a/python/scripts/test_virtual.py +++ b/python/scripts/test_virtual.py @@ -101,11 +101,11 @@ def test_module_size(virtual_jf_detectors): def test_settings(virtual_jf_detectors): d = ExperimentalDetector() - assert d.settings == detectorSettings.DYNAMICGAIN + assert d.settings == detectorSettings.GAIN0 gain_list = [ - detectorSettings.DYNAMICHG0, - detectorSettings.DYNAMICGAIN, + detectorSettings.GAIN0, + detectorSettings.HIGHGAIN0, ] # Set all viable gain for Jungfrau to make sure nothing is crashing @@ -113,14 +113,14 @@ def test_settings(virtual_jf_detectors): d.settings = gain assert d.settings == gain - d.setSettings(detectorSettings.DYNAMICGAIN, [1]) + d.setSettings(detectorSettings.GAIN0, [1]) assert d.settings == [ - detectorSettings.DYNAMICHG0, - detectorSettings.DYNAMICGAIN, + detectorSettings.GAIN0, + detectorSettings.HIGHGAIN0, ] - d.settings = detectorSettings.DYNAMICGAIN - assert d.settings == detectorSettings.DYNAMICGAIN + d.settings = detectorSettings.GAIN0 + assert d.settings == detectorSettings.GAIN0 def test_frames(virtual_jf_detectors): d = ExperimentalDetector() @@ -161,9 +161,12 @@ def test_gainmode(virtual_jf_detectors): assert d.gainMode == gainMode.NORMAL_GAIN_MODE gain_list = [ - gainMode.NORMAL_GAIN_MODE, + gainMode.DYNAMIC_GAIN, gainMode.FORCE_SWITCH_G1, gainMode.FORCE_SWITCH_G2, + gainMode.FIX_G1, + gainMode.FIX_G2, + gainMode.FIX_G0 ] # Set all viable gain for Jungfrau to make sure nothing is crashing @@ -173,9 +176,12 @@ def test_gainmode(virtual_jf_detectors): d.setGainMode(gainMode.FORCE_SWITCH_G1, [1]) assert d.gainMode == [ - gainMode.NORMAL_GAIN_MODE, + gainMode.DYNAMIC_GAIN, gainMode.FORCE_SWITCH_G1, gainMode.FORCE_SWITCH_G2, + gainMode.FIX_G1, + gainMode.FIX_G2, + gainMode.FIX_G0 ] d.gainMode = gainMode.FORCE_SWITCH_G1 diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 2f2beea66..26f7c0896 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -311,7 +311,7 @@ class Detector(CppDetectorApi): ----- [Eiger] Use threshold command to load settings - [Jungfrau] DYNAMICGAIN, DYNAMICHG0 \n + [Jungfrau] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n [Gotthard2] DYNAMICGAIN, FIXGAIN1, FIXGAIN2 \n [Moench] G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN \n @@ -2201,8 +2201,8 @@ class Detector(CppDetectorApi): [Jungfrau] Detector gain mode. Enum: gainMode Note ----- - [Jungfrau] NORMAL_GAIN_MODE, 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!!! + [Jungfrau] DYNAMIC_GAIN, 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 851779b13..75e490349 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -210,7 +210,7 @@ void init_enums(py::module &m) { .value("LOWGAIN", slsDetectorDefs::detectorSettings::LOWGAIN) .value("MEDIUMGAIN", slsDetectorDefs::detectorSettings::MEDIUMGAIN) .value("VERYHIGHGAIN", slsDetectorDefs::detectorSettings::VERYHIGHGAIN) - .value("DYNAMICHG0", slsDetectorDefs::detectorSettings::DYNAMICHG0) + .value("HIGHGAIN0", slsDetectorDefs::detectorSettings::HIGHGAIN0) .value("FIXGAIN1", slsDetectorDefs::detectorSettings::FIXGAIN1) .value("FIXGAIN2", slsDetectorDefs::detectorSettings::FIXGAIN2) .value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN) @@ -226,6 +226,7 @@ void init_enums(py::module &m) { slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN) .value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN) .value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN) + .value("GAIN0", slsDetectorDefs::detectorSettings::GAIN0) .value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED) .value("UNINITIALIZED", slsDetectorDefs::detectorSettings::UNINITIALIZED) @@ -307,8 +308,11 @@ void init_enums(py::module &m) { .export_values(); py::enum_(Defs, "gainMode") - .value("NORMAL_GAIN_MODE", slsDetectorDefs::gainMode::NORMAL_GAIN_MODE) + .value("DYNAMIC_GAIN", slsDetectorDefs::gainMode::DYNAMIC_GAIN) .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) + .value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2) + .value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0) .export_values(); } diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index 988da3eeb..710983598 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -32,29 +32,5 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { sls::Detector *det; std::vector counters; - enum { - STANDARD, - FAST, - HIGHGAIN, - DYNAMICGAIN, - LOWGAIN, - MEDIUMGAIN, - VERYHIGHGAIN, - DYNAMICHG0, - FIXGAIN1, - FIXGAIN2, - VERLOWGAIN, - G1_HIGHGAIN, - G1_LOWGAIN, - G2_HIGHCAP_HIGHGAIN, - G2_HIGHCAP_LOWGAIN, - G2_LOWCAP_HIGHGAIN, - G2_LOWCAP_LOWGAIN, - G4_HIGHGAIN, - G4_LOWGAIN, - UNDEFINED, - UNINITIALIZED, - NUMSETTINGS - }; enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 }; }; diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 33234fe96..d89078000 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -92,10 +92,11 @@ void qTabSettings::SetupWidgetWindow() { void qTabSettings::SetupDetectorSettings() { QStandardItemModel *model = qobject_cast(comboSettings->model()); + const int numSettings = comboSettings->count(); if (model) { - QModelIndex index[NUMSETTINGS]; - QStandardItem *item[NUMSETTINGS]; - for (int i = 0; i < NUMSETTINGS; ++i) { + QModelIndex index[numSettings]; + QStandardItem *item[numSettings]; + for (int i = 0; i < numSettings; ++i) { index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex()); item[i] = model->itemFromIndex(index[i]); @@ -160,7 +161,7 @@ void qTabSettings::GetSettings() { comboSettings->setCurrentIndex(UNINITIALIZED); break; default: - if ((int)retval < -1 || (int)retval >= NUMSETTINGS) { + if ((int)retval < -1 || (int)retval >= comboSettings->count()) { throw sls::RuntimeError(std::string("Unknown settings: ") + std::to_string(retval)); } diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h index 2eff513e6..5ea830d1b 100644 --- a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h @@ -351,6 +351,7 @@ #define DAQ_CRRNT_SRC_CLMN_FIX_MSK (0x00000001 << DAQ_CRRNT_SRC_CLMN_FIX_OFST) #define DAQ_CRRNT_SRC_CLMN_SLCT_OFST (20) #define DAQ_CRRNT_SRC_CLMN_SLCT_MSK (0x0000003F << DAQ_CRRNT_SRC_CLMN_SLCT_OFST) +#define DAQ_GAIN_MODE_MASK (DAQ_FRCE_SWTCH_GAIN_MSK | DAQ_FIX_GAIN_MSK | DAQ_CMP_RST_MSK) /** Chip Power Register */ #define CHIP_POWER_REG (0x5E << MEM_MAP_SHIFT) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 9941fdadb..40446e875 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -451,6 +451,7 @@ void setupDetector() { // Initialization of acquistion parameters setSettings(DEFAULT_SETTINGS); + setGainMode(DEFAULT_GAINMODE); setNumFrames(DEFAULT_NUM_FRAMES); setNumTriggers(DEFAULT_NUM_CYCLES); @@ -507,10 +508,10 @@ int resetToDefaultDacs(int hardReset) { // special dac: replace default value if (specialDacs[j] == i) { switch (oldSettings) { - case DYNAMICGAIN: + case GAIN0: value = defaultDacValue_G0[j]; break; - case DYNAMICHG0: + case HIGHGAIN0: value = defaultDacValue_HG0[j]; break; default: @@ -541,10 +542,10 @@ int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, for (int i = 0; i < NSPECIALDACS; ++i) { if ((int)index == specialDacs[i]) { switch (sett) { - case DYNAMICGAIN: + case GAIN0: *retval = defaultDacValue_G0[i]; return OK; - case DYNAMICHG0: + case HIGHGAIN0: *retval = defaultDacValue_HG0[i]; return OK; // unknown settings @@ -573,15 +574,14 @@ int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) { for (int i = 0; i < NSPECIALDACS; ++i) { if ((int)index == specialDacs[i]) { switch (sett) { - case DYNAMICGAIN: - LOG(logINFO, - ("Setting Default Dac [%d - %s, dynamicgain]: %d\n", - (int)index, dac_names[index], value)); + case GAIN0: + LOG(logINFO, ("Setting Default Dac [%d - %s, gain0]: %d\n", + (int)index, dac_names[index], value)); defaultDacValue_G0[i] = value; return OK; - case DYNAMICHG0: + case HIGHGAIN0: LOG(logINFO, - ("Setting Default Dac [%d - %s, dynamichg0]: %d\n", + ("Setting Default Dac [%d - %s, highgain0]: %d\n", (int)index, dac_names[index], value)); defaultDacValue_HG0[i] = value; return OK; @@ -1045,16 +1045,16 @@ enum detectorSettings setSettings(enum detectorSettings sett) { int *dacVals = NULL; // set settings switch (sett) { - case DYNAMICGAIN: + case GAIN0: bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_HIGH_GAIN_MSK); LOG(logINFO, - ("Set settings - Dyanmic Gain [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); + ("Set settings - Gain 0 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); dacVals = defaultDacValue_G0; break; - case DYNAMICHG0: + case HIGHGAIN0: bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_HIGH_GAIN_MSK); - LOG(logINFO, ("Set settings - Dyanmic High Gain 0 [DAQ Reg:0x%x]\n", - bus_r(DAQ_REG))); + LOG(logINFO, + ("Set settings - High Gain 0 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); dacVals = defaultDacValue_HG0; break; default: @@ -1080,8 +1080,8 @@ enum detectorSettings setSettings(enum detectorSettings sett) { enum detectorSettings getSettings() { if (bus_r(DAQ_REG) & DAQ_HIGH_GAIN_MSK) - return DYNAMICHG0; - return DYNAMICGAIN; + return HIGHGAIN0; + return GAIN0; } enum gainMode getGainMode() { @@ -1098,7 +1098,7 @@ enum gainMode getGainMode() { switch (retval_force) { case DAQ_FRCE_GAIN_STG_0_VAL: - return DYNAMICGAIN; + return DYNAMIC_GAIN; case DAQ_FRCE_GAIN_STG_1_VAL: return FORCE_SWITCH_G1; case DAQ_FRCE_GAIN_STG_2_VAL: @@ -1117,10 +1117,7 @@ enum gainMode getGainMode() { } if (retval_cmp_rst) { - if (getSettings() == DYNAMICGAIN) { - return FIX_G0; - } - return FIX_HG0; + return FIX_G0; } LOG(logERROR, ("This gain mode is undefined [DAQ reg: %d]\n", regval)); return -1; @@ -1131,46 +1128,46 @@ void setGainMode(enum gainMode mode) { uint32_t value = bus_r(addr); switch (mode) { - case DYNAMICGAIN: - value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK); + case DYNAMIC_GAIN: + value &= ~(DAQ_GAIN_MODE_MASK); bus_w(addr, value); - LOG(logINFO, ("Set gain mode - Normal Gain Mode [DAQ Reg:0x%x]\n", - bus_r(DAQ_REG))); + LOG(logINFO, + ("Set gain mode - Dynamic Gain [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); break; case FORCE_SWITCH_G1: - value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK); + value &= ~(DAQ_GAIN_MODE_MASK); value |= DAQ_FRCE_GAIN_STG_1_VAL; bus_w(addr, value); LOG(logINFO, ("Set gain mode - Force Switch G1 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); break; case FORCE_SWITCH_G2: - value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK); + value &= ~(DAQ_GAIN_MODE_MASK); value |= DAQ_FRCE_GAIN_STG_2_VAL; bus_w(addr, value); 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_GAIN_MODE_MASK); 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_GAIN_MODE_MASK); 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; + case FIX_G0: + value &= ~(DAQ_GAIN_MODE_MASK); + value |= DAQ_CMP_RST_MSK; bus_w(addr, value); LOG(logINFO, - ("Set gain mode - Fix G2 [DAQ Reg:0x%x]\n", bus_r(DAQ_REG))); + ("Set gain mode - Fix G0 [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/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index 9182ef65d..dc23238a9 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -97,7 +97,8 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define DEFAULT_DELAY (0) #define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_TIMING_MODE (AUTO_TIMING) -#define DEFAULT_SETTINGS (DYNAMICGAIN) +#define DEFAULT_SETTINGS (GAIN0) +#define DEFAULT_GAINMODE (DYNAMIC_GAIN) #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 eb3887bfb..9bbbe16c3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1561,8 +1561,8 @@ void validate_settings(enum detectorSettings sett) { #ifdef EIGERD case STANDARD: #elif JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: + case GAIN0: + case HIGHGAIN0: #elif GOTTHARDD case DYNAMICGAIN: case HIGHGAIN: @@ -8593,9 +8593,12 @@ int set_gain_mode(int file_des) { // only set if (Server_VerifyLock() == OK) { switch (gainmode) { - case NORMAL_GAIN_MODE: + case DYNAMIC_GAIN: case FORCE_SWITCH_G1: case FORCE_SWITCH_G2: + case FIX_G1: + case FIX_G2: + case FIX_G0: break; default: modeNotImplemented("Gain Mode Index", (int)gainmode); diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 38550100a..1bdb62b73 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -113,7 +113,7 @@ class Detector { /** [Jungfrau][Gotthard][Gotthard2][Mythen3] */ Result getSettings(Positions pos = {}) const; - /** [Jungfrau] DYNAMICGAIN, DYNAMICHG0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN, + /** [Jungfrau] GAIN0, HIGHGAIN0 \n [Gotthard] DYNAMICGAIN, HIGHGAIN, * LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN \n [Gotthard2] DYNAMICGAIN, * FIXGAIN1, FIXGAIN2 \n [Moench] G1_HIGHGAIN, G1_LOWGAIN, * G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN, @@ -1179,9 +1179,9 @@ class Detector { /** [Jungfrau]*/ Result getGainMode(Positions pos = {}) const; - /** [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 + /** [Jungfrau] Options: DYNAMIC_GAIN, 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 */ void setGainMode(const defs::gainMode mode, Positions pos = {}); diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 83988198d..c7ed685a0 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1203,12 +1203,12 @@ class CmdProxy { settings, getSettings, setSettings, sls::StringTo, "[standard, fast, highgain, dynamicgain, lowgain, " - "mediumgain, veryhighgain, dynamichg0, " + "mediumgain, veryhighgain, highgain0, " "fixgain1, fixgain2, forceswitchg1, forceswitchg2, " "verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, " - "g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]" + "g2_lc_hg, g2_lc_lg, g4_hg, g4_lg, gain0]" "\n\t Detector Settings" - "\n\t[Jungfrau] - [dynamicgain | dynamichg0]" + "\n\t[Jungfrau] - [ gain0 | highgain0]" "\n\t[Gotthard] - [dynamicgain | highgain | lowgain | " "mediumgain | veryhighgain]" "\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]" @@ -1877,9 +1877,9 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( gainmode, getGainMode, setGainMode, sls::StringTo, - "[forceswitchg1|forceswitchg2|fixgain1|fixgain2|fixgain0|" - "fixhighgain0]\n\t[Jungfrau] Gain mode.\n\tCAUTION: Do not use " - "fixgain0 and fixhighgain0 blindly, you can damage the detector!!!"); + "[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t[" + "Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 blindly, you can " + "damage the detector!!!"); /* Gotthard Specific */ TIME_GET_COMMAND(exptimel, getExptimeLeft, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 9e5937ea6..413eb3d1c 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -158,8 +158,8 @@ std::vector Detector::getSettingsList() const { defs::HIGHGAIN, defs::DYNAMICGAIN, defs::LOWGAIN, defs::MEDIUMGAIN, defs::VERYHIGHGAIN}; case defs::JUNGFRAU: - return std::vector{defs::DYNAMICGAIN, - defs::DYNAMICHG0}; + return std::vector{defs::GAIN0, + defs::HIGHGAIN0}; case defs::GOTTHARD2: return std::vector{ defs::DYNAMICGAIN, defs::DYNAMICHG0, defs::FIXGAIN1, @@ -1495,9 +1495,8 @@ std::vector Detector::getGainModeList() const { switch (getDetectorType().squash()) { case defs::JUNGFRAU: 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}; + defs::DYNAMIC_GAIN, 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/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index 75b2a78b7..3fddd6f26 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -456,6 +456,11 @@ TEST_CASE("gainmode", "[.cmd]") { proxy.Call("gainmode", {}, -1, GET, oss); REQUIRE(oss.str() == "gainmode forceswitchg1\n"); } + { + std::ostringstream oss; + proxy.Call("gainmode", {"dynamicgain"}, -1, PUT, oss); + REQUIRE(oss.str() == "gainmode dynamicgain\n"); + } { std::ostringstream oss; proxy.Call("gainmode", {"forceswitchg2"}, -1, PUT, oss); @@ -473,8 +478,8 @@ TEST_CASE("gainmode", "[.cmd]") { } { std::ostringstream oss; - proxy.Call("gainmode", {"dynamic"}, -1, PUT, oss); - REQUIRE(oss.str() == "gainmode dynamic\n"); + proxy.Call("gainmode", {"fixg0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gainmode fixg0\n"); } for (int i = 0; i != det.size(); ++i) { det.setGainMode(prev_val[i], {i}); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 9219b26b3..77b70a795 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -150,7 +150,7 @@ TEST_CASE("settings", "[.cmd]") { allSett.push_back("lowgain"); allSett.push_back("mediumgain"); allSett.push_back("veryhighgain"); - allSett.push_back("dynamichg0"); + allSett.push_back("highgain0"); allSett.push_back("fixgain1"); allSett.push_back("fixgain2"); allSett.push_back("verylowgain"); @@ -164,12 +164,13 @@ TEST_CASE("settings", "[.cmd]") { allSett.push_back("g4_lg"); allSett.push_back("forceswitchg1"); allSett.push_back("forceswitchg2"); + allSett.push_back("gain0"); std::vector sett; switch (det_type) { case defs::JUNGFRAU: - sett.push_back("dynamicgain"); - sett.push_back("dynamichg0"); + sett.push_back("gain0"); + sett.push_back("highgain0"); break; case defs::GOTTHARD: sett.push_back("highgain"); diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 872d17c66..c0ae55bb3 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -345,7 +345,7 @@ typedef struct { LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, - DYNAMICHG0, + HIGHGAIN0, FIXGAIN1, FIXGAIN2, VERYLOWGAIN, @@ -357,6 +357,7 @@ typedef struct { G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN, + GAIN0, UNDEFINED = 200, UNINITIALIZED }; @@ -415,13 +416,13 @@ typedef struct { enum vetoAlgorithm { DEFAULT_ALGORITHM }; enum gainMode { - DYNAMICGAIN, + DYNAMIC_GAIN, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0, - FIX_HG0 + FIX_G0 }; #ifdef __cplusplus diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 0f18afd86..a14cfa291 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -170,8 +170,8 @@ std::string ToString(const defs::detectorSettings s) { return std::string("mediumgain"); case defs::VERYHIGHGAIN: return std::string("veryhighgain"); - case defs::DYNAMICHG0: - return std::string("dynamichg0"); + case defs::HIGHGAIN0: + return std::string("highgain0"); case defs::FIXGAIN1: return std::string("fixgain1"); case defs::FIXGAIN2: @@ -194,6 +194,8 @@ std::string ToString(const defs::detectorSettings s) { return std::string("g4_hg"); case defs::G4_LOWGAIN: return std::string("g4_lg"); + case defs::GAIN0: + return std::string("gain0"); case defs::UNDEFINED: return std::string("undefined"); case defs::UNINITIALIZED: @@ -581,7 +583,7 @@ std::string ToString(const defs::vetoAlgorithm s) { std::string ToString(const defs::gainMode s) { switch (s) { - case defs::DYNAMICGAIN: + case defs::DYNAMIC_GAIN: return std::string("dynamicgain"); case defs::FORCE_SWITCH_G1: return std::string("forceswitchg1"); @@ -593,8 +595,6 @@ std::string ToString(const defs::gainMode s) { return std::string("fixg2"); case defs::FIX_G0: return std::string("fixg0"); - case defs::FIX_HG0: - return std::string("fixhg0"); default: return std::string("Unknown"); } @@ -635,8 +635,8 @@ template <> defs::detectorSettings StringTo(const std::string &s) { return defs::MEDIUMGAIN; if (s == "veryhighgain") return defs::VERYHIGHGAIN; - if (s == "dynamichg0") - return defs::DYNAMICHG0; + if (s == "highgain0") + return defs::HIGHGAIN0; if (s == "fixgain1") return defs::FIXGAIN1; if (s == "fixgain2") @@ -657,6 +657,8 @@ template <> defs::detectorSettings StringTo(const std::string &s) { return defs::G2_LOWCAP_LOWGAIN; if (s == "g4_hg") return defs::G4_HIGHGAIN; + if (s == "gain0") + return defs::GAIN0; if (s == "g4_lg") return defs::G4_LOWGAIN; throw sls::RuntimeError("Unknown setting " + s); @@ -985,7 +987,7 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) { template <> defs::gainMode StringTo(const std::string &s) { if (s == "dynamicgain") - return defs::DYNAMICGAIN; + return defs::DYNAMIC_GAIN; if (s == "forceswitchg1") return defs::FORCE_SWITCH_G1; if (s == "forceswitchg2") @@ -996,8 +998,6 @@ template <> defs::gainMode StringTo(const std::string &s) { return defs::FIX_G2; if (s == "fixg0") return defs::FIX_G0; - if (s == "fixhg0") - return defs::FIX_HG0; throw sls::RuntimeError("Unknown gain mode " + s); }