From dd12c7c2f5f6d97bed6fdc51ed3fea932c2a381d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 13:39:55 +0200 Subject: [PATCH 1/7] wip --- RELEASE.txt | 1 + slsDetectorSoftware/include/sls/Detector.h | 14 ++++++++------ slsDetectorSoftware/src/CmdProxy.h | 12 +++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index 8bc41c6fe..cf6d24ca1 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -64,6 +64,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases. getAutoCompDisable->getAutoComparatorDisable setBottom->setFlippedDataAcrossXAxis +filter->filterResistor 3. Firmware Requirements ======================== diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index a2b0074ac..7015a4665 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -477,6 +477,14 @@ class Detector { * [Mythen3] If exposure time is too short, acquisition will return with an * ERROR and take fewer frames than expected */ void setParallelMode(bool value, Positions pos = {}); + + /** [Gotthard2][Jungfrau] */ + Result getFilterResistor(Positions pos = {}) const; + + /** [Gotthard2] Options: 0-3. Default: 0 + * [Jungfrau] 0-1. Default: 1 */ + void setFilterResistor(int value, Positions pos = {}); + ///@{ /** @name Acquisition */ @@ -1282,12 +1290,6 @@ class Detector { /** default disabled */ void setCDSGain(bool value, Positions pos = {}); - /** [Gotthard2] */ - Result getFilter(Positions pos = {}) const; - - /** [Gotthard2] Set filter resister. Options: 0-3. Default: 0 */ - void setFilter(int value, Positions pos = {}); - /** [Gotthard2] */ Result getCurrentSource(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index bed86280f..d3f53a49a 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -591,6 +591,7 @@ class CmdProxy { {"clkdivider", "speed"}, {"vhighvoltage", "highvoltage"}, {"digitest", "imagetest"}, + {"filter", "filterresistor"}, /** temperature */ @@ -800,6 +801,7 @@ class CmdProxy { {"imagetest", &CmdProxy::imagetest}, {"extsig", &CmdProxy::ExternalSignal}, {"parallel", &CmdProxy::parallel}, + {"filterresistor", &CmdProxy::filterresistor}, /** temperature */ {"templist", &CmdProxy::templist}, @@ -947,7 +949,6 @@ class CmdProxy { {"vetofile", &CmdProxy::VetoFile}, {"burstmode", &CmdProxy::BurstMode}, {"cdsgain", &CmdProxy::cdsgain}, - {"filter", &CmdProxy::filter}, {"currentsource", &CmdProxy::currentsource}, {"timingsource", &CmdProxy::timingsource}, {"veto", &CmdProxy::veto}, @@ -1348,6 +1349,11 @@ class CmdProxy { "acquisition will return ERROR status and take fewer " "frames than expected."); + INTEGER_COMMAND_VEC_ID( + filterresistor, getFilterResistor, setFilterResistor, StringTo, + "[0|1|2|3] [Gotthard2] Set filter resistor. Default is 0.\n[0|1] " + "[Jungfrau] Set filter resistor. Default is 1."); + /** temperature */ GET_COMMAND_NOID( templist, getTemperatureList, @@ -1911,10 +1917,6 @@ class CmdProxy { "[0, 1]\n\t[Gotthard2] Enable or disable CDS gain. Default " "is disabled."); - INTEGER_COMMAND_VEC_ID( - filter, getFilter, setFilter, StringTo, - "[0|1|2|3]\n\t[Gotthard2] Set filter resistor. Default is 0."); - INTEGER_COMMAND_VEC_ID( currentsource, getCurrentSource, setCurrentSource, StringTo, "[0, 1]\n\t[Gotthard2] Enable or disable current source. " From 86126c7e275b510018b570471c8b784b3bc35ac5 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 16:56:53 +0200 Subject: [PATCH 2/7] filter resistor in --- python/slsdet/detector.py | 11 ++--- python/src/detector.cpp | 8 ++-- .../slsDetectorFunctionList.c | 24 +++++------ .../slsDetectorServer_defs.h | 4 +- .../jungfrauDetectorServer/RegisterDefs.h | 9 ++-- .../slsDetectorFunctionList.c | 35 +++++++++++++++- .../slsDetectorServer_defs.h | 4 +- .../include/slsDetectorFunctionList.h | 6 ++- .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 42 +++++++++++-------- slsDetectorSoftware/src/Detector.cpp | 16 +++---- slsDetectorSoftware/src/Module.cpp | 14 ++++--- slsDetectorSoftware/src/Module.h | 4 +- .../tests/test-CmdProxy-gotthard2.cpp | 30 ------------- slsDetectorSoftware/tests/test-CmdProxy.cpp | 37 ++++++++++++++++ .../include/sls/sls_detector_funcs.h | 8 ++-- 16 files changed, 156 insertions(+), 100 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 383c2265c..54b7b77e8 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2238,17 +2238,18 @@ class Detector(CppDetectorApi): @property @element - def filter(self): - """[Gotthard2] Set filter resistor. + def filterresistor(self): + """[Gotthard2][Jungfrau] Set filter resistor. Note ---- - Default is 0. Options: 0-3. + [Gotthard2] Default is 0. Options: 0-3. + [Jungfrau] Default is 1. Options: 0-1. """ - return self.getFilter() + return self.getFilterResistor() @filter.setter def filter(self, value): - ut.set_using_dict(self.setFilter, value) + ut.set_using_dict(self.setFilterResistor, value) @property def maxclkphaseshift(self): diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 7a5807a1d..482bc9f23 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1097,12 +1097,12 @@ void init_det(py::module &m) { .def("setCDSGain", (void (Detector::*)(bool, sls::Positions)) & Detector::setCDSGain, py::arg(), py::arg() = Positions{}) - .def("getFilter", + .def("getFilterResistor", (Result(Detector::*)(sls::Positions) const) & - Detector::getFilter, + Detector::getFilterResistor, py::arg() = Positions{}) - .def("setFilter", - (void (Detector::*)(int, sls::Positions)) & Detector::setFilter, + .def("setFilterResistor", + (void (Detector::*)(int, sls::Positions)) & Detector::setFilterResistor, py::arg(), py::arg() = Positions{}) .def("getCurrentSource", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index a71cbde0b..8c7ccc597 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -63,7 +63,7 @@ int64_t numTriggersReg = 1; int64_t delayReg = 0; int64_t numBurstsReg = 1; int64_t burstPeriodReg = 0; -int filter = 0; +int filterResistor = 0; int cdsGain = 0; int detPos[2] = {}; @@ -388,7 +388,7 @@ void setupDetector() { delayReg = 0; numBurstsReg = 1; burstPeriodReg = 0; - filter = 0; + filterResistor = 0; cdsGain = 0; memset(clkPhase, 0, sizeof(clkPhase)); memset(dacValues, 0, sizeof(dacValues)); @@ -467,7 +467,7 @@ void setupDetector() { return; } setBurstMode(DEFAULT_BURST_MODE); - setFilter(DEFAULT_FILTER); + setFilterResistor(DEFAULT_FILTER_RESISTOR); setCDSGain(DEFAILT_CDS_GAIN); setSettings(DEFAULT_SETTINGS); @@ -2458,7 +2458,7 @@ int setBurstMode(enum burstMode burst) { } int configureASICGlobalSettings() { - int value = ((filter << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) | + int value = ((filterResistor << ASIC_FILTER_OFST) & ASIC_FILTER_MSK) | ((cdsGain << ASIC_CDS_GAIN_OFST) & ASIC_CDS_GAIN_MSK); switch (burstMode) { case BURST_INTERNAL: @@ -2473,9 +2473,9 @@ int configureASICGlobalSettings() { value |= (ASIC_CONT_MODE_MSK | ASIC_EXT_TIMING_MSK); break; } - LOG(logINFO, ("\tSending Global Chip settings:0x%x (filter:%d, " + LOG(logINFO, ("\tSending Global Chip settings:0x%x (filterResistor:%d, " "cdsgain:%d)\n", - value, filter, cdsGain)); + value, filterResistor, cdsGain)); const int padding = 6; // due to address (4) to make it byte aligned const int lenTotalBits = padding + ASIC_GLOBAL_SETT_MAX_BITS + @@ -2551,17 +2551,17 @@ int setCDSGain(int enable) { int getCDSGain() { return cdsGain; } -int setFilter(int value) { - if (value < 0 || value > ASIC_FILTER_MAX_VALUE) { - LOG(logERROR, ("Invalid filter value %d\n", value)); +int setFilterResistor(int value) { + if (value < 0 || value > ASIC_FILTER_MAX_RES_VALUE) { + LOG(logERROR, ("Invalid filter resistor value %d\n", value)); return FAIL; } - filter = value; - LOG(logINFO, ("Setting Filter to %d\n", filter)); + filterResistor = value; + LOG(logINFO, ("Setting Filter Resistor to %d\n", filterResistor)); return configureASICGlobalSettings(); } -int getFilter() { return filter; } +int getFilterResistor() { return filterResistor; } void setCurrentSource(int value) { uint32_t addr = ASIC_CONFIG_REG; diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 91293d7e3..46124e855 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -35,7 +35,7 @@ /** Default Parameters */ #define DEFAULT_BURST_MODE (BURST_INTERNAL) -#define DEFAULT_FILTER (0) +#define DEFAULT_FILTER_RESISTOR (0) #define DEFAILT_CDS_GAIN (0) #define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_CYCLES (1) @@ -149,7 +149,7 @@ enum PLLINDEX { READOUT_PLL, SYSTEM_PLL }; #define ASIC_CONT_MODE_MSK (0x1 << ASIC_CONT_MODE_OFST) #define ASIC_FILTER_OFST (3) #define ASIC_FILTER_MSK (0x3 << ASIC_FILTER_OFST) -#define ASIC_FILTER_MAX_VALUE (3) +#define ASIC_FILTER_MAX_RES_VALUE (3) #define ASIC_CDS_GAIN_OFST (5) #define ASIC_CDS_GAIN_MSK (0x1 << ASIC_CDS_GAIN_OFST) diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h index df4a6e63f..704389cbc 100644 --- a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h @@ -108,8 +108,9 @@ // CSM mode = high current (100%), low current (16%) #define CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST (19) #define CONFIG_V11_STATUS_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST) -#define CONFIG_V11_STATUS_FLTR_RSSTR_OFST (21) -#define CONFIG_V11_STATUS_FLTR_RSSTR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_OFST) +#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21) +#define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST) +#define ASIC_FILTER_MAX_RES_VALUE (1) #define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23) #define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST) @@ -249,8 +250,8 @@ // CSM mode = high current (100%), low current (16%) #define CONFIG_V11_CRRNT_SRC_MODE_OFST (19) #define CONFIG_V11_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_CRRNT_SRC_MODE_OFST) -#define CONFIG_V11_FLTR_RSSTR_OFST (21) -#define CONFIG_V11_FLTR_RSSTR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_OFST) +#define CONFIG_V11_FLTR_RSSTR_SMLR_OFST (21) +#define CONFIG_V11_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_FLTR_RSSTR_SMLR_OFST) #define CONFIG_V11_AUTO_MODE_OVRRD_OFST (23) #define CONFIG_V11_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_AUTO_MODE_OVRRD_OFST) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index a48ffabd0..999b04036 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -474,7 +474,8 @@ void setupDetector() { // temp threshold and reset event setThresholdTemperature(DEFAULT_TMP_THRSHLD); setTemperatureEvent(0); - setFlipRows(0); + setFlipRows(DEFAULT_FLIP_ROWS); + setFilterResistor(DEFAULT_FILTER_RESISTOR); } int resetToDefaultDacs(int hardReset) { @@ -2022,6 +2023,38 @@ void setFlipRows(int arg) { } } +int getFilterResistor() { +#ifdef VIRTUAL + uint32_t addr = CONFIG_V11_REG; +#else + uint32_t addr = CONFIG_V11_STATUS_REG; +#endif + // 0 for lower value, 1 for higher value + if (bus_r(addr) & CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK) { + return 0; + } + return 1; +} + +int setFilterResistor(int value) { + // lower resistor + if (value == 0) { + LOG(logINFO, ("Setting Lower Filter Resistor\n")); + bus_w(CONFIG_V11_REG, + bus_r(CONFIG_V11_REG) | CONFIG_V11_FLTR_RSSTR_SMLR_MSK); + return OK; + } + // higher resistor + else if (value == 1) { + LOG(logINFO, ("Setting Higher Filter Resistor\n")); + bus_w(CONFIG_V11_REG, + bus_r(CONFIG_V11_REG) & ~CONFIG_V11_FLTR_RSSTR_SMLR_MSK); + return OK; + } + LOG(logERROR, ("Could not set Filter Resistor. Invalid value %d\n", value)); + return FAIL; +} + int getTenGigaFlowControl() { return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >> CONFIG_ETHRNT_FLW_CNTRL_OFST); diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index 6f222b746..4742c19fe 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -105,12 +105,14 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define DEFAULT_STRG_CLL_STRT (0xf) #define DEFAULT_STRG_CLL_STRT_CHIP11 (0x3) #define DEFAULT_STRG_CLL_DLY (0) +#define DEFAULT_FLIP_ROWS (0) +#define DEFAULT_FILTER_RESISTOR (1) // higher resistor #define HIGHVOLTAGE_MIN (60) #define HIGHVOLTAGE_MAX (200) #define DAC_MIN_MV (0) #define DAC_MAX_MV (2500) - + /* Defines in the Firmware */ #define MAX_TIMESLOT_VAL (0x1F) #define MAX_THRESHOLD_TEMP_VAL (127999) // millidegrees diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 77dc873f7..0643ac399 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -462,6 +462,8 @@ int setTemperatureEvent(int val); void alignDeserializer(); int getFlipRows(); void setFlipRows(int arg); +int setFilterResistor(int value); +int getFilterResistor(); // eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter #elif EIGERD @@ -533,8 +535,8 @@ int configureASICGlobalSettings(); enum burstMode getBurstMode(); int setCDSGain(int enable); int getCDSGain(); -int setFilter(int value); -int getFilter(); +int setFilterResistor(int value); +int getFilterResistor(); void setCurrentSource(int value); int getCurrentSource(); void setTimingSource(enum timingSourceType value); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 52b924528..5477cea6d 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -229,8 +229,8 @@ int set_scan(int); int get_scan_error_message(int); int get_cds_gain(int); int set_cds_gain(int); -int get_filter(int); -int set_filter(int); +int get_filter_resistor(int); +int set_filter_resistor(int); int get_adc_config(int); int set_adc_config(int); int get_bad_channels(int); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 6a83ebc55..506602d64 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -354,8 +354,8 @@ void function_table() { flist[F_GET_SCAN_ERROR_MESSAGE] = &get_scan_error_message; flist[F_GET_CDS_GAIN] = &get_cds_gain; flist[F_SET_CDS_GAIN] = &set_cds_gain; - flist[F_GET_FILTER] = &get_filter; - flist[F_SET_FILTER] = &set_filter; + flist[F_GET_FILTER_RESISTOR] = &get_filter_resistor; + flist[F_SET_FILTER_RESISTOR] = &set_filter_resistor; flist[F_GET_ADC_CONFIGURATION] = &get_adc_config; flist[F_SET_ADC_CONFIGURATION] = &set_adc_config; flist[F_GET_BAD_CHANNELS] = &get_bad_channels; @@ -7771,49 +7771,57 @@ int set_cds_gain(int file_des) { return Server_SendResult(file_des, INT32, NULL, 0); } -int get_filter(int file_des) { +int get_filter_resistor(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int retval = -1; - LOG(logDEBUG1, ("Getting filter\n")); + LOG(logDEBUG1, ("Getting filter resistor\n")); -#ifndef GOTTHARD2D +#if !defined(GOTTHAR2D) && !defined(JUNGFRAUD) functionNotImplemented(); #else // get only - retval = getFilter(); - LOG(logDEBUG1, ("filter retval: %u\n", retval)); + retval = getFilterResistor(); + LOG(logDEBUG1, ("filter resistor retval: %u\n", retval)); #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } -int set_filter(int file_des) { +int set_filter_resistor(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); int arg = 0; if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); - LOG(logINFO, ("Setting filter: %u\n", arg)); + LOG(logINFO, ("Setting filter resistor: %u\n", arg)); -#ifndef GOTTHARD2D +#if !defined(GOTTHAR2D) && !defined(JUNGFRAUD) functionNotImplemented(); #else // only set if (Server_VerifyLock() == OK) { - if (arg < 0 || arg > ASIC_FILTER_MAX_VALUE) { + if (arg < 0 || arg > ASIC_FILTER_MAX_RES_VALUE) { ret = FAIL; sprintf(mess, - "Could not set filter. Invalid filter %d. " + "Could not set filter resistor. Invalid filter argument %d. " "Options [0-%d]\n", - arg, ASIC_FILTER_MAX_VALUE); + arg, ASIC_FILTER_MAX_RES_VALUE); LOG(logERROR, (mess)); } else { - setFilter(arg); - int retval = getFilter(); - LOG(logDEBUG1, ("filter retval: %u\n", retval)); - validate(&ret, mess, arg, retval, "set filter", DEC); + ret = setFilterResistor(arg); + if (ret == FAIL) { + ret = FAIL; + strcpy(mess, "Could not set filter resistor.\n"); + LOG(logERROR, (mess)); + } +#ifndef JUNGFRAUD + // jungfrau might take time to update status register if acquiring + int retval = getFilterResistor(); + LOG(logDEBUG1, ("filter resistor retval: %u\n", retval)); + validate(&ret, mess, arg, retval, "set filter resistor", DEC); +#endif } } #endif diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 4929a3ead..66cfaa607 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -699,6 +699,14 @@ void Detector::setParallelMode(bool value, Positions pos) { pimpl->Parallel(&Module::setParallelMode, pos, value); } +Result Detector::getFilterResistor(Positions pos) const { + return pimpl->Parallel(&Module::getFilterResistor, pos); +} + +void Detector::setFilterResistor(int value, Positions pos) { + pimpl->Parallel(&Module::setFilterResistor, pos, value); +} + // Acquisition void Detector::acquire() { pimpl->acquire(); } @@ -1604,14 +1612,6 @@ void Detector::setCDSGain(bool value, Positions pos) { pimpl->Parallel(&Module::setCDSGain, pos, value); } -Result Detector::getFilter(Positions pos) const { - return pimpl->Parallel(&Module::getFilter, pos); -} - -void Detector::setFilter(int value, Positions pos) { - pimpl->Parallel(&Module::setFilter, pos, value); -} - Result Detector::getCurrentSource(Positions pos) const { return pimpl->Parallel(&Module::getCurrentSource, pos); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 70bb408fb..9113889e4 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -704,6 +704,14 @@ void Module::setParallelMode(const bool enable) { sendToDetector(F_SET_PARALLEL_MODE, static_cast(enable), nullptr); } +int Module::getFilterResistor() const { + return sendToDetector(F_GET_FILTER_RESISTOR); +} + +void Module::setFilterResistor(int value) { + sendToDetector(F_SET_FILTER_RESISTOR, value, nullptr); +} + // Acquisition void Module::startReceiver() { @@ -1898,12 +1906,6 @@ void Module::setCDSGain(bool value) { sendToDetector(F_SET_CDS_GAIN, static_cast(value), nullptr); } -int Module::getFilter() const { return sendToDetector(F_GET_FILTER); } - -void Module::setFilter(int value) { - sendToDetector(F_SET_FILTER, value, nullptr); -} - bool Module::getCurrentSource() const { return sendToDetector(F_GET_CURRENT_SOURCE); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 3a9250d36..240ea045a 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -170,6 +170,8 @@ class Module : public virtual slsDetectorDefs { void setExternalSignalFlags(int signalIndex, externalSignalFlag type); bool getParallelMode() const; void setParallelMode(const bool enable); + int getFilterResistor() const; + void setFilterResistor(int value); /************************************************** * * @@ -408,8 +410,6 @@ class Module : public virtual slsDetectorDefs { void setBurstMode(burstMode value); bool getCDSGain() const; void setCDSGain(bool value); - int getFilter() const; - void setFilter(int value); bool getCurrentSource() const; void setCurrentSource(bool value); slsDetectorDefs::timingSourceType getTimingSource() const; diff --git a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp index 6f67198ac..313d0c28a 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp @@ -519,36 +519,6 @@ TEST_CASE("cdsgain", "[.cmd]") { } } -TEST_CASE("filter", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - auto prev_val = det.getFilter(); - { - std::ostringstream oss; - proxy.Call("filter", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "filter 1\n"); - } - { - std::ostringstream oss; - proxy.Call("filter", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "filter 0\n"); - } - { - std::ostringstream oss; - proxy.Call("filter", {}, -1, GET, oss); - REQUIRE(oss.str() == "filter 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFilter(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("filter", {}, -1, GET)); - } -} - TEST_CASE("currentsource", "[.cmd]") { Detector det; CmdProxy proxy(&det); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 1da4eedff..962a480ec 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1379,6 +1379,43 @@ TEST_CASE("parallel", "[.cmd]") { } } +TEST_CASE("filterresistor", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU) { + auto prev_val = det.getFilterResistor(); + { + std::ostringstream oss; + proxy.Call("filterresistor", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "filterresistor 1\n"); + } + { + std::ostringstream oss; + proxy.Call("filterresistor", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "filterresistor 0\n"); + } + { + std::ostringstream oss; + proxy.Call("filterresistor", {}, -1, GET, oss); + REQUIRE(oss.str() == "filterresistor 0\n"); + } + if (det_type == defs::GOTTHARD2) { + REQUIRE_NOTHROW(proxy.Call("filterresistor", {"2"}, -1, PUT)); + REQUIRE_NOTHROW(proxy.Call("filterresistor", {"3"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("filterresistor", {"2"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("filterresistor", {"3"}, -1, PUT)); + } + for (int i = 0; i != det.size(); ++i) { + det.setFilterResistor(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("filterresistor", {}, -1, GET)); + } +} + /** temperature */ TEST_CASE("templist", "[.cmd]") { diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 08927974e..a7736368b 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -205,8 +205,8 @@ enum detFuncs { F_GET_SCAN_ERROR_MESSAGE, F_GET_CDS_GAIN, F_SET_CDS_GAIN, - F_GET_FILTER, - F_SET_FILTER, + F_GET_FILTER_RESISTOR, + F_SET_FILTER_RESISTOR, F_GET_ADC_CONFIGURATION, F_SET_ADC_CONFIGURATION, F_GET_BAD_CHANNELS, @@ -552,8 +552,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_SCAN_ERROR_MESSAGE: return "F_GET_SCAN_ERROR_MESSAGE"; case F_GET_CDS_GAIN: return "F_GET_CDS_GAIN"; case F_SET_CDS_GAIN: return "F_SET_CDS_GAIN"; - case F_GET_FILTER: return "F_GET_FILTER"; - case F_SET_FILTER: return "F_SET_FILTER"; + case F_GET_FILTER_RESISTOR: return "F_GET_FILTER_RESISTOR"; + case F_SET_FILTER_RESISTOR: return "F_SET_FILTER_RESISTOR"; case F_SET_ADC_CONFIGURATION: return "F_SET_ADC_CONFIGURATION"; case F_GET_ADC_CONFIGURATION: return "F_GET_ADC_CONFIGURATION"; case F_GET_BAD_CHANNELS: return "F_GET_BAD_CHANNELS"; From 074178848e051abdbed13b9e544ae7a02b4360a5 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 17:29:43 +0200 Subject: [PATCH 3/7] minor --- python/slsdet/detector.py | 4 +++- slsDetectorSoftware/include/sls/Detector.h | 5 +++-- slsDetectorSoftware/src/CmdProxy.h | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 54b7b77e8..d75291382 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2239,7 +2239,9 @@ class Detector(CppDetectorApi): @property @element def filterresistor(self): - """[Gotthard2][Jungfrau] Set filter resistor. + """ + [Gotthard2][Jungfrau] Set filter resistor. Increasing values for increasing " + "resistance. Note ---- [Gotthard2] Default is 0. Options: 0-3. diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 085a213e3..5401b4233 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -483,8 +483,9 @@ class Detector { /** [Gotthard2][Jungfrau] */ Result getFilterResistor(Positions pos = {}) const; - /** [Gotthard2] Options: 0-3. Default: 0 - * [Jungfrau] 0-1. Default: 1 */ + /** [Gotthard2][Jungfrau] Set filter resistor. Increasing values for + * increasing resistance.\n[Gotthard2] Options: [0|1|2|3]. Default is + * 0.\n[Jungfrau] Options: [0|1]. Default is 1.*/ void setFilterResistor(int value, Positions pos = {}); ///@{ diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 05370ab80..0bde34e55 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1350,8 +1350,9 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( filterresistor, getFilterResistor, setFilterResistor, StringTo, - "[0|1|2|3] [Gotthard2] Set filter resistor. Default is 0.\n[0|1] " - "[Jungfrau] Set filter resistor. Default is 1."); + "[value] [Gotthard2][Jungfrau] Set filter resistor. Increasing values " + "for increasing resistance.\n\t[Gotthard2] Options: [0|1|2|3]. Default " + "is 0.\n\t[Jungfrau] Options: [0|1]. Default is 1."); /** temperature */ GET_COMMAND_NOID( From 69356cf232af3863a12f52cc936aefc805a76084 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Aug 2021 17:50:46 +0200 Subject: [PATCH 4/7] filterresitsitor only in chipv1.1 --- .../src/slsDetectorServer_funcs.c | 25 ++++++++++++++++--- slsDetectorSoftware/tests/test-CmdProxy.cpp | 9 ++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 506602d64..5027f3fe3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -7782,8 +7782,18 @@ int get_filter_resistor(int file_des) { functionNotImplemented(); #else // get only - retval = getFilterResistor(); - LOG(logDEBUG1, ("filter resistor retval: %u\n", retval)); +#ifdef JUNGFRAUD + if (getChipVersion() == 10) { + ret = FAIL; + strcpy(mess, "Could not get filter cell. Not available for this chip " + "version 1.0.\n"); + LOG(logERROR, (mess)); + } +#endif + if (ret == OK) { + retval = getFilterResistor(); + LOG(logDEBUG1, ("filter resistor retval: %u\n", retval)); + } #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -7809,7 +7819,16 @@ int set_filter_resistor(int file_des) { "Options [0-%d]\n", arg, ASIC_FILTER_MAX_RES_VALUE); LOG(logERROR, (mess)); - } else { + } +#ifdef JUNGFRAUD + else if (getChipVersion() == 10) { + ret = FAIL; + strcpy(mess, "Could not set filter cell. Not available for this " + "chip version 1.0.\n"); + LOG(logERROR, (mess)); + } +#endif + else { ret = setFilterResistor(arg); if (ret == FAIL) { ret = FAIL; diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 962a480ec..6e2d89855 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1384,7 +1384,14 @@ TEST_CASE("filterresistor", "[.cmd]") { CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU) { + // only for chipv1.1 + bool chip11 = false; + if (det_type == defs::JUNGFRAU && + det.getChipVersion().squash() * 10 == 11) { + chip11 = true; + } + + if (det_type == defs::GOTTHARD2 || chip11) { auto prev_val = det.getFilterResistor(); { std::ostringstream oss; From 7bf03c02b7fcef679752cbd8da54694de0ba2d33 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 6 Aug 2021 09:01:51 +0200 Subject: [PATCH 5/7] python filterresitor --- python/slsdet/detector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index d75291382..8137f1526 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2249,8 +2249,8 @@ class Detector(CppDetectorApi): """ return self.getFilterResistor() - @filter.setter - def filter(self, value): + @filterresistor.setter + def filterresistor(self, value): ut.set_using_dict(self.setFilterResistor, value) @property From a32e19d74eea51e4a205e711a4abbf3de2176996 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 9 Aug 2021 11:40:53 +0200 Subject: [PATCH 6/7] moved a definition to server defs --- slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h | 1 - .../jungfrauDetectorServer/slsDetectorServer_defs.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h index 704389cbc..1baf7c9c7 100644 --- a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h @@ -110,7 +110,6 @@ #define CONFIG_V11_STATUS_CRRNT_SRC_MODE_MSK (0x00000001 << CONFIG_V11_STATUS_CRRNT_SRC_MODE_OFST) #define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST (21) #define CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_MSK (0x00000001 << CONFIG_V11_STATUS_FLTR_RSSTR_SMLR_OFST) -#define ASIC_FILTER_MAX_RES_VALUE (1) #define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST (23) #define CONFIG_V11_STATUS_AUTO_MODE_OVRRD_MSK (0x00000001 << CONFIG_V11_STATUS_AUTO_MODE_OVRRD_OFST) diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index ab259a837..9da86eb0e 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -120,6 +120,7 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; #define MAX_STORAGE_CELL_CHIP11_VAL (3) #define MAX_STORAGE_CELL_DLY_NS_VAL (ASIC_CTRL_EXPSRE_TMR_MAX_VAL) #define ACQ_TIME_MIN_CLOCK (2) +#define ASIC_FILTER_MAX_RES_VALUE (1) #define MAX_PHASE_SHIFTS (240) #define BIT16_MASK (0xFFFF) From c7c6d2d65411045f97ea1c14e79c7fe4fd8c3a08 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 9 Aug 2021 11:56:51 +0200 Subject: [PATCH 7/7] merge bugs --- python/slsdet/detector.py | 15 --------------- python/src/detector.cpp | 13 +++---------- slsDetectorSoftware/src/Detector.cpp | 8 -------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index a2a7ff92e..5b7d67e1f 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2254,21 +2254,6 @@ class Detector(CppDetectorApi): def filterresistor(self, value): ut.set_using_dict(self.setFilterResistor, value) - @property - @element - def filtercell(self): - """ - [Jungfrau] Set filter capacitor. - Note - ---- - [Jungfrau] Options: 0-12. Default: 0. Advanced user command. - """ - return self.getFilterCell() - - @filtercell.setter - def filtercell(self, value): - ut.set_using_dict(self.setFilterCell, value) - @property def maxclkphaseshift(self): """ diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 763b47f6c..322a4ca49 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -853,8 +853,7 @@ void init_det(py::module &m) { Detector::getFlipRows, py::arg() = Positions{}) .def("setFlipRows", - (void (Detector::*)(bool, sls::Positions)) & - Detector::setFlipRows, + (void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows, py::arg(), py::arg() = Positions{}) .def("getRateCorrection", (Result(Detector::*)(sls::Positions) const) & @@ -1102,14 +1101,8 @@ void init_det(py::module &m) { Detector::getFilterResistor, py::arg() = Positions{}) .def("setFilterResistor", - (void (Detector::*)(int, sls::Positions)) & Detector::setFilterResistor, - py::arg(), py::arg() = Positions{}) - .def("getFilterCell", - (Result(Detector::*)(sls::Positions) const) & - Detector::getFilterCell, - py::arg() = Positions{}) - .def("setFilterCell", - (void (Detector::*)(int, sls::Positions)) & Detector::setFilterCell, + (void (Detector::*)(int, sls::Positions)) & + Detector::setFilterResistor, py::arg(), py::arg() = Positions{}) .def("getCurrentSource", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index e5e36735c..394d77a09 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1521,14 +1521,6 @@ void Detector::setGainMode(const defs::gainMode mode, Positions pos) { pimpl->Parallel(&Module::setGainMode, pos, mode); } -Result Detector::getFilterCell(Positions pos) const { - return pimpl->Parallel(&Module::getFilterCell, pos); -} - -void Detector::setFilterCell(int cell, Positions pos) { - pimpl->Parallel(&Module::setFilterCell, pos, cell); -} - // Gotthard Specific Result Detector::getROI(Positions pos) const {