From d3d98db7e99fcb2250525f2fcee03c09b1022712 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 19 Jun 2023 15:19:50 +0200 Subject: [PATCH] 1. Ctb powerindices (#767) * power and sense returning dac indices instead of int in Detector class --- python/src/detector.cpp | 69 ++++++----- slsDetectorSoftware/include/sls/Detector.h | 27 ++--- slsDetectorSoftware/src/CmdProxy.cpp | 60 ---------- slsDetectorSoftware/src/CmdProxy.h | 110 +++++++++++++++--- slsDetectorSoftware/src/CtbConfig.cpp | 22 ++-- slsDetectorSoftware/src/Detector.cpp | 32 ++--- slsDetectorSoftware/src/DetectorImpl.cpp | 25 ++-- slsDetectorSoftware/src/DetectorImpl.h | 16 +-- .../tests/test-CmdProxy-chiptestboard.cpp | 8 +- slsSupportLib/include/sls/versionAPI.h | 10 +- 10 files changed, 205 insertions(+), 174 deletions(-) diff --git a/python/src/detector.cpp b/python/src/detector.cpp index fd35c1f84..37f85c689 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1643,17 +1643,18 @@ void init_det(py::module &m) { CppDetectorApi.def("getDacNames", (std::vector(Detector::*)() const) & Detector::getDacNames); - CppDetectorApi.def("getDacIndex", - (defs::dacIndex(Detector::*)(const std::string &)) & - Detector::getDacIndex, - py::arg()); + CppDetectorApi.def( + "getDacIndex", + (defs::dacIndex(Detector::*)(const std::string &) const) & + Detector::getDacIndex, + py::arg()); CppDetectorApi.def( "setDacName", - (void (Detector::*)(defs::dacIndex, const std::string &)) & + (void (Detector::*)(const defs::dacIndex, const std::string &)) & Detector::setDacName, py::arg(), py::arg()); CppDetectorApi.def("getDacName", - (std::string(Detector::*)(defs::dacIndex)) & + (std::string(Detector::*)(const defs::dacIndex) const) & Detector::getDacName, py::arg()); CppDetectorApi.def("setAdcNames", @@ -1664,7 +1665,7 @@ void init_det(py::module &m) { (std::vector(Detector::*)() const) & Detector::getAdcNames); CppDetectorApi.def("getAdcIndex", - (int (Detector::*)(const std::string &)) & + (int (Detector::*)(const std::string &) const) & Detector::getAdcIndex, py::arg()); CppDetectorApi.def("setAdcName", @@ -1672,7 +1673,8 @@ void init_det(py::module &m) { Detector::setAdcName, py::arg(), py::arg()); CppDetectorApi.def("getAdcName", - (std::string(Detector::*)(int)) & Detector::getAdcName, + (std::string(Detector::*)(const int) const) & + Detector::getAdcName, py::arg()); CppDetectorApi.def("setSignalNames", (void (Detector::*)(const std::vector)) & @@ -1682,16 +1684,17 @@ void init_det(py::module &m) { (std::vector(Detector::*)() const) & Detector::getSignalNames); CppDetectorApi.def("getSignalIndex", - (int (Detector::*)(const std::string &)) & + (int (Detector::*)(const std::string &) const) & Detector::getSignalIndex, py::arg()); CppDetectorApi.def("setSignalName", (void (Detector::*)(const int, const std::string &)) & Detector::setSignalName, py::arg(), py::arg()); - CppDetectorApi.def( - "getSignalName", - (std::string(Detector::*)(int)) & Detector::getSignalName, py::arg()); + CppDetectorApi.def("getSignalName", + (std::string(Detector::*)(const int) const) & + Detector::getSignalName, + py::arg()); CppDetectorApi.def("setPowerNames", (void (Detector::*)(const std::vector)) & Detector::setPowerNames, @@ -1699,16 +1702,19 @@ void init_det(py::module &m) { CppDetectorApi.def("getPowerNames", (std::vector(Detector::*)() const) & Detector::getPowerNames); - CppDetectorApi.def("getPowerIndex", - (int (Detector::*)(const std::string &)) & - Detector::getPowerIndex, - py::arg()); - CppDetectorApi.def("setPowerName", - (void (Detector::*)(const int, const std::string &)) & - Detector::setPowerName, - py::arg(), py::arg()); + CppDetectorApi.def( + "getPowerIndex", + (defs::dacIndex(Detector::*)(const std::string &) const) & + Detector::getPowerIndex, + py::arg()); + CppDetectorApi.def( + "setPowerName", + (void (Detector::*)(const defs::dacIndex, const std::string &)) & + Detector::setPowerName, + py::arg(), py::arg()); CppDetectorApi.def("getPowerName", - (std::string(Detector::*)(int)) & Detector::getPowerName, + (std::string(Detector::*)(const defs::dacIndex) const) & + Detector::getPowerName, py::arg()); CppDetectorApi.def("setSenseNames", (void (Detector::*)(const std::vector)) & @@ -1717,16 +1723,19 @@ void init_det(py::module &m) { CppDetectorApi.def("getSenseNames", (std::vector(Detector::*)() const) & Detector::getSenseNames); - CppDetectorApi.def("getSenseIndex", - (int (Detector::*)(const std::string &)) & - Detector::getSenseIndex, - py::arg()); - CppDetectorApi.def("setSenseName", - (void (Detector::*)(const int, const std::string &)) & - Detector::setSenseName, - py::arg(), py::arg()); + CppDetectorApi.def( + "getSenseIndex", + (defs::dacIndex(Detector::*)(const std::string &) const) & + Detector::getSenseIndex, + py::arg()); + CppDetectorApi.def( + "setSenseName", + (void (Detector::*)(const defs::dacIndex, const std::string &)) & + Detector::setSenseName, + py::arg(), py::arg()); CppDetectorApi.def("getSenseName", - (std::string(Detector::*)(int)) & Detector::getSenseName, + (std::string(Detector::*)(const defs::dacIndex) const) & + Detector::getSenseName, py::arg()); CppDetectorApi.def( "setPattern", diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index f1c09b48b..e38006626 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1726,12 +1726,13 @@ class Detector { std::vector getDacNames() const; - defs::dacIndex getDacIndex(const std::string &name); + defs::dacIndex getDacIndex(const std::string &name) const; /** [CTB] */ - void setDacName(defs::dacIndex i, const std::string &name); + void setDacName(const defs::dacIndex i, const std::string &name); - std::string getDacName(defs::dacIndex i); + /** [CTB] */ + std::string getDacName(const defs::dacIndex i) const; /** [CTB] */ void setAdcNames(const std::vector names); @@ -1740,13 +1741,13 @@ class Detector { std::vector getAdcNames() const; /** [CTB] */ - int getAdcIndex(const std::string &name); + int getAdcIndex(const std::string &name) const; /** [CTB] */ void setAdcName(const int i, const std::string &name); /** [CTB] */ - std::string getAdcName(int i); + std::string getAdcName(const int i) const; /** [CTB] */ void setSignalNames(const std::vector names); @@ -1755,13 +1756,13 @@ class Detector { std::vector getSignalNames() const; /** [CTB] */ - int getSignalIndex(const std::string &name); + int getSignalIndex(const std::string &name) const; /** [CTB] */ void setSignalName(const int i, const std::string &name); /** [CTB] */ - std::string getSignalName(int i); + std::string getSignalName(const int i) const; /** [CTB] */ void setPowerNames(const std::vector names); @@ -1770,13 +1771,13 @@ class Detector { std::vector getPowerNames() const; /** [CTB] */ - int getPowerIndex(const std::string &name); + defs::dacIndex getPowerIndex(const std::string &name) const; /** [CTB] */ - void setPowerName(const int i, const std::string &name); + void setPowerName(const defs::dacIndex i, const std::string &name); /** [CTB] */ - std::string getPowerName(int i); + std::string getPowerName(const defs::dacIndex i) const; /** [CTB] */ void setSenseNames(const std::vector names); @@ -1785,13 +1786,13 @@ class Detector { std::vector getSenseNames() const; /** [CTB] */ - int getSenseIndex(const std::string &name); + defs::dacIndex getSenseIndex(const std::string &name) const; /** [CTB] */ - void setSenseName(const int i, const std::string &name); + void setSenseName(const defs::dacIndex i, const std::string &name); /** [CTB] */ - std::string getSenseName(int i); + std::string getSenseName(const defs::dacIndex i) const; ///@} diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index e4f27bcf0..ee972f903 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1158,66 +1158,6 @@ std::string CmdProxy::DacList(const int action) { return os.str(); } -std::string CmdProxy::DacName(const int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == slsDetectorDefs::HELP_ACTION) { - os << "\n\t[0-18][name] \n\t\t[ChipTestBoard] Set " - "the dac at the given position to the given name." - << '\n'; - return os.str(); - } - if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { - throw RuntimeError("Named Dacs only allowed for CTB."); - } - defs::dacIndex index = static_cast(StringTo(args[0])); - if (action == slsDetectorDefs::GET_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - auto t = det->getDacName(index); - os << args[0] << ' ' << ToString(t) << '\n'; - } else if (action == slsDetectorDefs::PUT_ACTION) { - if (det_id != -1) { - throw RuntimeError("Cannot configure dacnames at module level"); - } - if (args.size() != 2) { - WrongNumberOfParameters(2); - } - det->setDacName(index, args[1]); - os << ToString(args) << '\n'; - } else { - throw RuntimeError("Unknown action"); - } - return os.str(); -} - -std::string CmdProxy::DacIndex(const int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == slsDetectorDefs::HELP_ACTION) { - os << "\n\t[name] \n\t\t[ChipTestBoard] Get " - "the dac index for the given name." - << '\n'; - return os.str(); - } - if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { - throw RuntimeError("Named Dacs only allowed for CTB."); - } - if (action == slsDetectorDefs::GET_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - auto t = det->getDacIndex(args[0]); - os << ToString(static_cast(t)) << '\n'; - } else if (action == slsDetectorDefs::PUT_ACTION) { - throw RuntimeError("Cannot set dac index"); - } else { - throw RuntimeError("Unknown action"); - } - return os.str(); -} - /* dacs */ std::string CmdProxy::Dac(int action) { std::ostringstream os; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index b3a28188f..18ac8a8d9 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -554,6 +554,73 @@ namespace sls { return os.str(); \ } +#define CTB_SINGLE_DACNAME(CMDNAME, GETFCN, SETFCN, STARTINDEX, HLPSTR) \ + std::string CMDNAME(const int action) { \ + std::ostringstream os; \ + os << cmd << ' '; \ + if (action == slsDetectorDefs::HELP_ACTION) { \ + os << HLPSTR << '\n'; \ + return os.str(); \ + } \ + if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { \ + throw RuntimeError(cmd + " only allowed for CTB."); \ + } \ + if (det_id != -1) { \ + throw RuntimeError("Cannot configure " + cmd + \ + " at module level"); \ + } \ + defs::dacIndex index = defs::DAC_0; \ + if (args.size() > 0) { \ + index = static_cast(StringTo(args[0]) + \ + STARTINDEX); \ + } \ + if (action == slsDetectorDefs::GET_ACTION) { \ + if (args.size() != 1) { \ + WrongNumberOfParameters(1); \ + } \ + auto t = det->GETFCN(index); \ + os << args[0] << ' ' << t << '\n'; \ + } else if (action == slsDetectorDefs::PUT_ACTION) { \ + if (args.size() != 2) { \ + WrongNumberOfParameters(2); \ + } \ + det->SETFCN(index, args[1]); \ + os << ToString(args) << '\n'; \ + } else { \ + throw RuntimeError("Unknown action"); \ + } \ + return os.str(); \ + } + +#define CTB_GET_DACINDEX(CMDNAME, GETFCN, STARTINDEX, HLPSTR) \ + std::string CMDNAME(const int action) { \ + std::ostringstream os; \ + os << cmd << ' '; \ + if (action == slsDetectorDefs::HELP_ACTION) { \ + os << HLPSTR << '\n'; \ + return os.str(); \ + } \ + if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { \ + throw RuntimeError(cmd + " only allowed for CTB."); \ + } \ + if (det_id != -1) { \ + throw RuntimeError("Cannot configure " + cmd + \ + " at module level"); \ + } \ + if (action == slsDetectorDefs::GET_ACTION) { \ + if (args.size() != 1) { \ + WrongNumberOfParameters(1); \ + } \ + auto t = det->GETFCN(args[0]); \ + os << ToString(static_cast(t) - STARTINDEX) << '\n'; \ + } else if (action == slsDetectorDefs::PUT_ACTION) { \ + throw RuntimeError("Cannot put"); \ + } else { \ + throw RuntimeError("Unknown action"); \ + } \ + return os.str(); \ + } + #define CTB_SINGLE_NAME(CMDNAME, GETFCN, SETFCN, HLPSTR) \ std::string CMDNAME(const int action) { \ std::ostringstream os; \ @@ -574,7 +641,7 @@ namespace sls { WrongNumberOfParameters(1); \ } \ auto t = det->GETFCN(StringTo(args[0])); \ - os << args[0] << ' ' << ToString(t) << '\n'; \ + os << args[0] << ' ' << t << '\n'; \ } else if (action == slsDetectorDefs::PUT_ACTION) { \ if (args.size() != 2) { \ WrongNumberOfParameters(2); \ @@ -607,7 +674,7 @@ namespace sls { WrongNumberOfParameters(1); \ } \ auto t = det->GETFCN(args[0]); \ - os << ToString(t) << '\n'; \ + os << ToString(static_cast(t)) << '\n'; \ } else if (action == slsDetectorDefs::PUT_ACTION) { \ throw RuntimeError("Cannot put"); \ } else { \ @@ -936,8 +1003,8 @@ class CmdProxy { /* lists */ {"daclist", &CmdProxy::DacList}, - {"dacname", &CmdProxy::DacName}, - {"dacindex", &CmdProxy::DacIndex}, + {"dacname", &CmdProxy::dacname}, + {"dacindex", &CmdProxy::dacindex}, {"adclist", &CmdProxy::adclist}, {"adcname", &CmdProxy::adcname}, {"adcindex", &CmdProxy::adcindex}, @@ -1252,8 +1319,6 @@ class CmdProxy { std::string TemperatureValues(int action); /* list */ std::string DacList(int action); - std::string DacName(int action); - std::string DacIndex(int action); /* dacs */ std::string Dac(int action); std::string DacValues(int action); @@ -1617,6 +1682,15 @@ class CmdProxy { "[n_value]\n\t[Ctb]Temperature of the slow adc"); /* lists */ + + CTB_SINGLE_DACNAME(dacname, getDacName, setDacName, defs::DAC_0, + "\n\t[0-18][name] \n\t\t[ChipTestBoard] Set " + "the dac at the given position to the given name."); + + CTB_GET_DACINDEX(dacindex, getDacIndex, defs::DAC_0, + "\n\t[name] \n\t\t[ChipTestBoard] Get " + "the dac index for the given name."); + CTB_NAMED_LIST(adclist, getAdcNames, setAdcNames, "[adcname1 adcname2 .. adcname32] \n\t\t[ChipTestBoard] Set " "the list of adc names for this board."); @@ -1647,26 +1721,26 @@ class CmdProxy { "[powername1 powername2 .. powername4] \n\t\t[ChipTestBoard] Set " "the list of power names for this board."); - CTB_SINGLE_NAME(powername, getPowerName, setPowerName, - "[0-31][name] \n\t\t[ChipTestBoard] Set " - "the power at the given position to the given name."); + CTB_SINGLE_DACNAME(powername, getPowerName, setPowerName, defs::V_POWER_A, + "[0-31][name] \n\t\t[ChipTestBoard] Set " + "the power at the given position to the given name."); - CTB_GET_INDEX(powerindex, getPowerIndex, - "[name] \n\t\t[ChipTestBoard] Get " - "the power index for the given name."); + CTB_GET_DACINDEX(powerindex, getPowerIndex, defs::V_POWER_A, + "[name] \n\t\t[ChipTestBoard] Get " + "the power index for the given name."); CTB_NAMED_LIST( senselist, getSenseNames, setSenseNames, "[sensename1 sensename2 .. sensename7] \n\t\t[ChipTestBoard] Set " "the list of sense names for this board."); - CTB_SINGLE_NAME(sensename, getSenseName, setSenseName, - "[0-31][name] \n\t\t[ChipTestBoard] Set " - "the sense at the given position to the given name."); + CTB_SINGLE_DACNAME(sensename, getSenseName, setSenseName, defs::SLOW_ADC0, + "[0-31][name] \n\t\t[ChipTestBoard] Set " + "the sense at the given position to the given name."); - CTB_GET_INDEX(senseindex, getSenseIndex, - "[name] \n\t\t[ChipTestBoard] Get " - "the sense index for the given name."); + CTB_GET_DACINDEX(senseindex, getSenseIndex, defs::SLOW_ADC0, + "[name] \n\t\t[ChipTestBoard] Get " + "the sense index for the given name."); /* dacs */ diff --git a/slsDetectorSoftware/src/CtbConfig.cpp b/slsDetectorSoftware/src/CtbConfig.cpp index 534331dec..a3f8e03f4 100644 --- a/slsDetectorSoftware/src/CtbConfig.cpp +++ b/slsDetectorSoftware/src/CtbConfig.cpp @@ -31,41 +31,43 @@ CtbConfig::CtbConfig() { } void CtbConfig::check_dac_index(size_t i) const { - if (!(i < num_dacs)) { + if (i >= num_dacs) { std::ostringstream oss; - oss << "DAC index is too large. Needs to be below " << num_dacs; + oss << "Invalid DAC index. Options: 0 - " << num_dacs; throw RuntimeError(oss.str()); } } void CtbConfig::check_adc_index(size_t i) const { - if (!(i < num_adcs)) { + if (i >= num_adcs) { std::ostringstream oss; - oss << "ADC index is too large.Needs to be below " << num_adcs; + oss << "Invalid ADC index. Options: 0 - " << num_adcs; throw RuntimeError(oss.str()); } } void CtbConfig::check_signal_index(size_t i) const { - if (!(i < num_signals)) { + if (i >= num_signals) { std::ostringstream oss; - oss << "Signal index is too large.Needs to be below " << num_signals; + oss << "Invalid Signal index. Options: 0 - " << num_signals; throw RuntimeError(oss.str()); } } void CtbConfig::check_power_index(size_t i) const { - if (!(i < num_powers)) { + if (i >= num_powers) { std::ostringstream oss; - oss << "Power index is too large.Needs to be below " << num_powers; + oss << "Invalid Power index. Options: 0 - " << num_signals + << " or V_POWER_A - V_POWER_IO"; throw RuntimeError(oss.str()); } } void CtbConfig::check_sense_index(size_t i) const { - if (!(i < num_senses)) { + if (i >= num_senses) { std::ostringstream oss; - oss << "Sense index is too large.Needs to be below " << num_senses; + oss << "Invalid Sense index. Options: 0 - " << num_senses + << " or SLOW_ADC0 - SLOW_ADC7"; throw RuntimeError(oss.str()); } } diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 7005fd65e..c8277e62e 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -2219,7 +2219,7 @@ std::vector Detector::getDacNames() const { return names; } -defs::dacIndex Detector::getDacIndex(const std::string &name) { +defs::dacIndex Detector::getDacIndex(const std::string &name) const { auto type = getDetectorType().squash(); if (type == defs::CHIPTESTBOARD) { auto names = getDacNames(); @@ -2231,13 +2231,13 @@ defs::dacIndex Detector::getDacIndex(const std::string &name) { return StringTo(name); } -void Detector::setDacName(defs::dacIndex i, const std::string &name) { +void Detector::setDacName(const defs::dacIndex i, const std::string &name) { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named dacs only for CTB"); pimpl->setCtbDacName(i, name); } -std::string Detector::getDacName(defs::dacIndex i) { +std::string Detector::getDacName(const defs::dacIndex i) const { auto type = getDetectorType().squash(); if (type == defs::CHIPTESTBOARD) return pimpl->getCtbDacName(i); @@ -2256,7 +2256,7 @@ std::vector Detector::getAdcNames() const { return pimpl->getCtbAdcNames(); } -int Detector::getAdcIndex(const std::string &name) { +int Detector::getAdcIndex(const std::string &name) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named adcs only for CTB"); auto names = getAdcNames(); @@ -2272,7 +2272,7 @@ void Detector::setAdcName(const int index, const std::string &name) { pimpl->setCtbAdcName(index, name); } -std::string Detector::getAdcName(int i) { +std::string Detector::getAdcName(const int i) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named adcs only for CTB"); return pimpl->getCtbAdcName(i); @@ -2290,7 +2290,7 @@ std::vector Detector::getSignalNames() const { return pimpl->getCtbSignalNames(); } -int Detector::getSignalIndex(const std::string &name) { +int Detector::getSignalIndex(const std::string &name) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named signals only for CTB"); auto names = getSignalNames(); @@ -2306,7 +2306,7 @@ void Detector::setSignalName(const int index, const std::string &name) { pimpl->setCtbSignalName(index, name); } -std::string Detector::getSignalName(int i) { +std::string Detector::getSignalName(const int i) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named signals only for CTB"); return pimpl->getCtbSignalName(i); @@ -2324,23 +2324,24 @@ std::vector Detector::getPowerNames() const { return pimpl->getCtbPowerNames(); } -int Detector::getPowerIndex(const std::string &name) { +defs::dacIndex Detector::getPowerIndex(const std::string &name) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named powers only for CTB"); auto names = getPowerNames(); auto it = std::find(names.begin(), names.end(), name); if (it == names.end()) throw RuntimeError("Power name not found"); - return (it - names.begin()); + return static_cast(it - names.begin() + defs::V_POWER_A); } -void Detector::setPowerName(const int index, const std::string &name) { +void Detector::setPowerName(const defs::dacIndex index, + const std::string &name) { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named powers only for CTB"); pimpl->setCtbPowerName(index, name); } -std::string Detector::getPowerName(int i) { +std::string Detector::getPowerName(const defs::dacIndex i) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named powers only for CTB"); return pimpl->getCtbPowerName(i); @@ -2358,23 +2359,24 @@ std::vector Detector::getSenseNames() const { return pimpl->getCtbSenseNames(); } -int Detector::getSenseIndex(const std::string &name) { +defs::dacIndex Detector::getSenseIndex(const std::string &name) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named senses only for CTB"); auto names = getSenseNames(); auto it = std::find(names.begin(), names.end(), name); if (it == names.end()) throw RuntimeError("Sense name not found"); - return (it - names.begin()); + return static_cast(it - names.begin() + defs::SLOW_ADC0); } -void Detector::setSenseName(const int index, const std::string &name) { +void Detector::setSenseName(const defs::dacIndex index, + const std::string &name) { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named senses only for CTB"); pimpl->setCtbSenseName(index, name); } -std::string Detector::getSenseName(int i) { +std::string Detector::getSenseName(const defs::dacIndex i) const { if (getDetectorType().squash() != defs::CHIPTESTBOARD) throw RuntimeError("Named senses only for CTB"); return pimpl->getCtbSenseName(i); diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index b9bccc5f1..7e2f941ec 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -2001,7 +2001,8 @@ std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const { return ctb_shm()->getDacName(static_cast(i)); } -void DetectorImpl::setCtbDacName(const int index, const std::string &name) { +void DetectorImpl::setCtbDacName(const defs::dacIndex index, + const std::string &name) { ctb_shm()->setDacName(index, name); } @@ -2013,7 +2014,7 @@ void DetectorImpl::setCtbAdcNames(const std::vector &names) { ctb_shm()->setAdcNames(names); } -std::string DetectorImpl::getCtbAdcName(int i) const { +std::string DetectorImpl::getCtbAdcName(const int i) const { return ctb_shm()->getAdcName(i); } @@ -2029,7 +2030,7 @@ void DetectorImpl::setCtbSignalNames(const std::vector &names) { ctb_shm()->setSignalNames(names); } -std::string DetectorImpl::getCtbSignalName(int i) const { +std::string DetectorImpl::getCtbSignalName(const int i) const { return ctb_shm()->getSignalName(i); } @@ -2045,12 +2046,13 @@ void DetectorImpl::setCtbPowerNames(const std::vector &names) { ctb_shm()->setPowerNames(names); } -std::string DetectorImpl::getCtbPowerName(int i) const { - return ctb_shm()->getPowerName(i); +std::string DetectorImpl::getCtbPowerName(const defs::dacIndex i) const { + return ctb_shm()->getPowerName(static_cast(i - defs::V_POWER_A)); } -void DetectorImpl::setCtbPowerName(const int index, const std::string &name) { - ctb_shm()->setPowerName(index, name); +void DetectorImpl::setCtbPowerName(const defs::dacIndex index, + const std::string &name) { + ctb_shm()->setPowerName(static_cast(index - defs::V_POWER_A), name); } std::vector DetectorImpl::getCtbSenseNames() const { @@ -2061,12 +2063,13 @@ void DetectorImpl::setCtbSenseNames(const std::vector &names) { ctb_shm()->setSenseNames(names); } -std::string DetectorImpl::getCtbSenseName(int i) const { - return ctb_shm()->getSenseName(i); +std::string DetectorImpl::getCtbSenseName(const defs::dacIndex i) const { + return ctb_shm()->getSenseName(static_cast(i - defs::SLOW_ADC0)); } -void DetectorImpl::setCtbSenseName(const int index, const std::string &name) { - ctb_shm()->setSenseName(index, name); +void DetectorImpl::setCtbSenseName(const defs::dacIndex index, + const std::string &name) { + ctb_shm()->setSenseName(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 e0b6adc0b..ef7cd5441 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -326,29 +326,29 @@ class DetectorImpl : public virtual slsDetectorDefs { void setBadChannels(const std::vector list, Positions pos); std::vector getCtbDacNames() const; - std::string getCtbDacName(defs::dacIndex i) const; + std::string getCtbDacName(const defs::dacIndex i) const; void setCtbDacNames(const std::vector &names); - void setCtbDacName(const int index, const std::string &name); + void setCtbDacName(const defs::dacIndex index, const std::string &name); std::vector getCtbAdcNames() const; - std::string getCtbAdcName(int i) const; + std::string getCtbAdcName(const int i) const; void setCtbAdcNames(const std::vector &names); void setCtbAdcName(const int index, const std::string &name); std::vector getCtbSignalNames() const; - std::string getCtbSignalName(int i) const; + std::string getCtbSignalName(const int i) const; void setCtbSignalNames(const std::vector &names); void setCtbSignalName(const int index, const std::string &name); std::vector getCtbPowerNames() const; - std::string getCtbPowerName(int i) const; + std::string getCtbPowerName(const defs::dacIndex i) const; void setCtbPowerNames(const std::vector &names); - void setCtbPowerName(const int index, const std::string &name); + void setCtbPowerName(const defs::dacIndex index, const std::string &name); std::vector getCtbSenseNames() const; - std::string getCtbSenseName(int i) const; + std::string getCtbSenseName(const defs::dacIndex i) const; void setCtbSenseNames(const std::vector &names); - void setCtbSenseName(const int index, const std::string &name); + void setCtbSenseName(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 0a30c719a..8e95e9130 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -299,7 +299,7 @@ TEST_CASE("powername", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD) { - int ind = 2; + defs::dacIndex ind = static_cast(2 + defs::V_POWER_A); std::string str_power_index = "2"; auto prev = det.getPowerName(ind); @@ -333,7 +333,7 @@ TEST_CASE("powerindex", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD) { - int ind = 2; + defs::dacIndex ind = static_cast(2 + defs::V_POWER_A); std::string str_power_index = "2"; // 1 arg throw @@ -391,7 +391,7 @@ TEST_CASE("sensename", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD) { - int ind = 2; + defs::dacIndex ind = static_cast(2 + defs::SLOW_ADC0); std::string str_sense_index = "2"; auto prev = det.getSenseName(ind); @@ -425,7 +425,7 @@ TEST_CASE("senseindex", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD) { - int ind = 2; + defs::dacIndex ind = static_cast(2 + defs::SLOW_ADC0); std::string str_sense_index = "2"; // 1 arg throw diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 5754d5665..c33337c94 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -5,9 +5,9 @@ #define APILIB "developer 0x230224" #define APIRECEIVER "developer 0x230224" #define APIEIGER "developer 0x230525" -#define APICTB "developer 0x230615" -#define APIGOTTHARD "developer 0x230615" +#define APICTB "developer 0x230615" +#define APIGOTTHARD "developer 0x230615" #define APIGOTTHARD2 "developer 0x230615" -#define APIJUNGFRAU "developer 0x230615" -#define APIMYTHEN3 "developer 0x230615" -#define APIMOENCH "developer 0x230615" +#define APIJUNGFRAU "developer 0x230615" +#define APIMYTHEN3 "developer 0x230615" +#define APIMOENCH "developer 0x230615"