From 3feed07d95e24d8446c1d64454479e3eb1aa35b0 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 17 Mar 2026 17:26:57 +0100 Subject: [PATCH] wip --- slsDetectorSoftware/generator/commands.yaml | 18 ++--- slsDetectorSoftware/include/sls/Detector.h | 6 ++ slsDetectorSoftware/src/CallerSpecial.cpp | 75 ++++----------------- 3 files changed, 29 insertions(+), 70 deletions(-) diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index dd8d92650..a5b9f307d 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -1542,6 +1542,15 @@ fmaster: function: setMasterFileWrite input_types: [ bool ] +v_limit: + inherit_actions: INTEGER_COMMAND_NOID + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Soft limit for power supplies and DACS in mV." + actions: + GET: + function: getVoltageLimit + PUT: + function: setVoltageLimit + input_types: [ int ] ################# INTEGER_USER_IND_COMMAND ################### vchip_comp_fe: @@ -2770,15 +2779,6 @@ powerdac: arg_types: [ std::string ] -v_limit: - is_description: true - actions: - GET: - argc: 0 - PUT: - argc: 1 - arg_types: [ int ] - power: is_description: true actions: diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index c2e7b1c7d..bb400ba1c 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1659,6 +1659,12 @@ class Detector { * Options: I_POWER_A, I_POWER_B, I_POWER_C, I_POWER_D, I_POWER_IO */ int getMeasuredCurrent(defs::powerIndex index) const; + /** [CTB][Xilinx CTB] */ + int getVoltageLimit() const; + + /** [CTB][Xilinx CTB] set a voltage limit for dacs and power dacs */ + void setVoltageLimit(const int limit_in_mV); + /** [CTB][Xilinx CTB] gets list of slow adc enums */ std::vector getSlowADCList() const; diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 017021f2e..d93c8ff93 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -1962,56 +1962,18 @@ defs::dacIndex Caller::parsePowerIndex(int argIndex) { "'. Use 'powername' command to see defined power names."); } -std::string Caller::v_limit(int action) { - std::ostringstream os; - - if (action == defs::HELP_ACTION) { - os << "[n_value]\n\t[Ctb][Xilinx Ctb] Soft limit for power supplies " - "and DACS in mV." - << '\n'; - return os.str(); - } - - auto detType = det->getDetectorType().squash(defs::GENERIC); - if (detType != defs::CHIPTESTBOARD && - detType != defs::XILINX_CHIPTESTBOARD) { - throw RuntimeError("v_limit command is only applicable for " - "ChipTestBoard and Xilinx ChipTestBoard."); - } - - if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getDAC(defs::V_LIMIT, true, std::vector{det_id}); - os << OutString(t) << " mV" << '\n'; - } - - else if (action == defs::PUT_ACTION) { - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - auto val = StringTo(args[0]); - det->setDAC(defs::V_LIMIT, val, true, std::vector{det_id}); - os << args[0] << " mV" << '\n'; - } - - else { - throw RuntimeError("Unknown action"); - } - - return os.str(); -} - std::string Caller::power(int action) { std::ostringstream os; if (action == defs::HELP_ACTION) { - os << "[list of power names] [on|off]\n\t[Ctb][Xilinx Ctb] Enable or " - "disable power rails. Power name can be v_a, v_b, v_c, v_d or " + 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'. When retrieving the " - "states of multiple power rails, they are queried sequentially " + "'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(); @@ -2044,9 +2006,7 @@ std::string Caller::power(int action) { if (action == defs::GET_ACTION) { if (!all) { - auto t = det->isPowerEnabled(parsePowerIndex(0), - std::vector{det_id}) - .tsquash("Inconsistent across modules"); + auto t = det->isPowerEnabled(parsePowerIndex(0)); os << args[0] << ' ' << ToString(t, defs::OnOff) << '\n'; } else { // get each state and store in map @@ -2054,9 +2014,7 @@ std::string Caller::power(int action) { auto powerIndices = det->getPowerList(); for (const auto &index : powerIndices) { auto name = ToString(index); - auto state = - det->isPowerEnabled(index, std::vector{det_id}) - .tsquash("Inconsistent across modules"); + auto state = det->isPowerEnabled(index); m[name] = ToString(state, defs::OnOff); } if (m.empty()) { @@ -2083,7 +2041,7 @@ std::string Caller::power(int action) { bool enable = StringTo(lastArg, defs::OnOff); // power indices - std::vector powerIndices; + std::vector powerIndices; if (all) { powerIndices = det->getPowerList(); } else { @@ -2093,7 +2051,7 @@ std::string Caller::power(int action) { } } - det->setPowerEnabled(powerIndices, enable, std::vector{det_id}); + det->setPowerEnabled(powerIndices, enable); args.pop_back(); os << ToString(args) << ' ' << ToString(enable, defs::OnOff) << '\n'; } else { @@ -2130,14 +2088,9 @@ std::string Caller::powervalues(int action) { while (it != t.cend()) { if (it != t.cbegin()) os << ", "; - os << ToString(*name_it++) << ' '; - if (det->isPowerEnabled(*it, std::vector{det_id}).squash(0)) { - os << OutString( - det->getDAC(*it, true, std::vector{det_id})) - << " mV"; - } else { - os << "0 mV"; - } + os << ToString(*name_it++) << ': ['; + os << ToString(det->isPowerEnabled(*it), defs::OnOff) << ", "; + os << det->getPowerDAC(*it) << " mV ]"; ++it; } os << "]" << '\n';