2. Ctb fname voltage (#768)

* power and sense returning dac indices instead of int in Detector class

* power -> voltage, sense -> slowadc
This commit is contained in:
maliakal_d 2023-06-19 16:05:30 +02:00 committed by GitHub
parent d3d98db7e9
commit 1a338346d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 236 additions and 236 deletions

View File

@ -1803,30 +1803,30 @@ class Detector(CppDetectorApi):
self.setSignalNames(value) self.setSignalNames(value)
@property @property
def powerlist(self): def voltagelist(self):
""" """
List of names for every power supply for this board. 5 power supply List of names for every voltage for this board. 5 voltage supply
:setter: Only implemented for Chiptestboard :setter: Only implemented for Chiptestboard
""" """
return self.getPowerNames() return self.getVoltageNames()
@powerlist.setter @voltagelist.setter
def powerlist(self, value): def voltagelist(self, value):
self.setPowerNames(value) self.setVoltageNames(value)
@property @property
def senselist(self): def slowadclist(self):
""" """
List of names for every sense for this board. 8 sense List of names for every slowadc for this board. 8 slowadc
:setter: Only implemented for Chiptestboard :setter: Only implemented for Chiptestboard
""" """
return self.getSenseNames() return self.getSlowAdcNames()
@senselist.setter @slowadclist.setter
def senselist(self, value): def slowadclist(self, value):
self.setSenseNames(value) self.setSlowAdcNames(value)
@property @property
def dacvalues(self): def dacvalues(self):

View File

@ -1695,47 +1695,47 @@ void init_det(py::module &m) {
(std::string(Detector::*)(const int) const) & (std::string(Detector::*)(const int) const) &
Detector::getSignalName, Detector::getSignalName,
py::arg()); py::arg());
CppDetectorApi.def("setPowerNames", CppDetectorApi.def("setVoltageNames",
(void (Detector::*)(const std::vector<std::string>)) & (void (Detector::*)(const std::vector<std::string>)) &
Detector::setPowerNames, Detector::setVoltageNames,
py::arg()); py::arg());
CppDetectorApi.def("getPowerNames", CppDetectorApi.def("getVoltageNames",
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getPowerNames); Detector::getVoltageNames);
CppDetectorApi.def( CppDetectorApi.def(
"getPowerIndex", "getVoltageIndex",
(defs::dacIndex(Detector::*)(const std::string &) const) & (defs::dacIndex(Detector::*)(const std::string &) const) &
Detector::getPowerIndex, Detector::getVoltageIndex,
py::arg()); py::arg());
CppDetectorApi.def( CppDetectorApi.def(
"setPowerName", "setVoltageName",
(void (Detector::*)(const defs::dacIndex, const std::string &)) & (void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setPowerName, Detector::setVoltageName,
py::arg(), py::arg()); py::arg(), py::arg());
CppDetectorApi.def("getPowerName", CppDetectorApi.def("getVoltageName",
(std::string(Detector::*)(const defs::dacIndex) const) & (std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getPowerName, Detector::getVoltageName,
py::arg()); py::arg());
CppDetectorApi.def("setSenseNames", CppDetectorApi.def("setSlowAdcNames",
(void (Detector::*)(const std::vector<std::string>)) & (void (Detector::*)(const std::vector<std::string>)) &
Detector::setSenseNames, Detector::setSlowAdcNames,
py::arg()); py::arg());
CppDetectorApi.def("getSenseNames", CppDetectorApi.def("getSlowAdcNames",
(std::vector<std::string>(Detector::*)() const) & (std::vector<std::string>(Detector::*)() const) &
Detector::getSenseNames); Detector::getSlowAdcNames);
CppDetectorApi.def( CppDetectorApi.def(
"getSenseIndex", "getSlowAdcIndex",
(defs::dacIndex(Detector::*)(const std::string &) const) & (defs::dacIndex(Detector::*)(const std::string &) const) &
Detector::getSenseIndex, Detector::getSlowAdcIndex,
py::arg()); py::arg());
CppDetectorApi.def( CppDetectorApi.def(
"setSenseName", "setSlowAdcName",
(void (Detector::*)(const defs::dacIndex, const std::string &)) & (void (Detector::*)(const defs::dacIndex, const std::string &)) &
Detector::setSenseName, Detector::setSlowAdcName,
py::arg(), py::arg()); py::arg(), py::arg());
CppDetectorApi.def("getSenseName", CppDetectorApi.def("getSlowAdcName",
(std::string(Detector::*)(const defs::dacIndex) const) & (std::string(Detector::*)(const defs::dacIndex) const) &
Detector::getSenseName, Detector::getSlowAdcName,
py::arg()); py::arg());
CppDetectorApi.def( CppDetectorApi.def(
"setPattern", "setPattern",

View File

@ -1765,34 +1765,34 @@ class Detector {
std::string getSignalName(const int i) const; std::string getSignalName(const int i) const;
/** [CTB] */ /** [CTB] */
void setPowerNames(const std::vector<std::string> names); void setVoltageNames(const std::vector<std::string> names);
/** [CTB] */ /** [CTB] */
std::vector<std::string> getPowerNames() const; std::vector<std::string> getVoltageNames() const;
/** [CTB] */ /** [CTB] */
defs::dacIndex getPowerIndex(const std::string &name) const; defs::dacIndex getVoltageIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setPowerName(const defs::dacIndex i, const std::string &name); void setVoltageName(const defs::dacIndex i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getPowerName(const defs::dacIndex i) const; std::string getVoltageName(const defs::dacIndex i) const;
/** [CTB] */ /** [CTB] */
void setSenseNames(const std::vector<std::string> names); void setSlowAdcNames(const std::vector<std::string> names);
/** [CTB] */ /** [CTB] */
std::vector<std::string> getSenseNames() const; std::vector<std::string> getSlowAdcNames() const;
/** [CTB] */ /** [CTB] */
defs::dacIndex getSenseIndex(const std::string &name) const; defs::dacIndex getSlowAdcIndex(const std::string &name) const;
/** [CTB] */ /** [CTB] */
void setSenseName(const defs::dacIndex i, const std::string &name); void setSlowAdcName(const defs::dacIndex i, const std::string &name);
/** [CTB] */ /** [CTB] */
std::string getSenseName(const defs::dacIndex i) const; std::string getSlowAdcName(const defs::dacIndex i) const;
///@} ///@}

View File

@ -1011,12 +1011,12 @@ class CmdProxy {
{"signallist", &CmdProxy::signallist}, {"signallist", &CmdProxy::signallist},
{"signalname", &CmdProxy::signalname}, {"signalname", &CmdProxy::signalname},
{"signalindex", &CmdProxy::signalindex}, {"signalindex", &CmdProxy::signalindex},
{"powerlist", &CmdProxy::powerlist}, {"voltagelist", &CmdProxy::voltagelist},
{"powername", &CmdProxy::powername}, {"voltagename", &CmdProxy::voltagename},
{"powerindex", &CmdProxy::powerindex}, {"voltageindex", &CmdProxy::voltageindex},
{"senselist", &CmdProxy::senselist}, {"slowadclist", &CmdProxy::slowadclist},
{"sensename", &CmdProxy::sensename}, {"slowadcname", &CmdProxy::slowadcname},
{"senseindex", &CmdProxy::senseindex}, {"slowadcindex", &CmdProxy::slowadcindex},
/* dacs */ /* dacs */
{"dac", &CmdProxy::Dac}, {"dac", &CmdProxy::Dac},
@ -1684,7 +1684,7 @@ class CmdProxy {
/* lists */ /* lists */
CTB_SINGLE_DACNAME(dacname, getDacName, setDacName, defs::DAC_0, CTB_SINGLE_DACNAME(dacname, getDacName, setDacName, defs::DAC_0,
"\n\t[0-18][name] \n\t\t[ChipTestBoard] Set " "\n\t[0-17][name] \n\t\t[ChipTestBoard] Set "
"the dac at the given position to the given name."); "the dac at the given position to the given name.");
CTB_GET_DACINDEX(dacindex, getDacIndex, defs::DAC_0, CTB_GET_DACINDEX(dacindex, getDacIndex, defs::DAC_0,
@ -1709,7 +1709,7 @@ class CmdProxy {
"the list of signal names for this board."); "the list of signal names for this board.");
CTB_SINGLE_NAME(signalname, getSignalName, setSignalName, CTB_SINGLE_NAME(signalname, getSignalName, setSignalName,
"[0-31][name] \n\t\t[ChipTestBoard] Set " "[0-63][name] \n\t\t[ChipTestBoard] Set "
"the signal at the given position to the given name."); "the signal at the given position to the given name.");
CTB_GET_INDEX(signalindex, getSignalIndex, CTB_GET_INDEX(signalindex, getSignalIndex,
@ -1717,30 +1717,30 @@ class CmdProxy {
"the signal index for the given name."); "the signal index for the given name.");
CTB_NAMED_LIST( CTB_NAMED_LIST(
powerlist, getPowerNames, setPowerNames, voltagelist, getVoltageNames, setVoltageNames,
"[powername1 powername2 .. powername4] \n\t\t[ChipTestBoard] Set " "[voltagename1 voltagename2 .. voltagename4] \n\t\t[ChipTestBoard] Set "
"the list of power names for this board."); "the list of voltage names for this board.");
CTB_SINGLE_DACNAME(powername, getPowerName, setPowerName, defs::V_POWER_A, CTB_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName, defs::V_POWER_A,
"[0-31][name] \n\t\t[ChipTestBoard] Set " "[0-4][name] \n\t\t[ChipTestBoard] Set "
"the power at the given position to the given name."); "the voltage at the given position to the given name.");
CTB_GET_DACINDEX(powerindex, getPowerIndex, defs::V_POWER_A, CTB_GET_DACINDEX(voltageindex, getVoltageIndex, defs::V_POWER_A,
"[name] \n\t\t[ChipTestBoard] Get " "[name] \n\t\t[ChipTestBoard] Get "
"the power index for the given name."); "the voltage index for the given name.");
CTB_NAMED_LIST( CTB_NAMED_LIST(
senselist, getSenseNames, setSenseNames, slowadclist, getSlowAdcNames, setSlowAdcNames,
"[sensename1 sensename2 .. sensename7] \n\t\t[ChipTestBoard] Set " "[slowadcname1 slowadcname2 .. slowadcname7] \n\t\t[ChipTestBoard] Set "
"the list of sense names for this board."); "the list of slowadc names for this board.");
CTB_SINGLE_DACNAME(sensename, getSenseName, setSenseName, defs::SLOW_ADC0, CTB_SINGLE_DACNAME(slowadcname, getSlowAdcName, setSlowAdcName, defs::SLOW_ADC0,
"[0-31][name] \n\t\t[ChipTestBoard] Set " "[0-7][name] \n\t\t[ChipTestBoard] Set "
"the sense at the given position to the given name."); "the slowadc at the given position to the given name.");
CTB_GET_DACINDEX(senseindex, getSenseIndex, defs::SLOW_ADC0, CTB_GET_DACINDEX(slowadcindex, getSlowAdcIndex, defs::SLOW_ADC0,
"[name] \n\t\t[ChipTestBoard] Get " "[name] \n\t\t[ChipTestBoard] Get "
"the sense index for the given name."); "the slowadc index for the given name.");
/* dacs */ /* dacs */

View File

@ -20,13 +20,13 @@ CtbConfig::CtbConfig() {
for (size_t i = 0; i != num_signals; ++i) { for (size_t i = 0; i != num_signals; ++i) {
setSignalName(i, "BIT" + ToString(i)); setSignalName(i, "BIT" + ToString(i));
} }
setPowerName(0, "VA"); setVoltageName(0, "VA");
setPowerName(1, "VB"); setVoltageName(1, "VB");
setPowerName(2, "VC"); setVoltageName(2, "VC");
setPowerName(3, "VD"); setVoltageName(3, "VD");
setPowerName(4, "VIO"); setVoltageName(4, "VIO");
for (size_t i = 0; i != num_senses; ++i) { for (size_t i = 0; i != num_slowAdcs; ++i) {
setSenseName(i, "SENSE" + ToString(i)); setSlowAdcName(i, "SLOWADC" + ToString(i));
} }
} }
@ -54,19 +54,19 @@ void CtbConfig::check_signal_index(size_t i) const {
} }
} }
void CtbConfig::check_power_index(size_t i) const { void CtbConfig::check_voltage_index(size_t i) const {
if (i >= num_powers) { if (i >= num_voltages) {
std::ostringstream oss; std::ostringstream oss;
oss << "Invalid Power index. Options: 0 - " << num_signals oss << "Invalid Voltage index. Options: 0 - " << num_voltages
<< " or V_POWER_A - V_POWER_IO"; << " 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_slow_adc_index(size_t i) const {
if (i >= num_senses) { if (i >= num_slowAdcs) {
std::ostringstream oss; std::ostringstream oss;
oss << "Invalid Sense index. Options: 0 - " << num_senses oss << "Invalid Slow ADC index. Options: 0 - " << num_slowAdcs
<< " or SLOW_ADC0 - SLOW_ADC7"; << " or SLOW_ADC0 - SLOW_ADC7";
throw RuntimeError(oss.str()); throw RuntimeError(oss.str());
} }
@ -176,63 +176,63 @@ std::vector<std::string> CtbConfig::getSignalNames() const {
return names; return names;
} }
void CtbConfig::setPowerName(size_t index, const std::string &name) { void CtbConfig::setVoltageName(size_t index, const std::string &name) {
check_power_index(index); check_voltage_index(index);
check_size(name); check_size(name);
char *dst = &powernames[index * name_length]; char *dst = &voltagenames[index * name_length];
memset(dst, '\0', name_length); memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size()); memcpy(dst, &name[0], name.size());
} }
void CtbConfig::setPowerNames(const std::vector<std::string> &names) { void CtbConfig::setVoltageNames(const std::vector<std::string> &names) {
if (names.size() != num_powers) { if (names.size() != num_voltages) {
throw RuntimeError("Power names need to be of size " + throw RuntimeError("Voltage names need to be of size " +
std::to_string(num_powers)); std::to_string(num_voltages));
} }
for (size_t i = 0; i != num_powers; ++i) { for (size_t i = 0; i != num_voltages; ++i) {
setPowerName(i, names[i]); setVoltageName(i, names[i]);
} }
} }
std::string CtbConfig::getPowerName(size_t index) const { std::string CtbConfig::getVoltageName(size_t index) const {
check_power_index(index); check_voltage_index(index);
return powernames + index * name_length; return voltagenames + index * name_length;
} }
std::vector<std::string> CtbConfig::getPowerNames() const { std::vector<std::string> CtbConfig::getVoltageNames() const {
std::vector<std::string> names; std::vector<std::string> names;
for (size_t i = 0; i != num_powers; ++i) for (size_t i = 0; i != num_voltages; ++i)
names.push_back(getPowerName(i)); names.push_back(getVoltageName(i));
return names; return names;
} }
void CtbConfig::setSenseName(size_t index, const std::string &name) { void CtbConfig::setSlowAdcName(size_t index, const std::string &name) {
check_sense_index(index); check_slow_adc_index(index);
check_size(name); check_size(name);
char *dst = &sensenames[index * name_length]; char *dst = &slowAdcnames[index * name_length];
memset(dst, '\0', name_length); memset(dst, '\0', name_length);
memcpy(dst, &name[0], name.size()); memcpy(dst, &name[0], name.size());
} }
void CtbConfig::setSenseNames(const std::vector<std::string> &names) { void CtbConfig::setSlowAdcNames(const std::vector<std::string> &names) {
if (names.size() != num_senses) { if (names.size() != num_slowAdcs) {
throw RuntimeError("Sense names need to be of size " + throw RuntimeError("Slow ADC names need to be of size " +
std::to_string(num_senses)); std::to_string(num_slowAdcs));
} }
for (size_t i = 0; i != num_senses; ++i) { for (size_t i = 0; i != num_slowAdcs; ++i) {
setSenseName(i, names[i]); setSlowAdcName(i, names[i]);
} }
} }
std::string CtbConfig::getSenseName(size_t index) const { std::string CtbConfig::getSlowAdcName(size_t index) const {
check_sense_index(index); check_slow_adc_index(index);
return sensenames + index * name_length; return slowAdcnames + index * name_length;
} }
std::vector<std::string> CtbConfig::getSenseNames() const { std::vector<std::string> CtbConfig::getSlowAdcNames() const {
std::vector<std::string> names; std::vector<std::string> names;
for (size_t i = 0; i != num_senses; ++i) for (size_t i = 0; i != num_slowAdcs; ++i)
names.push_back(getSenseName(i)); names.push_back(getSlowAdcName(i));
return names; return names;
} }

View File

@ -8,20 +8,20 @@ class CtbConfig {
static constexpr size_t num_dacs = 18; static constexpr size_t num_dacs = 18;
static constexpr size_t num_adcs = 32; static constexpr size_t num_adcs = 32;
static constexpr size_t num_signals = 64; static constexpr size_t num_signals = 64;
static constexpr size_t num_powers = 5; static constexpr size_t num_voltages = 5;
static constexpr size_t num_senses = 8; static constexpr size_t num_slowAdcs = 8;
static constexpr const char *shm_tag_ = "ctbdacs"; static constexpr const char *shm_tag_ = "ctbdacs";
char dacnames[name_length * num_dacs]{}; char dacnames[name_length * num_dacs]{};
char adcnames[name_length * num_adcs]{}; char adcnames[name_length * num_adcs]{};
char signalnames[name_length * num_signals]{}; char signalnames[name_length * num_signals]{};
char powernames[name_length * num_powers]{}; char voltagenames[name_length * num_voltages]{};
char sensenames[name_length * num_senses]{}; char slowAdcnames[name_length * num_slowAdcs]{};
void check_dac_index(size_t i) const; void check_dac_index(size_t i) const;
void check_adc_index(size_t i) const; void check_adc_index(size_t i) const;
void check_signal_index(size_t i) const; void check_signal_index(size_t i) const;
void check_power_index(size_t i) const; void check_voltage_index(size_t i) const;
void check_sense_index(size_t i) const; void check_slow_adc_index(size_t i) const;
void check_size(const std::string &name) const; void check_size(const std::string &name) const;
public: public:
@ -46,15 +46,15 @@ class CtbConfig {
std::string getSignalName(size_t index) const; std::string getSignalName(size_t index) const;
std::vector<std::string> getSignalNames() const; std::vector<std::string> getSignalNames() const;
void setPowerNames(const std::vector<std::string> &names); void setVoltageNames(const std::vector<std::string> &names);
void setPowerName(size_t index, const std::string &name); void setVoltageName(size_t index, const std::string &name);
std::string getPowerName(size_t index) const; std::string getVoltageName(size_t index) const;
std::vector<std::string> getPowerNames() const; std::vector<std::string> getVoltageNames() const;
void setSenseNames(const std::vector<std::string> &names); void setSlowAdcNames(const std::vector<std::string> &names);
void setSenseName(size_t index, const std::string &name); void setSlowAdcName(size_t index, const std::string &name);
std::string getSenseName(size_t index) const; std::string getSlowAdcName(size_t index) const;
std::vector<std::string> getSenseNames() const; std::vector<std::string> getSlowAdcNames() const;
static const char *shm_tag(); static const char *shm_tag();
}; };

View File

@ -2312,74 +2312,74 @@ std::string Detector::getSignalName(const int i) const {
return pimpl->getCtbSignalName(i); return pimpl->getCtbSignalName(i);
} }
void Detector::setPowerNames(const std::vector<std::string> names) { void Detector::setVoltageNames(const std::vector<std::string> names) {
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->setCtbPowerNames(names); pimpl->setCtbVoltageNames(names);
} }
std::vector<std::string> Detector::getPowerNames() const { std::vector<std::string> Detector::getVoltageNames() 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->getCtbPowerNames(); return pimpl->getCtbVoltageNames();
} }
defs::dacIndex Detector::getPowerIndex(const std::string &name) const { defs::dacIndex Detector::getVoltageIndex(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 = getVoltageNames();
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("Voltage name not found");
return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A); return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A);
} }
void Detector::setPowerName(const defs::dacIndex index, void Detector::setVoltageName(const defs::dacIndex index,
const std::string &name) { 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->setCtbVoltageName(index, name);
} }
std::string Detector::getPowerName(const defs::dacIndex i) const { std::string Detector::getVoltageName(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->getCtbVoltageName(i);
} }
void Detector::setSenseNames(const std::vector<std::string> names) { void Detector::setSlowAdcNames(const std::vector<std::string> names) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named SlowAdcs only for CTB");
pimpl->setCtbSenseNames(names); pimpl->setCtbSlowAdcNames(names);
} }
std::vector<std::string> Detector::getSenseNames() const { std::vector<std::string> Detector::getSlowAdcNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named SlowAdcs only for CTB");
return pimpl->getCtbSenseNames(); return pimpl->getCtbSlowAdcNames();
} }
defs::dacIndex Detector::getSenseIndex(const std::string &name) const { defs::dacIndex Detector::getSlowAdcIndex(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 SlowAdcs only for CTB");
auto names = getSenseNames(); auto names = getSlowAdcNames();
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("SlowAdc name not found");
return static_cast<defs::dacIndex>(it - names.begin() + defs::SLOW_ADC0); return static_cast<defs::dacIndex>(it - names.begin() + defs::SLOW_ADC0);
} }
void Detector::setSenseName(const defs::dacIndex index, void Detector::setSlowAdcName(const defs::dacIndex index,
const std::string &name) { const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD) if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB"); throw RuntimeError("Named SlowAdcs only for CTB");
pimpl->setCtbSenseName(index, name); pimpl->setCtbSlowAdcName(index, name);
} }
std::string Detector::getSenseName(const defs::dacIndex i) const { std::string Detector::getSlowAdcName(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 SlowAdcs only for CTB");
return pimpl->getCtbSenseName(i); return pimpl->getCtbSlowAdcName(i);
} }
// Pattern // Pattern

