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)
@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
"""
return self.getPowerNames()
return self.getVoltageNames()
@powerlist.setter
def powerlist(self, value):
self.setPowerNames(value)
@voltagelist.setter
def voltagelist(self, value):
self.setVoltageNames(value)
@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
"""
return self.getSenseNames()
return self.getSlowAdcNames()
@senselist.setter
def senselist(self, value):
self.setSenseNames(value)
@slowadclist.setter
def slowadclist(self, value):
self.setSlowAdcNames(value)
@property
def dacvalues(self):

View File

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

View File

@ -1765,34 +1765,34 @@ class Detector {
std::string getSignalName(const int i) const;
/** [CTB] */
void setPowerNames(const std::vector<std::string> names);
void setVoltageNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getPowerNames() const;
std::vector<std::string> getVoltageNames() const;
/** [CTB] */
defs::dacIndex getPowerIndex(const std::string &name) const;
defs::dacIndex getVoltageIndex(const std::string &name) const;
/** [CTB] */
void setPowerName(const defs::dacIndex i, const std::string &name);
void setVoltageName(const defs::dacIndex i, const std::string &name);
/** [CTB] */
std::string getPowerName(const defs::dacIndex i) const;
std::string getVoltageName(const defs::dacIndex i) const;
/** [CTB] */
void setSenseNames(const std::vector<std::string> names);
void setSlowAdcNames(const std::vector<std::string> names);
/** [CTB] */
std::vector<std::string> getSenseNames() const;
std::vector<std::string> getSlowAdcNames() const;
/** [CTB] */
defs::dacIndex getSenseIndex(const std::string &name) const;
defs::dacIndex getSlowAdcIndex(const std::string &name) const;
/** [CTB] */
void setSenseName(const defs::dacIndex i, const std::string &name);
void setSlowAdcName(const defs::dacIndex i, const std::string &name);
/** [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},
{"signalname", &CmdProxy::signalname},
{"signalindex", &CmdProxy::signalindex},
{"powerlist", &CmdProxy::powerlist},
{"powername", &CmdProxy::powername},
{"powerindex", &CmdProxy::powerindex},
{"senselist", &CmdProxy::senselist},
{"sensename", &CmdProxy::sensename},
{"senseindex", &CmdProxy::senseindex},
{"voltagelist", &CmdProxy::voltagelist},
{"voltagename", &CmdProxy::voltagename},
{"voltageindex", &CmdProxy::voltageindex},
{"slowadclist", &CmdProxy::slowadclist},
{"slowadcname", &CmdProxy::slowadcname},
{"slowadcindex", &CmdProxy::slowadcindex},
/* dacs */
{"dac", &CmdProxy::Dac},
@ -1684,7 +1684,7 @@ class CmdProxy {
/* lists */
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.");
CTB_GET_DACINDEX(dacindex, getDacIndex, defs::DAC_0,
@ -1709,7 +1709,7 @@ class CmdProxy {
"the list of signal names for this board.");
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.");
CTB_GET_INDEX(signalindex, getSignalIndex,
@ -1717,30 +1717,30 @@ class CmdProxy {
"the signal index for the given name.");
CTB_NAMED_LIST(
powerlist, getPowerNames, setPowerNames,
"[powername1 powername2 .. powername4] \n\t\t[ChipTestBoard] Set "
"the list of power names for this board.");
voltagelist, getVoltageNames, setVoltageNames,
"[voltagename1 voltagename2 .. voltagename4] \n\t\t[ChipTestBoard] Set "
"the list of voltage names for this board.");
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_SINGLE_DACNAME(voltagename, getVoltageName, setVoltageName, defs::V_POWER_A,
"[0-4][name] \n\t\t[ChipTestBoard] Set "
"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 "
"the power index for the given name.");
"the voltage 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.");
slowadclist, getSlowAdcNames, setSlowAdcNames,
"[slowadcname1 slowadcname2 .. slowadcname7] \n\t\t[ChipTestBoard] Set "
"the list of slowadc names for this board.");
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_SINGLE_DACNAME(slowadcname, getSlowAdcName, setSlowAdcName, defs::SLOW_ADC0,
"[0-7][name] \n\t\t[ChipTestBoard] Set "
"the slowadc at the given position to the given name.");
CTB_GET_DACINDEX(senseindex, getSenseIndex, defs::SLOW_ADC0,
CTB_GET_DACINDEX(slowadcindex, getSlowAdcIndex, defs::SLOW_ADC0,
"[name] \n\t\t[ChipTestBoard] Get "
"the sense index for the given name.");
"the slowadc index for the given name.");
/* dacs */

View File

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

View File

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

View File

@ -2312,74 +2312,74 @@ std::string Detector::getSignalName(const int i) const {
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)
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)
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)
throw RuntimeError("Named powers only for CTB");
auto names = getPowerNames();
auto names = getVoltageNames();
auto it = std::find(names.begin(), names.end(), name);
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);
}
void Detector::setPowerName(const defs::dacIndex index,
void Detector::setVoltageName(const defs::dacIndex index,
const std::string &name) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
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)
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)
throw RuntimeError("Named senses only for CTB");
pimpl->setCtbSenseNames(names);
throw RuntimeError("Named SlowAdcs only for CTB");
pimpl->setCtbSlowAdcNames(names);
}
std::vector<std::string> Detector::getSenseNames() const {
std::vector<std::string> Detector::getSlowAdcNames() const {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB");
return pimpl->getCtbSenseNames();
throw RuntimeError("Named SlowAdcs only for CTB");
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)
throw RuntimeError("Named senses only for CTB");
auto names = getSenseNames();
throw RuntimeError("Named SlowAdcs only for CTB");
auto names = getSlowAdcNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Sense name not found");
throw RuntimeError("SlowAdc name not found");
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) {
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
throw RuntimeError("Named senses only for CTB");
pimpl->setCtbSenseName(index, name);
throw RuntimeError("Named SlowAdcs only for CTB");
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)
throw RuntimeError("Named senses only for CTB");
return pimpl->getCtbSenseName(i);
throw RuntimeError("Named SlowAdcs only for CTB");
return pimpl->getCtbSlowAdcName(i);
}
// Pattern

