Merge branch 'developer' into dev/ctb_clocks
Build on RHEL8 docker image / build (push) Failing after 0s
Build on RHEL9 docker image / build (push) Failing after 0s
Run Simulator Tests on local RHEL9 / build (push) Successful in 14m42s
Run Simulator Tests on local RHEL8 / build (push) Successful in 17m12s

This commit is contained in:
2026-04-22 16:36:13 +02:00
72 changed files with 43083 additions and 36506 deletions
File diff suppressed because it is too large Load Diff
+20 -12
View File
@@ -5,6 +5,7 @@
#include "sls/Detector.h"
#include <iostream>
#include <optional>
#include <string>
#include <vector>
namespace sls {
@@ -215,7 +216,9 @@ class Caller {
std::string periodl(int action);
std::string polarity(int action);
std::string port(int action);
std::string power(int action);
std::string powerchip(int action);
std::string powerdac(int action);
std::string powerindex(int action);
std::string powerlist(int action);
std::string powername(int action);
@@ -358,12 +361,6 @@ class Caller {
std::string updatekernel(int action);
std::string updatemode(int action);
std::string user(int action);
std::string v_a(int action);
std::string v_b(int action);
std::string v_c(int action);
std::string v_chip(int action);
std::string v_d(int action);
std::string v_io(int action);
std::string v_limit(int action);
std::string vchip_comp_adc(int action);
std::string vchip_comp_fe(int action);
@@ -396,6 +393,7 @@ class Caller {
private:
bool ReplaceIfDeprecated(std::string &command);
void SuggestIfRemoved(const std::string &command);
using FunctionMap = std::map<std::string, std::string (Caller::*)(int)>;
using StringMap = std::map<std::string, std::string>;
Detector *ptr; // pointer to the detector that executes the command
@@ -420,6 +418,9 @@ class Caller {
// applicable
RegisterAddress getRegisterAddress(const std::string &saddr) const;
BitAddress getBitAddress() const;
defs::dacIndex parseDacIndex(int argIndex, bool isCtb);
bool parseMV(int argIndex);
defs::powerIndex parsePowerIndex(int argIndex);
FunctionMap functions{
{"list", &Caller::list},
@@ -585,7 +586,9 @@ class Caller {
{"periodl", &Caller::periodl},
{"polarity", &Caller::polarity},
{"port", &Caller::port},
{"power", &Caller::power},
{"powerchip", &Caller::powerchip},
{"powerdac", &Caller::powerdac},
{"powerindex", &Caller::powerindex},
{"powerlist", &Caller::powerlist},
{"powername", &Caller::powername},
@@ -729,12 +732,6 @@ class Caller {
{"updatekernel", &Caller::updatekernel},
{"updatemode", &Caller::updatemode},
{"user", &Caller::user},
{"v_a", &Caller::v_a},
{"v_b", &Caller::v_b},
{"v_c", &Caller::v_c},
{"v_chip", &Caller::v_chip},
{"v_d", &Caller::v_d},
{"v_io", &Caller::v_io},
{"v_limit", &Caller::v_limit},
{"vchip_comp_adc", &Caller::vchip_comp_adc},
{"vchip_comp_fe", &Caller::vchip_comp_fe},
@@ -902,6 +899,17 @@ class Caller {
{"frameindex", "rx_frameindex"},
};
StringMap removed_functions{
{"v_a", "'dac v_a' and 'power v_a'"},
{"v_b", "'dac v_b' and 'power v_b'"},
{"v_c", "'dac v_c' and 'power v_c'"},
{"v_d", "'dac v_d' and 'power v_d'"},
{"v_io", "'dac v_io' and 'power v_io'"},
{"v_chip", "'dac v_chip'"},
};
};
} // namespace sls
+307
View File
@@ -4,8 +4,10 @@
#include "sls/file_utils.h"
#include "sls/logger.h"
#include "sls/string_utils.h"
#include <iostream>
#include <thread>
namespace sls {
// some helper functions to print
@@ -25,6 +27,7 @@ void Caller::call(const std::string &command,
int action, std::ostream &os, int receiver_id) {
cmd = command;
args = arguments; // copy args before replacing
SuggestIfRemoved(cmd);
std::string temp;
while (temp != cmd) {
temp = cmd;
@@ -66,6 +69,16 @@ bool Caller::ReplaceIfDeprecated(std::string &command) {
return false;
}
void Caller::SuggestIfRemoved(const std::string &command) {
auto r_it = removed_functions.find(command);
if (r_it != removed_functions.end()) {
std::ostringstream oss;
oss << command << " is removed and is no longer available. Please use: "
<< r_it->second;
throw RuntimeError(oss.str());
}
}
std::string Caller::list(int action) {
if (action == defs::HELP_ACTION) {
return "[deprecated(optional)]\n\tlists all available commands, list "
@@ -1798,4 +1811,298 @@ BitAddress Caller::getBitAddress() const {
throw RuntimeError("Invalid number of parameters for bit address.");
}
std::string Caller::dac(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
if (args.size() == 0)
os << GetHelpDac("");
else
os << args[0] << GetHelpDac(args[0]) << '\n';
return os.str();
}
bool isCtb = false;
auto detType = det->getDetectorType().squash(defs::GENERIC);
if (detType == defs::CHIPTESTBOARD ||
detType == defs::XILINX_CHIPTESTBOARD) {
isCtb = true;
}
if (action == defs::GET_ACTION) {
auto index = parseDacIndex(0, isCtb);
auto mV = parseMV(1);
auto t = det->getDAC(index, mV, std::vector<int>{det_id});
os << args[0] << ' ' << OutString(t) << (mV ? " mV" : "") << '\n';
}
else if (action == defs::PUT_ACTION) {
auto index = parseDacIndex(0, isCtb);
if (args.size() < 2) {
WrongNumberOfParameters(2);
}
auto val = StringTo<int>(args[1]);
auto mV = parseMV(2);
det->setDAC(index, val, mV, std::vector<int>{det_id});
os << args[0] << ' ' << args[1] << (mV ? " mV" : "") << '\n';
}
else {
throw RuntimeError("Unknown action");
}
return os.str();
}
defs::dacIndex Caller::parseDacIndex(int argIndex, bool isCtb) {
if (argIndex >= (int)args.size()) {
throw RuntimeError("Invalid arguments. DAC index is required.");
}
auto arg = args[argIndex];
if (isCtb) {
// dac index
if (is_int(arg)) {
return StringTo<defs::dacIndex>(arg);
}
// dac name
return det->getDacIndex(arg);
}
// not ctb
if (is_int(arg)) {
throw RuntimeError("DAC index is not supported for your detector. "
"Please use dac name. Use daclist command to get "
"the list of dac names for your detector.");
}
return StringTo<defs::dacIndex>(arg);
}
bool Caller::parseMV(int argIndex) {
if (argIndex < (int)args.size()) {
auto arg = args[argIndex];
if (arg != "mv" && arg != "mV") {
throw RuntimeError("Unknown argument " + arg +
". Did you mean mV?");
}
return true;
}
return false;
}
std::string Caller::powerdac(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
os << "[powername][mV value]\n\t[Ctb][Xilinx Ctb] Controls the dac "
"used for Power supply. Default names for powername are v_a, "
"v_b, v_c, v_d, v_io, v_chip(v_chip only applies to Ctb, not "
"Xilinx_Ctb). If custom names are assigned using the 'powername' "
"command, those names could be used instead instead of the "
"defaults. By default, all are set to minimum values. \n\t[Ctb] "
"v_chip can also be queried to get the vchip dac value, although "
"its rail cannot be enabled or disabled by the user. It is "
"enabled by default. Its dac value is automatically updated "
"whenever a power dac is modified. It is then set to the max of "
"power dacs + 200mV."
<< '\n';
return os.str();
}
auto detType = det->getDetectorType().squash(defs::GENERIC);
if (detType != defs::CHIPTESTBOARD &&
detType != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError("This command is only applicable for ChipTestBoard "
"and Xilinx ChipTestBoard.");
}
if (det_id != -1) {
throw RuntimeError("Cannot use powerdac at module level.");
}
auto index = parsePowerIndex(0);
if (action == defs::GET_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
auto t = det->getPowerDAC(index);
os << args[0] << ' ' << OutString(t) << '\n';
}
else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
auto val = StringTo<int>(args[1]);
det->setPowerDAC(index, val);
os << args[0] << ' ' << args[1] << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
defs::powerIndex Caller::parsePowerIndex(int argIndex) {
if (argIndex >= (int)args.size()) {
throw RuntimeError("Invalid arguments. Power name is required.");
}
auto arg = args[argIndex];
// power default names
if (is_int(arg) || arg == "v_a" || arg == "v_b" || arg == "v_c" ||
arg == "v_d" || arg == "v_io" || arg == "v_chip") {
return StringTo<defs::powerIndex>(arg);
}
// power name
auto names = det->getPowerNames();
auto it = std::find(names.begin(), names.end(), arg);
if (it != names.end()) {
return det->getPowerIndex(arg);
}
throw RuntimeError(
"Unknown power name '" + arg +
"'. Use 'powername' command to see defined power names.");
}
std::string Caller::power(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
os << "[all|list of power names] [on|off]\n\t[Ctb][Xilinx Ctb] Enable "
"or "
"disable power rails. Power name can be all, v_a, v_b, v_c, v_d "
"or "
"v_io or any defines using 'powername'. If power name is set to "
"'all', the command applies to all 'powers'. Enabling the power "
"rails is in parallel, whereas retrieving the states of multiple "
"power rails, they are queried sequentially "
"(one after another), not in parallel."
<< '\n';
return os.str();
}
auto detType = det->getDetectorType().squash(defs::GENERIC);
if (detType != defs::CHIPTESTBOARD &&
detType != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError("This command is only applicable for ChipTestBoard "
"and Xilinx ChipTestBoard.");
}
// 'all' argument
bool all = false;
if (std::find(args.begin(), args.end(), "all") != args.end()) {
all = true;
}
// number of args
if (action == defs::GET_ACTION && args.size() != 1)
WrongNumberOfParameters(1);
if (all) {
if (action == defs::PUT_ACTION && args.size() != 2) {
WrongNumberOfParameters(2);
}
} else {
if (args.size() < 1 || args.size() > 6)
WrongNumberOfParameters(1);
}
if (action == defs::GET_ACTION) {
if (!all) {
auto t = det->isPowerEnabled(parsePowerIndex(0));
os << args[0] << ' ' << ToString(t, defs::OnOff) << '\n';
} else {
// get each state and store in map
std::map<std::string, std::string> m;
auto powerIndices = det->getPowerList();
for (const auto &index : powerIndices) {
auto name = ToString(index);
auto state = det->isPowerEnabled(index);
m[name] = ToString(state, defs::OnOff);
}
if (m.empty()) {
throw RuntimeError("Could not get power states.");
}
auto first = m.begin()->second;
// if all the same, print in short form, else print all states
if (std::all_of(m.begin(), m.end(),
[&](const auto &p) { return p.second == first; })) {
os << "all " << first << '\n';
} else {
os << ToString(m) << '\n';
}
}
}
else if (action == defs::PUT_ACTION) {
// enable arg
std::string lastArg = args.back();
if (lastArg != "on" && lastArg != "off") {
throw RuntimeError("Last argument '" + lastArg +
"' is enable. Options: 'on' or 'off'");
}
bool enable = StringTo(lastArg, defs::OnOff);
// power indices
std::vector<defs::powerIndex> powerIndices;
if (all) {
powerIndices = det->getPowerList();
} else {
// push back indices from command line
for (size_t i = 0; i < args.size() - 1; ++i) {
powerIndices.push_back(parsePowerIndex(i));
}
}
det->setPowerEnabled(powerIndices, enable);
args.pop_back();
os << ToString(args) << ' ' << ToString(enable, defs::OnOff) << '\n';
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
std::string Caller::powervalues(int action) {
std::ostringstream os;
if (action == defs::HELP_ACTION) {
os << "\n\t\t[Ctb][Xilinx_Ctb] Get dac values of all powers if "
"enabled, else '0'."
<< '\n';
return os.str();
}
auto detType = det->getDetectorType().squash(defs::GENERIC);
if (detType != defs::CHIPTESTBOARD &&
detType != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError("This command is only applicable for ChipTestBoard "
"and Xilinx ChipTestBoard.");
}
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPowerList();
auto names = det->getPowerNames();
auto name_it = names.begin();
os << '[';
auto it = t.cbegin();
while (it != t.cend()) {
if (it != t.cbegin())
os << ", ";
os << ToString(*name_it++) << ": [";
os << ToString(det->isPowerEnabled(*it), defs::OnOff) << ", ";
os << det->getPowerDAC(*it) << " mV ]";
++it;
}
os << "]" << '\n';
} else if (action == defs::PUT_ACTION) {
throw RuntimeError("Cannot put");
} else {
throw RuntimeError("Unknown action");
}
return os.str();
}
} // namespace sls
+14 -5
View File
@@ -20,11 +20,11 @@ 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");
setPowerName(static_cast<int>(defs::V_POWER_A), "VA");
setPowerName(static_cast<int>(defs::V_POWER_B), "VB");
setPowerName(static_cast<int>(defs::V_POWER_C), "VC");
setPowerName(static_cast<int>(defs::V_POWER_D), "VD");
setPowerName(static_cast<int>(defs::V_POWER_IO), "VIO");
for (size_t i = 0; i != num_slowADCs; ++i) {
setSlowADCName(i, "SLOWADC" + ToString(i));
}
@@ -80,6 +80,15 @@ CtbConfig::getNames(size_t expected_size,
void CtbConfig::setDacName(size_t index, const std::string &name) {
check_index(index, num_dacs, "DAC");
std::vector<std::string> powers = {"v_a", "v_b", "v_c", "v_d", "v_io",
"va", "vb", "vc", "vd", "vio"};
std::string lower = name;
std::transform(lower.begin(), lower.end(), lower.begin(),
[](unsigned char c) { return std::tolower(c); });
if (std::find(powers.begin(), powers.end(), lower) != powers.end()) {
throw RuntimeError("DAC name cannot be a power name (VA, VB, VC, VD, "
"VIO, V_A, V_B, V_C, V_D, V_IO)");
}
set_name(name, dacnames, index);
}
+88 -72
View File
@@ -2166,15 +2166,80 @@ Result<int> Detector::getSYNCClock(Positions pos) const {
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
}
std::vector<defs::dacIndex> Detector::getPowerList() const {
std::vector<defs::powerIndex> Detector::getPowerList() const {
auto dettype = getDetectorType().squash();
if (dettype != defs::CHIPTESTBOARD &&
dettype != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError("Power list not implemented for this detector");
}
return std::vector<defs::dacIndex>{defs::V_POWER_A, defs::V_POWER_B,
defs::V_POWER_C, defs::V_POWER_D,
defs::V_POWER_IO};
return std::vector<defs::powerIndex>{defs::V_POWER_A, defs::V_POWER_B,
defs::V_POWER_C, defs::V_POWER_D,
defs::V_POWER_IO};
}
int Detector::getPowerDAC(defs::powerIndex index) const {
pimpl->verifyChipTestBoard(__func__);
return pimpl->Parallel(&Module::getPowerDAC, {0}, index)[0];
}
void Detector::setPowerDAC(defs::powerIndex index, int value) {
pimpl->verifyChipTestBoard(__func__);
pimpl->Parallel(&Module::setPowerDAC, {0}, index, value);
}
bool Detector::isPowerEnabled(defs::powerIndex index) const {
pimpl->verifyChipTestBoard(__func__);
return pimpl->Parallel(&Module::isPowerEnabled, {0}, index)[0];
}
void Detector::setPowerEnabled(const std::vector<defs::powerIndex> &indices,
bool enable) {
pimpl->verifyChipTestBoard(__func__);
if (indices.empty()) {
throw RuntimeError("No Power Index provided");
}
pimpl->Parallel(&Module::setPowerEnabled, {0}, indices, enable);
}
int Detector::getMeasuredPower(defs::powerIndex index) const {
pimpl->verifyChipTestBoard(__func__);
switch (index) {
case defs::V_POWER_A:
case defs::V_POWER_B:
case defs::V_POWER_C:
case defs::V_POWER_D:
case defs::V_POWER_IO:
case defs::V_POWER_CHIP:
break;
default:
throw RuntimeError("Unknown Power Index " + std::to_string(index));
}
return pimpl->Parallel(&Module::getPowerADC, {0}, index)[0];
}
int Detector::getMeasuredCurrent(defs::powerIndex index) const {
pimpl->verifyChipTestBoard(__func__);
switch (index) {
case defs::I_POWER_A:
case defs::I_POWER_B:
case defs::I_POWER_C:
case defs::I_POWER_D:
case defs::I_POWER_IO:
break;
default:
throw RuntimeError("Unknown Current Index " + std::to_string(index));
}
return pimpl->Parallel(&Module::getPowerADC, {0}, index)[0];
}
int Detector::getVoltageLimit() const {
pimpl->verifyChipTestBoard(__func__);
return pimpl->Parallel(&Module::getVoltageLimit, {0})[0];
}
void Detector::setVoltageLimit(int value) {
pimpl->verifyChipTestBoard(__func__);
pimpl->Parallel(&Module::setVoltageLimit, {0}, value);
}
std::vector<defs::dacIndex> Detector::getSlowADCList() const {
@@ -2188,38 +2253,6 @@ std::vector<defs::dacIndex> Detector::getSlowADCList() const {
defs::SLOW_ADC4, defs::SLOW_ADC5, defs::SLOW_ADC6, defs::SLOW_ADC7};
}
Result<int> Detector::getPower(defs::dacIndex index, Positions pos) const {
switch (index) {
case defs::V_LIMIT:
case defs::V_POWER_A:
case defs::V_POWER_B:
case defs::V_POWER_C:
case defs::V_POWER_D:
case defs::V_POWER_IO:
case defs::V_POWER_CHIP:
break;
default:
throw RuntimeError("Unknown Power Index");
}
return pimpl->Parallel(&Module::getDAC, pos, index, true);
}
void Detector::setPower(defs::dacIndex index, int value, Positions pos) {
switch (index) {
case defs::V_LIMIT:
case defs::V_POWER_A:
case defs::V_POWER_B:
case defs::V_POWER_C:
case defs::V_POWER_D:
case defs::V_POWER_IO:
case defs::V_POWER_CHIP:
break;
default:
throw RuntimeError("Unknown Power Index");
}
pimpl->Parallel(&Module::setDAC, pos, value, index, true);
}
Result<int> Detector::getADCVpp(bool mV, Positions pos) const {
return pimpl->Parallel(&Module::getDAC, pos, defs::ADC_VPP, mV);
}
@@ -2286,37 +2319,6 @@ void Detector::setDBITClock(int value_in_Hz, Positions pos) {
value_in_Hz);
}
Result<int> Detector::getMeasuredPower(defs::dacIndex index,
Positions pos) const {
switch (index) {
case defs::V_POWER_A:
case defs::V_POWER_B:
case defs::V_POWER_C:
case defs::V_POWER_D:
case defs::V_POWER_IO:
case defs::V_POWER_CHIP:
break;
default:
throw RuntimeError("Unknown Power Index");
}
return pimpl->Parallel(&Module::getADC, pos, index);
}
Result<int> Detector::getMeasuredCurrent(defs::dacIndex index,
Positions pos) const {
switch (index) {
case defs::I_POWER_A:
case defs::I_POWER_B:
case defs::I_POWER_C:
case defs::I_POWER_D:
case defs::I_POWER_IO:
break;
default:
throw RuntimeError("Unknown Current Index");
}
return pimpl->Parallel(&Module::getADC, pos, index);
}
Result<int> Detector::getSlowADC(defs::dacIndex index, Positions pos) const {
if (index < defs::SLOW_ADC0 || index > defs::SLOW_ADC7) {
throw RuntimeError("Unknown Slow ADC Index");
@@ -2398,7 +2400,14 @@ defs::dacIndex Detector::getDacIndex(const std::string &name) const {
throw RuntimeError("Dac name not found");
return static_cast<defs::dacIndex>(it - names.begin());
}
return StringTo<defs::dacIndex>(name);
auto retval = StringTo<defs::dacIndex>(name);
auto list = getDacList();
if (std::find(list.begin(), list.end(), retval) == list.end()) {
throw RuntimeError("Dac name not found in dac list. Use 'daclist' or "
"Detector::getDacNames() to get the list of dac "
"names for this detector.");
}
return retval;
}
void Detector::setDacName(const defs::dacIndex i, const std::string &name) {
@@ -2408,6 +2417,13 @@ void Detector::setDacName(const defs::dacIndex i, const std::string &name) {
std::string Detector::getDacName(const defs::dacIndex i) const {
if (pimpl->isChipTestBoard())
return pimpl->getCtbDacName(i);
auto list = getDacList();
if (std::find(list.begin(), list.end(), i) == list.end()) {
auto count = getDacList().size();
throw RuntimeError(
"Dac index not found in dac list. Use an index from 0 to " +
std::to_string(count - 1) + ".");
}
return ToString(i);
}
@@ -2467,20 +2483,20 @@ std::vector<std::string> Detector::getPowerNames() const {
return pimpl->getCtbPowerNames();
}
defs::dacIndex Detector::getPowerIndex(const std::string &name) const {
defs::powerIndex Detector::getPowerIndex(const std::string &name) const {
auto names = getPowerNames();
auto it = std::find(names.begin(), names.end(), name);
if (it == names.end())
throw RuntimeError("Power name not found");
return static_cast<defs::dacIndex>(it - names.begin() + defs::V_POWER_A);
return static_cast<defs::powerIndex>(it - names.begin());
}
void Detector::setPowerName(const defs::dacIndex index,
void Detector::setPowerName(const defs::powerIndex index,
const std::string &name) {
pimpl->setCtbPowerName(index, name);
}
std::string Detector::getPowerName(const defs::dacIndex i) const {
std::string Detector::getPowerName(const defs::powerIndex i) const {
return pimpl->getCtbPowerName(i);
}
+3 -3
View File
@@ -2026,17 +2026,17 @@ void DetectorImpl::setCtbPowerNames(const std::vector<std::string> &names) {
ctb_shm()->setPowerNames(names);
}
std::string DetectorImpl::getCtbPowerName(const defs::dacIndex i) const {
std::string DetectorImpl::getCtbPowerName(const defs::powerIndex i) const {
if (!isChipTestBoard())
throw RuntimeError("Named Powers only for CTB");
return ctb_shm()->getPowerName(static_cast<int>(i - defs::V_POWER_A));
}
void DetectorImpl::setCtbPowerName(const defs::dacIndex index,
void DetectorImpl::setCtbPowerName(const defs::powerIndex index,
const std::string &name) {
if (!isChipTestBoard())
throw RuntimeError("Named Powers only for CTB");
ctb_shm()->setPowerName(static_cast<int>(index - defs::V_POWER_A), name);
ctb_shm()->setPowerName(static_cast<int>(index), name);
}
std::vector<std::string> DetectorImpl::getCtbSlowADCNames() const {
+13 -2
View File
@@ -188,6 +188,17 @@ class DetectorImpl : public virtual slsDetectorDefs {
shm()->detType == defs::XILINX_CHIPTESTBOARD);
}
inline void verifyChipTestBoard(const std::string &funcName) const {
if (!isChipTestBoard())
throw RuntimeError(funcName +
" is not implemented for this detector. It is "
"only valid for chip test board");
if (size() != 1)
throw RuntimeError(
funcName +
" is only valid for single module setup (chip test board).");
}
/** set acquiring flag in shared memory */
void setAcquiringFlag(bool flag);
@@ -324,9 +335,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
void setCtbSignalName(const int index, const std::string &name);
std::vector<std::string> getCtbPowerNames() const;
std::string getCtbPowerName(const defs::dacIndex i) const;
std::string getCtbPowerName(const defs::powerIndex i) const;
void setCtbPowerNames(const std::vector<std::string> &names);
void setCtbPowerName(const defs::dacIndex index, const std::string &name);
void setCtbPowerName(const defs::powerIndex index, const std::string &name);
std::vector<std::string> getCtbSlowADCNames() const;
std::string getCtbSlowADCName(const defs::dacIndex i) const;
+4 -18
View File
@@ -7,7 +7,7 @@
namespace sls {
std::string GetHelpDac(std::string dac) {
if (sls::is_int(dac)) {
if (dac.empty() || sls::is_int(dac)) {
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
"\n\t[Ctb] Use dac index for dac name.");
}
@@ -280,24 +280,10 @@ std::string GetHelpDac(std::string dac) {
return std::string(
"[dac or mV value][(optional unit) mV] \n\t[Moench] Dac for 7");
}
// clang-format off
if (dac == "vtgstv") { return std::string(""); }
// clang-format on
if (dac == "vtgstv") {
return std::string("");
}
throw sls::RuntimeError("Unknown dac command");
}
std::string GetHelpDacWrapper(const std::string &cmd,
const std::vector<std::string> &args) {
std::ostringstream os;
os << cmd << ' ';
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
return os.str();
}
} // namespace sls
-3
View File
@@ -7,7 +7,4 @@ namespace sls {
std::string GetHelpDac(std::string dac);
std::string GetHelpDacWrapper(const std::string &cmd,
const std::vector<std::string> &args);
} // namespace sls
+44
View File
@@ -819,6 +819,50 @@ void Module::setPowerChip(bool on) {
sendToDetector<int>(F_POWER_CHIP, static_cast<int>(on));
}
int Module::getPowerDAC(defs::powerIndex index) const {
return sendToDetector<int>(F_GET_POWER_DAC, static_cast<int>(index));
}
void Module::setPowerDAC(defs::powerIndex index, int value) {
int args[]{static_cast<int>(index), value};
sendToDetector(F_SET_POWER_DAC, args, nullptr);
}
bool Module::isPowerEnabled(defs::powerIndex index) const {
return sendToDetector<int>(F_GET_POWER, static_cast<int>(index));
}
void Module::setPowerEnabled(const std::vector<defs::powerIndex> &indices,
bool enable) {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_SET_POWER);
client.setFnum(F_SET_POWER);
int count = indices.size();
client.Send(count);
std::vector<int> indices_int(count);
for (size_t i = 0; i < indices.size(); ++i) {
indices_int[i] = static_cast<int>(indices[i]);
}
client.Send(indices_int);
client.Send(static_cast<int>(enable));
if (client.Receive<int>() == FAIL) {
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
int Module::getPowerADC(defs::powerIndex index) const {
return sendToDetector<int>(F_GET_POWER_ADC, static_cast<int>(index));
}
int Module::getVoltageLimit() const {
return sendToDetector<int>(F_GET_VOLTAGE_LIMIT);
}
void Module::setVoltageLimit(const int limit_in_mV) {
sendToDetector(F_SET_VOLTAGE_LIMIT, limit_in_mV, nullptr);
}
int Module::getImageTestMode() const {
return sendToDetector<int>(F_GET_IMAGE_TEST_MODE);
}
+8
View File
@@ -177,6 +177,14 @@ class Module : public virtual slsDetectorDefs {
void setDAC(int val, dacIndex index, bool mV);
bool getPowerChip() const;
void setPowerChip(bool on);
int getPowerDAC(defs::powerIndex index) const;
void setPowerDAC(defs::powerIndex index, int value);
bool isPowerEnabled(defs::powerIndex index) const;
void setPowerEnabled(const std::vector<defs::powerIndex> &indices,
bool enable);
int getPowerADC(defs::powerIndex index) const;
int getVoltageLimit() const;
void setVoltageLimit(const int limit_in_mV);
int getImageTestMode() const;
void setImageTestMode(const int value);
/* temperature in millidegrees */
+22 -96
View File
@@ -2256,6 +2256,12 @@ int InferAction::port() {
}
}
int InferAction::power() {
throw RuntimeError("sls_detector is disabled for command: power. Use "
"sls_detector_get or sls_detector_put");
}
int InferAction::powerchip() {
if (args.size() == 0) {
@@ -2272,6 +2278,22 @@ int InferAction::powerchip() {
}
}
int InferAction::powerdac() {
if (args.size() == 1) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 2) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::powerindex() {
if (args.size() == 1) {
@@ -4253,102 +4275,6 @@ int InferAction::user() {
}
}
int InferAction::v_a() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_b() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_c() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_chip() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_d() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_io() {
if (args.size() == 0) {
return slsDetectorDefs::GET_ACTION;
}
if (args.size() == 1) {
return slsDetectorDefs::PUT_ACTION;
}
else {
throw RuntimeError("Could not infer action: Wrong number of arguments");
}
}
int InferAction::v_limit() {
if (args.size() == 0) {
+4 -12
View File
@@ -170,7 +170,9 @@ class InferAction {
int periodl();
int polarity();
int port();
int power();
int powerchip();
int powerdac();
int powerindex();
int powerlist();
int powername();
@@ -313,12 +315,6 @@ class InferAction {
int updatekernel();
int updatemode();
int user();
int v_a();
int v_b();
int v_c();
int v_chip();
int v_d();
int v_io();
int v_limit();
int vchip_comp_adc();
int vchip_comp_fe();
@@ -510,7 +506,9 @@ class InferAction {
{"periodl", &InferAction::periodl},
{"polarity", &InferAction::polarity},
{"port", &InferAction::port},
{"power", &InferAction::power},
{"powerchip", &InferAction::powerchip},
{"powerdac", &InferAction::powerdac},
{"powerindex", &InferAction::powerindex},
{"powerlist", &InferAction::powerlist},
{"powername", &InferAction::powername},
@@ -654,12 +652,6 @@ class InferAction {
{"updatekernel", &InferAction::updatekernel},
{"updatemode", &InferAction::updatemode},
{"user", &InferAction::user},
{"v_a", &InferAction::v_a},
{"v_b", &InferAction::v_b},
{"v_c", &InferAction::v_c},
{"v_chip", &InferAction::v_chip},
{"v_d", &InferAction::v_d},
{"v_io", &InferAction::v_io},
{"v_limit", &InferAction::v_limit},
{"vchip_comp_adc", &InferAction::vchip_comp_adc},
{"vchip_comp_fe", &InferAction::vchip_comp_fe},