1. Ctb powerindices (#767)

* power and sense returning dac indices instead of int in Detector class
This commit is contained in:
2023-06-19 15:19:50 +02:00
committed by GitHub
parent 3f9ec695db
commit d3d98db7e9
10 changed files with 205 additions and 174 deletions

View File

@ -1643,17 +1643,18 @@ void init_det(py::module &m) {
CppDetectorApi.def("getDacNames", CppDetectorApi.def("getDacNames",
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getDacNames); Detector::getDacNames);
CppDetectorApi.def("getDacIndex", CppDetectorApi.def(
(defs::dacIndex(Detector::*)(const std::string &)) & "getDacIndex",
Detector::getDacIndex, (defs::dacIndex(Detector::*)(const std::string &) const) &
py::arg()); Detector::getDacIndex,
py::arg());
CppDetectorApi.def( CppDetectorApi.def(
"setDacName", "setDacName",
(void (Detector::*)(defs::dacIndex, const std::string &)) & (void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setDacName, Detector::setDacName,
py::arg(), py::arg()); py::arg(), py::arg());
CppDetectorApi.def("getDacName", CppDetectorApi.def("getDacName",
(std::string(Detector::*)(defs::dacIndex)) & (std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getDacName, Detector::getDacName,
py::arg()); py::arg());
CppDetectorApi.def("setAdcNames", CppDetectorApi.def("setAdcNames",
@ -1664,7 +1665,7 @@ void init_det(py::module &m) {
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getAdcNames); Detector::getAdcNames);
CppDetectorApi.def("getAdcIndex", CppDetectorApi.def("getAdcIndex",
(int (Detector::*)(const std::string &)) & (int (Detector::*)(const std::string &) const) &
Detector::getAdcIndex, Detector::getAdcIndex,
py::arg()); py::arg());
CppDetectorApi.def("setAdcName", CppDetectorApi.def("setAdcName",
@ -1672,7 +1673,8 @@ void init_det(py::module &m) {
Detector::setAdcName, Detector::setAdcName,
py::arg(), py::arg()); py::arg(), py::arg());
CppDetectorApi.def("getAdcName", CppDetectorApi.def("getAdcName",
(std::string(Detector::*)(int)) & Detector::getAdcName, (std::string(Detector::*)(const int) const) &
Detector::getAdcName,
py::arg()); py::arg());
CppDetectorApi.def("setSignalNames", CppDetectorApi.def("setSignalNames",
(void (Detector::*)(const std::vector<std::string>)) & (void (Detector::*)(const std::vector<std::string>)) &
@ -1682,16 +1684,17 @@ void init_det(py::module &m) {
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getSignalNames); Detector::getSignalNames);
CppDetectorApi.def("getSignalIndex", CppDetectorApi.def("getSignalIndex",
(int (Detector::*)(const std::string &)) & (int (Detector::*)(const std::string &) const) &
Detector::getSignalIndex, Detector::getSignalIndex,
py::arg()); py::arg());
CppDetectorApi.def("setSignalName", CppDetectorApi.def("setSignalName",
(void (Detector::*)(const int, const std::string &)) & (void (Detector::*)(const int, const std::string &)) &
Detector::setSignalName, Detector::setSignalName,
py::arg(), py::arg()); py::arg(), py::arg());
CppDetectorApi.def( CppDetectorApi.def("getSignalName",
"getSignalName", (std::string(Detector::*)(const int) const) &
(std::string(Detector::*)(int)) & Detector::getSignalName, py::arg()); Detector::getSignalName,
py::arg());
CppDetectorApi.def("setPowerNames", CppDetectorApi.def("setPowerNames",
(void (Detector::*)(const std::vector<std::string>)) & (void (Detector::*)(const std::vector<std::string>)) &
Detector::setPowerNames, Detector::setPowerNames,
@ -1699,16 +1702,19 @@ void init_det(py::module &m) {
CppDetectorApi.def("getPowerNames", CppDetectorApi.def("getPowerNames",
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getPowerNames); Detector::getPowerNames);
CppDetectorApi.def("getPowerIndex", CppDetectorApi.def(
(int (Detector::*)(const std::string &)) & "getPowerIndex",
Detector::getPowerIndex, (defs::dacIndex(Detector::*)(const std::string &) const) &
py::arg()); Detector::getPowerIndex,
CppDetectorApi.def("setPowerName", py::arg());
(void (Detector::*)(const int, const std::string &)) & CppDetectorApi.def(
Detector::setPowerName, "setPowerName",
py::arg(), py::arg()); (void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setPowerName,
py::arg(), py::arg());
CppDetectorApi.def("getPowerName", CppDetectorApi.def("getPowerName",
(std::string(Detector::*)(int)) & Detector::getPowerName, (std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getPowerName,
py::arg()); py::arg());
CppDetectorApi.def("setSenseNames", CppDetectorApi.def("setSenseNames",
(void (Detector::*)(const std::vector<std::string>)) & (void (Detector::*)(const std::vector<std::string>)) &
@ -1717,16 +1723,19 @@ void init_det(py::module &m) {
CppDetectorApi.def("getSenseNames", CppDetectorApi.def("getSenseNames",
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getSenseNames); Detector::getSenseNames);
CppDetectorApi.def("getSenseIndex", CppDetectorApi.def(
(int (Detector::*)(const std::string &)) & "getSenseIndex",
Detector::getSenseIndex, (defs::dacIndex(Detector::*)(const std::string &) const) &
py::arg()); Detector::getSenseIndex,
CppDetectorApi.def("setSenseName", py::arg());
(void (Detector::*)(const int, const std::string &)) & CppDetectorApi.def(
Detector::setSenseName, "setSenseName",
py::arg(), py::arg()); (void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setSenseName,
py::arg(), py::arg());
CppDetectorApi.def("getSenseName", CppDetectorApi.def("getSenseName",
(std::string(Detector::*)(int)) & Detector::getSenseName, (std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getSenseName,
py::arg()); py::arg());
CppDetectorApi.def( CppDetectorApi.def(
"setPattern", "setPattern",

View File

@ -1726,12 +1726,13 @@ class Detector {
std::vector<std::string> getDacNames() const; std::vector<std::string> getDacNames() const;
defs::dacIndex getDacIndex(const std::string &name); defs::dacIndex getDacIndex(const std::string &name) const;
/** [CTB] */ /** [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] */ /** [CTB] */
void setAdcNames(const std::vector<std::string> names); void setAdcNames(const std::vector<std::string> names);
@ -1740,13 +1741,13 @@ class Detector {
std::vector<std::string> getAdcNames() const; std::vector<std::string> getAdcNames() const;
/** [CTB] */ /** [CTB] */
int getAdcIndex(const std::string &name); int getAdcIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setAdcName(const int i, const std::string &name); void setAdcName(const int i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getAdcName(int i); std::string getAdcName(const int i) const;
/** [CTB] */ /** [CTB] */
void setSignalNames(const std::vector<std::string> names); void setSignalNames(const std::vector<std::string> names);
@ -1755,13 +1756,13 @@ class Detector {
std::vector<std::string> getSignalNames() const; std::vector<std::string> getSignalNames() const;
/** [CTB] */ /** [CTB] */
int getSignalIndex(const std::string &name); int getSignalIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setSignalName(const int i, const std::string &name); void setSignalName(const int i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getSignalName(int i); std::string getSignalName(const int i) const;
/** [CTB] */ /** [CTB] */
void setPowerNames(const std::vector<std::string> names); void setPowerNames(const std::vector<std::string> names);
@ -1770,13 +1771,13 @@ class Detector {
std::vector<std::string> getPowerNames() const; std::vector<std::string> getPowerNames() const;
/** [CTB] */ /** [CTB] */
int getPowerIndex(const std::string &name); defs::dacIndex getPowerIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setPowerName(const int i, const std::string &name); void setPowerName(const defs::dacIndex i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getPowerName(int i); std::string getPowerName(const defs::dacIndex i) const;
/** [CTB] */ /** [CTB] */
void setSenseNames(const std::vector<std::string> names); void setSenseNames(const std::vector<std::string> names);
@ -1785,13 +1786,13 @@ class Detector {
std::vector<std::string> getSenseNames() const; std::vector<std::string> getSenseNames() const;
/** [CTB] */ /** [CTB] */
int getSenseIndex(const std::string &name); defs::dacIndex getSenseIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setSenseName(const int i, const std::string &name); void setSenseName(const defs::dacIndex i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getSenseName(int i); std::string getSenseName(const defs::dacIndex i) const;
///@} ///@}

View File

@ -1158,66 +1158,6 @@ std::string CmdProxy::DacList(const int action) {
return os.str(); 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<defs::dacIndex>(StringTo<int>(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<int>(t)) << '\n';
} else if (action == slsDetectorDefs::PUT_ACTION) {
throw RuntimeError("Cannot set dac index");
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
/* dacs */ /* dacs */
std::string CmdProxy::Dac(int action) { std::string CmdProxy::Dac(int action) {
std::ostringstream os; std::ostringstream os;

View File

@ -554,6 +554,73 @@ namespace sls {
return os.str(); \ 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<defs::dacIndex>(StringTo<int>(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<int>(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) \ #define CTB_SINGLE_NAME(CMDNAME, GETFCN, SETFCN, HLPSTR) \
std::string CMDNAME(const int action) { \ std::string CMDNAME(const int action) { \
std::ostringstream os; \ std::ostringstream os; \
@ -574,7 +641,7 @@ namespace sls {
WrongNumberOfParameters(1); \ WrongNumberOfParameters(1); \
} \ } \
auto t = det->GETFCN(StringTo<int>(args[0])); \ auto t = det->GETFCN(StringTo<int>(args[0])); \
os << args[0] << ' ' << ToString(t) << '\n'; \ os << args[0] << ' ' << t << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 2) { \ if (args.size() != 2) { \
WrongNumberOfParameters(2); \ WrongNumberOfParameters(2); \
@ -607,7 +674,7 @@ namespace sls {
WrongNumberOfParameters(1); \ WrongNumberOfParameters(1); \
} \ } \
auto t = det->GETFCN(args[0]); \ auto t = det->GETFCN(args[0]); \
os << ToString(t) << '\n'; \ os << ToString(static_cast<int>(t)) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("Cannot put"); \ throw RuntimeError("Cannot put"); \
} else { \ } else { \
@ -936,8 +1003,8 @@ class CmdProxy {
/* lists */ /* lists */
{"daclist", &CmdProxy::DacList}, {"daclist", &CmdProxy::DacList},
{"dacname", &CmdProxy::DacName}, {"dacname", &CmdProxy::dacname},
{"dacindex", &CmdProxy::DacIndex}, {"dacindex", &CmdProxy::dacindex},
{"adclist", &CmdProxy::adclist}, {"adclist", &CmdProxy::adclist},
{"adcname", &CmdProxy::adcname}, {"adcname", &CmdProxy::adcname},
{"adcindex", &CmdProxy::adcindex}, {"adcindex", &CmdProxy::adcindex},
@ -1252,8 +1319,6 @@ class CmdProxy {
std::string TemperatureValues(int action); std::string TemperatureValues(int action);
/* list */ /* list */
std::string DacList(int action); std::string DacList(int action);
std::string DacName(int action);
std::string DacIndex(int action);
/* dacs */ /* dacs */
std::string Dac(int action); std::string Dac(int action);
std::string DacValues(int action); std::string DacValues(int action);
@ -1617,6 +1682,15 @@ class CmdProxy {
"[n_value]\n\t[Ctb]Temperature of the slow adc"); "[n_value]\n\t[Ctb]Temperature of the slow adc");
/* lists */ /* 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, CTB_NAMED_LIST(adclist, getAdcNames, setAdcNames,
"[adcname1 adcname2 .. adcname32] \n\t\t[ChipTestBoard] Set " "[adcname1 adcname2 .. adcname32] \n\t\t[ChipTestBoard] Set "
"the list of adc names for this board."); "the list of adc names for this board.");
@ -1647,26 +1721,26 @@ class CmdProxy {
"[powername1 powername2 .. powername4] \n\t\t[ChipTestBoard] Set " "[powername1 powername2 .. powername4] \n\t\t[ChipTestBoard] Set "
"the list of power names for this board."); "the list of power names for this board.");
CTB_SINGLE_NAME(powername, getPowerName, setPowerName, CTB_SINGLE_DACNAME(powername, getPowerName, setPowerName, defs::V_POWER_A,
"[0-31][name] \n\t\t[ChipTestBoard] Set " "[0-31][name] \n\t\t[ChipTestBoard] Set "
"the power at the given position to the given name."); "the power at the given position to the given name.");
CTB_GET_INDEX(powerindex, getPowerIndex, CTB_GET_DACINDEX(powerindex, getPowerIndex, defs::V_POWER_A,
"[name] \n\t\t[ChipTestBoard] Get " "[name] \n\t\t[ChipTestBoard] Get "
"the power index for the given name."); "the power index for the given name.");
CTB_NAMED_LIST( CTB_NAMED_LIST(
senselist, getSenseNames, setSenseNames, senselist, getSenseNames, setSenseNames,
"[sensename1 sensename2 .. sensename7] \n\t\t[ChipTestBoard] Set " "[sensename1 sensename2 .. sensename7] \n\t\t[ChipTestBoard] Set "
"the list of sense names for this board."); "the list of sense names for this board.");
CTB_SINGLE_NAME(sensename, getSenseName, setSenseName, CTB_SINGLE_DACNAME(sensename, getSenseName, setSenseName, defs::SLOW_ADC0,
"[0-31][name] \n\t\t[ChipTestBoard] Set " "[0-31][name] \n\t\t[ChipTestBoard] Set "
"the sense at the given position to the given name."); "the sense at the given position to the given name.");
CTB_GET_INDEX(senseindex, getSenseIndex, CTB_GET_DACINDEX(senseindex, getSenseIndex, defs::SLOW_ADC0,
"[name] \n\t\t[ChipTestBoard] Get " "[name] \n\t\t[ChipTestBoard] Get "
"the sense index for the given name."); "the sense index for the given name.");
/* dacs */ /* dacs */

View File

@ -31,41 +31,43 @@ CtbConfig::CtbConfig() {
} }
void CtbConfig::check_dac_index(size_t i) const { void CtbConfig::check_dac_index(size_t i) const {
if (!(i < num_dacs)) { if (i >= num_dacs) {
std::ostringstream oss; 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()); throw RuntimeError(oss.str());
} }
} }
void CtbConfig::check_adc_index(size_t i) const { void CtbConfig::check_adc_index(size_t i) const {
if (!(i < num_adcs)) { if (i >= num_adcs) {
std::ostringstream oss; 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()); throw RuntimeError(oss.str());
} }
} }
void CtbConfig::check_signal_index(size_t i) const { void CtbConfig::check_signal_index(size_t i) const {
if (!(i < num_signals)) { if (i >= num_signals) {
std::ostringstream oss; 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()); throw RuntimeError(oss.str());
} }
} }
void CtbConfig::check_power_index(size_t i) const { void CtbConfig::check_power_index(size_t i) const {
if (!(i < num_powers)) { if (i >= num_powers) {
std::ostringstream oss; 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()); throw RuntimeError(oss.str());
} }
} }
void CtbConfig::check_sense_index(size_t i) const { void CtbConfig::check_sense_index(size_t i) const {
if (!(i < num_senses)) { if (i >= num_senses) {
std::ostringstream oss; 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()); throw RuntimeError(oss.str());
} }
} }

View File

@ -2219,7 +2219,7 @@ std::vector<std::string> Detector::getDacNames() const {
return names; return names;
} }
defs::dacIndex Detector::getDacIndex(const std::string &name) { defs::dacIndex Detector::getDacIndex(const std::string &name) const {
auto type = getDetectorType().squash(); auto type = getDetectorType().squash();
if (type == defs::CHIPTESTBOARD) { if (type == defs::CHIPTESTBOARD) {
auto names = getDacNames(); auto names = getDacNames();
@ -2231,13 +2231,13 @@ defs::dacIndex Detector::getDacIndex(const std::string &name) {
return StringTo<defs::dacIndex>(name); return StringTo<defs::dacIndex>(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) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named dacs only for CTB"); throw RuntimeError("Named dacs only for CTB");
pimpl->setCtbDacName(i, name); pimpl->setCtbDacName(i, name);
} }
std::string Detector::getDacName(defs::dacIndex i) { std::string Detector::getDacName(const defs::dacIndex i) const {
auto type = getDetectorType().squash(); auto type = getDetectorType().squash();
if (type == defs::CHIPTESTBOARD) if (type == defs::CHIPTESTBOARD)
return pimpl->getCtbDacName(i); return pimpl->getCtbDacName(i);
@ -2256,7 +2256,7 @@ std::vector<std::string> Detector::getAdcNames() const {
return pimpl->getCtbAdcNames(); return pimpl->getCtbAdcNames();
} }
int Detector::getAdcIndex(const std::string &name) { int Detector::getAdcIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB"); throw RuntimeError("Named adcs only for CTB");
auto names = getAdcNames(); auto names = getAdcNames();
@ -2272,7 +2272,7 @@ void Detector::setAdcName(const int index, const std::string &name) {
pimpl->setCtbAdcName(index, name); pimpl->setCtbAdcName(index, name);
} }
std::string Detector::getAdcName(int i) { std::string Detector::getAdcName(const int i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named adcs only for CTB"); throw RuntimeError("Named adcs only for CTB");
return pimpl->getCtbAdcName(i); return pimpl->getCtbAdcName(i);
@ -2290,7 +2290,7 @@ std::vector<std::string> Detector::getSignalNames() const {
return pimpl->getCtbSignalNames(); return pimpl->getCtbSignalNames();
} }
int Detector::getSignalIndex(const std::string &name) { int Detector::getSignalIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB"); throw RuntimeError("Named signals only for CTB");
auto names = getSignalNames(); auto names = getSignalNames();
@ -2306,7 +2306,7 @@ void Detector::setSignalName(const int index, const std::string &name) {
pimpl->setCtbSignalName(index, name); pimpl->setCtbSignalName(index, name);
} }
std::string Detector::getSignalName(int i) { std::string Detector::getSignalName(const int i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named signals only for CTB"); throw RuntimeError("Named signals only for CTB");
return pimpl->getCtbSignalName(i); return pimpl->getCtbSignalName(i);
@ -2324,23 +2324,24 @@ std::vector<std::string> Detector::getPowerNames() const {
return pimpl->getCtbPowerNames(); return pimpl->getCtbPowerNames();
} }
int Detector::getPowerIndex(const std::string &name) { defs::dacIndex Detector::getPowerIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB"); throw RuntimeError("Named powers only for CTB");
auto names = getPowerNames(); auto names = getPowerNames();
auto it = std::find(names.begin(), names.end(), name); auto it = std::find(names.begin(), names.end(), name);
if (it == names.end()) if (it == names.end())
throw RuntimeError("Power name not found"); throw RuntimeError("Power name not found");
return (it - names.begin()); return static_cast<defs::dacIndex>(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) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB"); throw RuntimeError("Named powers only for CTB");
pimpl->setCtbPowerName(index, name); pimpl->setCtbPowerName(index, name);
} }
std::string Detector::getPowerName(int i) { std::string Detector::getPowerName(const defs::dacIndex i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named powers only for CTB"); throw RuntimeError("Named powers only for CTB");
return pimpl->getCtbPowerName(i); return pimpl->getCtbPowerName(i);
@ -2358,23 +2359,24 @@ std::vector<std::string> Detector::getSenseNames() const {
return pimpl->getCtbSenseNames(); return pimpl->getCtbSenseNames();
} }
int Detector::getSenseIndex(const std::string &name) { defs::dacIndex Detector::getSenseIndex(const std::string &name) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named senses only for CTB");
auto names = getSenseNames(); auto names = getSenseNames();
auto it = std::find(names.begin(), names.end(), name); auto it = std::find(names.begin(), names.end(), name);
if (it == names.end()) if (it == names.end())
throw RuntimeError("Sense name not found"); throw RuntimeError("Sense name not found");
return (it - names.begin()); return static_cast<defs::dacIndex>(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) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named senses only for CTB");
pimpl->setCtbSenseName(index, name); pimpl->setCtbSenseName(index, name);
} }
std::string Detector::getSenseName(int i) { std::string Detector::getSenseName(const defs::dacIndex i) const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named senses only for CTB");
return pimpl->getCtbSenseName(i); return pimpl->getCtbSenseName(i);

View File

@ -2001,7 +2001,8 @@ std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const {
return ctb_shm()->getDacName(static_cast<int>(i)); return ctb_shm()->getDacName(static_cast<int>(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); ctb_shm()->setDacName(index, name);
} }
@ -2013,7 +2014,7 @@ void DetectorImpl::setCtbAdcNames(const std::vector<std::string> &names) {
ctb_shm()->setAdcNames(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); return ctb_shm()->getAdcName(i);
} }
@ -2029,7 +2030,7 @@ void DetectorImpl::setCtbSignalNames(const std::vector<std::string> &names) {
ctb_shm()->setSignalNames(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); return ctb_shm()->getSignalName(i);
} }
@ -2045,12 +2046,13 @@ void DetectorImpl::setCtbPowerNames(const std::vector<std::string> &names) {
ctb_shm()->setPowerNames(names); ctb_shm()->setPowerNames(names);
} }
std::string DetectorImpl::getCtbPowerName(int i) const { std::string DetectorImpl::getCtbPowerName(const defs::dacIndex i) const {
return ctb_shm()->getPowerName(i); return ctb_shm()->getPowerName(static_cast<int>(i - defs::V_POWER_A));
} }
void DetectorImpl::setCtbPowerName(const int index, const std::string &name) { void DetectorImpl::setCtbPowerName(const defs::dacIndex index,
ctb_shm()->setPowerName(index, name); const std::string &name) {
ctb_shm()->setPowerName(static_cast<int>(index - defs::V_POWER_A), name);
} }
std::vector<std::string> DetectorImpl::getCtbSenseNames() const { std::vector<std::string> DetectorImpl::getCtbSenseNames() const {
@ -2061,12 +2063,13 @@ void DetectorImpl::setCtbSenseNames(const std::vector<std::string> &names) {
ctb_shm()->setSenseNames(names); ctb_shm()->setSenseNames(names);
} }
std::string DetectorImpl::getCtbSenseName(int i) const { std::string DetectorImpl::getCtbSenseName(const defs::dacIndex i) const {
return ctb_shm()->getSenseName(i); return ctb_shm()->getSenseName(static_cast<int>(i - defs::SLOW_ADC0));
} }
void DetectorImpl::setCtbSenseName(const int index, const std::string &name) { void DetectorImpl::setCtbSenseName(const defs::dacIndex index,
ctb_shm()->setSenseName(index, name); const std::string &name) {
ctb_shm()->setSenseName(static_cast<int>(index - defs::SLOW_ADC0), name);
} }
} // namespace sls } // namespace sls

View File

@ -326,29 +326,29 @@ class DetectorImpl : public virtual slsDetectorDefs {
void setBadChannels(const std::vector<int> list, Positions pos); void setBadChannels(const std::vector<int> list, Positions pos);
std::vector<std::string> getCtbDacNames() const; std::vector<std::string> getCtbDacNames() const;
std::string getCtbDacName(defs::dacIndex i) const; std::string getCtbDacName(const defs::dacIndex i) const;
void setCtbDacNames(const std::vector<std::string> &names); void setCtbDacNames(const std::vector<std::string> &names);
void setCtbDacName(const int index, const std::string &name); void setCtbDacName(const defs::dacIndex index, const std::string &name);
std::vector<std::string> getCtbAdcNames() const; std::vector<std::string> getCtbAdcNames() const;
std::string getCtbAdcName(int i) const; std::string getCtbAdcName(const int i) const;
void setCtbAdcNames(const std::vector<std::string> &names); void setCtbAdcNames(const std::vector<std::string> &names);
void setCtbAdcName(const int index, const std::string &name); void setCtbAdcName(const int index, const std::string &name);
std::vector<std::string> getCtbSignalNames() const; std::vector<std::string> getCtbSignalNames() const;
std::string getCtbSignalName(int i) const; std::string getCtbSignalName(const int i) const;
void setCtbSignalNames(const std::vector<std::string> &names); void setCtbSignalNames(const std::vector<std::string> &names);
void setCtbSignalName(const int index, const std::string &name); void setCtbSignalName(const int index, const std::string &name);
std::vector<std::string> getCtbPowerNames() const; std::vector<std::string> getCtbPowerNames() const;
std::string getCtbPowerName(int i) const; std::string getCtbPowerName(const defs::dacIndex i) const;
void setCtbPowerNames(const std::vector<std::string> &names); void setCtbPowerNames(const std::vector<std::string> &names);
void setCtbPowerName(const int index, const std::string &name); void setCtbPowerName(const defs::dacIndex index, const std::string &name);
std::vector<std::string> getCtbSenseNames() const; std::vector<std::string> getCtbSenseNames() const;
std::string getCtbSenseName(int i) const; std::string getCtbSenseName(const defs::dacIndex i) const;
void setCtbSenseNames(const std::vector<std::string> &names); void setCtbSenseNames(const std::vector<std::string> &names);
void setCtbSenseName(const int index, const std::string &name); void setCtbSenseName(const defs::dacIndex index, const std::string &name);
private: private:
/** /**

View File

@ -299,7 +299,7 @@ TEST_CASE("powername", "[.cmd]") {
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
int ind = 2; defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_power_index = "2"; std::string str_power_index = "2";
auto prev = det.getPowerName(ind); auto prev = det.getPowerName(ind);
@ -333,7 +333,7 @@ TEST_CASE("powerindex", "[.cmd]") {
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
int ind = 2; defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_power_index = "2"; std::string str_power_index = "2";
// 1 arg throw // 1 arg throw
@ -391,7 +391,7 @@ TEST_CASE("sensename", "[.cmd]") {
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
int ind = 2; defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_sense_index = "2"; std::string str_sense_index = "2";
auto prev = det.getSenseName(ind); auto prev = det.getSenseName(ind);
@ -425,7 +425,7 @@ TEST_CASE("senseindex", "[.cmd]") {
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
int ind = 2; defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_sense_index = "2"; std::string str_sense_index = "2";
// 1 arg throw // 1 arg throw

View File

@ -5,9 +5,9 @@
#define APILIB "developer 0x230224" #define APILIB "developer 0x230224"
#define APIRECEIVER "developer 0x230224" #define APIRECEIVER "developer 0x230224"
#define APIEIGER "developer 0x230525" #define APIEIGER "developer 0x230525"
#define APICTB "developer 0x230615" #define APICTB "developer 0x230615"
#define APIGOTTHARD "developer 0x230615" #define APIGOTTHARD "developer 0x230615"
#define APIGOTTHARD2 "developer 0x230615" #define APIGOTTHARD2 "developer 0x230615"
#define APIJUNGFRAU "developer 0x230615" #define APIJUNGFRAU "developer 0x230615"
#define APIMYTHEN3 "developer 0x230615" #define APIMYTHEN3 "developer 0x230615"
#define APIMOENCH "developer 0x230615" #define APIMOENCH "developer 0x230615"