diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index ecb56b749..998be1230 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -883,18 +883,21 @@ enum detectorSettings setSettings(enum detectorSettings sett) { if (sett == UNINITIALIZED) return thisSettings; + int *specialDacValues[] = 0; // set settings switch (sett) { case DYNAMICGAIN: bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); LOG(logINFO, ("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); + specialDacValues = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS; break; case DYNAMICHG0: bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL); LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); + specialDacValues = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS; break; /* case FIXGAIN1: @@ -930,6 +933,17 @@ enum detectorSettings setSettings(enum detectorSettings sett) { thisSettings = sett; + // set special dacs to defined values + int *specialDacs[] = {SPECIALDACINDEX}; + for (int i = 0; i < NSPECIALDACS; ++i) { + setDAC(specialDacs[i], specialDacValues[i], 0); + } + + // if chip 1.1, and power chip on, configure chip + if (getChipVersion() == 11 && powerChip(-1)) { + configureChip(); + } + return getSettings(); } diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index d7efd4fbb..5f2d2d895 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -63,9 +63,10 @@ enum DACINDEX { 420 /* J_VREF_COMP */ \ }; -#define NSPECIALDACS (3) -#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP}; -#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {}; +#define NSPECIALDACS (3) +#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP}; +#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {1000, 500, 400}; +#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS {1500, 550, 450}; enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G }; enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 1ef36a614..4b0350a91 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1201,8 +1201,7 @@ class CmdProxy { "verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, " "g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]" "\n\t Detector Settings" - "\n\t[Jungfrau] - [dynamicgain | dynamichg0 | fixgain1 | " - "fixgain2 | forceswitchg1 | forceswitchg2]" + "\n\t[Jungfrau] - [dynamicgain | dynamichg0]" "\n\t[Gotthard] - [dynamicgain | highgain | lowgain | " "mediumgain | veryhighgain]" "\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]" diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index b0cf8446f..984a3fd51 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -142,15 +142,34 @@ TEST_CASE("settings", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); + std::vector allSett; + allSett.push_back("standard"); + allSett.push_back("fast"); + allSett.push_back("highgain"); + allSett.push_back("dynamicgain"); + allSett.push_back("lowgain"); + allSett.push_back("mediumgain"); + allSett.push_back("veryhighgain"); + allSett.push_back("dynamichg0"); + allSett.push_back("fixgain1"); + allSett.push_back("fixgain2"); + allSett.push_back("verylowgain"); + allSett.push_back("g1_hg"); + allSett.push_back("g1_lg"); + allSett.push_back("g2_hc_hg"); + allSett.push_back("g2_hc_lg"); + allSett.push_back("g2_lc_hg"); + allSett.push_back("g2_lc_lg"); + allSett.push_back("g4_hg"); + allSett.push_back("g4_lg"); + allSett.push_back("forceswitchg1"); + allSett.push_back("forceswitchg2"); + std::vector sett; switch (det_type) { case defs::JUNGFRAU: sett.push_back("dynamicgain"); sett.push_back("dynamichg0"); - sett.push_back("fixgain1"); - sett.push_back("fixgain2"); - sett.push_back("forceswitchg1"); - sett.push_back("forceswitchg2"); break; case defs::GOTTHARD: sett.push_back("highgain"); @@ -203,10 +222,9 @@ TEST_CASE("settings", "[.cmd]") { REQUIRE(oss.str() == "settings " + it + "\n"); } } - for (int i = 0; i != det.size(); ++i) { - if (prev_val[i] != defs::UNDEFINED && - prev_val[i] != defs::UNINITIALIZED) { - det.setSettings(prev_val[i], {i}); + for (auto &it : allSett) { + if (std::find(sett.begin(), sett.end(), it) == sett.end()) { + REQUIRE_THROWS(proxy.Call("settings", {it}, -1, PUT)); } } }