jungfrau: gainmode

This commit is contained in:
maliakal_d 2021-08-02 12:44:57 +02:00
parent 526aa3273e
commit 9ed3a294ce
20 changed files with 298 additions and 16 deletions

View File

@ -156,4 +156,28 @@ def test_period(virtual_jf_detectors):
d.period = t d.period = t
assert d.period == 10e-6 assert d.period == 10e-6
def test_gainmode(virtual_jf_detectors):
d = ExperimentalDetector()
assert d.gainMode == gainMode.NORMAL_GAIN_MODE
gain_list = [
gainMode.NORMAL_GAIN_MODE,
gainMode.FORCE_SWITCH_G1,
gainMode.FORCE_SWITCH_G2,
]
# Set all viable gain for Jungfrau to make sure nothing is crashing
for gain in gain_list:
d.gainMode = gain
assert d.gainMode == gain
d.setGainMode(gainMode.FORCE_SWITCH_G1, [1])
assert d.gainMode == [
gainMode.NORMAL_GAIN_MODE,
gainMode.FORCE_SWITCH_G1,
gainMode.FORCE_SWITCH_G2,
]
d.gainMode = gainMode.FORCE_SWITCH_G1
assert d.gainMode == gainMode.FORCE_SWITCH_G1

View File

@ -2165,6 +2165,26 @@ class Detector(CppDetectorApi):
def selinterface(self, i): def selinterface(self, i):
ut.set_using_dict(self.selectUDPInterface, i) ut.set_using_dict(self.selectUDPInterface, i)
@property
def gainmodelist(self):
"""List of gainmode implemented for this detector."""
return self.getGainModeList()
@property
def gainmode(self):
"""
[Jungfrau] Detector gain mode. Enum: gainMode
Note
-----
[Jungfrau] NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2
"""
return element_if_equal(self.getGainMode())
@gainmode.setter
def gainmode(self, value):
self.setGainMode(value)
""" """
---------------------------<<<Gotthard2 specific>>>--------------------------- ---------------------------<<<Gotthard2 specific>>>---------------------------
""" """

View File

