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'
This commit is contained in:
maliakal_d 2023-12-13 15:38:10 +01:00 committed by GitHub
parent ce7270e8a2
commit 51412f40cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 101 deletions

1
bash_autocomplete.sh Symbolic link
View File

@ -0,0 +1 @@
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh

View File

@ -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():

View File

@ -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());
}
}

View File

@ -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<int>{ 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

View File

@ -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<std::string> &parameters) {
for (const auto &current_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());
}
}

View File

@ -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 <sstream>
namespace sls {

View File

@ -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() {