dacs with power dac names should work and do not take in dac units to avoid ambiguity, test with 0 value for power dacs should fail, to do: implement power commands
Build on RHEL9 docker image / build (push) Successful in 3m56s
Build on RHEL8 docker image / build (push) Successful in 4m47s

This commit is contained in:
2026-03-05 17:09:00 +01:00
parent b2cd043358
commit 4723eb2ff4
16 changed files with 242 additions and 442 deletions
-193
View File
@@ -2229,199 +2229,6 @@ std::string Caller::configtransceiver(int action) {
return os.str();
}
std::string Caller::dac(int action) {
std::ostringstream os;
// print help
if (action == slsDetectorDefs::HELP_ACTION) {
return GetHelpDacWrapper(cmd, args);
}
// check if action and arguments are valid
if (action == slsDetectorDefs::GET_ACTION) {
if (1 && args.size() != 1 && args.size() != 2) {
throw RuntimeError("Wrong number of arguments for action GET");
}
if (args.size() == 1) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
try {
StringTo<bool>("0");
} catch (...) {
throw RuntimeError("Could not convert argument 1 to bool");
}
}
if (args.size() == 2) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
try {
StringTo<bool>("1");
} catch (...) {
throw RuntimeError("Could not convert argument 1 to bool");
}
}
}
else if (action == slsDetectorDefs::PUT_ACTION) {
if (1 && args.size() != 2 && args.size() != 3) {
throw RuntimeError("Wrong number of arguments for action PUT");
}
if (args.size() == 2) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
try {
StringTo<int>(args[1]);
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("0");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
if (args.size() == 3) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
try {
StringTo<int>(args[1]);
} catch (...) {
throw RuntimeError("Could not convert argument 1 to int");
}
try {
StringTo<bool>("1");
} catch (...) {
throw RuntimeError("Could not convert argument 2 to bool");
}
}
}
else {
throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions "
"are ['GET', 'PUT']");
}
// generate code for each action
if (action == slsDetectorDefs::GET_ACTION) {
if (args.size() == 1) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
if (is_int(args[0]) &&
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError(
"Dac indices can only be used for chip test board. Use "
"daclist to get list of dac names for current detector.");
}
auto arg1 = StringTo<bool>("0");
auto t = det->getDAC(dacIndex, arg1, std::vector<int>{det_id});
os << args[0] << ' ' << OutString(t) << '\n';
}
if (args.size() == 2) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
if (is_int(args[0]) &&
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError(
"Dac indices can only be used for chip test board. Use "
"daclist to get list of dac names for current detector.");
}
if (args[1] != "mv" && args[1] != "mV") {
throw RuntimeError("Unknown argument " + args[1] +
". Did you mean mV?");
}
auto arg1 = StringTo<bool>("1");
auto t = det->getDAC(dacIndex, arg1, std::vector<int>{det_id});
os << args[0] << ' ' << OutString(t) << " mV" << '\n';
}
}
if (action == slsDetectorDefs::PUT_ACTION) {
if (args.size() == 2) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
if (is_int(args[0]) &&
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError(
"Dac indices can only be used for chip test board. Use "
"daclist to get list of dac names for current detector.");
}
auto arg1 = StringTo<int>(args[1]);
auto arg2 = StringTo<bool>("0");
det->setDAC(dacIndex, arg1, arg2, std::vector<int>{det_id});
os << args[0] << ' ' << args[1] << '\n';
}
if (args.size() == 3) {
defs::dacIndex dacIndex =
((det->getDetectorType().squash() == defs::CHIPTESTBOARD ||
det->getDetectorType().squash() ==
defs::XILINX_CHIPTESTBOARD) &&
!is_int(args[0]))
? det->getDacIndex(args[0])
: StringTo<defs::dacIndex>(args[0]);
if (is_int(args[0]) &&
det->getDetectorType().squash() != defs::CHIPTESTBOARD &&
det->getDetectorType().squash() != defs::XILINX_CHIPTESTBOARD) {
throw RuntimeError(
"Dac indices can only be used for chip test board. Use "
"daclist to get list of dac names for current detector.");
}
auto arg1 = StringTo<int>(args[1]);
auto arg2 = StringTo<bool>("1");
det->setDAC(dacIndex, arg1, arg2, std::vector<int>{det_id});
os << args[0] << ' ' << args[1] << " mV" << '\n';
}
}
return os.str();
}
std::string Caller::dacindex(int action) {
std::ostringstream os;