@ -1002,6 +1002,17 @@ void init_det(py::module &m) {
(void (Detector::*)(sls::ns, sls::Positions)) & (void (Detector::*)(sls::ns, sls::Positions)) &
Detector::setStorageCellDelay, Detector::setStorageCellDelay,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("getGainModeList",
(std::vector<defs::gainMode>(Detector::*)() const) &
Detector::getGainModeList)
.def("getGainMode",
(Result<defs::gainMode>(Detector::*)(sls::Positions) const) &
Detector::getGainMode,
py::arg() = Positions{})
.def("setGainMode",
(void (Detector::*)(defs::gainMode, sls::Positions)) &
Detector::setGainMode,
py::arg(), py::arg() = Positions{})
.def("getROI", .def("getROI",
(Result<defs::ROI>(Detector::*)(sls::Positions) const) & (Result<defs::ROI>(Detector::*)(sls::Positions) const) &
Detector::getROI, Detector::getROI,

View File

@ -305,4 +305,10 @@ void init_enums(py::module &m) {
.value("DEFAULT_ALGORITHM", .value("DEFAULT_ALGORITHM",
slsDetectorDefs::vetoAlgorithm::DEFAULT_ALGORITHM) slsDetectorDefs::vetoAlgorithm::DEFAULT_ALGORITHM)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::gainMode>(Defs, "gainMode")
.value("NORMAL_GAIN_MODE", slsDetectorDefs::gainMode::NORMAL_GAIN_MODE)
.value("FORCE_SWITCH_G1", slsDetectorDefs::gainMode::FORCE_SWITCH_G1)
.value("FORCE_SWITCH_G2", slsDetectorDefs::gainMode::FORCE_SWITCH_G2)
.export_values();
} }

View File

@ -308,11 +308,9 @@
/** DAQ Register */ /** DAQ Register */
#define DAQ_REG (0x5D << MEM_MAP_SHIFT) #define DAQ_REG (0x5D << MEM_MAP_SHIFT)
#define DAQ_SETTINGS_MSK (DAQ_HIGH_GAIN_MSK | DAQ_FIX_GAIN_MSK | DAQ_FRCE_SWTCH_GAIN_MSK) // dynamic gain (default)
#define DAQ_HIGH_GAIN_OFST (0) #define DAQ_HIGH_GAIN_OFST (0)
#define DAQ_HIGH_GAIN_MSK (0x00000001 << DAQ_HIGH_GAIN_OFST) #define DAQ_HIGH_GAIN_MSK (0x00000001 << DAQ_HIGH_GAIN_OFST)
#define DAQ_FIX_GAIN_DYNMC_VAL ((0x0 << DAQ_HIGH_GAIN_OFST) & DAQ_HIGH_GAIN_MSK)
#define DAQ_FIX_GAIN_HIGHGAIN_VAL ((0x1 << DAQ_HIGH_GAIN_OFST) & DAQ_HIGH_GAIN_MSK)
#define DAQ_FIX_GAIN_OFST (1) #define DAQ_FIX_GAIN_OFST (1)
#define DAQ_FIX_GAIN_MSK (0x00000003 << DAQ_FIX_GAIN_OFST) #define DAQ_FIX_GAIN_MSK (0x00000003 << DAQ_FIX_GAIN_OFST)
#define DAQ_FIX_GAIN_STG_1_VAL ((0x1 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK) #define DAQ_FIX_GAIN_STG_1_VAL ((0x1 << DAQ_FIX_GAIN_OFST) & DAQ_FIX_GAIN_MSK)
@ -323,6 +321,7 @@
#define DAQ_STRG_CELL_SLCT_MSK (0x0000000F << DAQ_STRG_CELL_SLCT_OFST) #define DAQ_STRG_CELL_SLCT_MSK (0x0000000F << DAQ_STRG_CELL_SLCT_OFST)
#define DAQ_FRCE_SWTCH_GAIN_OFST (12) #define DAQ_FRCE_SWTCH_GAIN_OFST (12)
#define DAQ_FRCE_SWTCH_GAIN_MSK (0x00000003 << DAQ_FRCE_SWTCH_GAIN_OFST) #define DAQ_FRCE_SWTCH_GAIN_MSK (0x00000003 << DAQ_FRCE_SWTCH_GAIN_OFST)
#define DAQ_FRCE_GAIN_STG_0_VAL ((0x0 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_FRCE_GAIN_STG_1_VAL ((0x1 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK) #define DAQ_FRCE_GAIN_STG_1_VAL ((0x1 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_FRCE_GAIN_STG_2_VAL ((0x3 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK) #define DAQ_FRCE_GAIN_STG_2_VAL ((0x3 << DAQ_FRCE_SWTCH_GAIN_OFST) & DAQ_FRCE_SWTCH_GAIN_MSK)
#define DAQ_ELCTRN_CLLCTN_MDE_OFST (14) #define DAQ_ELCTRN_CLLCTN_MDE_OFST (14)

View File

@ -1036,21 +1036,19 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
// set settings // set settings
switch (sett) { switch (sett) {
case DYNAMICGAIN: case DYNAMICGAIN:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_HIGH_GAIN_MSK);
LOG(logINFO, LOG(logINFO,
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); ("Set settings - Dyanmic Gain [DAQ Reg:0x%x]\n", bus_r(DAQ_REG)));
dacVals = defaultDacValue_G0; dacVals = defaultDacValue_G0;
break; break;
case DYNAMICHG0: case DYNAMICHG0:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_HIGH_GAIN_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",
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
bus_r(DAQ_REG))); bus_r(DAQ_REG)));
dacVals = defaultDacValue_HG0; dacVals = defaultDacValue_HG0;
break; break;
default: default:
LOG(logERROR, LOG(logERROR, ("This settings %d is not defined\n", (int)sett));
("This settings is not defined for this detector %d\n", (int)sett));
return -1; return -1;
} }
@ -1107,6 +1105,53 @@ void validateSettings() {
enum detectorSettings getSettings() { return thisSettings; } enum detectorSettings getSettings() { return thisSettings; }
enum gainMode getGainMode() {
uint32_t retval = bus_r(DAQ_REG) & DAQ_FRCE_SWTCH_GAIN_MSK;
switch (retval) {
case DAQ_FRCE_GAIN_STG_0_VAL:
return NORMAL_GAIN_MODE;
case DAQ_FRCE_GAIN_STG_1_VAL:
return FORCE_SWITCH_G1;
case DAQ_FRCE_GAIN_STG_2_VAL:
return FORCE_SWITCH_G2;
default:
LOG(logERROR, ("This gain mode %d is not defined [DAQ reg: %d]\n",
(retval << DAQ_FRCE_SWTCH_GAIN_OFST), retval));
return -1;
}
}
void setGainMode(enum gainMode mode) {
uint32_t addr = DAQ_REG;
uint32_t value = bus_r(addr);
switch (mode) {
case NORMAL_GAIN_MODE:
value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK);
bus_w(addr, value);
LOG(logINFO, ("Set gain mode - Normal Gain Mode [DAQ Reg:0x%x]\n",
bus_r(DAQ_REG)));
break;
case FORCE_SWITCH_G1:
value &= ~(DAQ_FRCE_SWTCH_GAIN_MSK);
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_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;
default:
LOG(logERROR, ("This gain mode %d is not defined\n", (int)mode));
}
}
/* parameters - dac, adc, hv */ /* parameters - dac, adc, hv */
void setDAC(enum DACINDEX ind, int val, int mV) { void setDAC(enum DACINDEX ind, int val, int mV) {
if (val < 0) if (val < 0)

View File

@ -65,7 +65,7 @@ enum DACINDEX {
#define NUMSETTINGS (2) #define NUMSETTINGS (2)
#define NSPECIALDACS (3) #define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP}; #define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \ #define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1000, 500, 400 } { 1000, 500, 400 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \ #define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \

View File

@ -301,6 +301,10 @@ enum detectorSettings setSettings(enum detectorSettings sett);
void validateSettings(); void validateSettings();
#endif #endif
enum detectorSettings getSettings(); enum detectorSettings getSettings();
#ifdef JUNGFRAUD
enum gainMode getGainMode();
void setGainMode(enum gainMode mode);
#endif
// parameters - threshold // parameters - threshold
#ifdef EIGERD #ifdef EIGERD

View File

@ -257,3 +257,5 @@ int set_veto_algorithm(int);
int get_chip_version(int); int get_chip_version(int);
int get_default_dac(int); int get_default_dac(int);
int set_default_dac(int); int set_default_dac(int);
int get_gain_mode(int);
int set_gain_mode(int);

View File

@ -382,6 +382,8 @@ void function_table() {
flist[F_GET_CHIP_VERSION] = &get_chip_version; flist[F_GET_CHIP_VERSION] = &get_chip_version;
flist[F_GET_DEFAULT_DAC] = &get_default_dac; flist[F_GET_DEFAULT_DAC] = &get_default_dac;
flist[F_SET_DEFAULT_DAC] = &set_default_dac; flist[F_SET_DEFAULT_DAC] = &set_default_dac;
flist[F_GET_GAIN_MODE] = &get_gain_mode;
flist[F_SET_GAIN_MODE] = &set_gain_mode;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -8551,4 +8553,63 @@ int set_default_dac(int file_des) {
} }
#endif #endif
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
int get_gain_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum gainMode retval = NORMAL_GAIN_MODE;
LOG(logDEBUG1, ("Getting gain mode\n"));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// get only
retval = getGainMode();
LOG(logDEBUG1, ("gainmode retval: %u\n", retval));
if ((int)retval == -1) {
ret = FAIL;
strcpy(mess, "Could not get gain mode.\n");
LOG(logERROR, (mess));
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_gain_mode(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
enum gainMode gainmode = arg;
LOG(logINFO, ("Setting gain mode %d\n", (int)gainmode));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (gainmode) {
case NORMAL_GAIN_MODE:
case FORCE_SWITCH_G1:
case FORCE_SWITCH_G2:
break;
default:
modeNotImplemented("Gain Mode Index", (int)gainmode);
break;
}
setGainMode(gainmode);
int retval = getGainMode();
LOG(logDEBUG1, ("gainmode retval: %u\n", retval));
if (retval == -1) {
ret = FAIL;
strcpy(mess, "Could not get gain mode.\n");
LOG(logERROR, (mess));
}
validate(&ret, mess, arg, retval, "set gain mode", DEC);
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -1164,6 +1164,17 @@ class Detector {
* Only applicable for chipv1.0. * Only applicable for chipv1.0.
*/ */
void setStorageCellDelay(ns value, Positions pos = {}); void setStorageCellDelay(ns value, Positions pos = {});
/** list of possible gainmode */
std::vector<defs::gainMode> getGainModeList() const;
/** [Jungfrau]*/
Result<defs::gainMode> getGainMode(Positions pos = {}) const;
/** [Jungfrau] Options: NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2\n
*/
void setGainMode(const defs::gainMode mode, Positions pos = {});
///@{ ///@{
/** @name Gotthard Specific */ /** @name Gotthard Specific */

View File

@ -717,8 +717,6 @@ class CmdProxy {
{"resmat", "partialreset"}, {"resmat", "partialreset"},
/* Jungfrau Specific */ /* Jungfrau Specific */
{"mode", "mode"},
/* Gotthard Specific */ /* Gotthard Specific */
/* Gotthard2 Specific */ /* Gotthard2 Specific */
/* Mythen3 Specific */ /* Mythen3 Specific */
@ -931,6 +929,7 @@ class CmdProxy {
{"storagecells", &CmdProxy::storagecells}, {"storagecells", &CmdProxy::storagecells},
{"storagecell_start", &CmdProxy::storagecell_start}, {"storagecell_start", &CmdProxy::storagecell_start},
{"storagecell_delay", &CmdProxy::storagecell_delay}, {"storagecell_delay", &CmdProxy::storagecell_delay},
{"gainmode", &CmdProxy::gainmode},
/* Gotthard Specific */ /* Gotthard Specific */
{"roi", &CmdProxy::ROI}, {"roi", &CmdProxy::ROI},
@ -1866,6 +1865,11 @@ class CmdProxy {
"Additional time delay between 2 consecutive exposures in burst mode " "Additional time delay between 2 consecutive exposures in burst mode "
"(resolution of 25ns). Only applicable for chipv1.0. For advanced users only."); "(resolution of 25ns). Only applicable for chipv1.0. For advanced users only.");
INTEGER_COMMAND_VEC_ID(
gainmode, getGainMode, setGainMode,
sls::StringTo<slsDetectorDefs::gainMode>,
"[forceswitchg1, forceswitchg2]\n\t[Jungfrau] Gain mode.");
/* Gotthard Specific */ /* Gotthard Specific */
TIME_GET_COMMAND(exptimel, getExptimeLeft, TIME_GET_COMMAND(exptimel, getExptimeLeft,
"[(optional unit) ns|us|ms|s]\n\t[Gotthard] Exposure time " "[(optional unit) ns|us|ms|s]\n\t[Gotthard] Exposure time "

View File

@ -1483,6 +1483,26 @@ void Detector::setStorageCellDelay(ns value, Positions pos) {
pimpl->Parallel(&Module::setStorageCellDelay, pos, value.count()); pimpl->Parallel(&Module::setStorageCellDelay, pos, value.count());
} }
std::vector<defs::gainMode> Detector::getGainModeList() const {
switch (getDetectorType().squash()) {
case defs::JUNGFRAU:
return std::vector<defs::gainMode>{defs::NORMAL_GAIN_MODE,
defs::FORCE_SWITCH_G1,
defs::FORCE_SWITCH_G2};
break;
default:
throw RuntimeError("Gain mode is not implemented for this detector.");
}
}
Result<defs::gainMode> Detector::getGainMode(Positions pos) const {
return pimpl->Parallel(&Module::getGainMode, pos);
}
void Detector::setGainMode(const defs::gainMode mode, Positions pos) {
pimpl->Parallel(&Module::setGainMode, pos, mode);
}
// Gotthard Specific // Gotthard Specific
Result<defs::ROI> Detector::getROI(Positions pos) const { Result<defs::ROI> Detector::getROI(Positions pos) const {

View File

@ -1601,6 +1601,14 @@ void Module::setStorageCellDelay(int64_t value) {
sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr); sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr);
} }
slsDetectorDefs::gainMode Module::getGainMode() const {
return sendToDetector<gainMode>(F_GET_GAIN_MODE);
}
void Module::setGainMode(const slsDetectorDefs::gainMode mode) {
sendToDetector(F_SET_GAIN_MODE, mode, nullptr);
}
// Gotthard Specific // Gotthard Specific
slsDetectorDefs::ROI Module::getROI() const { slsDetectorDefs::ROI Module::getROI() const {

View File

@ -369,6 +369,8 @@ class Module : public virtual slsDetectorDefs {
void setStorageCellStart(int pos); void setStorageCellStart(int pos);
int64_t getStorageCellDelay() const; int64_t getStorageCellDelay() const;
void setStorageCellDelay(int64_t value); void setStorageCellDelay(int64_t value);
gainMode getGainMode() const;
void setGainMode(const gainMode mode);
/************************************************** /**************************************************
* * * *

View File

@ -408,4 +408,38 @@ TEST_CASE("storagecell_delay", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("storagecell_delay", {"0"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("storagecell_delay", {"0"}, -1, PUT));
} }
} }
TEST_CASE("gainmode", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
auto prev_val = det.getGainMode();
{
std::ostringstream oss;
proxy.Call("gainmode", {"forceswitchg1"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode forceswitchg1\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {}, -1, GET, oss);
REQUIRE(oss.str() == "gainmode forceswitchg1\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {"forceswitchg2"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode forceswitchg2\n");
}
{
std::ostringstream oss;
proxy.Call("gainmode", {"normal"}, -1, PUT, oss);
REQUIRE(oss.str() == "gainmode normal\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setGainMode(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("gainmode", {}, -1, GET));
}
}

View File

@ -40,6 +40,7 @@ std::string ToString(const defs::M3_GainCaps s);
std::string ToString(const defs::portPosition s); std::string ToString(const defs::portPosition s);
std::string ToString(const defs::ethernetInterface s); std::string ToString(const defs::ethernetInterface s);
std::string ToString(const defs::vetoAlgorithm s); std::string ToString(const defs::vetoAlgorithm s);
std::string ToString(const defs::gainMode s);
std::string ToString(const slsDetectorDefs::xy &coord); std::string ToString(const slsDetectorDefs::xy &coord);
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord); std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
@ -305,6 +306,7 @@ template <> defs::M3_GainCaps StringTo(const std::string &s);
template <> defs::portPosition StringTo(const std::string &s); template <> defs::portPosition StringTo(const std::string &s);
template <> defs::ethernetInterface StringTo(const std::string &s); template <> defs::ethernetInterface StringTo(const std::string &s);
template <> defs::vetoAlgorithm StringTo(const std::string &s); template <> defs::vetoAlgorithm StringTo(const std::string &s);
template <> defs::gainMode StringTo(const std::string &s);
template <> uint32_t StringTo(const std::string &s); template <> uint32_t StringTo(const std::string &s);
template <> uint64_t StringTo(const std::string &s); template <> uint64_t StringTo(const std::string &s);

View File

@ -414,6 +414,8 @@ typedef struct {
enum vetoAlgorithm { DEFAULT_ALGORITHM }; enum vetoAlgorithm { DEFAULT_ALGORITHM };
enum gainMode { NORMAL_GAIN_MODE, FORCE_SWITCH_G1, FORCE_SWITCH_G2 };
#ifdef __cplusplus #ifdef __cplusplus
/** scan structure */ /** scan structure */

View File

@ -233,6 +233,8 @@ enum detFuncs {
F_GET_CHIP_VERSION, F_GET_CHIP_VERSION,
F_GET_DEFAULT_DAC, F_GET_DEFAULT_DAC,
F_SET_DEFAULT_DAC, F_SET_DEFAULT_DAC,
F_GET_GAIN_MODE,
F_SET_GAIN_MODE,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -572,6 +574,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_CHIP_VERSION: return "F_GET_CHIP_VERSION"; case F_GET_CHIP_VERSION: return "F_GET_CHIP_VERSION";
case F_GET_DEFAULT_DAC: return "F_GET_DEFAULT_DAC"; case F_GET_DEFAULT_DAC: return "F_GET_DEFAULT_DAC";
case F_SET_DEFAULT_DAC: return "F_SET_DEFAULT_DAC"; case F_SET_DEFAULT_DAC: return "F_SET_DEFAULT_DAC";
case F_GET_GAIN_MODE: return "F_GET_GAIN_MODE";
case F_SET_GAIN_MODE: return "F_SET_GAIN_MODE";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";

View File

@ -579,6 +579,19 @@ 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::FORCE_SWITCH_G1:
return std::string("forceswitchg1");
case defs::FORCE_SWITCH_G2:
return std::string("forceswitchg2");
default:
return std::string("Unknown");
}
}
const std::string &ToString(const std::string &s) { return s; } const std::string &ToString(const std::string &s) { return s; }
template <> defs::detectorType StringTo(const std::string &s) { template <> defs::detectorType StringTo(const std::string &s) {
@ -962,6 +975,16 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown veto algorithm " + s); throw sls::RuntimeError("Unknown veto algorithm " + s);
} }
template <> defs::gainMode StringTo(const std::string &s) {
if (s == "normal")
return defs::NORMAL_GAIN_MODE;
if (s == "forceswitchg1")
return defs::FORCE_SWITCH_G1;
if (s == "forceswitchg2")
return defs::FORCE_SWITCH_G2;
throw sls::RuntimeError("Unknown gain mode " + s);
}
template <> uint32_t StringTo(const std::string &s) { template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10; int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base); return std::stoul(s, nullptr, base);