View File

@ -2038,38 +2038,38 @@ void DetectorImpl::setCtbSignalName(const int index, const std::string &name) {
ctb_shm()->setSignalName(index, name); ctb_shm()->setSignalName(index, name);
} }
std::vector<std::string> DetectorImpl::getCtbPowerNames() const { std::vector<std::string> DetectorImpl::getCtbVoltageNames() const {
return ctb_shm()->getPowerNames(); return ctb_shm()->getVoltageNames();
} }
void DetectorImpl::setCtbPowerNames(const std::vector<std::string> &names) { void DetectorImpl::setCtbVoltageNames(const std::vector<std::string> &names) {
ctb_shm()->setPowerNames(names); ctb_shm()->setVoltageNames(names);
} }
std::string DetectorImpl::getCtbPowerName(const defs::dacIndex i) const { std::string DetectorImpl::getCtbVoltageName(const defs::dacIndex i) const {
return ctb_shm()->getPowerName(static_cast<int>(i - defs::V_POWER_A)); return ctb_shm()->getVoltageName(static_cast<int>(i - defs::V_POWER_A));
} }
void DetectorImpl::setCtbPowerName(const defs::dacIndex index, void DetectorImpl::setCtbVoltageName(const defs::dacIndex index,
const std::string &name) { const std::string &name) {
ctb_shm()->setPowerName(static_cast<int>(index - defs::V_POWER_A), name); ctb_shm()->setVoltageName(static_cast<int>(index - defs::V_POWER_A), name);
} }
std::vector<std::string> DetectorImpl::getCtbSenseNames() const { std::vector<std::string> DetectorImpl::getCtbSlowAdcNames() const {
return ctb_shm()->getSenseNames(); return ctb_shm()->getSlowAdcNames();
} }
void DetectorImpl::setCtbSenseNames(const std::vector<std::string> &names) { void DetectorImpl::setCtbSlowAdcNames(const std::vector<std::string> &names) {
ctb_shm()->setSenseNames(names); ctb_shm()->setSlowAdcNames(names);
} }
std::string DetectorImpl::getCtbSenseName(const defs::dacIndex i) const { std::string DetectorImpl::getCtbSlowAdcName(const defs::dacIndex i) const {
return ctb_shm()->getSenseName(static_cast<int>(i - defs::SLOW_ADC0)); return ctb_shm()->getSlowAdcName(static_cast<int>(i - defs::SLOW_ADC0));
} }
void DetectorImpl::setCtbSenseName(const defs::dacIndex index, void DetectorImpl::setCtbSlowAdcName(const defs::dacIndex index,
const std::string &name) { const std::string &name) {
ctb_shm()->setSenseName(static_cast<int>(index - defs::SLOW_ADC0), name); ctb_shm()->setSlowAdcName(static_cast<int>(index - defs::SLOW_ADC0), name);
} }
} // namespace sls } // namespace sls

