From 15f4dd97b5778ac5e397665541ae4491e5b74675 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 2 Aug 2021 17:10:46 +0200 Subject: [PATCH 1/3] wip, jungfrau: auto comp disable has time for 1.1 chip --- slsDetectorSoftware/src/CmdProxy.cpp | 31 ++++++++++++++++++++++++++++ slsDetectorSoftware/src/CmdProxy.h | 13 ++---------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 3f8b93659..190cfde8a 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1729,6 +1729,37 @@ std::string CmdProxy::TemperatureEvent(int action) { return os.str(); } +std::string AutoComparatorDisable(const int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == slsDetectorDefs::HELP_ACTION) + os << "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, " + "the on-chip gain switching is active during the entire " + "exposure.This mode disables the on - chip gain switching " + "comparator automatically after 93.75% of exposure time (only " + "for longer than 100us). \n\tDefault is 0 or this mode " + "disabled(comparator enabled throughout). 1 enables mode. 0 " + "disables mode." + << '\n'; + else if (action == slsDetectorDefs::GET_ACTION) { + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto t = det->GETFCN(std::vector{det_id}); + os << OutString(t) << '\n'; + } else if (action == slsDetectorDefs::PUT_ACTION) { + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + auto val = CONV(args[0]); + det->SETFCN(val, std::vector{det_id}); + os << args.front() << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + /* Gotthard Specific */ std::string CmdProxy::ROI(int action) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 9ada9ea09..47f5cc7a1 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -925,7 +925,7 @@ class CmdProxy { {"temp_threshold", &CmdProxy::temp_threshold}, {"temp_control", &CmdProxy::temp_control}, {"temp_event", &CmdProxy::TemperatureEvent}, - {"auto_comp_disable", &CmdProxy::auto_comp_disable}, + {"auto_comp_disable", &CmdProxy::AutoComparatorDisable}, {"storagecells", &CmdProxy::storagecells}, {"storagecell_start", &CmdProxy::storagecell_start}, {"storagecell_delay", &CmdProxy::storagecell_delay}, @@ -1123,6 +1123,7 @@ class CmdProxy { std::string DataStream(int action); /* Jungfrau Specific */ std::string TemperatureEvent(int action); + std::string AutoComparatorDisable(int action); /* Gotthard Specific */ std::string ROI(int action); std::string ClearROI(int action); @@ -1836,16 +1837,6 @@ class CmdProxy { "to be less than threshold temperature and temperature event has to be " "cleared."); - INTEGER_COMMAND_VEC_ID( - auto_comp_disable, getAutoCompDisable, setAutoCompDisable, - StringTo, - "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the " - "on-chip gain switching is active during the entire exposure.This mode " - "disables the on - chip gain switching comparator automatically after " - "93.75% of exposure time (only for longer than 100us). \n\tDefault is " - "0 or this mode disabled(comparator enabled throughout). 1 enables " - "mode. 0 disables mode. "); - INTEGER_COMMAND_SET_NOID_GET_ID( storagecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, StringTo, From 9c4ecf050614957d165f13a84faf2075ac663b65 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 3 Aug 2021 13:12:58 +0200 Subject: [PATCH 2/3] jungfrau: comp disable time --- python/slsdet/detector.py | 27 ++++++++- python/src/detector.cpp | 8 +++ .../slsDetectorFunctionList.c | 26 ++++++++ .../include/slsDetectorFunctionList.h | 2 + .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 60 +++++++++++++++++++ slsDetectorSoftware/include/sls/Detector.h | 20 +++++-- slsDetectorSoftware/src/CmdProxy.cpp | 31 ---------- slsDetectorSoftware/src/CmdProxy.h | 22 ++++++- slsDetectorSoftware/src/Detector.cpp | 8 +++ slsDetectorSoftware/src/Module.cpp | 8 +++ slsDetectorSoftware/src/Module.h | 2 + .../tests/test-CmdProxy-jungfrau.cpp | 30 ++++++++++ .../include/sls/sls_detector_funcs.h | 4 ++ 14 files changed, 211 insertions(+), 41 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 819522a56..9f6d60a1d 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2013,7 +2013,7 @@ class Detector(CppDetectorApi): Note ----- - By default, the on-chip gain switching is active during the entire exposure. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us).\n + By default, the on-chip gain switching is active during the entire exposure. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). The % is only for chipv1.0, the duration can be set for chipv1.1.\n Default is 0 or this mode disabled (comparator enabled throughout). 1 enables mode. 0 disables mode. """ return self.getAutoCompDisable() @@ -2022,6 +2022,31 @@ class Detector(CppDetectorApi): def auto_comp_disable(self, value): ut.set_using_dict(self.setAutoCompDisable, value) + @property + @element + def comp_disable_time(self): + """[Jungfrau] Time before end of exposure when comparator is disabled. + + Note + ----- + It is only possible for chipv1.1. + :getter: always returns in seconds. To get in datetime.delta, use getComparatorDisableTime + + Example + ----------- + >>> d.comp_disable_time = 1.05 + >>> d.comp_disable_time = datetime.timedelta(minutes = 3, seconds = 1.23) + >>> d.comp_disable_time + 181.23 + >>> d.getComparatorDisableTime() + [datetime.timedelta(seconds=181, microseconds=230000)] + """ + return ut.reduce_time(self.getComparatorDisableTime()) + + @comp_disable_time.setter + def comp_disable_time(self, value): + ut.set_time_using_dict(self.setComparatorDisableTime, value) + @property @element diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 4b3200ce0..d751d5e18 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -978,6 +978,14 @@ void init_det(py::module &m) { (void (Detector::*)(bool, sls::Positions)) & Detector::setAutoCompDisable, py::arg(), py::arg() = Positions{}) + .def("getComparatorDisableTime", + (Result(Detector::*)(sls::Positions) const) & + Detector::getComparatorDisableTime, + py::arg() = Positions{}) + .def("setComparatorDisableTime", + (void (Detector::*)(sls::ns, sls::Positions)) & + Detector::setComparatorDisableTime, + py::arg(), py::arg() = Positions{}) .def("getNumberOfAdditionalStorageCells", (Result(Detector::*)(sls::Positions) const) & Detector::getNumberOfAdditionalStorageCells, diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 6c92644f8..d03e8a9f5 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1662,6 +1662,32 @@ int autoCompDisable(int on) { EXT_DAQ_CTRL_CMP_LGC_ENBL_OFST); } +int setComparatorDisableTime(int64_t val) { + if (getChipVersion() != 11) { + return FAIL; + } + if (val < 0) { + LOG(logERROR, + ("Invalid comp disable time: %lld ns\n", (long long int)val)); + return FAIL; + } + LOG(logINFO, ("Setting comp disable time %lld ns\n", (long long int)val)); + val *= (1E-3 * CLK_RUN); + bus_w(COMP_DSBLE_TIME_REG, val); + + // validate for tolerance + int64_t retval = getComparatorDisableTime(); + val /= (1E-3 * CLK_RUN); + if (val != retval) { + return FAIL; + } + return OK; +} + +int64_t getComparatorDisableTime() { + return bus_r(COMP_DSBLE_TIME_REG) / (1E-3 * CLK_RUN); +} + void configureASICTimer() { LOG(logINFO, ("Configuring ASIC Timer\n")); bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_PRCHRG_TMR_MSK) | diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index b971e56ad..de06ff9ff 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -450,6 +450,8 @@ int powerChip(int on); int isChipConfigured(); void configureChip(); int autoCompDisable(int on); +int setComparatorDisableTime(int64_t val); +int64_t getComparatorDisableTime(); void configureASICTimer(); int setClockDivider(enum CLKINDEX ind, int val); int getClockDivider(enum CLKINDEX ind); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index d1f0aa6e6..594de8402 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -258,4 +258,6 @@ int get_chip_version(int); int get_default_dac(int); int set_default_dac(int); int get_gain_mode(int); -int set_gain_mode(int); \ No newline at end of file +int set_gain_mode(int); +int get_comp_disable_time(int); +int set_comp_disable_time(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 35668d4c9..eb3887bfb 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -384,6 +384,8 @@ void function_table() { flist[F_SET_DEFAULT_DAC] = &set_default_dac; flist[F_GET_GAIN_MODE] = &get_gain_mode; flist[F_SET_GAIN_MODE] = &set_gain_mode; + flist[F_GET_COMP_DISABLE_TIME] = &get_comp_disable_time; + flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8613,3 +8615,61 @@ int set_gain_mode(int file_des) { #endif return Server_SendResult(file_des, INT32, NULL, 0); } + +int get_comp_disable_time(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t retval = -1; +#ifndef JUNGFRAUD + functionNotImplemented(); +#else + // get only + if (getChipVersion() != 11) { + ret = FAIL; + strcpy(mess, + "Cannot get comparator disable time. Only valid for chipv1.1\n"); + LOG(logERROR, (mess)); + } else { + retval = getComparatorDisableTime(); + LOG(logDEBUG1, + ("retval comp disable time %lld ns\n", (long long int)retval)); + } +#endif + return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); +} + +int set_comp_disable_time(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int64_t arg = -1; + if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0) + return printSocketReadError(); + LOG(logDEBUG1, ("Setting comp disable time %lld ns\n", (long long int)arg)); + +#ifndef JUNGFRAUD + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + if (getChipVersion() != 11) { + ret = FAIL; + strcpy(mess, "Cannot get comparator disable time. Only valid for " + "chipv1.1\n"); + LOG(logERROR, (mess)); + } else { + ret = setComparatorDisableTime(arg); + int64_t retval = getComparatorDisableTime(); + LOG(logDEBUG1, ("retval get comp disable time %lld ns\n", + (long long int)retval)); + if (ret == FAIL) { + sprintf(mess, + "Could not set comp disable time. Set %lld ns, read " + "%lld ns.\n", + (long long int)arg, (long long int)retval); + LOG(logERROR, (mess)); + } + } + } +#endif + return Server_SendResult(file_des, INT64, NULL, 0); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index dc4f6c6ba..08eaa8bc8 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1131,15 +1131,23 @@ class Detector { /** [Jungfrau] Advanced * //TODO naming - * By default, the on-chip gain switching is active during the entire - * exposure. This mode disables the on-chip gain switching comparator - * automatically after 93.75% of exposure time (only for longer than - * 100us).\n - * Default is false or this mode disabled(comparator enabled throughout). - * true enables mode. 0 disables mode. + * By default, the on-chip gain switching is active during the + * entire exposure. This mode disables the on-chip gain switching comparator + * automatically after 93.75% of exposure time (only for longer than 100us). + * The % is for chipv1.0. One can set the duration for chipv1.1 using + * setComparatorDisableTime\n Default is false or this mode + * disabled(comparator enabled throughout). true enables mode. 0 disables + * mode. */ void setAutoCompDisable(bool value, Positions pos = {}); + /** [Jungfrau] */ + Result getComparatorDisableTime(Positions pos = {}) const; + + /** [Jungfrau] Time before end of exposure when comparator is disabled. It + * is only possible for chipv1.1.*/ + void setComparatorDisableTime(ns t, Positions pos = {}); + /** [Jungfrau] Advanced TODO naming */ Result getNumberOfAdditionalStorageCells(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 190cfde8a..3f8b93659 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1729,37 +1729,6 @@ std::string CmdProxy::TemperatureEvent(int action) { return os.str(); } -std::string AutoComparatorDisable(const int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == slsDetectorDefs::HELP_ACTION) - os << "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, " - "the on-chip gain switching is active during the entire " - "exposure.This mode disables the on - chip gain switching " - "comparator automatically after 93.75% of exposure time (only " - "for longer than 100us). \n\tDefault is 0 or this mode " - "disabled(comparator enabled throughout). 1 enables mode. 0 " - "disables mode." - << '\n'; - else if (action == slsDetectorDefs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->GETFCN(std::vector{det_id}); - os << OutString(t) << '\n'; - } else if (action == slsDetectorDefs::PUT_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - auto val = CONV(args[0]); - det->SETFCN(val, std::vector{det_id}); - os << args.front() << '\n'; - } else { - throw sls::RuntimeError("Unknown action"); - } - return os.str(); -} - /* Gotthard Specific */ std::string CmdProxy::ROI(int action) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 47f5cc7a1..036f8b972 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -925,7 +925,8 @@ class CmdProxy { {"temp_threshold", &CmdProxy::temp_threshold}, {"temp_control", &CmdProxy::temp_control}, {"temp_event", &CmdProxy::TemperatureEvent}, - {"auto_comp_disable", &CmdProxy::AutoComparatorDisable}, + {"auto_comp_disable", &CmdProxy::auto_comp_disable}, + {"comp_disable_time", &CmdProxy::comp_disable_time}, {"storagecells", &CmdProxy::storagecells}, {"storagecell_start", &CmdProxy::storagecell_start}, {"storagecell_delay", &CmdProxy::storagecell_delay}, @@ -1123,7 +1124,6 @@ class CmdProxy { std::string DataStream(int action); /* Jungfrau Specific */ std::string TemperatureEvent(int action); - std::string AutoComparatorDisable(int action); /* Gotthard Specific */ std::string ROI(int action); std::string ClearROI(int action); @@ -1837,6 +1837,24 @@ class CmdProxy { "to be less than threshold temperature and temperature event has to be " "cleared."); + INTEGER_COMMAND_VEC_ID( + auto_comp_disable, getAutoCompDisable, setAutoCompDisable, + StringTo, + "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the " + "on-chip gain switching is active during the entire exposure.This mode " + "disables the on - chip gain switching comparator automatically after " + "93.75% (only for chipv1.0) of exposure time (only for longer than " + "100us). It is possible to set the duration for chipv1.1 using " + "comp_disable_time command.\n\tDefault is 0 or this mode " + "disabled(comparator enabled throughout). 1 enables mode. 0 disables " + "mode. "); + + TIME_COMMAND(comp_disable_time, getComparatorDisableTime, + setComparatorDisableTime, + "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau] Time " + "before end of exposure when comparator is disabled. It is " + "only possible for chipv1.1."); + INTEGER_COMMAND_SET_NOID_GET_ID( storagecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, StringTo, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index ea889fff2..cd89fec41 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1459,6 +1459,14 @@ void Detector::setAutoCompDisable(bool value, Positions pos) { pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, value); } +Result Detector::getComparatorDisableTime(Positions pos) const { + return pimpl->Parallel(&Module::getComparatorDisableTime, pos); +} + +void Detector::setComparatorDisableTime(ns t, Positions pos) { + pimpl->Parallel(&Module::setComparatorDisableTime, pos, t.count()); +} + Result Detector::getNumberOfAdditionalStorageCells(Positions pos) const { return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index ac9ecc212..cac7590ea 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1577,6 +1577,14 @@ void Module::setAutoComparatorDisableMode(bool val) { sendToDetector(F_AUTO_COMP_DISABLE, static_cast(val)); } +int64_t Module::getComparatorDisableTime() const { + return sendToDetector(F_GET_COMP_DISABLE_TIME); +} + +void Module::setComparatorDisableTime(int64_t value) { + sendToDetector(F_SET_COMP_DISABLE_TIME, value, nullptr); +} + int Module::getNumberOfAdditionalStorageCells() const { return sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index d7f75fef3..6855d91b5 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -363,6 +363,8 @@ class Module : public virtual slsDetectorDefs { void resetTemperatureEvent(); bool getAutoComparatorDisableMode() const; void setAutoComparatorDisableMode(bool val); + int64_t getComparatorDisableTime() const; + void setComparatorDisableTime(int64_t value); int getNumberOfAdditionalStorageCells() const; void setNumberOfAdditionalStorageCells(int value); int getStorageCellStart() const; diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index f894e4105..9a540f3a5 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -283,6 +283,36 @@ TEST_CASE("auto_comp_disable", "[.cmd]") { } } +TEST_CASE("comp_disable_time", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getComparatorDisableTime(); + { + std::ostringstream oss; + proxy.Call("comp_disable_time", {"125ns"}, -1, PUT, oss); + REQUIRE(oss.str() == "comp_disable_time 125ns\n"); + } + { + std::ostringstream oss; + proxy.Call("comp_disable_time", {}, -1, GET, oss); + REQUIRE(oss.str() == "comp_disable_time 125ns\n"); + } + { + std::ostringstream oss; + proxy.Call("comp_disable_time", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "comp_disable_time 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setComparatorDisableTime(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("comp_disable_time", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("comp_disable_time", {"0"}, -1, PUT)); + } +} + TEST_CASE("storagecells", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 0a955cec0..952843f21 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -235,6 +235,8 @@ enum detFuncs { F_SET_DEFAULT_DAC, F_GET_GAIN_MODE, F_SET_GAIN_MODE, + F_GET_COMP_DISABLE_TIME, + F_SET_COMP_DISABLE_TIME, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -576,6 +578,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { 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 F_GET_COMP_DISABLE_TIME: return "F_GET_COMP_DISABLE_TIME"; + case F_SET_COMP_DISABLE_TIME: return "F_SET_COMP_DISABLE_TIME"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; From 9370fd3ab0e727bba65a60bd8106abd73dd95201 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 3 Aug 2021 20:13:25 +0200 Subject: [PATCH 3/3] refactor --- RELEASE.txt | 5 ++++- python/slsdet/detector.py | 4 ++-- python/src/detector.cpp | 8 ++++---- slsDetectorSoftware/include/sls/Detector.h | 4 ++-- slsDetectorSoftware/src/CmdProxy.h | 2 +- slsDetectorSoftware/src/Detector.cpp | 4 ++-- slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp | 4 ++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index ee767353c..c5b81f899 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -38,6 +38,9 @@ This document describes the differences between 5.2.0 and 5.1.0 releases. 1. Bad Channels moved to a new register + + Jungfrau- many Features + 2. Resolved Issues @@ -59,7 +62,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases. detector server to reset core until firmware release. - +getAutoCompDisable->getAutoComparatorDisable 3. Firmware Requirements ======================== diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 9f6d60a1d..b47699d11 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2016,11 +2016,11 @@ class Detector(CppDetectorApi): By default, the on-chip gain switching is active during the entire exposure. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). The % is only for chipv1.0, the duration can be set for chipv1.1.\n Default is 0 or this mode disabled (comparator enabled throughout). 1 enables mode. 0 disables mode. """ - return self.getAutoCompDisable() + return self.getAutoComparatorDisable() @auto_comp_disable.setter def auto_comp_disable(self, value): - ut.set_using_dict(self.setAutoCompDisable, value) + ut.set_using_dict(self.setAutoComparatorDisable, value) @property @element diff --git a/python/src/detector.cpp b/python/src/detector.cpp index d751d5e18..6980fc55f 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -970,13 +970,13 @@ void init_det(py::module &m) { (void (Detector::*)(sls::Positions)) & Detector::resetTemperatureEvent, py::arg() = Positions{}) - .def("getAutoCompDisable", + .def("getAutoComparatorDisable", (Result(Detector::*)(sls::Positions) const) & - Detector::getAutoCompDisable, + Detector::getAutoComparatorDisable, py::arg() = Positions{}) - .def("setAutoCompDisable", + .def("setAutoComparatorDisable", (void (Detector::*)(bool, sls::Positions)) & - Detector::setAutoCompDisable, + Detector::setAutoComparatorDisable, py::arg(), py::arg() = Positions{}) .def("getComparatorDisableTime", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 08eaa8bc8..988f8b174 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1127,7 +1127,7 @@ class Detector { void resetTemperatureEvent(Positions pos = {}); /** [Jungfrau] */ - Result getAutoCompDisable(Positions pos = {}) const; + Result getAutoComparatorDisable(Positions pos = {}) const; /** [Jungfrau] Advanced * //TODO naming @@ -1139,7 +1139,7 @@ class Detector { * disabled(comparator enabled throughout). true enables mode. 0 disables * mode. */ - void setAutoCompDisable(bool value, Positions pos = {}); + void setAutoComparatorDisable(bool value, Positions pos = {}); /** [Jungfrau] */ Result getComparatorDisableTime(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 036f8b972..106897719 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1838,7 +1838,7 @@ class CmdProxy { "cleared."); INTEGER_COMMAND_VEC_ID( - auto_comp_disable, getAutoCompDisable, setAutoCompDisable, + auto_comp_disable, getAutoComparatorDisable, setAutoComparatorDisable, StringTo, "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the " "on-chip gain switching is active during the entire exposure.This mode " diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index cd89fec41..ddd7253f2 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1451,11 +1451,11 @@ void Detector::resetTemperatureEvent(Positions pos) { pimpl->Parallel(&Module::resetTemperatureEvent, pos); } -Result Detector::getAutoCompDisable(Positions pos) const { +Result Detector::getAutoComparatorDisable(Positions pos) const { return pimpl->Parallel(&Module::getAutoComparatorDisableMode, pos); } -void Detector::setAutoCompDisable(bool value, Positions pos) { +void Detector::setAutoComparatorDisable(bool value, Positions pos) { pimpl->Parallel(&Module::setAutoComparatorDisableMode, pos, value); } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index 9a540f3a5..521b0faee 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -258,7 +258,7 @@ TEST_CASE("auto_comp_disable", "[.cmd]") { CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU) { - auto prev_val = det.getAutoCompDisable(); + auto prev_val = det.getAutoComparatorDisable(); { std::ostringstream oss; proxy.Call("auto_comp_disable", {"0"}, -1, PUT, oss); @@ -275,7 +275,7 @@ TEST_CASE("auto_comp_disable", "[.cmd]") { REQUIRE(oss.str() == "auto_comp_disable 1\n"); } for (int i = 0; i != det.size(); ++i) { - det.setAutoCompDisable(prev_val[i], {i}); + det.setAutoComparatorDisable(prev_val[i], {i}); } } else { REQUIRE_THROWS(proxy.Call("auto_comp_disable", {}, -1, GET));