View File

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

View File

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

View File

@ -261,15 +261,15 @@ TEST_CASE("signalindex", "[.cmd]") {
}
}
TEST_CASE("powerlist", "[.cmd]") {
TEST_CASE("voltagelist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
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;
for (int iarg = 0; iarg != 5; ++iarg) {
@ -277,91 +277,91 @@ TEST_CASE("powerlist", "[.cmd]") {
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powerlist", names, -1, PUT, oss));
REQUIRE_NOTHROW(proxy.Call("voltagelist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powerlist", {}, -1, GET, oss));
REQUIRE_NOTHROW(proxy.Call("voltagelist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("powerlist ") + ToString(names) + '\n');
std::string("voltagelist ") + ToString(names) + '\n');
}
det.setPowerNames(prev);
det.setVoltageNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("powerlist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("powerlist", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("voltagelist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltagelist", {}, -1, GET));
}
}
TEST_CASE("powername", "[.cmd]") {
TEST_CASE("voltagename", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::V_POWER_A);
std::string str_power_index = "2";
auto prev = det.getPowerName(ind);
std::string str_voltage_index = "2";
auto prev = det.getVoltageName(ind);
// 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
REQUIRE_THROWS(proxy.Call("powername", {"5", "bname"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltagename", {"5", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("powername", {str_power_index, "bname"},
REQUIRE_NOTHROW(proxy.Call("voltagename", {str_voltage_index, "bname"},
-1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("powername", {str_power_index}, -1, GET, oss));
proxy.Call("voltagename", {str_voltage_index}, -1, GET, oss));
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 {
REQUIRE_THROWS(proxy.Call("powername", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("powername", {"2"}, -1, GET));
REQUIRE_THROWS(proxy.Call("voltagename", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltagename", {"2"}, -1, GET));
}
}
TEST_CASE("powerindex", "[.cmd]") {
TEST_CASE("voltageindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
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
REQUIRE_THROWS(proxy.Call("powerindex", {"2", "2"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("voltageindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("powerindex", {"5"}, -1, PUT));
auto powername = det.getPowerName(ind);
REQUIRE_THROWS(proxy.Call("voltageindex", {"5"}, -1, PUT));
auto voltagename = det.getVoltageName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("powerindex", {powername}, -1, GET, oss));
proxy.Call("voltageindex", {voltagename}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("powerindex ") + str_power_index + '\n');
std::string("voltageindex ") + str_voltage_index + '\n');
}
} 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;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
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;
for (int iarg = 0; iarg != 8; ++iarg) {
@ -369,79 +369,79 @@ TEST_CASE("senselist", "[.cmd]") {
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("senselist", names, -1, PUT, oss));
REQUIRE_NOTHROW(proxy.Call("slowadclist", names, -1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("senselist", {}, -1, GET, oss));
REQUIRE_NOTHROW(proxy.Call("slowadclist", {}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("senselist ") + ToString(names) + '\n');
std::string("slowadclist ") + ToString(names) + '\n');
}
det.setSenseNames(prev);
det.setSlowAdcNames(prev);
} else {
REQUIRE_THROWS(proxy.Call("senselist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("senselist", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("slowadclist", {"a", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadclist", {}, -1, GET));
}
}
TEST_CASE("sensename", "[.cmd]") {
TEST_CASE("slowadcname", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
defs::dacIndex ind = static_cast<defs::dacIndex>(2 + defs::SLOW_ADC0);
std::string str_sense_index = "2";
auto prev = det.getSenseName(ind);
std::string str_slowadc_index = "2";
auto prev = det.getSlowAdcName(ind);
// 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
REQUIRE_THROWS(proxy.Call("sensename", {"8", "bname"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadcname", {"8", "bname"}, -1, PUT));
{
std::ostringstream oss;
REQUIRE_NOTHROW(proxy.Call("sensename", {str_sense_index, "bname"},
REQUIRE_NOTHROW(proxy.Call("slowadcname", {str_slowadc_index, "bname"},
-1, PUT, oss));
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("sensename", {str_sense_index}, -1, GET, oss));
proxy.Call("slowadcname", {str_slowadc_index}, -1, GET, oss));
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 {
REQUIRE_THROWS(proxy.Call("sensename", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("sensename", {"2"}, -1, GET));
REQUIRE_THROWS(proxy.Call("slowadcname", {"2", "b"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadcname", {"2"}, -1, GET));
}
}
TEST_CASE("senseindex", "[.cmd]") {
TEST_CASE("slowadcindex", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::CHIPTESTBOARD) {
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
REQUIRE_THROWS(proxy.Call("senseindex", {"2", "2"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("slowadcindex", {"2", "2"}, -1, PUT));
// invalid index
REQUIRE_THROWS(proxy.Call("senseindex", {"8"}, -1, PUT));
auto sensename = det.getSenseName(ind);
REQUIRE_THROWS(proxy.Call("slowadcindex", {"8"}, -1, PUT));
auto slowadcname = det.getSlowAdcName(ind);
{
std::ostringstream oss;
REQUIRE_NOTHROW(
proxy.Call("senseindex", {sensename}, -1, GET, oss));
proxy.Call("slowadcindex", {slowadcname}, -1, GET, oss));
REQUIRE(oss.str() ==
std::string("senseindex ") + str_sense_index + '\n');
std::string("slowadcindex ") + str_slowadc_index + '\n');
}
} 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[2] == "ADC2");
REQUIRE(adcnames[3] == "ADC3");
auto powernames = c.getPowerNames();
auto powernames = c.getVoltageNames();
REQUIRE(powernames.size() == 5);
REQUIRE(powernames[0] == "VA");
REQUIRE(powernames[1] == "VB");
@ -39,12 +39,12 @@ TEST_CASE("Default construction") {
REQUIRE(signalnames[1] == "BIT1");
REQUIRE(signalnames[2] == "BIT2");
REQUIRE(signalnames[3] == "BIT3");
auto sensenames = c.getSenseNames();
auto sensenames = c.getSlowAdcNames();
REQUIRE(sensenames.size() == 8);
REQUIRE(sensenames[0] == "SENSE0");
REQUIRE(sensenames[1] == "SENSE1");
REQUIRE(sensenames[2] == "SENSE2");
REQUIRE(sensenames[3] == "SENSE3");
REQUIRE(sensenames[0] == "SLOWADC0");
REQUIRE(sensenames[1] == "SLOWADC1");
REQUIRE(sensenames[2] == "SLOWADC2");
REQUIRE(sensenames[3] == "SLOWADC3");
}
TEST_CASE("Set and get a single dac name") {