From 51412f40cf52186ee8e88b9061f629a8f2c16fd8 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 13 Dec 2023 15:38:10 +0100 Subject: [PATCH] Generate commands/fix det command rename (#881) * made a link to bash autocompletion script in main folder, and replaced all references to 'det' command with 'sls_detector' --- bash_autocomplete.sh | 1 + .../generator/cpp_codegen/codegen.py | 4 +- .../generator/inferAction.in.cpp | 2 +- slsDetectorSoftware/generator/readme.md | 12 +- slsDetectorSoftware/src/Detector.cpp | 4 +- slsDetectorSoftware/src/HelpDacs.cpp | 2 +- slsDetectorSoftware/src/inferAction.cpp | 182 +++++++++--------- 7 files changed, 106 insertions(+), 101 deletions(-) create mode 120000 bash_autocomplete.sh diff --git a/bash_autocomplete.sh b/bash_autocomplete.sh new file mode 120000 index 000000000..f79749d0d --- /dev/null +++ b/bash_autocomplete.sh @@ -0,0 +1 @@ +slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh \ No newline at end of file diff --git a/slsDetectorSoftware/generator/cpp_codegen/codegen.py b/slsDetectorSoftware/generator/cpp_codegen/codegen.py index 5df7c3b61..03dac76cf 100644 --- a/slsDetectorSoftware/generator/cpp_codegen/codegen.py +++ b/slsDetectorSoftware/generator/cpp_codegen/codegen.py @@ -93,7 +93,7 @@ class CodeGenerator: with function('int', f"InferAction::{command['function_alias']}", []) as f: if (command_name, -1) in non_dist| type_dist: self.write_line( - f'throw RuntimeError("det is disabled for command: {command_name}. Use detg or detp");') + f'throw RuntimeError("sls_detector is disabled for command: {command_name}. Use detg or detp");') elif not command['infer_action']: self.write_line('throw RuntimeError("infer_action is disabled");') else: @@ -107,7 +107,7 @@ class CodeGenerator: # check if this argc is not distinguishable if (command_name, arg["argc"]) in non_dist | type_dist: self.write_line( - f'throw RuntimeError("det is disabled for command: {command_name} with number of arguments {arg["argc"]}. Use detg or detp");') + f'throw RuntimeError("sls_detector is disabled for command: {command_name} with number of arguments {arg["argc"]}. Use detg or detp");') else: self.write_line(f'return {self.actions_dict[action]};') with else_block(): diff --git a/slsDetectorSoftware/generator/inferAction.in.cpp b/slsDetectorSoftware/generator/inferAction.in.cpp index 6d74f968f..3e355bf4e 100644 --- a/slsDetectorSoftware/generator/inferAction.in.cpp +++ b/slsDetectorSoftware/generator/inferAction.in.cpp @@ -9,7 +9,7 @@ int InferAction::infer(sls::CmdParser &parser, std::ostream &os) { if (it != functions.end()) { return ((*this).*(it->second))(); } else { - throw RuntimeError("det not implemented for command: " + + throw RuntimeError("sls_detector not implemented for command: " + parser.command()); } } diff --git a/slsDetectorSoftware/generator/readme.md b/slsDetectorSoftware/generator/readme.md index d98510675..6fb8d741b 100644 --- a/slsDetectorSoftware/generator/readme.md +++ b/slsDetectorSoftware/generator/readme.md @@ -194,12 +194,12 @@ Now for C++ code generation. After parsing the commands.yaml file and producing ### infer action -the generated code will produce 5 new targets: "detg detp deta deth det" +the generated code will produce 5 new targets: "sls_detector_get sls_detector_put sls_detector_acquire sls_detector_help sls_detector" -`detg` will set the action as GET -`detp` will the action as PUT +`sls_detector_get` will set the action as GET +`sls_detector_put` will the action as PUT -`det` will guess the action depending on the number of arguments +`sls_detector` will guess the action depending on the number of arguments the codegen module will generate a function for every command that will return the action based on the number of arguments @@ -221,7 +221,7 @@ int InferAction::activate() { the `inferAction` class will be called from `CmdApp.cpp` to infer the action and the command function will be called with the appropriate action. -some commands have the same number of argument count for both get and put. These commands can be found using the the `check_infer.py` script. in the generated code it will say that "det is disabled" +some commands have the same number of argument count for both get and put. These commands can be found using the the `check_infer.py` script. in the generated code it will say that "sls_detector is disabled" ```bash # to see these commands python infer_action/check_infer.py @@ -257,7 +257,7 @@ write_arg in codegen reads the argument fields and generate c++ code accordingly - check_det_id: if true it will check the detector id and throw an error if it is not valid - convert_det_id: if true it will convert the detector id to the correct type `std::vector{ det_id }` - store_result_in_t: if true it will store the result of the function in the variable t (more on it in tricky things) -- infer_action: if true it will infer the action (only if det is used) +- infer_action: if true it will infer the action (only if sls_detector is used) - detectors: the detectors that have specific behaviour - args: the arguments of the command - argc: the number of arguments diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 56eb77fa9..4a25c0d87 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -3,8 +3,8 @@ #include "sls/Detector.h" #include "sls/detectorData.h" -#include "CmdParser.h" #include "Caller.h" +#include "CmdParser.h" #include "CtbConfig.h" #include "DetectorImpl.h" #include "Module.h" @@ -96,7 +96,7 @@ void Detector::loadParameters(const std::vector ¶meters) { for (const auto ¤t_line : parameters) { parser.Parse(current_line); caller.call(parser.command(), parser.arguments(), parser.detector_id(), - defs::PUT_ACTION, std::cout, parser.receiver_id()); + defs::PUT_ACTION, std::cout, parser.receiver_id()); } } diff --git a/slsDetectorSoftware/src/HelpDacs.cpp b/slsDetectorSoftware/src/HelpDacs.cpp index 9ce150bd1..3a2c0504c 100644 --- a/slsDetectorSoftware/src/HelpDacs.cpp +++ b/slsDetectorSoftware/src/HelpDacs.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package -#include "sls/string_utils.h" #include "sls/sls_detector_defs.h" +#include "sls/string_utils.h" #include namespace sls { diff --git a/slsDetectorSoftware/src/inferAction.cpp b/slsDetectorSoftware/src/inferAction.cpp index c10087bd2..4bc9b3fbe 100644 --- a/slsDetectorSoftware/src/inferAction.cpp +++ b/slsDetectorSoftware/src/inferAction.cpp @@ -18,7 +18,7 @@ int InferAction::infer(sls::CmdParser &parser, std::ostream &os) { } else { - throw RuntimeError("det not implemented for command: " + + throw RuntimeError("sls_detector not implemented for command: " + parser.command()); } @@ -27,8 +27,8 @@ int InferAction::infer(sls::CmdParser &parser, std::ostream &os) { int InferAction::acquire() { if (args.size() == 0) { - throw RuntimeError("det is disabled for command: acquire with number " - "of arguments 0. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: acquire with " + "number of arguments 0. Use detg or detp"); } else { @@ -132,7 +132,7 @@ int InferAction::adcinvert() { int InferAction::adclist() { throw RuntimeError( - "det is disabled for command: adclist. Use detg or detp"); + "sls_detector is disabled for command: adclist. Use detg or detp"); } int InferAction::adcname() { @@ -158,8 +158,8 @@ int InferAction::adcphase() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: adcphase with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: adcphase " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -207,8 +207,8 @@ int InferAction::adcvpp() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: adcvpp with number of " - "arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: adcvpp with " + "number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -272,7 +272,7 @@ int InferAction::autocompdisable() { int InferAction::badchannels() { throw RuntimeError( - "det is disabled for command: badchannels. Use detg or detp"); + "sls_detector is disabled for command: badchannels. Use detg or detp"); } int InferAction::blockingtrigger() { @@ -310,8 +310,8 @@ int InferAction::burstperiod() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: burstperiod with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: burstperiod " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -475,8 +475,8 @@ int InferAction::clkphase() { } if (args.size() == 2) { - throw RuntimeError("det is disabled for command: clkphase with number " - "of arguments 2. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: clkphase " + "with number of arguments 2. Use detg or detp"); } if (args.size() == 3) { @@ -512,8 +512,9 @@ int InferAction::compdisabletime() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: compdisabletime with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError( + "sls_detector is disabled for command: compdisabletime with number " + "of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -557,7 +558,7 @@ int InferAction::config() { int InferAction::counters() { throw RuntimeError( - "det is disabled for command: counters. Use detg or detp"); + "sls_detector is disabled for command: counters. Use detg or detp"); } int InferAction::currentsource() { @@ -591,8 +592,8 @@ int InferAction::dac() { } if (args.size() == 2) { - throw RuntimeError("det is disabled for command: dac with number of " - "arguments 2. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: dac with " + "number of arguments 2. Use detg or detp"); } if (args.size() == 3) { @@ -620,7 +621,7 @@ int InferAction::dacindex() { int InferAction::daclist() { throw RuntimeError( - "det is disabled for command: daclist. Use detg or detp"); + "sls_detector is disabled for command: daclist. Use detg or detp"); } int InferAction::dacname() { @@ -694,8 +695,8 @@ int InferAction::dbitphase() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: dbitphase with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: dbitphase " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -731,8 +732,8 @@ int InferAction::defaultdac() { } if (args.size() == 2) { - throw RuntimeError("det is disabled for command: defaultdac with " - "number of arguments 2. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: defaultdac " + "with number of arguments 2. Use detg or detp"); } if (args.size() == 3) { @@ -764,8 +765,8 @@ int InferAction::delay() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: delay with number of " - "arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: delay with " + "number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -897,7 +898,7 @@ int InferAction::dsamples() { int InferAction::execcommand() { throw RuntimeError( - "det is disabled for command: execcommand. Use detg or detp"); + "sls_detector is disabled for command: execcommand. Use detg or detp"); } int InferAction::exptime() { @@ -907,8 +908,8 @@ int InferAction::exptime() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: exptime with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: exptime with " + "number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -928,8 +929,8 @@ int InferAction::exptime1() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: exptime1 with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: exptime1 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -949,8 +950,8 @@ int InferAction::exptime2() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: exptime2 with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: exptime2 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -970,8 +971,8 @@ int InferAction::exptime3() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: exptime3 with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: exptime3 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -1307,8 +1308,8 @@ int InferAction::frametime() { int InferAction::free() { if (args.size() == 0) { - throw RuntimeError("det is disabled for command: free with number of " - "arguments 0. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: free with " + "number of arguments 0. Use detg or detp"); } else { @@ -1336,7 +1337,7 @@ int InferAction::fwrite() { int InferAction::gaincaps() { throw RuntimeError( - "det is disabled for command: gaincaps. Use detg or detp"); + "sls_detector is disabled for command: gaincaps. Use detg or detp"); } int InferAction::gainmode() { @@ -1378,8 +1379,8 @@ int InferAction::gatedelay() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: gatedelay with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: gatedelay " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -1399,8 +1400,8 @@ int InferAction::gatedelay1() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: gatedelay1 with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: gatedelay1 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -1420,8 +1421,8 @@ int InferAction::gatedelay2() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: gatedelay2 with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: gatedelay2 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -1441,8 +1442,8 @@ int InferAction::gatedelay3() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: gatedelay3 with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: gatedelay3 " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -1514,7 +1515,7 @@ int InferAction::highvoltage() { int InferAction::hostname() { throw RuntimeError( - "det is disabled for command: hostname. Use detg or detp"); + "sls_detector is disabled for command: hostname. Use detg or detp"); } int InferAction::im_a() { @@ -1956,31 +1957,31 @@ int InferAction::patioctrl() { int InferAction::patlimits() { throw RuntimeError( - "det is disabled for command: patlimits. Use detg or detp"); + "sls_detector is disabled for command: patlimits. Use detg or detp"); } int InferAction::patloop() { throw RuntimeError( - "det is disabled for command: patloop. Use detg or detp"); + "sls_detector is disabled for command: patloop. Use detg or detp"); } int InferAction::patloop0() { throw RuntimeError( - "det is disabled for command: patloop0. Use detg or detp"); + "sls_detector is disabled for command: patloop0. Use detg or detp"); } int InferAction::patloop1() { throw RuntimeError( - "det is disabled for command: patloop1. Use detg or detp"); + "sls_detector is disabled for command: patloop1. Use detg or detp"); } int InferAction::patloop2() { throw RuntimeError( - "det is disabled for command: patloop2. Use detg or detp"); + "sls_detector is disabled for command: patloop2. Use detg or detp"); } int InferAction::patmask() { @@ -2002,25 +2003,25 @@ int InferAction::patmask() { int InferAction::patnloop() { throw RuntimeError( - "det is disabled for command: patnloop. Use detg or detp"); + "sls_detector is disabled for command: patnloop. Use detg or detp"); } int InferAction::patnloop0() { throw RuntimeError( - "det is disabled for command: patnloop0. Use detg or detp"); + "sls_detector is disabled for command: patnloop0. Use detg or detp"); } int InferAction::patnloop1() { throw RuntimeError( - "det is disabled for command: patnloop1. Use detg or detp"); + "sls_detector is disabled for command: patnloop1. Use detg or detp"); } int InferAction::patnloop2() { throw RuntimeError( - "det is disabled for command: patnloop2. Use detg or detp"); + "sls_detector is disabled for command: patnloop2. Use detg or detp"); } int InferAction::patsetbit() { @@ -2066,49 +2067,49 @@ int InferAction::patternstart() { int InferAction::patwait() { throw RuntimeError( - "det is disabled for command: patwait. Use detg or detp"); + "sls_detector is disabled for command: patwait. Use detg or detp"); } int InferAction::patwait0() { throw RuntimeError( - "det is disabled for command: patwait0. Use detg or detp"); + "sls_detector is disabled for command: patwait0. Use detg or detp"); } int InferAction::patwait1() { throw RuntimeError( - "det is disabled for command: patwait1. Use detg or detp"); + "sls_detector is disabled for command: patwait1. Use detg or detp"); } int InferAction::patwait2() { throw RuntimeError( - "det is disabled for command: patwait2. Use detg or detp"); + "sls_detector is disabled for command: patwait2. Use detg or detp"); } int InferAction::patwaittime() { throw RuntimeError( - "det is disabled for command: patwaittime. Use detg or detp"); + "sls_detector is disabled for command: patwaittime. Use detg or detp"); } int InferAction::patwaittime0() { throw RuntimeError( - "det is disabled for command: patwaittime0. Use detg or detp"); + "sls_detector is disabled for command: patwaittime0. Use detg or detp"); } int InferAction::patwaittime1() { throw RuntimeError( - "det is disabled for command: patwaittime1. Use detg or detp"); + "sls_detector is disabled for command: patwaittime1. Use detg or detp"); } int InferAction::patwaittime2() { throw RuntimeError( - "det is disabled for command: patwaittime2. Use detg or detp"); + "sls_detector is disabled for command: patwaittime2. Use detg or detp"); } int InferAction::patword() { @@ -2154,8 +2155,8 @@ int InferAction::period() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: period with number of " - "arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: period with " + "number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -2247,7 +2248,7 @@ int InferAction::powerindex() { int InferAction::powerlist() { throw RuntimeError( - "det is disabled for command: powerlist. Use detg or detp"); + "sls_detector is disabled for command: powerlist. Use detg or detp"); } int InferAction::powername() { @@ -2601,7 +2602,7 @@ int InferAction::rx_clearroi() { int InferAction::rx_dbitlist() { throw RuntimeError( - "det is disabled for command: rx_dbitlist. Use detg or detp"); + "sls_detector is disabled for command: rx_dbitlist. Use detg or detp"); } int InferAction::rx_dbitoffset() { @@ -2695,20 +2696,20 @@ int InferAction::rx_framesperfile() { int InferAction::rx_hostname() { throw RuntimeError( - "det is disabled for command: rx_hostname. Use detg or detp"); + "sls_detector is disabled for command: rx_hostname. Use detg or detp"); } int InferAction::rx_jsonaddheader() { - throw RuntimeError( - "det is disabled for command: rx_jsonaddheader. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: " + "rx_jsonaddheader. Use detg or detp"); } int InferAction::rx_jsonpara() { if (args.size() == 1) { - throw RuntimeError("det is disabled for command: rx_jsonpara with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: rx_jsonpara " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -2852,7 +2853,7 @@ int InferAction::rx_start() { int InferAction::rx_status() { throw RuntimeError( - "det is disabled for command: rx_status. Use detg or detp"); + "sls_detector is disabled for command: rx_status. Use detg or detp"); } int InferAction::rx_stop() { @@ -3182,7 +3183,7 @@ int InferAction::signalindex() { int InferAction::signallist() { throw RuntimeError( - "det is disabled for command: signallist. Use detg or detp"); + "sls_detector is disabled for command: signallist. Use detg or detp"); } int InferAction::signalname() { @@ -3228,7 +3229,7 @@ int InferAction::slowadcindex() { int InferAction::slowadclist() { throw RuntimeError( - "det is disabled for command: slowadclist. Use detg or detp"); + "sls_detector is disabled for command: slowadclist. Use detg or detp"); } int InferAction::slowadcname() { @@ -3273,7 +3274,8 @@ int InferAction::start() { int InferAction::status() { - throw RuntimeError("det is disabled for command: status. Use detg or detp"); + throw RuntimeError( + "sls_detector is disabled for command: status. Use detg or detp"); } int InferAction::stop() { @@ -3311,8 +3313,9 @@ int InferAction::storagecell_delay() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: storagecell_delay " - "with number of arguments 1. Use detg or detp"); + throw RuntimeError( + "sls_detector is disabled for command: storagecell_delay with " + "number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -3348,8 +3351,8 @@ int InferAction::subdeadtime() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: subdeadtime with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: subdeadtime " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -3369,8 +3372,8 @@ int InferAction::subexptime() { } if (args.size() == 1) { - throw RuntimeError("det is disabled for command: subexptime with " - "number of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: subexptime " + "with number of arguments 1. Use detg or detp"); } if (args.size() == 2) { @@ -3766,8 +3769,8 @@ int InferAction::triggersl() { int InferAction::trimbits() { if (args.size() == 1) { - throw RuntimeError("det is disabled for command: trimbits with number " - "of arguments 1. Use detg or detp"); + throw RuntimeError("sls_detector is disabled for command: trimbits " + "with number of arguments 1. Use detg or detp"); } else { @@ -3778,7 +3781,8 @@ int InferAction::trimbits() { int InferAction::trimen() { - throw RuntimeError("det is disabled for command: trimen. Use detg or detp"); + throw RuntimeError( + "sls_detector is disabled for command: trimen. Use detg or detp"); } int InferAction::trimval() { @@ -3936,7 +3940,7 @@ int InferAction::udp_dstip2() { int InferAction::udp_dstlist() { throw RuntimeError( - "det is disabled for command: udp_dstlist. Use detg or detp"); + "sls_detector is disabled for command: udp_dstlist. Use detg or detp"); } int InferAction::udp_dstmac() { @@ -4438,7 +4442,7 @@ int InferAction::vetoalg() { int InferAction::vetofile() { throw RuntimeError( - "det is disabled for command: vetofile. Use detg or detp"); + "sls_detector is disabled for command: vetofile. Use detg or detp"); } int InferAction::vetophoton() { @@ -4460,13 +4464,13 @@ int InferAction::vetophoton() { int InferAction::vetoref() { throw RuntimeError( - "det is disabled for command: vetoref. Use detg or detp"); + "sls_detector is disabled for command: vetoref. Use detg or detp"); } int InferAction::vetostream() { throw RuntimeError( - "det is disabled for command: vetostream. Use detg or detp"); + "sls_detector is disabled for command: vetostream. Use detg or detp"); } int InferAction::virtualFunction() {