From 054e733cd504ada8dfa2c47114fc77e0b41a04b4 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 10 Jul 2023 16:10:23 +0200 Subject: [PATCH] Voltage and slow adc naming (#772) * voltages in python * added voltage values in cmd line, added voltagelist in detector class * voltage values in python * slow adc list --- python/CMakeLists.txt | 2 + python/slsdet/__init__.py | 2 + python/slsdet/ctb.py | 11 + python/slsdet/detector.py | 52 +- python/slsdet/slowadcs.py | 195 +++++++ python/slsdet/voltages.py | 195 +++++++ python/src/detector.cpp | 26 +- slsDetectorSoftware/include/sls/Detector.h | 16 +- slsDetectorSoftware/src/CmdProxy.cpp | 31 +- slsDetectorSoftware/src/CmdProxy.h | 521 ++++++++++-------- slsDetectorSoftware/src/CtbConfig.cpp | 32 +- slsDetectorSoftware/src/CtbConfig.h | 12 +- slsDetectorSoftware/src/Detector.cpp | 50 +- slsDetectorSoftware/src/DetectorImpl.cpp | 16 +- slsDetectorSoftware/src/DetectorImpl.h | 8 +- .../tests/test-CmdProxy-chiptestboard.cpp | 24 +- slsDetectorSoftware/tests/test-CtbConfig.cpp | 2 +- 17 files changed, 842 insertions(+), 353 deletions(-) create mode 100755 python/slsdet/slowadcs.py create mode 100755 python/slsdet/voltages.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index ae05bbf99..9079c932e 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,6 +27,8 @@ set( PYTHON_FILES slsdet/__init__.py slsdet/adcs.py slsdet/dacs.py + slsdet/voltages.py + slsdet/slowadcs.py slsdet/decorators.py slsdet/detector_property.py slsdet/detector.py diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py index 09568cbd1..dd657ecf8 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -4,6 +4,8 @@ from .eiger import Eiger from .ctb import Ctb from .dacs import DetectorDacs, Dac +from .voltages import DetectorVoltages, Voltage +from .slowadcs import DetectorSlowAdcs, SlowAdc from .detector import Detector from .jungfrau import Jungfrau from .mythen3 import Mythen3 diff --git a/python/slsdet/ctb.py b/python/slsdet/ctb.py index cfcc03f72..74e4a59ee 100644 --- a/python/slsdet/ctb.py +++ b/python/slsdet/ctb.py @@ -3,6 +3,8 @@ from .detector import Detector, freeze from .utils import element_if_equal from .dacs import DetectorDacs, NamedDacs +from .voltages import DetectorVoltages, NamedVoltages +from .slowadcs import DetectorSlowAdcs, NamedSlowAdcs import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty @@ -15,8 +17,17 @@ class Ctb(Detector): super().__init__(id) self._frozen = False self._dacs = NamedDacs(self) + self._voltages = NamedVoltages(self) + self._slowadcs = NamedSlowAdcs(self) @property def dacs(self): return self._dacs + @property + def voltages(self): + return self._voltages + + @property + def slowadcs(self): + return self._slowadcs \ No newline at end of file diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 4de3d1848..135d753ae 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -1837,6 +1837,22 @@ class Detector(CppDetectorApi): for dac in self.getDacList() } + @property + def voltagevalues(self): + """Gets the voltage values for every voltage for this detector.""" + return { + voltage.name.lower(): element_if_equal(np.array(self.getVoltage(voltage))) + for voltage in self.getVoltageList() + } + + @property + def slowadcvalues(self): + """Gets the slow adc values for every slow adc for this detector.""" + return { + slowadc.name.lower(): element_if_equal(np.array(self.getSlowADC(slowadc))) + for slowadc in self.getSlowADCList() + } + @property def timinglist(self): """Gets the list of timing modes (timingMode) for this detector.""" @@ -3755,45 +3771,45 @@ class Detector(CppDetectorApi): @element def v_a(self): """[Ctb] Voltage supply a in mV.""" - return self.getDAC(dacIndex.V_POWER_A, True) + return self.getVoltage(dacIndex.V_POWER_A) @v_a.setter def v_a(self, value): - value = ut.merge_args(dacIndex.V_POWER_A, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_POWER_A, value) + ut.set_using_dict(self.setVoltage, *value) @property @element def v_b(self): """[Ctb] Voltage supply b in mV.""" - return self.getDAC(dacIndex.V_POWER_B, True) + return self.getVoltage(dacIndex.V_POWER_B) @v_b.setter def v_b(self, value): - value = ut.merge_args(dacIndex.V_POWER_B, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_POWER_B, value) + ut.set_using_dict(self.setVoltage, *value) @property @element def v_c(self): """[Ctb] Voltage supply c in mV.""" - return self.getDAC(dacIndex.V_POWER_C, True) + return self.getVoltage(dacIndex.V_POWER_C) @v_c.setter def v_c(self, value): - value = ut.merge_args(dacIndex.V_POWER_C, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_POWER_C, value) + ut.set_using_dict(self.setVoltage, *value) @property @element def v_d(self): """[Ctb] Voltage supply d in mV.""" - return self.getDAC(dacIndex.V_POWER_D, True) + return self.getVoltage(dacIndex.V_POWER_D) @v_d.setter def v_d(self, value): - value = ut.merge_args(dacIndex.V_POWER_D, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_POWER_D, value) + ut.set_using_dict(self.setVoltage, *value) @property @element @@ -3804,23 +3820,23 @@ class Detector(CppDetectorApi): ---- Must be the first power regulator to be set after fpga reset (on-board detector server start up). """ - return self.getDAC(dacIndex.V_POWER_IO, True) + return self.getVoltage(dacIndex.V_POWER_IO) @v_io.setter def v_io(self, value): - value = ut.merge_args(dacIndex.V_POWER_IO, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_POWER_IO, value) + ut.set_using_dict(self.setVoltage, *value) @property @element def v_limit(self): """[Ctb] Soft limit for power supplies (ctb only) and DACS in mV.""" - return self.getDAC(dacIndex.V_LIMIT, True) + return self.getVoltage(dacIndex.V_LIMIT) @v_limit.setter def v_limit(self, value): - value = ut.merge_args(dacIndex.V_LIMIT, value, True) - ut.set_using_dict(self.setDAC, *value) + value = ut.merge_args(dacIndex.V_LIMIT, value) + ut.set_using_dict(self.setVoltage, *value) @property diff --git a/python/slsdet/slowadcs.py b/python/slsdet/slowadcs.py new file mode 100755 index 000000000..ae153a706 --- /dev/null +++ b/python/slsdet/slowadcs.py @@ -0,0 +1,195 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package +from .detector_property import DetectorProperty +from functools import partial +import numpy as np +import _slsdet +from .detector import freeze +dacIndex = _slsdet.slsDetectorDefs.dacIndex +class SlowAdc(DetectorProperty): + """ + This class represents a slowadc on the Chip Test Board. One instance handles all + slowadcs with the same name for a multi detector instance. (TODO: Not needed for CTB) + + .. note :: + + This class is used to build up DetectorSlowAdcs and is in general + not directly accessible to the user. + + + """ + def __init__(self, name, enum, default, detector): + + super().__init__(partial(detector.getVoltage, enum), + lambda x, y : detector.setVoltage(enum, x, y), + detector.size, + name) + + self.default = default + + + def __repr__(self): + """String representation for a single slowadc in all modules""" + slowadcstr = ''.join([f'{item:5d}' for item in self.get()]) + return f'{self.__name__:15s}:{slowadcstr}' + +class NamedSlowAdcs: + """ + New implementation of the detector slowadcs. + """ + _frozen = False + _direct_access = ['_detector', '_current', '_voltagenames'] + def __init__(self, detector): + self._detector = detector + self._current = 0 + + #only get the voltagenames if we have modules attached + if detector.size() == 0: + self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"] + else: + self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()] + + # Populate the slowadcs + for i,name in enumerate(self._voltagenames): + #name, enum, low, high, default, detector + k = dacIndex(i + int(dacIndex.V_POWER_A)) + setattr(self, name, SlowAdc(name, k, 0, detector)) + + self._frozen = True + + # def __getattr__(self, name): + # return self.__getattribute__('_' + name) + + def __setattr__(self, name, value): + if not self._frozen: + #durning init we need to be able to set up the class + super().__setattr__(name, value) + else: + #Later we restrict us to manipulate slowadcs and a few fields + if name in self._direct_access: + super().__setattr__(name, value) + elif name in self._voltagenames: + return self.__getattribute__(name).__setitem__(slice(None, None), value) + else: + raise AttributeError(f'SlowAdc not found: {name}') + + def __next__(self): + if self._current >= len(self._voltagenames): + self._current = 0 + raise StopIteration + else: + self._current += 1 + return self.__getattribute__(self._voltagenames[self._current-1]) + # return self.__getattr__(self._voltagenames[self._current-1]) + + def __iter__(self): + return self + + def __repr__(self): + r_str = ['========== SLOW ADCS ========='] + r_str += [repr(slowadc) for slowadc in self] + return '\n'.join(r_str) + def get_asarray(self): + """ + Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules] + """ + voltage_array = np.zeros((len(self._voltagenames), len(self._detector))) + for i, _d in enumerate(self): + voltage_array[i,:] = _d[:] + return voltage_array + + def to_array(self): + return self.get_asarray() + + def set_from_array(self, voltage_array): + """ + Set the slowadc from an numpy array with slowadc values. [nslowadcs, nmodules] + """ + voltage_array = voltage_array.astype(np.int) + for i, _d in enumerate(self): + _d[:] = voltage_array[i] + + def from_array(self, voltage_array): + self.set_from_array(voltage_array) + +class DetectorSlowAdcs: + _slowadcs = [] + _voltagenames = [_d[0] for _d in _slowadcs] + _allowed_attr = ['_detector', '_current'] + _frozen = False + + def __init__(self, detector): + # We need to at least initially know which detector we are connected to + self._detector = detector + + # Index to support iteration + self._current = 0 + + # Name the attributes? + for _d in self._slowadcs: + setattr(self, '_'+_d[0], SlowAdc(*_d, detector)) + + self._frozen = True + + def __getattr__(self, name): + return self.__getattribute__('_' + name) + + @property + def voltagenames(self): + return [_d[0] for _d in _slowadcs] + + def __setattr__(self, name, value): + if name in self._voltagenames: + return self.__getattribute__('_' + name).__setitem__(slice(None, None), value) + else: + if self._frozen == True and name not in self._allowed_attr: + raise AttributeError(f'SlowAdc not found: {name}') + super().__setattr__(name, value) + + + def __next__(self): + if self._current >= len(self._slowadcs): + self._current = 0 + raise StopIteration + else: + self._current += 1 + return self.__getattr__(self._voltagenames[self._current-1]) + + def __iter__(self): + return self + + def __repr__(self): + r_str = ['========== SLOW ADCS ========='] + r_str += [repr(slowadc) for slowadc in self] + return '\n'.join(r_str) + + def get_asarray(self): + """ + Read the slowadcs into a numpy array with dimensions [nslowadcs, nmodules] + """ + voltage_array = np.zeros((len(self._slowadcs), len(self._detector))) + for i, _d in enumerate(self): + voltage_array[i,:] = _d[:] + return voltage_array + + def to_array(self): + return self.get_asarray() + + def set_from_array(self, voltage_array): + """ + Set the slowadcs from an numpy array with slowadc values. [nslowadcs, nmodules] + """ + voltage_array = voltage_array.astype(np.int) + for i, _d in enumerate(self): + _d[:] = voltage_array[i] + + def from_array(self, voltage_array): + self.set_from_array(voltage_array) + + def set_default(self): + """ + Set all slowadcs to their default values + """ + for _d in self: + _d[:] = _d.default + diff --git a/python/slsdet/voltages.py b/python/slsdet/voltages.py new file mode 100755 index 000000000..f545d5dd0 --- /dev/null +++ b/python/slsdet/voltages.py @@ -0,0 +1,195 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package +from .detector_property import DetectorProperty +from functools import partial +import numpy as np +import _slsdet +from .detector import freeze +dacIndex = _slsdet.slsDetectorDefs.dacIndex +class Voltage(DetectorProperty): + """ + This class represents a voltage on the Chip Test Board. One instance handles all + voltages with the same name for a multi detector instance. (TODO: Not needed for CTB) + + .. note :: + + This class is used to build up DetectorVoltages and is in general + not directly accessible to the user. + + + """ + def __init__(self, name, enum, default, detector): + + super().__init__(partial(detector.getVoltage, enum), + lambda x, y : detector.setVoltage(enum, x, y), + detector.size, + name) + + self.default = default + + + def __repr__(self): + """String representation for a single voltage in all modules""" + voltagestr = ''.join([f'{item:5d}' for item in self.get()]) + return f'{self.__name__:15s}:{voltagestr}' + +class NamedVoltages: + """ + New implementation of the detector voltages. + """ + _frozen = False + _direct_access = ['_detector', '_current', '_voltagenames'] + def __init__(self, detector): + self._detector = detector + self._current = 0 + + #only get the voltagenames if we have modules attached + if detector.size() == 0: + self._voltagenames = ["VA", "VB", "VC", "VD", "VIO"] + else: + self._voltagenames = [n.replace(" ", "") for n in detector.getVoltageNames()] + + # Populate the voltages + for i,name in enumerate(self._voltagenames): + #name, enum, low, high, default, detector + k = dacIndex(i + int(dacIndex.V_POWER_A)) + setattr(self, name, Voltage(name, k, 0, detector)) + + self._frozen = True + + # def __getattr__(self, name): + # return self.__getattribute__('_' + name) + + def __setattr__(self, name, value): + if not self._frozen: + #durning init we need to be able to set up the class + super().__setattr__(name, value) + else: + #Later we restrict us to manipulate voltages and a few fields + if name in self._direct_access: + super().__setattr__(name, value) + elif name in self._voltagenames: + return self.__getattribute__(name).__setitem__(slice(None, None), value) + else: + raise AttributeError(f'Voltage not found: {name}') + + def __next__(self): + if self._current >= len(self._voltagenames): + self._current = 0 + raise StopIteration + else: + self._current += 1 + return self.__getattribute__(self._voltagenames[self._current-1]) + # return self.__getattr__(self._voltagenames[self._current-1]) + + def __iter__(self): + return self + + def __repr__(self): + r_str = ['========== VOLTAGES ========='] + r_str += [repr(voltage) for voltage in self] + return '\n'.join(r_str) + def get_asarray(self): + """ + Read the voltages into a numpy array with dimensions [nvoltages, nmodules] + """ + voltage_array = np.zeros((len(self._voltagenames), len(self._detector))) + for i, _d in enumerate(self): + voltage_array[i,:] = _d[:] + return voltage_array + + def to_array(self): + return self.get_asarray() + + def set_from_array(self, voltage_array): + """ + Set the voltage from an numpy array with voltage values. [nvoltages, nmodules] + """ + voltage_array = voltage_array.astype(np.int) + for i, _d in enumerate(self): + _d[:] = voltage_array[i] + + def from_array(self, voltage_array): + self.set_from_array(voltage_array) + +class DetectorVoltages: + _voltages = [] + _voltagenames = [_d[0] for _d in _voltages] + _allowed_attr = ['_detector', '_current'] + _frozen = False + + def __init__(self, detector): + # We need to at least initially know which detector we are connected to + self._detector = detector + + # Index to support iteration + self._current = 0 + + # Name the attributes? + for _d in self._voltages: + setattr(self, '_'+_d[0], Voltage(*_d, detector)) + + self._frozen = True + + def __getattr__(self, name): + return self.__getattribute__('_' + name) + + @property + def voltagenames(self): + return [_d[0] for _d in _voltages] + + def __setattr__(self, name, value): + if name in self._voltagenames: + return self.__getattribute__('_' + name).__setitem__(slice(None, None), value) + else: + if self._frozen == True and name not in self._allowed_attr: + raise AttributeError(f'Voltage not found: {name}') + super().__setattr__(name, value) + + + def __next__(self): + if self._current >= len(self._voltages): + self._current = 0 + raise StopIteration + else: + self._current += 1 + return self.__getattr__(self._voltagenames[self._current-1]) + + def __iter__(self): + return self + + def __repr__(self): + r_str = ['========== VOLTAGES ========='] + r_str += [repr(voltage) for voltage in self] + return '\n'.join(r_str) + + def get_asarray(self): + """ + Read the voltages into a numpy array with dimensions [nvoltages, nmodules] + """ + voltage_array = np.zeros((len(self._voltages), len(self._detector))) + for i, _d in enumerate(self): + voltage_array[i,:] = _d[:] + return voltage_array + + def to_array(self): + return self.get_asarray() + + def set_from_array(self, voltage_array): + """ + Set the voltages from an numpy array with voltage values. [nvoltages, nmodules] + """ + voltage_array = voltage_array.astype(np.int) + for i, _d in enumerate(self): + _d[:] = voltage_array[i] + + def from_array(self, voltage_array): + self.set_from_array(voltage_array) + + def set_default(self): + """ + Set all voltages to their default values + """ + for _d in self: + _d[:] = _d.default + diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 5dfd3ed4c..4d6dd2415 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1516,6 +1516,12 @@ void init_det(py::module &m) { (void (Detector::*)(int, sls::Positions)) & Detector::setADCPipeline, py::arg(), py::arg() = Positions{}); + CppDetectorApi.def("getVoltageList", + (std::vector(Detector::*)() const) & + Detector::getVoltageList); + CppDetectorApi.def("getSlowADCList", + (std::vector(Detector::*)() const) & + Detector::getSlowADCList); CppDetectorApi.def( "getVoltage", (Result(Detector::*)(defs::dacIndex, sls::Positions) const) & @@ -1716,26 +1722,26 @@ void init_det(py::module &m) { (std::string(Detector::*)(const defs::dacIndex) const) & Detector::getVoltageName, py::arg()); - CppDetectorApi.def("setSlowAdcNames", + CppDetectorApi.def("setSlowADCNames", (void (Detector::*)(const std::vector)) & - Detector::setSlowAdcNames, + Detector::setSlowADCNames, py::arg()); - CppDetectorApi.def("getSlowAdcNames", + CppDetectorApi.def("getSlowADCNames", (std::vector(Detector::*)() const) & - Detector::getSlowAdcNames); + Detector::getSlowADCNames); CppDetectorApi.def( - "getSlowAdcIndex", + "getSlowADCIndex", (defs::dacIndex(Detector::*)(const std::string &) const) & - Detector::getSlowAdcIndex, + Detector::getSlowADCIndex, py::arg()); CppDetectorApi.def( - "setSlowAdcName", + "setSlowADCName", (void (Detector::*)(const defs::dacIndex, const std::string &)) & - Detector::setSlowAdcName, + Detector::setSlowADCName, py::arg(), py::arg()); - CppDetectorApi.def("getSlowAdcName", + CppDetectorApi.def("getSlowADCName", (std::string(Detector::*)(const defs::dacIndex) const) & - Detector::getSlowAdcName, + Detector::getSlowADCName, py::arg()); CppDetectorApi.def( "getPatterFileName", diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 390caaac2..9dd152aad 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1611,6 +1611,12 @@ class Detector { /** [CTB] */ void setADCPipeline(int value, Positions pos = {}); + /** gets list of voltage enums */ + std::vector getVoltageList() const; + + /** gets list of slow adc enums */ + std::vector getSlowADCList() const; + /** [CTB] */ Result getVoltage(defs::dacIndex index, Positions pos = {}) const; @@ -1783,19 +1789,19 @@ class Detector { std::string getVoltageName(const defs::dacIndex i) const; /** [CTB] */ - void setSlowAdcNames(const std::vector names); + void setSlowADCNames(const std::vector names); /** [CTB] */ - std::vector getSlowAdcNames() const; + std::vector getSlowADCNames() const; /** [CTB] */ - defs::dacIndex getSlowAdcIndex(const std::string &name) const; + defs::dacIndex getSlowADCIndex(const std::string &name) const; /** [CTB] */ - void setSlowAdcName(const defs::dacIndex i, const std::string &name); + void setSlowADCName(const defs::dacIndex i, const std::string &name); /** [CTB] */ - std::string getSlowAdcName(const defs::dacIndex i) const; + std::string getSlowADCName(const defs::dacIndex i) const; ///@} diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index adb5ba447..2e24f54af 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1127,35 +1127,6 @@ std::string CmdProxy::TemperatureValues(int action) { } /* list */ -std::string CmdProxy::DacList(const int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == slsDetectorDefs::HELP_ACTION) { - os << "\n\t[dacname1 dacname2 .. dacname18] \n\t\t[ChipTestBoard] Set " - "the list of dac names for this detector.\n\t\t[All] Gets the " - "list of dac names for every dac for this detector." - << '\n'; - } else if (action == slsDetectorDefs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getDacNames(); - os << ToString(t) << '\n'; - } else if (action == slsDetectorDefs::PUT_ACTION) { - if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { - throw RuntimeError("This detector already has fixed dac " - "names. Cannot change them."); - } - if (det_id != -1) { - throw RuntimeError("Cannot configure dacnames at module level"); - } - det->setDacNames(args); - os << ToString(args) << '\n'; - } else { - throw RuntimeError("Unknown action"); - } - return os.str(); -} /* dacs */ std::string CmdProxy::Dac(int action) { @@ -2688,7 +2659,7 @@ std::string CmdProxy::AdcVpp(int action) { return os.str(); } -std::string CmdProxy::SlowAdc(int action) { +std::string CmdProxy::SlowADC(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 1db1a7091..a9c5edafe 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -532,7 +532,8 @@ namespace sls { os << HLPSTR << '\n'; \ return os.str(); \ } \ - if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { \ + if (cmd != "daclist" && \ + det->getDetectorType().squash() != defs::CHIPTESTBOARD) { \ throw RuntimeError(cmd + " only allowed for CTB."); \ } \ if (det_id != -1) { \ @@ -546,6 +547,11 @@ namespace sls { auto t = det->GETFCN(); \ os << ToString(t) << '\n'; \ } else if (action == slsDetectorDefs::PUT_ACTION) { \ + if (cmd == "daclist" && \ + det->getDetectorType().squash() != defs::CHIPTESTBOARD) { \ + throw RuntimeError("This detector already has fixed dac " \ + "names. Cannot change them."); \ + } \ det->SETFCN(args); \ os << ToString(args) << '\n'; \ } else { \ @@ -554,6 +560,41 @@ namespace sls { return os.str(); \ } +#define CTB_VALUES(CMDNAME, GETFCN, GETFCNLIST, GETFCNNAME, HLPSTR) \ + std::string CMDNAME(const int action) { \ + std::ostringstream os; \ + os << cmd << ' '; \ + if (action == slsDetectorDefs::HELP_ACTION) { \ + os << HLPSTR << '\n'; \ + return os.str(); \ + } \ + if (action == slsDetectorDefs::GET_ACTION) { \ + if (!args.empty()) { \ + WrongNumberOfParameters(0); \ + } \ + std::string suffix = " mV"; \ + auto t = det->GETFCNLIST(); \ + auto names = det->GETFCNNAME(); \ + auto name_it = names.begin(); \ + os << '['; \ + auto it = t.cbegin(); \ + os << ToString(*name_it++) << ' '; \ + os << OutString(det->GETFCN(*it++, std::vector{det_id})) \ + << suffix; \ + while (it != t.cend()) { \ + os << ", " << ToString(*name_it++) << ' '; \ + os << OutString(det->GETFCN(*it++, std::vector{det_id})) \ + << suffix; \ + } \ + os << "]\n"; \ + } else if (action == slsDetectorDefs::PUT_ACTION) { \ + throw RuntimeError("Cannot put"); \ + } else { \ + throw RuntimeError("Unknown action"); \ + } \ + return os.str(); \ + } + #define CTB_SINGLE_DACNAME(CMDNAME, GETFCN, SETFCN, STARTINDEX, HLPSTR) \ std::string CMDNAME(const int action) { \ std::ostringstream os; \ @@ -1002,7 +1043,7 @@ class CmdProxy { {"temp_slowadc", &CmdProxy::temp_slowadc}, /* lists */ - {"daclist", &CmdProxy::DacList}, + {"daclist", &CmdProxy::daclist}, {"dacname", &CmdProxy::dacname}, {"dacindex", &CmdProxy::dacindex}, {"adclist", &CmdProxy::adclist}, @@ -1014,9 +1055,11 @@ class CmdProxy { {"voltagelist", &CmdProxy::voltagelist}, {"voltagename", &CmdProxy::voltagename}, {"voltageindex", &CmdProxy::voltageindex}, + {"voltagevalues", &CmdProxy::voltagevalues}, {"slowadclist", &CmdProxy::slowadclist}, {"slowadcname", &CmdProxy::slowadcname}, {"slowadcindex", &CmdProxy::slowadcindex}, + {"slowadcvalues", &CmdProxy::slowadcvalues}, /* dacs */ {"dac", &CmdProxy::Dac}, @@ -1214,7 +1257,7 @@ class CmdProxy { {"im_c", &CmdProxy::im_c}, {"im_d", &CmdProxy::im_d}, {"im_io", &CmdProxy::im_io}, - {"slowadc", &CmdProxy::SlowAdc}, + {"slowadc", &CmdProxy::SlowADC}, {"extsampling", &CmdProxy::extsampling}, {"extsamplingsrc", &CmdProxy::extsamplingsrc}, {"rx_dbitlist", &CmdProxy::ReceiverDbitList}, @@ -1319,7 +1362,6 @@ class CmdProxy { /** temperature */ std::string TemperatureValues(int action); /* list */ - std::string DacList(int action); /* dacs */ std::string Dac(int action); std::string DacValues(int action); @@ -1375,7 +1417,7 @@ class CmdProxy { std::string Samples(int action); /* CTB Specific */ std::string AdcVpp(int action); - std::string SlowAdc(int action); + std::string SlowADC(int action); std::string ReceiverDbitList(int action); std::string DigitalIODelay(int action); /* Pattern */ @@ -1411,10 +1453,10 @@ class CmdProxy { "[fname]\n\tFrees shared memory before loading configuration file. " "Set up once."); - EXECUTE_SET_COMMAND_NOID_1ARG( - parameters, loadParameters, - "[fname]\n\tSets detector measurement parameters to those contained in " - "fname. Set up per measurement."); + EXECUTE_SET_COMMAND_NOID_1ARG(parameters, loadParameters, + "[fname]\n\tSets detector measurement " + "parameters to those contained in " + "fname. Set up per measurement."); GET_COMMAND(detectorserverversion, getDetectorServerVersion, "\n\tOn-board detector server software version"); @@ -1506,8 +1548,9 @@ class CmdProxy { frames, getNumberOfFrames, setNumberOfFrames, StringTo, "[n_frames]\n\tNumber of frames per acquisition. In " "trigger mode, number of frames per trigger. \n\tCannot be set in " - "modular level. \n\tIn scan mode, number of frames is set to number of " - "steps.\n\t[Gotthard2] Burst mode has a maximum of 2720 frames."); + "modular level. \n\tIn scan mode, number of frames is set to " + "number of steps.\n\t[Gotthard2] Burst mode has a maximum of 2720 " + "frames."); INTEGER_COMMAND_SET_NOID_GET_ID( triggers, getNumberOfTriggers, setNumberOfTriggers, StringTo, @@ -1518,11 +1561,10 @@ class CmdProxy { period, getPeriod, setPeriod, "[duration] [(optional unit) ns|us|ms|s]\n\tPeriod between frames"); - TIME_COMMAND( - delay, getDelayAfterTrigger, setDelayAfterTrigger, - "[duration] [(optional unit) " - "ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][" - "Moench] Delay after trigger"); + TIME_COMMAND(delay, getDelayAfterTrigger, setDelayAfterTrigger, + "[duration] [(optional unit) " + "ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][" + "Gotthard2][Ctb][Moench] Delay after trigger"); GET_COMMAND(framesl, getNumberOfFramesLeft, "\n\t[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][CTB] " @@ -1594,16 +1636,15 @@ class CmdProxy { "will return power status. Can be off if temperature event occured " "(temperature over temp_threshold with temp_control " "enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] " - "Default is 1. If module not " - "connected or wrong module, powerchip will fail."); + "Default is 1. If module not connected or wrong module, powerchip will " + "fail."); INTEGER_COMMAND_VEC_ID( imagetest, getImageTestMode, setImageTestMode, StringTo, "[0, 1]\n\t[Gotthard] 1 adds channel intensity with precalculated " "values when taking an acquisition. Default is 0." "\n\t[Eiger][Jungfrau][Moench] Only for Virtual servers. If 0, each " - "pixel " - "intensity incremented by 1. If 1, all pixels almost saturated."); + "pixel intensity incremented by 1. If 1, all pixels almost saturated."); INTEGER_COMMAND_VEC_ID( parallel, getParallelMode, setParallelMode, StringTo, @@ -1618,8 +1659,8 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( filterresistor, getFilterResistor, setFilterResistor, StringTo, "[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."); + "values for increasing resistance.\n\t[Gotthard2] Options: " + "[0|1|2|3]. Default is 0.\n\t[Jungfrau] Options: [0|1]. Default is 1."); INTEGER_COMMAND_VEC_ID(dbitpipeline, getDBITPipeline, setDBITPipeline, StringTo, @@ -1629,14 +1670,14 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( readnrows, getReadNRows, setReadNRows, StringTo, - "\n\t[1-256]\n\t\t[Eiger] Number of rows to readout per half module " - "starting from the centre. Options: 0 - 256. 256 is default. The " - "permissible values depend on dynamic range and 10Gbe " + "\n\t[1-256]\n\t\t[Eiger] Number of rows to readout per half " + "module starting from the centre. Options: 0 - 256. 256 is default. " + "The permissible values depend on dynamic range and 10Gbe " "enabled.\n\t[8-512 (multiple of 8)]\n\t\t[Jungfrau] Number of rows " "per module starting from the centre. Options: 8 - 512, must be " - "multiples of 8. Default is 512.\n\t\t[Moench] Number of rows " - "per module starting from the centre. Options:16 - 400, must be " - "multiples of 16. Default is 400."); + "multiples of 8. Default is 512.\n\t\t[Moench] Number of rows per " + "module starting from the centre. Options:16 - 400, must be multiples " + "of 16. Default is 400."); /** temperature */ GET_COMMAND_NOID( @@ -1668,23 +1709,30 @@ class CmdProxy { temp_sodl, getTemperature, slsDetectorDefs::TEMPERATURE_SODL, " °C", "[n_value]\n\t[Eiger]Temperature close to the left so-dimm memory"); - GET_IND_COMMAND( - temp_sodr, getTemperature, slsDetectorDefs::TEMPERATURE_SODR, " °C", - "[n_value]\n\t[Eiger]Temperature close to the right so-dimm memory"); + GET_IND_COMMAND(temp_sodr, getTemperature, + slsDetectorDefs::TEMPERATURE_SODR, " °C", + "[n_value]\n\t[Eiger]Temperature close to the right " + "so-dimm memory"); - GET_IND_COMMAND( - temp_fpgafl, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA2, " °C", - "[n_value]\n\t[Eiger]Temperature of the left front end board fpga."); + GET_IND_COMMAND(temp_fpgafl, getTemperature, + slsDetectorDefs::TEMPERATURE_FPGA2, " °C", + "[n_value]\n\t[Eiger]Temperature of the left front end " + "board fpga."); - GET_IND_COMMAND( - temp_fpgafr, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA3, " °C", - "[n_value]\n\t[Eiger]Temperature of the left front end board fpga."); + GET_IND_COMMAND(temp_fpgafr, getTemperature, + slsDetectorDefs::TEMPERATURE_FPGA3, " °C", + "[n_value]\n\t[Eiger]Temperature of the left front end " + "board fpga."); GET_IND_COMMAND(temp_slowadc, getTemperature, slsDetectorDefs::SLOW_ADC_TEMP, " °C", "[n_value]\n\t[Ctb]Temperature of the slow adc"); /* lists */ + CTB_NAMED_LIST(daclist, getDacNames, setDacNames, + "[dacname1 dacname2 .. dacname18] \n\t\t[ChipTestBoard] Set " + "the list of dac names for this detector.\n\t\t[All] Gets " + "the list of dac names for every dac for this detector."); CTB_SINGLE_DACNAME(dacname, getDacName, setDacName, defs::DAC_0, "\n\t[0-17][name] \n\t\t[ChipTestBoard] Set " @@ -1706,10 +1754,10 @@ class CmdProxy { "[name] \n\t\t[ChipTestBoard] Get " "the adc index for the given name."); - CTB_NAMED_LIST( - signallist, getSignalNames, setSignalNames, - "[signalname1 signalname2 .. signalname63] \n\t\t[ChipTestBoard] Set " - "the list of signal names for this board."); + CTB_NAMED_LIST(signallist, getSignalNames, setSignalNames, + "[signalname1 signalname2 .. signalname63] " + "\n\t\t[ChipTestBoard] Set " + "the list of signal names for this board."); CTB_SINGLE_NAME(signalname, getSignalName, setSignalName, "[0-63][name] \n\t\t[ChipTestBoard] Set " @@ -1719,10 +1767,10 @@ class CmdProxy { "[name] \n\t\t[ChipTestBoard] Get " "the signal index for the given name."); - CTB_NAMED_LIST( - voltagelist, getVoltageNames, setVoltageNames, - "[voltagename1 voltagename2 .. voltagename4] \n\t\t[ChipTestBoard] Set " - "the list of voltage names for this board."); + CTB_NAMED_LIST(voltagelist, getVoltageNames, setVoltageNames, + "[voltagename1 voltagename2 .. voltagename4] " + "\n\t\t[ChipTestBoard] Set " + "the list of voltage names for this board."); CTB_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName, defs::V_POWER_A, @@ -1733,17 +1781,23 @@ class CmdProxy { "[name] \n\t\t[ChipTestBoard] Get " "the voltage index for the given name."); - CTB_NAMED_LIST( - slowadclist, getSlowAdcNames, setSlowAdcNames, - "[slowadcname1 slowadcname2 .. slowadcname7] \n\t\t[ChipTestBoard] Set " - "the list of slowadc names for this board."); + CTB_VALUES(voltagevalues, getVoltage, getVoltageList, getVoltageNames, + "[name] \n\t\t[ChipTestBoard] Get values of all voltages."); - CTB_SINGLE_DACNAME(slowadcname, getSlowAdcName, setSlowAdcName, + CTB_VALUES(slowadcvalues, getSlowADC, getSlowADCList, getSlowADCNames, + "[name] \n\t\t[ChipTestBoard] Get values of all slow adcs."); + + CTB_NAMED_LIST( + slowadclist, getSlowADCNames, setSlowADCNames, + "[slowadcname1 slowadcname2 .. slowadcname7] " + "\n\t\t[ChipTestBoard] Set the list of slowadc names for this board."); + + CTB_SINGLE_DACNAME(slowadcname, getSlowADCName, setSlowADCName, defs::SLOW_ADC0, "[0-7][name] \n\t\t[ChipTestBoard] Set " "the slowadc at the given position to the given name."); - CTB_GET_DACINDEX(slowadcindex, getSlowAdcIndex, defs::SLOW_ADC0, + CTB_GET_DACINDEX(slowadcindex, getSlowADCIndex, defs::SLOW_ADC0, "[name] \n\t\t[ChipTestBoard] Get " "the slowadc index for the given name."); @@ -1753,50 +1807,53 @@ class CmdProxy { INTEGER_USER_IND_COMMAND( vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo, defs::VB_COMP_FE, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " - "chip Dac for comparator current of analogue front end."); + "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] " + "On chip Dac for comparator current of analogue front end."); INTEGER_USER_IND_COMMAND( vchip_opa_1st, getOnChipDAC, setOnChipDAC, StringTo, defs::VB_OPA_1ST, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " + "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] " + "On " "chip Dac for opa current for driving the other DACs in chip."); - INTEGER_USER_IND_COMMAND( - vchip_opa_fd, getOnChipDAC, setOnChipDAC, StringTo, - defs::VB_OPA_FD, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " - "chip Dac current for CDS opa stage."); + INTEGER_USER_IND_COMMAND(vchip_opa_fd, getOnChipDAC, setOnChipDAC, + StringTo, defs::VB_OPA_FD, + "[chip index 0-10, -1 for all][10 bit hex " + "value] \n\t[Gotthard2] On " + "chip Dac current for CDS opa stage."); - INTEGER_USER_IND_COMMAND( - vchip_comp_adc, getOnChipDAC, setOnChipDAC, StringTo, - defs::VB_COMP_ADC, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " - "chip Dac for comparator current of ADC."); + INTEGER_USER_IND_COMMAND(vchip_comp_adc, getOnChipDAC, setOnChipDAC, + StringTo, defs::VB_COMP_ADC, + "[chip index 0-10, -1 for all][10 bit hex " + "value] \n\t[Gotthard2] On " + "chip Dac for comparator current of ADC."); - INTEGER_USER_IND_COMMAND( - vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, StringTo, - defs::VREF_COMP_FE, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " - "chip Dac for reference voltage of the comparator of analogue front " - "end."); + INTEGER_USER_IND_COMMAND(vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, + StringTo, defs::VREF_COMP_FE, + "[chip index 0-10, -1 for all][10 bit hex " + "value] \n\t[Gotthard2] On " + "chip Dac for reference voltage of the " + "comparator of analogue front " + "end."); INTEGER_USER_IND_COMMAND( vchip_cs, getOnChipDAC, setOnChipDAC, StringTo, defs::VB_CS, - "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On " - "chip Dac for current injection into preamplifier."); + "[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] " + "On chip Dac for current injection into preamplifier."); /* acquisition */ EXECUTE_SET_COMMAND_NOID( clearbusy, clearAcquiringFlag, - "\n\tIf acquisition aborted during acquire command, use this to clear " - "acquiring flag in shared memory before starting next acquisition"); + "\n\tIf acquisition aborted during acquire command, use this to " + "clear acquiring flag in shared memory before starting next " + "acquisition"); - EXECUTE_SET_COMMAND_NOID( - rx_start, startReceiver, - "\n\tStarts receiver listener for detector data packets and create a " - "data file (if file write enabled)."); + EXECUTE_SET_COMMAND_NOID(rx_start, startReceiver, + "\n\tStarts receiver listener for detector " + "data packets and create a " + "data file (if file write enabled)."); EXECUTE_SET_COMMAND_NOID( rx_stop, stopReceiver, @@ -1805,15 +1862,16 @@ class CmdProxy { EXECUTE_SET_COMMAND( start, startDetector, - "\n\tStarts detector acquisition. Status changes to RUNNING or WAITING " - "and automatically returns to idle at the end of acquisition. If the " - "acquisition was abruptly stopped, some detectors come back to " + "\n\tStarts detector acquisition. Status changes to RUNNING or " + "WAITING and automatically returns to idle at the end of acquisition. " + "If the acquisition was abruptly stopped, some detectors come back to " "STOPPED."); EXECUTE_SET_COMMAND_NOID( readout, startDetectorReadout, - "\n\t[Mythen3] Starts detector readout. Status changes to TRANSMITTING " - "and automatically returns to idle at the end of readout."); + "\n\t[Mythen3] Starts detector readout. Status changes to " + "TRANSMITTING and automatically returns to idle at the end of " + "readout."); EXECUTE_SET_COMMAND(stop, stopDetector, "\n\tAbort detector acquisition. Status changes " @@ -1847,24 +1905,23 @@ class CmdProxy { numinterfaces, getNumberofUDPInterfaces, setNumberofUDPInterfaces, StringTo, "[1, 2]\n\t[Jungfrau][Moench] Number of udp interfaces to stream " - "data from detector. Default: 1.\n\tAlso enables second interface in " - "receiver for listening (Writes a file per interface if writing " + "data from detector. Default: 1.\n\tAlso enables second interface " + "in receiver for listening (Writes a file per interface if writing " "enabled).\n\tAlso restarts client and receiver zmq sockets if zmq " "streaming enabled.\n\t[Eiger] Only gets with result 2."); - INTEGER_COMMAND_VEC_ID( - selinterface, getSelectedUDPInterface, selectUDPInterface, - StringTo, - "[0, 1]\n\t[Jungfrau][Moench] The udp interface to stream data from " - "detector. " - "Effective only when number of interfaces is 1. Default: 0 (outer)"); + INTEGER_COMMAND_VEC_ID(selinterface, getSelectedUDPInterface, + selectUDPInterface, StringTo, + "[0, 1]\n\t[Jungfrau][Moench] The udp interface " + "to stream data from detector. Effective only when " + "number of interfaces is 1. Default: 0 (outer)"); GET_COMMAND( udp_numdst, getNumberofUDPDestinations, - "\n\t[Jungfrau][Moench][Eiger][Mythen3][Gotthard2] One can enter upto " - "32 (64 " - "for Mythen3) destinations that the detector will stream images out in " - "a round robin fashion. This is get only command. Default: 1"); + "\n\t[Jungfrau][Moench][Eiger][Mythen3][Gotthard2] One can enter " + "upto 32 (64 for Mythen3) destinations that the detector will stream " + "images out in a round robin fashion. This is get only command. " + "Default: 1"); EXECUTE_SET_COMMAND(udp_cleardst, clearUDPDestinations, "\n\tClears udp destination details on the detector."); @@ -1873,17 +1930,16 @@ class CmdProxy { udp_firstdst, getFirstUDPDestination, setFirstUDPDestination, StringTo, "\n[0 - 31 (or number of udp " - "destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n[0-63]\n\t[Mythen3]" - "\n\n\t " - "One can set which is the first destination that the detector will " - "stream images out from in a round robin fashion. The entry must not " - "have been empty. Default: 0"); + "destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n[0-63]\n\t[" + "Mythen3]\n\n\t One can set which is the first destination that the " + "detector will stream images out from in a round robin fashion. The " + "entry must not have been empty. Default: 0"); INTEGER_COMMAND_VEC_ID( udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr, "[x:x:x:x:x:x]\n\tMac address of the detector (source) udp " - "interface. \n\t[Eiger] Do not set as detector will replace with its " - "own DHCP Mac (1G) or DHCP Mac + 1 (10G)."); + "interface. \n\t[Eiger] Do not set as detector will replace with " + "its own DHCP Mac (1G) or DHCP Mac + 1 (10G)."); INTEGER_COMMAND_VEC_ID( udp_srcmac2, getSourceUDPMAC2, setSourceUDPMAC2, MacAddr, @@ -1901,13 +1957,11 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( udp_dstmac2, getDestinationUDPMAC2, setDestinationUDPMAC2, MacAddr, "[x:x:x:x:x:x]\n\t[Jungfrau][Moench] Mac address of the receiver " - "(destination) " - "udp interface 2. Not mandatory to set as udp_dstip2 retrieves it from " - "slsReceiver process but must be set if you use a custom receiver (not " - "slsReceiver). \n\t [Jungfrau][Moench] top half or inner interface " - "\n\t " - "[Gotthard2] veto debugging. Use router mac if router between detector " - "and receiver."); + "(destination) udp interface 2. Not mandatory to set as udp_dstip2 " + "retrieves it from slsReceiver process but must be set if you use a " + "custom receiver (not slsReceiver). \n\t [Jungfrau][Moench] top half " + "or inner interface \n\t [Gotthard2] veto debugging. Use router mac if " + "router between detector and receiver."); INTEGER_COMMAND_VEC_ID_GET( udp_dstport, getDestinationUDPPort, setDestinationUDPPort, @@ -1922,15 +1976,14 @@ class CmdProxy { "[n]\n\t[Jungfrau][Moench][Eiger][Gotthard2] Port number of the " "receiver (destination) udp interface 2. Default is 50002. " "\n\tIf multi command, ports for each module is calculated " - "(incremented by 2) \n\t[Jungfrau][Moench] top half or inner interface " - "\n\t[Eiger] " - "right half \n\t[Gotthard2] veto debugging"); + "(incremented by 2) \n\t[Jungfrau][Moench] top half or inner " + "interface \n\t[Eiger] right half \n\t[Gotthard2] veto debugging"); EXECUTE_SET_COMMAND( udp_reconfigure, reconfigureUDPDestination, - "\n\tReconfigures Detector with UDP destination. More for debugging as " - "the configuration is done automatically when the detector has " - "sufficient UDP details."); + "\n\tReconfigures Detector with UDP destination. More for " + "debugging as the configuration is done automatically when the " + "detector has sufficient UDP details."); EXECUTE_SET_COMMAND( udp_validate, validateUDPConfiguration, @@ -1952,27 +2005,26 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( txdelay_frame, getTransmissionDelayFrame, setTransmissionDelayFrame, StringTo, - "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Transmission delay of " - "first " - "udp packet being streamed out of the module.\n\t[Jungfrau][Moench] " - "[0-31] " - "Each value represents 1 ms\n\t[Eiger] Additional delay to " - "txdelay_left and txdelay_right. Each value represents 10ns. Typical " - "value is 50000.\n\t[Mythen3] [0-16777215] Each value represents 8 ns " - "(125 MHz clock), max is 134 ms."); + "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Transmission " + "delay of first udp packet being streamed out of the " + "module.\n\t[Jungfrau][Moench] [0-31] Each value represents 1 " + "ms\n\t[Eiger] Additional delay to txdelay_left and txdelay_right. " + "Each value represents 10ns. Typical value is 50000.\n\t[Mythen3] " + "[0-16777215] Each value represents 8 ns (125 MHz clock), max is 134 " + "ms."); INTEGER_COMMAND_VEC_ID( txdelay_left, getTransmissionDelayLeft, setTransmissionDelayLeft, StringTo, - "[n_delay]\n\t[Eiger] Transmission delay of first packet in an image " - "being streamed out of the module's left UDP port. Each value " + "[n_delay]\n\t[Eiger] Transmission delay of first packet in an " + "image being streamed out of the module's left UDP port. Each value " "represents 10ns. Typical value is 50000."); INTEGER_COMMAND_VEC_ID( txdelay_right, getTransmissionDelayRight, setTransmissionDelayRight, StringTo, - "[n_delay]\n\t[Eiger] Transmission delay of first packet in an image " - "being streamed out of the module's right UDP port. Each value " + "[n_delay]\n\t[Eiger] Transmission delay of first packet in an " + "image being streamed out of the module's right UDP port. Each value " "represents 10ns. Typical value is 50000."); /* Receiver Config */ @@ -1989,9 +2041,10 @@ class CmdProxy { "[n_frames]\n\tSet the number of frames in the receiver " "fifo depth (buffer between listener and writer threads)."); - INTEGER_COMMAND_VEC_ID( - rx_silent, getRxSilentMode, setRxSilentMode, StringTo, - "[0, 1]\n\tSwitch on or off receiver text output during acquisition."); + INTEGER_COMMAND_VEC_ID(rx_silent, getRxSilentMode, setRxSilentMode, + StringTo, + "[0, 1]\n\tSwitch on or off receiver text " + "output during acquisition."); INTEGER_COMMAND_VEC_ID( rx_discardpolicy, getRxFrameDiscardPolicy, setRxFrameDiscardPolicy, @@ -2006,20 +2059,19 @@ class CmdProxy { "[0, 1]\n\tPartial frames padding enable in the " "receiver. Default: enabled. Disabling is fastest."); - INTEGER_COMMAND_VEC_ID( - rx_udpsocksize, getRxUDPSocketBufferSize, setRxUDPSocketBufferSize, - StringTo, - "[n_size]\n\tUDP socket buffer size in receiver. Tune rmem_default and " - "rmem_max accordingly. Max value is INT_MAX/2."); + INTEGER_COMMAND_VEC_ID(rx_udpsocksize, getRxUDPSocketBufferSize, + setRxUDPSocketBufferSize, StringTo, + "[n_size]\n\tUDP socket buffer size in " + "receiver. Tune rmem_default and rmem_max " + "accordingly. Max value is INT_MAX/2."); GET_COMMAND(rx_realudpsocksize, getRxRealUDPSocketBufferSize, "\n\tActual udp socket buffer size. Double the size of " "rx_udpsocksize due to kernel bookkeeping."); - INTEGER_COMMAND_VEC_ID( - rx_lock, getRxLock, setRxLock, StringTo, - "[0, 1]\n\tLock receiver to one client IP, 1 locks, 0 " - "unlocks. Default is unlocked."); + INTEGER_COMMAND_VEC_ID(rx_lock, getRxLock, setRxLock, StringTo, + "[0, 1]\n\tLock receiver to one client IP, 1 locks, " + "0 unlocks. Default is unlocked."); GET_COMMAND( rx_lastclient, getRxLastClientIP, @@ -2028,27 +2080,26 @@ class CmdProxy { GET_COMMAND( rx_threads, getRxThreadIds, "\n\tGet kernel thread ids from the receiver in order of [parent, " - "tcp, listener 0, processor 0, streamer 0, listener 1, " - "processor 1, streamer 1, arping]. If no streamer yet or there " - "is no second interface, it gives 0 in its place."); + "tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, " + "streamer 1, arping]. If no streamer yet or there is no second " + "interface, it gives 0 in its place."); - INTEGER_COMMAND_VEC_ID(rx_arping, getRxArping, setRxArping, StringTo, - "[0, 1]\n\tStarts a thread in slsReceiver to arping " - "the interface it is " - "listening to every minute. Useful in 10G mode."); + INTEGER_COMMAND_VEC_ID( + rx_arping, getRxArping, setRxArping, StringTo, + "[0, 1]\n\tStarts a thread in slsReceiver to arping " + "the interface it is listening to every minute. Useful in 10G mode."); - EXECUTE_SET_COMMAND_NOID( - rx_clearroi, clearRxROI, - "Resets Region of interest in receiver. Default is all " - "channels/pixels enabled."); + EXECUTE_SET_COMMAND_NOID(rx_clearroi, clearRxROI, + "Resets Region of interest in receiver. Default " + "is all channels/pixels enabled."); /* File */ INTEGER_COMMAND_VEC_ID( fformat, getFileFormat, setFileFormat, StringTo, - "[binary|hdf5]\n\tFile format of data file. For HDF5, package must be " - "compiled with HDF5 flags. Default is binary."); + "[binary|hdf5]\n\tFile format of data file. For " + "HDF5, package must be compiled with HDF5 flags. Default is binary."); STRING_COMMAND(fpath, getFilePath, setFilePath, "[path]\n\tDirectory where output data files are written in " @@ -2079,25 +2130,26 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( rx_framesperfile, getFramesPerFile, setFramesPerFile, StringTo, "[n_frames]\n\tNumber of frames per file in receiver in an " - "acquisition. Default depends on detector type. 0 is infinite or all " + "acquisition. Default depends on detector type. 0 is infinite or " + "all " "frames in single file."); /* ZMQ Streaming Parameters (Receiver<->Client) */ INTEGER_COMMAND_VEC_ID( rx_zmqstream, getRxZmqDataStream, setRxZmqDataStream, StringTo, - "[0, 1]\n\tEnable/ disable data streaming from receiver via zmq (eg. " - "to GUI or to another process for further processing). This creates/ " - "destroys zmq streamer threads in receiver. \n\tSwitching to Gui " - "automatically enables data streaming in receiver. \n\tSwitching back " - "to command line acquire will require disabling data streaming in " + "[0, 1]\n\tEnable/ disable data streaming from receiver via zmq " + "(eg. to GUI or to another process for further processing). This " + "creates/ destroys zmq streamer threads in receiver. \n\tSwitching to " + "Gui automatically enables data streaming in receiver. \n\tSwitching " + "back to command line acquire will require disabling data streaming in " "receiver for fast applications. "); INTEGER_COMMAND_VEC_ID( rx_zmqfreq, getRxZmqFrequency, setRxZmqFrequency, StringTo, "[nth frame]\n\tFrequency of frames streamed out from receiver via " - "zmq\n\tDefault: 1, Means every frame is streamed out. \n\tIf 2, every " - "second frame is streamed out. \n\tIf 0, streaming timer is the " + "zmq\n\tDefault: 1, Means every frame is streamed out. \n\tIf 2, " + "every second frame is streamed out. \n\tIf 0, streaming timer is the " "timeout, after which current frame is sent out. (default timeout is " "500 ms). Usually used for gui purposes."); @@ -2110,42 +2162,42 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID_GET( rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo, - "[port]\n\tZmq port for data to be streamed out of the receiver. Also " - "restarts receiver zmq streaming if enabled. Default is 30001. " + "[port]\n\tZmq port for data to be streamed out of the receiver. " + "Also restarts receiver zmq streaming if enabled. Default is 30001. " "Modified only when using an intermediate process between receiver and " "client(gui). Must be different for every detector (and udp port). " "Multi command will automatically increment for individual modules."); INTEGER_COMMAND_VEC_ID_GET( zmqport, getClientZmqPort, setClientZmqPort, StringTo, - "[port]\n\tZmq port in client(gui) or intermediate process for data to " - "be streamed to from receiver. Default connects to receiver zmq " - "streaming out port (30001). Modified only when using an intermediate " - "process between receiver and client(gui). Also restarts client zmq " - "streaming if enabled. Must be different for every detector (and udp " - "port). Multi command will automatically increment for individual " - "modules."); + "[port]\n\tZmq port in client(gui) or intermediate process for " + "data to be streamed to from receiver. Default connects to receiver " + "zmq streaming out port (30001). Modified only when using an " + "intermediate process between receiver and client(gui). Also restarts " + "client zmq streaming if enabled. Must be different for every detector " + "(and udp port). Multi command will automatically increment for " + "individual modules."); INTEGER_COMMAND_VEC_ID( rx_zmqip, getRxZmqIP, setRxZmqIP, IpAddr, - "[x.x.x.x]\n\tZmq Ip Address from which data is to be streamed out of " - "the receiver. Also restarts receiver zmq streaming if enabled. " + "[x.x.x.x]\n\tZmq Ip Address from which data is to be streamed out " + "of the receiver. Also restarts receiver zmq streaming if enabled. " "Default is from rx_hostname. Modified only when using an intermediate " "process between receiver."); INTEGER_COMMAND_VEC_ID( zmqip, getClientZmqIp, setClientZmqIp, IpAddr, "[x.x.x.x]\n\tIp Address to listen to zmq data streamed out from " - "receiver or intermediate process. Default connects to " - "receiver zmq Ip Address (from rx_hostname). Modified only when using " - "an intermediate process between receiver and client(gui). Also " - "restarts client zmq streaming if enabled."); + "receiver or intermediate process. Default connects to receiver zmq Ip " + "Address (from rx_hostname). Modified only when using an intermediate " + "process between receiver and client(gui). Also restarts client zmq " + "streaming if enabled."); INTEGER_COMMAND_SET_NOID_GET_ID( rx_zmqhwm, getRxZmqHwm, setRxZmqHwm, StringTo, - "[n_value]\n\tReceiver's zmq send high water mark. Default is the zmq " - "library's default (1000). This is a high number and can be set to 2 " - "for gui purposes. One must also set the client's receive high water " + "[n_value]\n\tReceiver's zmq send high water mark. Default is the " + "zmq library's default (1000). This is a high number and can be set to " + "2 for gui purposes. One must also set the client's receive high water " "mark to similar value. Final effect is sum of them. Also restarts " "receiver zmq streaming if enabled. Can set to -1 to set default " "value."); @@ -2188,9 +2240,9 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( partialreset, getPartialReset, setPartialReset, StringTo, - "[0, 1]\n\t[Eiger] Sets up detector to do partial or complete reset at " - "start of acquisition. 0 complete reset, 1 partial reset. Default is " - "complete reset. Advanced function!"); + "[0, 1]\n\t[Eiger] Sets up detector to do " + "partial or complete reset at start of acquisition. 0 complete reset, " + "1 partial reset. Default is complete reset. Advanced function!"); INTEGER_COMMAND_VEC_ID( top, getTop, setTop, StringTo, @@ -2204,18 +2256,18 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( temp_threshold, getThresholdTemperature, setThresholdTemperature, StringTo, - "[n_temp (in degrees)]\n\t[Jungfrau][Moench] Threshold temperature in " - "degrees. " - "If temperature crosses threshold temperature and temperature control " - "is enabled, power to chip will be switched off and temperature event " - "occurs. To power on chip again, temperature has to be less than " - "threshold temperature and temperature event has to be cleared."); + "[n_temp (in degrees)]\n\t[Jungfrau][Moench] Threshold temperature " + "in degrees. If temperature crosses threshold temperature and " + "temperature control is enabled, power to chip will be switched off " + "and temperature event occurs. To power on chip again, temperature has " + "to be less than threshold temperature and temperature event has to be " + "cleared."); INTEGER_COMMAND_VEC_ID( temp_control, getTemperatureControl, setTemperatureControl, StringTo, - "[0, 1]\n\t[Jungfrau][Moench] Temperature control enable. Default is 0 " - "(disabled). If temperature crosses threshold temperature and " + "[0, 1]\n\t[Jungfrau][Moench] Temperature control enable. Default " + "is 0 (disabled). If temperature crosses threshold temperature and " "temperature control is enabled, power to chip will be switched off " "and temperature event occurs. To power on chip again, temperature has " "to be less than threshold temperature and temperature event has to be " @@ -2226,12 +2278,12 @@ class CmdProxy { 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 compdisabletime command.\n\tDefault is 0 or this mode " - "disabled(comparator enabled throughout). 1 enables mode. 0 disables " - "mode. "); + "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 compdisabletime command.\n\tDefault is 0 or this " + "mode disabled(comparator enabled throughout). 1 enables mode. 0 " + "disables mode. "); TIME_COMMAND(compdisabletime, getComparatorDisableTime, setComparatorDisableTime, @@ -2242,16 +2294,16 @@ class CmdProxy { INTEGER_COMMAND_SET_NOID_GET_ID( extrastoragecells, getNumberOfAdditionalStorageCells, setNumberOfAdditionalStorageCells, StringTo, - "[0-15]\n\t[Jungfrau] Only for chipv1.0. Number of additional storage " - "cells. Default is 0. For advanced users only. \n\tThe #images = " - "#frames x #triggers x (#extrastoragecells + 1)."); + "[0-15]\n\t[Jungfrau] Only for chipv1.0. Number of additional " + "storage cells. Default is 0. For advanced users only. \n\tThe #images " + "= #frames x #triggers x (#extrastoragecells + 1)."); INTEGER_COMMAND_VEC_ID( storagecell_start, getStorageCellStart, setStorageCellStart, StringTo, - "[0-max]\n\t[Jungfrau] Storage cell that stores the first acquisition " - "of the series. max is 15 (default) for chipv1.0 and 3 (default) for " - "chipv1.1. For advanced users only."); + "[0-max]\n\t[Jungfrau] Storage cell that stores " + "the first acquisition of the series. max is 15 (default) for chipv1.0 " + "and 3 (default) for chipv1.1. For advanced users only."); TIME_COMMAND(storagecell_delay, getStorageCellDelay, setStorageCellDelay, "[duration (0-1638375 ns)] [(optional unit) " @@ -2262,8 +2314,8 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( gainmode, getGainMode, setGainMode, StringTo, "[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t[" - "Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, " - "you can damage the detector!!!"); + "Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without " + "caution, you can damage the detector!!!"); INTEGER_COMMAND_VEC_ID(filtercells, getNumberOfFilterCells, setNumberOfFilterCells, StringTo, @@ -2286,10 +2338,10 @@ class CmdProxy { "timing mode and burst mode. Use timing command to set timing mode and " "burstmode command to set burst mode."); - TIME_COMMAND( - burstperiod, getBurstPeriod, setBurstPeriod, - "[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] " - "Period between 2 bursts. Only in burst mode and auto timing mode."); + TIME_COMMAND(burstperiod, getBurstPeriod, setBurstPeriod, + "[duration] [(optional unit) ns|us|ms|s]\n\t[Gotthard2] " + "Period between 2 bursts. Only in burst mode and auto " + "timing mode."); GET_COMMAND(burstsl, getNumberOfBurstsLeft, "\n\t[Gotthard2] Number of bursts left in acquisition. Only in " @@ -2303,8 +2355,8 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( timingsource, getTimingSource, setTimingSource, StringTo, - "[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal " - "and external is system timing. Default is internal."); + "[internal|external]\n\t[Gotthard2] Timing source. Internal is " + "crystal and external is system timing. Default is internal."); INTEGER_COMMAND_VEC_ID(veto, getVeto, setVeto, StringTo, "[0, 1]\n\t[Gotthard2] Enable or disable veto data " @@ -2380,8 +2432,8 @@ class CmdProxy { adcenable10g, getTenGigaADCEnableMask, setTenGigaADCEnableMask, StringTo, "[bitmask]\n\t[Ctb] ADC Enable Mask for 10Gb mode for each 32 " - "ADC channel. However, if any of a consecutive 4 bits are enabled, the " - "complete 4 bits are enabled."); + "ADC channel. However, if any of a consecutive 4 bits are enabled, " + "the complete 4 bits are enabled."); /* CTB Specific */ @@ -2396,9 +2448,9 @@ class CmdProxy { "[analog|digital|analog_digital]\n\t[CTB] Readout mode. " "Default is analog."); - INTEGER_COMMAND_VEC_ID( - dbitclk, getDBITClock, setDBITClock, StringTo, - "[n_clk in MHz]\n\t[Ctb] Clock for latching the digital bits in MHz."); + INTEGER_COMMAND_VEC_ID(dbitclk, getDBITClock, setDBITClock, StringTo, + "[n_clk in MHz]\n\t[Ctb] Clock for latching the " + "digital bits in MHz."); INTEGER_IND_COMMAND(v_a, getVoltage, setVoltage, StringTo, defs::V_POWER_A, @@ -2418,13 +2470,14 @@ class CmdProxy { INTEGER_IND_COMMAND( v_io, getVoltage, setVoltage, StringTo, defs::V_POWER_IO, - "[n_value]\n\t[Ctb] Voltage supply io in mV. Minimum 1200 mV. Must be " - "the first power regulator to be set after fpga reset (on-board " + "[n_value]\n\t[Ctb] Voltage supply io in mV. Minimum 1200 mV. Must " + "be the first power regulator to be set after fpga reset (on-board " "detector server start up)."); INTEGER_IND_COMMAND( v_chip, getVoltage, setVoltage, StringTo, defs::V_POWER_CHIP, - "[n_value]\n\t[Ctb] Voltage supply chip in mV. Do not use it unless " + "[n_value]\n\t[Ctb] Voltage supply chip in mV. Do not use it " + "unless " "you are completely sure you will not fry the board."); GET_IND_COMMAND(vm_a, getMeasuredVoltage, defs::V_POWER_A, "", @@ -2459,8 +2512,8 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( extsampling, getExternalSampling, setExternalSampling, StringTo, - "[0, 1]\n\t[Ctb] Enable for external sampling signal for digital data " - "to signal by extsampling src command. For advanced users only."); + "[0, 1]\n\t[Ctb] Enable for external sampling signal for digital " + "data to signal by extsampling src command. For advanced users only."); INTEGER_COMMAND_VEC_ID( extsamplingsrc, getExternalSamplingSource, setExternalSamplingSource, @@ -2524,19 +2577,19 @@ class CmdProxy { INTEGER_COMMAND_VEC_ID( updatemode, getUpdateMode, setUpdateMode, StringTo, - "[0|1]\n\tRestart the detector server in update mode or not. This is " - "useful when server-firmware compatibility is at its worst and server " - "cannot start up normally"); + "[0|1]\n\tRestart the detector server in update " + "mode or not. This is useful when server-firmware compatibility is at " + "its worst and server cannot start up normally"); EXECUTE_SET_COMMAND( firmwaretest, executeFirmwareTest, - "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Firmware " - "test, ie. reads a read fixed pattern from a register."); + "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] " + "Firmware test, ie. reads a read fixed pattern from a register."); EXECUTE_SET_COMMAND( bustest, executeBusTest, - "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Bus test, " - "ie. Writes different values in a R/W register and confirms the " + "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Bus " + "test, ie. Writes different values in a R/W register and confirms the " "writes to check bus.\n\tAdvanced User function!"); INTEGER_COMMAND_HEX( @@ -2565,22 +2618,22 @@ class CmdProxy { lastclient, getLastClientIP, "\n\tClient IP Address that last communicated with the detector."); - GET_COMMAND(framecounter, getNumberOfFramesFromStart, - "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][CTB] " - "Number of frames from start run control." - "\n\t[Gotthard2] only in continuous mode."); + GET_COMMAND( + framecounter, getNumberOfFramesFromStart, + "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames from " + "start run control.\n\t[Gotthard2] only in continuous mode."); TIME_GET_COMMAND(runtime, getActualTime, "[(optional unit) " "ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][" - "CTB] Time from detector start up." - "\n\t[Gotthard2] not in burst and auto mode."); + "CTB] Time from detector start up.\n\t[Gotthard2] not in " + "burst and auto mode."); TIME_GET_COMMAND(frametime, getMeasurementTime, "[(optional unit) " "ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][" - "CTB] Timestamp at a frame start." - "\n\t[Gotthard2] not in burst and auto mode."); + "CTB] Timestamp at a frame start.\n\t[Gotthard2] not in " + "burst and auto mode."); }; } // namespace sls diff --git a/slsDetectorSoftware/src/CtbConfig.cpp b/slsDetectorSoftware/src/CtbConfig.cpp index 77edb1a3d..a76a99b43 100644 --- a/slsDetectorSoftware/src/CtbConfig.cpp +++ b/slsDetectorSoftware/src/CtbConfig.cpp @@ -25,8 +25,8 @@ CtbConfig::CtbConfig() { setVoltageName(2, "VC"); setVoltageName(3, "VD"); setVoltageName(4, "VIO"); - for (size_t i = 0; i != num_slowAdcs; ++i) { - setSlowAdcName(i, "SLOWADC" + ToString(i)); + for (size_t i = 0; i != num_slowADCs; ++i) { + setSlowADCName(i, "SLOWADC" + ToString(i)); } } @@ -64,9 +64,9 @@ void CtbConfig::check_voltage_index(size_t i) const { } void CtbConfig::check_slow_adc_index(size_t i) const { - if (i >= num_slowAdcs) { + if (i >= num_slowADCs) { std::ostringstream oss; - oss << "Invalid Slow ADC index. Options: 0 - " << num_slowAdcs + oss << "Invalid Slow ADC index. Options: 0 - " << num_slowADCs << " or SLOW_ADC0 - SLOW_ADC7"; throw RuntimeError(oss.str()); } @@ -206,33 +206,33 @@ std::vector CtbConfig::getVoltageNames() const { return names; } -void CtbConfig::setSlowAdcName(size_t index, const std::string &name) { +void CtbConfig::setSlowADCName(size_t index, const std::string &name) { check_slow_adc_index(index); check_size(name); - char *dst = &slowAdcnames[index * name_length]; + char *dst = &slowADCnames[index * name_length]; memset(dst, '\0', name_length); memcpy(dst, &name[0], name.size()); } -void CtbConfig::setSlowAdcNames(const std::vector &names) { - if (names.size() != num_slowAdcs) { +void CtbConfig::setSlowADCNames(const std::vector &names) { + if (names.size() != num_slowADCs) { throw RuntimeError("Slow ADC names need to be of size " + - std::to_string(num_slowAdcs)); + std::to_string(num_slowADCs)); } - for (size_t i = 0; i != num_slowAdcs; ++i) { - setSlowAdcName(i, names[i]); + for (size_t i = 0; i != num_slowADCs; ++i) { + setSlowADCName(i, names[i]); } } -std::string CtbConfig::getSlowAdcName(size_t index) const { +std::string CtbConfig::getSlowADCName(size_t index) const { check_slow_adc_index(index); - return slowAdcnames + index * name_length; + return slowADCnames + index * name_length; } -std::vector CtbConfig::getSlowAdcNames() const { +std::vector CtbConfig::getSlowADCNames() const { std::vector names; - for (size_t i = 0; i != num_slowAdcs; ++i) - names.push_back(getSlowAdcName(i)); + for (size_t i = 0; i != num_slowADCs; ++i) + names.push_back(getSlowADCName(i)); return names; } diff --git a/slsDetectorSoftware/src/CtbConfig.h b/slsDetectorSoftware/src/CtbConfig.h index 78863f5f6..2232dc29d 100644 --- a/slsDetectorSoftware/src/CtbConfig.h +++ b/slsDetectorSoftware/src/CtbConfig.h @@ -9,13 +9,13 @@ class CtbConfig { static constexpr size_t num_adcs = 32; static constexpr size_t num_signals = 64; static constexpr size_t num_voltages = 5; - static constexpr size_t num_slowAdcs = 8; + static constexpr size_t num_slowADCs = 8; static constexpr const char *shm_tag_ = "ctbdacs"; char dacnames[name_length * num_dacs]{}; char adcnames[name_length * num_adcs]{}; char signalnames[name_length * num_signals]{}; char voltagenames[name_length * num_voltages]{}; - char slowAdcnames[name_length * num_slowAdcs]{}; + char slowADCnames[name_length * num_slowADCs]{}; void check_dac_index(size_t i) const; void check_adc_index(size_t i) const; @@ -51,10 +51,10 @@ class CtbConfig { std::string getVoltageName(size_t index) const; std::vector getVoltageNames() const; - void setSlowAdcNames(const std::vector &names); - void setSlowAdcName(size_t index, const std::string &name); - std::string getSlowAdcName(size_t index) const; - std::vector getSlowAdcNames() const; + void setSlowADCNames(const std::vector &names); + void setSlowADCName(size_t index, const std::string &name); + std::string getSlowADCName(size_t index) const; + std::vector getSlowADCNames() const; static const char *shm_tag(); }; diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index bea46a61a..83cdf2c7d 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -2040,6 +2040,24 @@ void Detector::setADCPipeline(int value, Positions pos) { pimpl->Parallel(&Module::setADCPipeline, pos, value); } +std::vector Detector::getVoltageList() const { + if (getDetectorType().squash() != defs::CHIPTESTBOARD) { + throw RuntimeError("Voltage list not implemented for this detector"); + } + return std::vector{defs::V_POWER_A, defs::V_POWER_B, + defs::V_POWER_C, defs::V_POWER_D, + defs::V_POWER_IO}; +} + +std::vector Detector::getSlowADCList() const { + if (getDetectorType().squash() != defs::CHIPTESTBOARD) { + throw RuntimeError("Slow ADC list not implemented for this detector"); + } + return std::vector{ + defs::SLOW_ADC0, defs::SLOW_ADC1, defs::SLOW_ADC2, defs::SLOW_ADC3, + defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7}; +} + Result Detector::getVoltage(defs::dacIndex index, Positions pos) const { switch (index) { case defs::V_LIMIT: @@ -2352,39 +2370,39 @@ std::string Detector::getVoltageName(const defs::dacIndex i) const { return pimpl->getCtbVoltageName(i); } -void Detector::setSlowAdcNames(const std::vector names) { +void Detector::setSlowADCNames(const std::vector names) { if (getDetectorType().squash() != defs::CHIPTESTBOARD) - throw RuntimeError("Named SlowAdcs only for CTB"); - pimpl->setCtbSlowAdcNames(names); + throw RuntimeError("Named SlowADCs only for CTB"); + pimpl->setCtbSlowADCNames(names); } -std::vector Detector::getSlowAdcNames() const { +std::vector Detector::getSlowADCNames() const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) - throw RuntimeError("Named SlowAdcs only for CTB"); - return pimpl->getCtbSlowAdcNames(); + throw RuntimeError("Named SlowADCs only for CTB"); + return pimpl->getCtbSlowADCNames(); } -defs::dacIndex Detector::getSlowAdcIndex(const std::string &name) const { +defs::dacIndex Detector::getSlowADCIndex(const std::string &name) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) - throw RuntimeError("Named SlowAdcs only for CTB"); - auto names = getSlowAdcNames(); + throw RuntimeError("Named SlowADCs only for CTB"); + auto names = getSlowADCNames(); auto it = std::find(names.begin(), names.end(), name); if (it == names.end()) - throw RuntimeError("SlowAdc name not found"); + throw RuntimeError("SlowADC name not found"); return static_cast(it - names.begin() + defs::SLOW_ADC0); } -void Detector::setSlowAdcName(const defs::dacIndex index, +void Detector::setSlowADCName(const defs::dacIndex index, const std::string &name) { if (getDetectorType().squash() != defs::CHIPTESTBOARD) - throw RuntimeError("Named SlowAdcs only for CTB"); - pimpl->setCtbSlowAdcName(index, name); + throw RuntimeError("Named SlowADCs only for CTB"); + pimpl->setCtbSlowADCName(index, name); } -std::string Detector::getSlowAdcName(const defs::dacIndex i) const { +std::string Detector::getSlowADCName(const defs::dacIndex i) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) - throw RuntimeError("Named SlowAdcs only for CTB"); - return pimpl->getCtbSlowAdcName(i); + throw RuntimeError("Named SlowADCs only for CTB"); + return pimpl->getCtbSlowADCName(i); } // Pattern diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index b08cec4df..202d621fd 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -2055,21 +2055,21 @@ void DetectorImpl::setCtbVoltageName(const defs::dacIndex index, ctb_shm()->setVoltageName(static_cast(index - defs::V_POWER_A), name); } -std::vector DetectorImpl::getCtbSlowAdcNames() const { - return ctb_shm()->getSlowAdcNames(); +std::vector DetectorImpl::getCtbSlowADCNames() const { + return ctb_shm()->getSlowADCNames(); } -void DetectorImpl::setCtbSlowAdcNames(const std::vector &names) { - ctb_shm()->setSlowAdcNames(names); +void DetectorImpl::setCtbSlowADCNames(const std::vector &names) { + ctb_shm()->setSlowADCNames(names); } -std::string DetectorImpl::getCtbSlowAdcName(const defs::dacIndex i) const { - return ctb_shm()->getSlowAdcName(static_cast(i - defs::SLOW_ADC0)); +std::string DetectorImpl::getCtbSlowADCName(const defs::dacIndex i) const { + return ctb_shm()->getSlowADCName(static_cast(i - defs::SLOW_ADC0)); } -void DetectorImpl::setCtbSlowAdcName(const defs::dacIndex index, +void DetectorImpl::setCtbSlowADCName(const defs::dacIndex index, const std::string &name) { - ctb_shm()->setSlowAdcName(static_cast(index - defs::SLOW_ADC0), name); + ctb_shm()->setSlowADCName(static_cast(index - defs::SLOW_ADC0), name); } } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 08727df07..da37f6c00 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -345,10 +345,10 @@ class DetectorImpl : public virtual slsDetectorDefs { void setCtbVoltageNames(const std::vector &names); void setCtbVoltageName(const defs::dacIndex index, const std::string &name); - std::vector getCtbSlowAdcNames() const; - std::string getCtbSlowAdcName(const defs::dacIndex i) const; - void setCtbSlowAdcNames(const std::vector &names); - void setCtbSlowAdcName(const defs::dacIndex index, const std::string &name); + std::vector getCtbSlowADCNames() const; + std::string getCtbSlowADCName(const defs::dacIndex i) const; + void setCtbSlowADCNames(const std::vector &names); + void setCtbSlowADCName(const defs::dacIndex index, const std::string &name); private: /** diff --git a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp index 3a35fdc03..3396beee6 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -353,13 +353,27 @@ TEST_CASE("voltageindex", "[.cmd]") { } } +TEST_CASE("voltagevalues", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("voltagevalues", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("voltagevalues", {}, -1, PUT)); +} + +TEST_CASE("slowadcvalues", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("slowadcvalues", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("slowadcvalues", {}, -1, PUT)); +} + TEST_CASE("slowadclist", "[.cmd]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD) { - auto prev = det.getSlowAdcNames(); + auto prev = det.getSlowADCNames(); REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "s", "d"}, -1, PUT)); @@ -377,7 +391,7 @@ TEST_CASE("slowadclist", "[.cmd]") { REQUIRE(oss.str() == std::string("slowadclist ") + ToString(names) + '\n'); } - det.setSlowAdcNames(prev); + det.setSlowADCNames(prev); } else { REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "b"}, -1, PUT)); @@ -393,7 +407,7 @@ TEST_CASE("slowadcname", "[.cmd]") { if (det_type == defs::CHIPTESTBOARD) { defs::dacIndex ind = static_cast(2 + defs::SLOW_ADC0); std::string str_slowadc_index = "2"; - auto prev = det.getSlowAdcName(ind); + auto prev = det.getSlowADCName(ind); // 1 arg throw REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "3", "bname"}, -1, PUT)); @@ -411,7 +425,7 @@ TEST_CASE("slowadcname", "[.cmd]") { REQUIRE(oss.str() == std::string("slowadcname ") + str_slowadc_index + " bname\n"); } - det.setSlowAdcName(ind, prev); + det.setSlowADCName(ind, prev); } else { REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "b"}, -1, PUT)); @@ -432,7 +446,7 @@ TEST_CASE("slowadcindex", "[.cmd]") { REQUIRE_THROWS(proxy.Call("slowadcindex", {"2", "2"}, -1, PUT)); // invalid index REQUIRE_THROWS(proxy.Call("slowadcindex", {"8"}, -1, PUT)); - auto slowadcname = det.getSlowAdcName(ind); + auto slowadcname = det.getSlowADCName(ind); { std::ostringstream oss; REQUIRE_NOTHROW( diff --git a/slsDetectorSoftware/tests/test-CtbConfig.cpp b/slsDetectorSoftware/tests/test-CtbConfig.cpp index 7fb6a76ff..9b75f94c4 100644 --- a/slsDetectorSoftware/tests/test-CtbConfig.cpp +++ b/slsDetectorSoftware/tests/test-CtbConfig.cpp @@ -39,7 +39,7 @@ TEST_CASE("Default construction") { REQUIRE(signalnames[1] == "BIT1"); REQUIRE(signalnames[2] == "BIT2"); REQUIRE(signalnames[3] == "BIT3"); - auto sensenames = c.getSlowAdcNames(); + auto sensenames = c.getSlowADCNames(); REQUIRE(sensenames.size() == 8); REQUIRE(sensenames[0] == "SLOWADC0"); REQUIRE(sensenames[1] == "SLOWADC1");