mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 15:50:03 +02:00
* commands code generation (#803) * commands code generation for only frames command * fix cmake file and add Caller files * working exptime, fully extended commands file and its variants * start adding template commands * add INT_CMD_VEC_ID template * add list command, generate multiple bins, format code * reach 208 commands using the cpp macros * add tests for command parser * start adding tests for commands parser * fix typo to use commands.yaml * add more tests for command_parser * add all template functions (up to 218 commands) * finish template functions and add more CmdProxy.cpp functions (250+) * 257 commands * 300 commands the rest are very special commands * add special commands without generation * separate special functions from generated c++ file * implementing one command for put and get (buggy) * add infer action in a separate file * generate header for special commands from yaml * allow only 0 or 1 for bool inputs * group all commands in gen_commands.py * add help to gen_commands.py * add autocomplete bash script * autocompletion: add support for module levels and help * remove debugging line * add autocompletion, help to commands, change int [0,1] to bool * copy tests for Caller.cpp. Tests pass * update with the new developer branch changes * fix errors after merging (there is problems with tests) * fixed port/stopport in yaml (intput typo), added '_caller' to the test dac and test on chip dac command in global test for cmdcaller * undo previous test simulator debug change * add documentation for the generated code * reducing the comment to be replaced in length so formatting does not split into 2 lines * removed formatting specific style of C++11 in gen_commands.py to keep with the top level clang format of the project * regeneratign code for commands * automation generated * Redirect deprecated commands (#872) * working implementation, need to fix dac * fixed deprecation redirect for dac command * Detector specific autocomplete (#873) * working implementation, need to fix dac * fixed deprecation redirect for dac command * detector specific completion for dac * added autocomplete using detector specific * fixed error when autocompleting partial words * Generate commands/fix commands (#875) * fix vm_a, im_a etc have deg Celsius suffix, also help missing or changed in some places * dac: require det id for all, arg0 to be printed at output, help for onchip dac and dac, onchipdac: spacing * getscan detid and blocking trigger help * udp_Dstlist det_id fixed, but rx_id invalid * cmdApp in line with cmdLineApp (missing version, receiver_id, not creating det object in help action * added set_command to differentiate between check_det_id and require_det_id (mixed up), args: -1 needs to check for at least one argument * reordering * reordering and checked till integer_command_hex * fixed a lot more commands * fix caller tests for eiger * changes to tests after Bechir left * changing .cmd to .cmdcall for the caller commands * fixed tests for caller, still warning for setexptime about cast input * autocomplete ran * add moench test * regenerating autocomplete and commands * fixing other things from merge conflicts (renaming slsDetectorDefs to defs in commands.yaml) * formatting * added code injection to help (#876) * updated 3 commands to have get output that can be put into put (#877) * updated some commands to have get output that can be put into put * fix tests for clkdiv * adding help to free (#878) * removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy) (#879) * More helpful error messages for unsupported actions (#880) * removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy) * Added specific help for unsupported actions * fixed a vetofile get special exception message. more specific warning for special exception message instead of no function warning * added condition checking true in exceptions for special message --------- Co-authored-by: Bechir Brahem <bachbrahem@gmail.com> Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
176 lines
7.1 KiB
C++
176 lines
7.1 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#include "Caller.h"
|
|
#include "catch.hpp"
|
|
#include "sls/Detector.h"
|
|
#include "sls/sls_detector_defs.h"
|
|
#include <sstream>
|
|
|
|
#include "sls/Result.h"
|
|
#include "sls/ToString.h"
|
|
#include "sls/versionAPI.h"
|
|
#include "test-Caller-global.h"
|
|
#include "tests/globals.h"
|
|
|
|
namespace sls {
|
|
|
|
using test::GET;
|
|
using test::PUT;
|
|
|
|
/* dacs */
|
|
|
|
TEST_CASE("Caller::Setting and reading back GOTTHARD dacs",
|
|
"[.cmdcall][.dacs]") {
|
|
// vref_ds, vcascn_pb, vcascp_pb, vout_cm, vcasc_out, vin_cm, vref_comp,
|
|
// ib_test_c
|
|
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::GOTTHARD) {
|
|
SECTION("vref_ds") { test_dac_caller(defs::VREF_DS, "vref_ds", 660); }
|
|
SECTION("vcascn_pb") {
|
|
test_dac_caller(defs::VCASCN_PB, "vcascn_pb", 650);
|
|
}
|
|
SECTION("vcascp_pb") {
|
|
test_dac_caller(defs::VCASCP_PB, "vcascp_pb", 1480);
|
|
}
|
|
SECTION("vout_cm") { test_dac_caller(defs::VOUT_CM, "vout_cm", 1520); }
|
|
SECTION("vcasc_out") {
|
|
test_dac_caller(defs::VCASC_OUT, "vcasc_out", 1320);
|
|
}
|
|
SECTION("vin_cm") { test_dac_caller(defs::VIN_CM, "vin_cm", 1350); }
|
|
SECTION("vref_comp") {
|
|
test_dac_caller(defs::VREF_COMP, "vref_comp", 350);
|
|
}
|
|
SECTION("ib_test_c") {
|
|
test_dac_caller(defs::IB_TESTC, "ib_test_c", 2001);
|
|
}
|
|
// eiger
|
|
REQUIRE_THROWS(caller.call("dac", {"vthreshold"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vsvp"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vsvn"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vtrim"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vrpreamp"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vrshaper"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vtgstv"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcmp_ll"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcmp_lr"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcal"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcmp_rl"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcmp_rr"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"rxb_rb"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"rxb_lb"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcp"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcn"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vishaper"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"iodelay"}, -1, GET));
|
|
// jungfrau
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_comp"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vdd_prot"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vin_com"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_prech"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_pixbuf"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_ds"}, -1, GET));
|
|
// REQUIRE_THROWS(caller.call("dac", {"vref_ds"}, -1, GET));
|
|
// REQUIRE_THROWS(caller.call("dac", {"vref_comp"}, -1, GET));
|
|
// mythen3
|
|
REQUIRE_THROWS(caller.call("dac", {"vrpreamp"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vrshaper"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vrshaper_n"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vipre"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vishaper"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vdcsh"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vth1"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vth2"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vth3"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcal_n"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcal_p"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vtrim"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcassh"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcas"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vicin"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vipre_out"}, -1, GET));
|
|
// gotthard2
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_h_adc"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_comp_fe"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_comp_adc"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcom_cds"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_rstore"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_opa_1st"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_comp_fe"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcom_adc1"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_l_adc"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vref_cds"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_cs"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vb_opa_fd"}, -1, GET));
|
|
REQUIRE_THROWS(caller.call("dac", {"vcom_adc2"}, -1, GET));
|
|
}
|
|
}
|
|
|
|
/* Gotthard Specific */
|
|
|
|
TEST_CASE("Caller::roi", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::GOTTHARD) {
|
|
if (det.size() > 1) {
|
|
REQUIRE_THROWS(caller.call("roi", {"0", "255"}, -1, PUT));
|
|
REQUIRE_NOTHROW(caller.call("roi", {}, -1, GET));
|
|
} else {
|
|
auto prev_val = det.getROI();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("roi", {"0", "255"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "roi [0, 255]\n");
|
|
}
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("roi", {"256", "511"}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "roi [256, 511]\n");
|
|
}
|
|
REQUIRE_THROWS(caller.call("roi", {"0", "256"}, -1, PUT));
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setROI(prev_val[i], i);
|
|
}
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("roi", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("Caller::clearroi", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
|
|
if (det_type == defs::GOTTHARD) {
|
|
auto prev_val = det.getROI();
|
|
{
|
|
std::ostringstream oss;
|
|
caller.call("clearroi", {}, -1, PUT, oss);
|
|
REQUIRE(oss.str() == "clearroi successful\n");
|
|
}
|
|
for (int i = 0; i != det.size(); ++i) {
|
|
det.setROI(prev_val[i], i);
|
|
}
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("clearroi", {}, -1, PUT));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("Caller::exptimel", "[.cmdcall]") {
|
|
Detector det;
|
|
Caller caller(&det);
|
|
auto det_type = det.getDetectorType().squash();
|
|
if (det_type == defs::GOTTHARD) {
|
|
REQUIRE_NOTHROW(caller.call("exptimel", {}, -1, GET));
|
|
} else {
|
|
REQUIRE_THROWS(caller.call("exptimel", {}, -1, GET));
|
|
}
|
|
}
|
|
|
|
} // namespace sls
|