View File

@ -340,15 +340,15 @@ class DetectorImpl : public virtual slsDetectorDefs {
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> getCtbVoltageNames() const;
std::string getCtbPowerName(const defs::dacIndex i) const; std::string getCtbVoltageName(const defs::dacIndex i) const;
void setCtbPowerNames(const std::vector<std::string> &names); void setCtbVoltageNames(const std::vector<std::string> &names);
void setCtbPowerName(const defs::dacIndex index, const std::string &name); void setCtbVoltageName(const defs::dacIndex index, const std::string &name);
std::vector<std::string> getCtbSenseNames() const; std::vector<std::string> getCtbSlowAdcNames() const;
std::string getCtbSenseName(const defs::dacIndex i) const; std::string getCtbSlowAdcName(const defs::dacIndex i) const;
void setCtbSenseNames(const std::vector<std::string> &names); void setCtbSlowAdcNames(const std::vector<std::string> &names);
void setCtbSenseName(const defs::dacIndex index, const std::string &name); void setCtbSlowAdcName(const defs::dacIndex index, const std::string &name);
private: private:
/** /**

View File

@ -261,15 +261,15 @@ TEST_CASE("signalindex", "[.cmd]") {
} }
} }
TEST_CASE("powerlist", "[.cmd]") { TEST_CASE("voltagelist", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getPowerNames(); auto prev = det.getVoltageNames();
REQUIRE_THROWS(proxy.Call("powerlist", {"a", "s", "d"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names; std::vector<std::string> names;
for (int iarg = 0; iarg != 5; ++iarg) { for (int iarg = 0; iarg != 5; ++iarg) {
@ -277,91 +277,91 @@ TEST_CASE("powerlist", "[.cmd]") {
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powerlist", names, -1, PUT, oss)); REQUIRE_NOTHROW(proxy.Call("voltagelist", names, -1, PUT, oss));
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powerlist", {}, -1, GET, oss)); REQUIRE_NOTHROW(proxy.Call("voltagelist", {}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("powerlist ") + ToString(names) + '\n'); std::string("voltagelist ") + ToString(names) + '\n');
} }
det.setPowerNames(prev); det.setVoltageNames(prev);
} else { } else {
REQUIRE_THROWS(proxy.Call("powerlist", {"a", "b"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("powerlist", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("voltagelist", {}, -1, GET));
} }
} }
TEST_CASE("powername", "[.cmd]") { TEST_CASE("voltagename", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A); defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_power_index = "2"; std::string str_voltage_index = "2";
auto prev = det.getPowerName(ind); auto prev = det.getVoltageName(ind);
// 1 arg throw // 1 arg throw
REQUIRE_THROWS(proxy.Call("powername", {"2", "3", "bname"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltagename", {"2", "3", "bname"}, -1, PUT));
// invalid index // invalid index
REQUIRE_THROWS(proxy.Call("powername", {"5", "bname"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltagename", {"5", "bname"}, -1, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powername", {str_power_index, "bname"}, REQUIRE_NOTHROW(proxy.Call("voltagename", {str_voltage_index, "bname"},
-1, PUT, oss)); -1, PUT, oss));
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW( REQUIRE_NOTHROW(
proxy.Call("powername", {str_power_index}, -1, GET, oss)); proxy.Call("voltagename", {str_voltage_index}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("powername ") + str_power_index + " bname\n"); std::string("voltagename ") + str_voltage_index + " bname\n");
} }
det.setPowerName(ind, prev); det.setVoltageName(ind, prev);
} else { } else {
REQUIRE_THROWS(proxy.Call("powername", {"2", "b"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltagename", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("powername", {"2"}, -1, GET)); REQUIRE_THROWS(proxy.Call("voltagename", {"2"}, -1, GET));
} }
} }
TEST_CASE("powerindex", "[.cmd]") { TEST_CASE("voltageindex", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A); defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_power_index = "2"; std::string str_voltage_index = "2";
// 1 arg throw // 1 arg throw
REQUIRE_THROWS(proxy.Call("powerindex", {"2", "2"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltageindex", {"2", "2"}, -1, PUT));
// invalid index // invalid index
REQUIRE_THROWS(proxy.Call("powerindex", {"5"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("voltageindex", {"5"}, -1, PUT));
auto powername = det.getPowerName(ind); auto voltagename = det.getVoltageName(ind);
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW( REQUIRE_NOTHROW(
proxy.Call("powerindex", {powername}, -1, GET, oss)); proxy.Call("voltageindex", {voltagename}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("powerindex ") + str_power_index + '\n'); std::string("voltageindex ") + str_voltage_index + '\n');
} }
} else { } else {
REQUIRE_THROWS(proxy.Call("powerindex", {"2"}, -1, GET)); REQUIRE_THROWS(proxy.Call("voltageindex", {"2"}, -1, GET));
} }
} }
TEST_CASE("senselist", "[.cmd]") { TEST_CASE("slowadclist", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
auto prev = det.getSenseNames(); auto prev = det.getSlowAdcNames();
REQUIRE_THROWS(proxy.Call("senselist", {"a", "s", "d"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "s", "d"}, -1, PUT));
std::vector<std::string> names; std::vector<std::string> names;
for (int iarg = 0; iarg != 8; ++iarg) { for (int iarg = 0; iarg != 8; ++iarg) {
@ -369,79 +369,79 @@ TEST_CASE("senselist", "[.cmd]") {
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("senselist", names, -1, PUT, oss)); REQUIRE_NOTHROW(proxy.Call("slowadclist", names, -1, PUT, oss));
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("senselist", {}, -1, GET, oss)); REQUIRE_NOTHROW(proxy.Call("slowadclist", {}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("senselist ") + ToString(names) + '\n'); std::string("slowadclist ") + ToString(names) + '\n');
} }
det.setSenseNames(prev); det.setSlowAdcNames(prev);
} else { } else {
REQUIRE_THROWS(proxy.Call("senselist", {"a", "b"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("senselist", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("slowadclist", {}, -1, GET));
} }
} }
TEST_CASE("sensename", "[.cmd]") { TEST_CASE("slowadcname", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0); defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_sense_index = "2"; std::string str_slowadc_index = "2";
auto prev = det.getSenseName(ind); auto prev = det.getSlowAdcName(ind);
// 1 arg throw // 1 arg throw
REQUIRE_THROWS(proxy.Call("sensename", {"2", "3", "bname"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "3", "bname"}, -1, PUT));
// invalid index // invalid index
REQUIRE_THROWS(proxy.Call("sensename", {"8", "bname"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadcname", {"8", "bname"}, -1, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("sensename", {str_sense_index, "bname"}, REQUIRE_NOTHROW(proxy.Call("slowadcname", {str_slowadc_index, "bname"},
-1, PUT, oss)); -1, PUT, oss));
} }
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW( REQUIRE_NOTHROW(
proxy.Call("sensename", {str_sense_index}, -1, GET, oss)); proxy.Call("slowadcname", {str_slowadc_index}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("sensename ") + str_sense_index + " bname\n"); std::string("slowadcname ") + str_slowadc_index + " bname\n");
} }
det.setSenseName(ind, prev); det.setSlowAdcName(ind, prev);
} else { } else {
REQUIRE_THROWS(proxy.Call("sensename", {"2", "b"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("sensename", {"2"}, -1, GET)); REQUIRE_THROWS(proxy.Call("slowadcname", {"2"}, -1, GET));
} }
} }
TEST_CASE("senseindex", "[.cmd]") { TEST_CASE("slowadcindex", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) { if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0); defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_sense_index = "2"; std::string str_slowadc_index = "2";
// 1 arg throw // 1 arg throw
REQUIRE_THROWS(proxy.Call("senseindex", {"2", "2"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadcindex", {"2", "2"}, -1, PUT));
// invalid index // invalid index
REQUIRE_THROWS(proxy.Call("senseindex", {"8"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("slowadcindex", {"8"}, -1, PUT));
auto sensename = det.getSenseName(ind); auto slowadcname = det.getSlowAdcName(ind);
{ {
std::ostringstream oss; std::ostringstream oss;
REQUIRE_NOTHROW( REQUIRE_NOTHROW(
proxy.Call("senseindex", {sensename}, -1, GET, oss)); proxy.Call("slowadcindex", {slowadcname}, -1, GET, oss));
REQUIRE(oss.str() == REQUIRE(oss.str() ==
std::string("senseindex ") + str_sense_index + '\n'); std::string("slowadcindex ") + str_slowadc_index + '\n');
} }
} else { } else {
REQUIRE_THROWS(proxy.Call("senseindex", {"2"}, -1, GET)); REQUIRE_THROWS(proxy.Call("slowadcindex", {"2"}, -1, GET));
} }
} }

View File

@ -26,7 +26,7 @@ TEST_CASE("Default construction") {
REQUIRE(adcnames[1] == "ADC1"); REQUIRE(adcnames[1] == "ADC1");
REQUIRE(adcnames[2] == "ADC2"); REQUIRE(adcnames[2] == "ADC2");
REQUIRE(adcnames[3] == "ADC3"); REQUIRE(adcnames[3] == "ADC3");
auto powernames = c.getPowerNames(); auto powernames = c.getVoltageNames();
REQUIRE(powernames.size() == 5); REQUIRE(powernames.size() == 5);
REQUIRE(powernames[0] == "VA"); REQUIRE(powernames[0] == "VA");
REQUIRE(powernames[1] == "VB"); REQUIRE(powernames[1] == "VB");
@ -39,12 +39,12 @@ TEST_CASE("Default construction") {
REQUIRE(signalnames[1] == "BIT1"); REQUIRE(signalnames[1] == "BIT1");
REQUIRE(signalnames[2] == "BIT2"); REQUIRE(signalnames[2] == "BIT2");
REQUIRE(signalnames[3] == "BIT3"); REQUIRE(signalnames[3] == "BIT3");
auto sensenames = c.getSenseNames(); auto sensenames = c.getSlowAdcNames();
REQUIRE(sensenames.size() == 8); REQUIRE(sensenames.size() == 8);
REQUIRE(sensenames[0] == "SENSE0"); REQUIRE(sensenames[0] == "SLOWADC0");
REQUIRE(sensenames[1] == "SENSE1"); REQUIRE(sensenames[1] == "SLOWADC1");
REQUIRE(sensenames[2] == "SENSE2"); REQUIRE(sensenames[2] == "SLOWADC2");
REQUIRE(sensenames[3] == "SENSE3"); REQUIRE(sensenames[3] == "SLOWADC3");
} }
TEST_CASE("Set and get a single dac name") { TEST_CASE("Set and get a single dac name") {