From c891b906d4cf0e0fee7df76518c2bf41420cfa4c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 20 Mar 2026 15:52:01 +0100 Subject: [PATCH] fixed tests --- .../slsDetectorFunctionList.c | 12 +----------- .../src/slsDetectorServer_funcs.c | 2 +- .../slsDetectorFunctionList.c | 1 + slsDetectorSoftware/generator/commands.yaml | 12 ++++++------ .../generator/extended_commands.yaml | 12 ++++++------ slsDetectorSoftware/src/Caller.cpp | 12 ++++++------ slsDetectorSoftware/src/CallerSpecial.cpp | 3 +++ .../Caller/test-Caller-chiptestboard.cpp | 19 +++++++++++-------- 8 files changed, 35 insertions(+), 38 deletions(-) diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 20f38837f..694dcbf4a 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1273,6 +1273,7 @@ int setVLimit(int val, char *mess) { LOG(logERROR, (mess)); return FAIL; } + LOG(logINFO, ("Setting vlimit to %d mV\n", val)); vLimit = val; return OK; } @@ -1721,19 +1722,8 @@ int getVchipToSet(int *retval_vchip, char *mess) { return OK; } -int validatePowerADCIndex(enum powerIndex ind, char *mess) { - if (ind < 0 || ind > I_POWER_IO || ind == V_POWER_CHIP) { - sprintf(mess, "Could not get Power ADC. Invalid index %d\n", ind); - LOG(logERROR, (mess)); - return FAIL; - } - return OK; -} - int getPowerADC(enum powerIndex index, int *retval, char *mess) { *retval = -1; - if (validatePowerADCIndex(index, mess) == FAIL) - return FAIL; enum ADCINDEX adcIndex = V_PWR_IO; switch (index) { diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 92e1ab832..7859ce9ca 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -11336,7 +11336,7 @@ int get_voltage_limit(int file_des) { #if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else - ret = getVLimit(&retval, mess); + retval = getVLimit(); #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 6f29c8545..862894a7a 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -869,6 +869,7 @@ int setVLimit(int val, char *mess) { LOG(logERROR, (mess)); return FAIL; } + LOG(logINFO, ("Setting vlimit to %d mV\n", val)); vLimit = val; return OK; } diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index 184b2810c..20f94b12a 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -2136,7 +2136,7 @@ im_a: help: "\n\t[Ctb] Measured current of power supply a in mA." actions: GET: - function: getMeasuredPower + function: getMeasuredCurrent input: [ 'defs::I_POWER_A' ] output: [ OutString(t), '" mA"' ] @@ -2145,7 +2145,7 @@ im_b: help: "\n\t[Ctb] Measured current of power supply b in mA." actions: GET: - function: getMeasuredPower + function: getMeasuredCurrent input: [ 'defs::I_POWER_B' ] output: [ OutString(t), '" mA"' ] @@ -2154,7 +2154,7 @@ im_c: help: "\n\t[Ctb] Measured current of power supply c in mA." actions: GET: - function: getMeasuredPower + function: getMeasuredCurrent input: [ 'defs::I_POWER_C' ] output: [ OutString(t), '" mA"' ] @@ -2163,7 +2163,7 @@ im_d: help: "\n\t[Ctb] Measured current of power supply d in mA." actions: GET: - function: getMeasuredPower + function: getMeasuredCurrent input: [ 'defs::I_POWER_D' ] output: [ OutString(t), '" mA"' ] @@ -2172,7 +2172,7 @@ im_io: help: "\n\t[Ctb] Measured current of power supply io in mA." actions: GET: - function: getMeasuredPower + function: getMeasuredCurrent input: [ 'defs::I_POWER_IO' ] output: [ OutString(t), '" mA"' ] @@ -2322,7 +2322,7 @@ powerindex: actions: GET: function: getPowerIndex - output: [ 'ToString(t)' ] + output: [ 'ToString(static_cast(t))' ] slowadcindex: inherit_actions: CTB_GET_DACINDEX diff --git a/slsDetectorSoftware/generator/extended_commands.yaml b/slsDetectorSoftware/generator/extended_commands.yaml index c61df2654..9dd24bb5d 100644 --- a/slsDetectorSoftware/generator/extended_commands.yaml +++ b/slsDetectorSoftware/generator/extended_commands.yaml @@ -4827,7 +4827,7 @@ im_a: - false check_det_id: true convert_det_id: true - function: getMeasuredPower + function: getMeasuredCurrent input: - defs::I_POWER_A input_types: @@ -4852,7 +4852,7 @@ im_b: - false check_det_id: true convert_det_id: true - function: getMeasuredPower + function: getMeasuredCurrent input: - defs::I_POWER_B input_types: @@ -4877,7 +4877,7 @@ im_c: - false check_det_id: true convert_det_id: true - function: getMeasuredPower + function: getMeasuredCurrent input: - defs::I_POWER_C input_types: @@ -4902,7 +4902,7 @@ im_d: - false check_det_id: true convert_det_id: true - function: getMeasuredPower + function: getMeasuredCurrent input: - defs::I_POWER_D input_types: @@ -4927,7 +4927,7 @@ im_io: - false check_det_id: true convert_det_id: true - function: getMeasuredPower + function: getMeasuredCurrent input: - defs::I_POWER_IO input_types: @@ -7362,7 +7362,7 @@ powerindex: input_types: - std::string output: - - ToString(t) + - ToString(static_cast(t)) require_det_id: false store_result_in_t: true command_name: powerindex diff --git a/slsDetectorSoftware/src/Caller.cpp b/slsDetectorSoftware/src/Caller.cpp index c6b99e01e..17405241e 100644 --- a/slsDetectorSoftware/src/Caller.cpp +++ b/slsDetectorSoftware/src/Caller.cpp @@ -5770,7 +5770,7 @@ std::string Caller::im_a(int action) { if (det_id != -1) { throw RuntimeError("Cannot execute im_a at module level"); } - auto t = det->getMeasuredPower(defs::I_POWER_A); + auto t = det->getMeasuredCurrent(defs::I_POWER_A); os << OutString(t) << " mA" << '\n'; } } @@ -5812,7 +5812,7 @@ std::string Caller::im_b(int action) { if (det_id != -1) { throw RuntimeError("Cannot execute im_b at module level"); } - auto t = det->getMeasuredPower(defs::I_POWER_B); + auto t = det->getMeasuredCurrent(defs::I_POWER_B); os << OutString(t) << " mA" << '\n'; } } @@ -5854,7 +5854,7 @@ std::string Caller::im_c(int action) { if (det_id != -1) { throw RuntimeError("Cannot execute im_c at module level"); } - auto t = det->getMeasuredPower(defs::I_POWER_C); + auto t = det->getMeasuredCurrent(defs::I_POWER_C); os << OutString(t) << " mA" << '\n'; } } @@ -5896,7 +5896,7 @@ std::string Caller::im_d(int action) { if (det_id != -1) { throw RuntimeError("Cannot execute im_d at module level"); } - auto t = det->getMeasuredPower(defs::I_POWER_D); + auto t = det->getMeasuredCurrent(defs::I_POWER_D); os << OutString(t) << " mA" << '\n'; } } @@ -5938,7 +5938,7 @@ std::string Caller::im_io(int action) { if (det_id != -1) { throw RuntimeError("Cannot execute im_io at module level"); } - auto t = det->getMeasuredPower(defs::I_POWER_IO); + auto t = det->getMeasuredCurrent(defs::I_POWER_IO); os << OutString(t) << " mA" << '\n'; } } @@ -8933,7 +8933,7 @@ std::string Caller::powerindex(int action) { throw RuntimeError("Cannot execute powerindex at module level"); } auto t = det->getPowerIndex(args[0]); - os << ToString(t) << '\n'; + os << ToString(static_cast(t)) << '\n'; } } diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 81de5acd9..cf339ee5d 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -1921,6 +1921,9 @@ std::string Caller::powerdac(int action) { 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'; } diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index 3fb0b2fe4..5ac1e8e49 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -362,8 +362,7 @@ TEST_CASE("powerindex", "[.detectorintegration]") { std::ostringstream oss; REQUIRE_NOTHROW( caller.call("powerindex", {powername}, -1, GET, oss)); - REQUIRE(oss.str() == - std::string("powerindex ") + str_power_index + '\n'); + REQUIRE(oss.str() == "powerindex 2\n"); } } else { REQUIRE_THROWS(caller.call("powerindex", {"2"}, -1, GET)); @@ -677,9 +676,11 @@ TEST_CASE("powerdac", "[.detectorintegration][dacs]") { std::ostringstream oss1, oss2; caller.call("powerdac", {names[iPower], "1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dac " + names[iPower] + " 1200\n"); + REQUIRE(oss1.str() == + "powerdac " + names[iPower] + " 1200\n"); caller.call("powerdac", {names[iPower]}, -1, GET, oss2); - REQUIRE(oss2.str() == "dac " + names[iPower] + " 1200\n"); + REQUIRE(oss2.str() == + "powerdac " + names[iPower] + " 1200\n"); } { // power name @@ -690,11 +691,11 @@ TEST_CASE("powerdac", "[.detectorintegration][dacs]") { {"pwrname_" + names[iPower], "1200"}, -1, PUT, oss1); REQUIRE(oss1.str() == - "dac pwrname_" + names[iPower] + " 1200\n"); + "powerdac pwrname_" + names[iPower] + " 1200\n"); caller.call("powerdac", {"pwrname_" + names[iPower]}, -1, GET, oss2); REQUIRE(oss2.str() == - "dac pwrname_" + names[iPower] + " 1200 mV\n"); + "powerdac pwrname_" + names[iPower] + " 1200\n"); } // trying to set dac when power is on { @@ -702,9 +703,11 @@ TEST_CASE("powerdac", "[.detectorintegration][dacs]") { std::ostringstream oss1, oss2; caller.call("powerdac", {names[iPower], "1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "dac " + names[iPower] + " 1200\n"); + REQUIRE(oss1.str() == + "powerdac " + names[iPower] + " 1200\n"); caller.call("powerdac", {names[iPower]}, -1, GET, oss2); - REQUIRE(oss2.str() == "dac " + names[iPower] + " 1200\n"); + REQUIRE(oss2.str() == + "powerdac " + names[iPower] + " 1200\n"); } // Reset all dacs to previous value