From 4fb66865fdef348dd8828227611c0d4564f92cae Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 13 Oct 2025 10:55:46 +0200 Subject: [PATCH] improved autocomplete for getbit,setbit, clearbit --- .../autocomplete/bash_autocomplete.sh | 49 +++++++++++++++++++ .../autocomplete/zsh_autocomplete.sh | 49 +++++++++++++++++++ slsDetectorSoftware/generator/commands.yaml | 16 ++++-- .../generator/extended_commands.yaml | 46 ++++++++++++++--- slsDetectorSoftware/src/inferAction.cpp | 38 +++++++++++--- 5 files changed, 183 insertions(+), 15 deletions(-) diff --git a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh index b59733678..8e554502a 100644 --- a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh @@ -323,10 +323,32 @@ return 0 } __clearbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __clearbusy() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __clientversion() { @@ -1160,6 +1182,22 @@ return 0 } __getbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __hardwareversion() { @@ -2354,6 +2392,17 @@ return 0 } __setbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __settings() { diff --git a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh index a916429ad..c84920583 100644 --- a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh @@ -247,10 +247,32 @@ return 0 } __clearbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __clearbusy() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __clientversion() { @@ -1084,6 +1106,22 @@ return 0 } __getbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __hardwareversion() { @@ -2278,6 +2316,17 @@ return 0 } __setbit() { FCN_RETURN="" +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="0 1" +fi +fi return 0 } __settings() { diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index 69f1f1db4..3f49ed114 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -2799,20 +2799,30 @@ getbit: is_description: true actions: GET: - argc: -1 + argc: 2 + arg_types: [ std::string, std::string ] setbit: is_description: true actions: PUT: - argc: -1 + args: + - argc: 2 + arg_types: [ std::string, std::string ] + - argc: 3 + arg_types: [ std::string, std::string, bool ] clearbit: is_description: true actions: PUT: - argc: -1 + args: + - argc: 2 + arg_types: [ std::string, std::string ] + - argc: 3 + arg_types: [ std::string, std::string, bool ] + ################# special commands ########################## diff --git a/slsDetectorSoftware/generator/extended_commands.yaml b/slsDetectorSoftware/generator/extended_commands.yaml index eaff94d5d..938ab71e2 100644 --- a/slsDetectorSoftware/generator/extended_commands.yaml +++ b/slsDetectorSoftware/generator/extended_commands.yaml @@ -1095,8 +1095,24 @@ clearbit: actions: PUT: args: - - arg_types: [] - argc: -1 + - arg_types: + - std::string + - std::string + argc: 2 + cast_input: [] + check_det_id: false + convert_det_id: true + function: '' + input: [] + input_types: [] + output: [] + require_det_id: false + store_result_in_t: false + - arg_types: + - std::string + - std::string + - bool + argc: 3 cast_input: [] check_det_id: false convert_det_id: true @@ -4724,8 +4740,10 @@ getbit: actions: GET: args: - - arg_types: [] - argc: -1 + - arg_types: + - std::string + - std::string + argc: 2 cast_input: [] check_det_id: false convert_det_id: true @@ -9546,8 +9564,24 @@ setbit: actions: PUT: args: - - arg_types: [] - argc: -1 + - arg_types: + - std::string + - std::string + argc: 2 + cast_input: [] + check_det_id: false + convert_det_id: true + function: '' + input: [] + input_types: [] + output: [] + require_det_id: false + store_result_in_t: false + - arg_types: + - std::string + - std::string + - bool + argc: 3 cast_input: [] check_det_id: false convert_det_id: true diff --git a/slsDetectorSoftware/src/inferAction.cpp b/slsDetectorSoftware/src/inferAction.cpp index 110bf716c..28323e3b4 100644 --- a/slsDetectorSoftware/src/inferAction.cpp +++ b/slsDetectorSoftware/src/inferAction.cpp @@ -400,8 +400,18 @@ int InferAction::chipversion() { int InferAction::clearbit() { - throw RuntimeError("sls_detector is disabled for command: clearbit. Use " - "sls_detector_get or sls_detector_put"); + if (args.size() == 2) { + return slsDetectorDefs::PUT_ACTION; + } + + if (args.size() == 3) { + return slsDetectorDefs::PUT_ACTION; + } + + else { + + throw RuntimeError("Could not infer action: Wrong number of arguments"); + } } int InferAction::clearbusy() { @@ -1510,8 +1520,14 @@ int InferAction::gates() { int InferAction::getbit() { - throw RuntimeError("sls_detector is disabled for command: getbit. Use " - "sls_detector_get or sls_detector_put"); + if (args.size() == 2) { + return slsDetectorDefs::GET_ACTION; + } + + else { + + throw RuntimeError("Could not infer action: Wrong number of arguments"); + } } int InferAction::hardwareversion() { @@ -3061,8 +3077,18 @@ int InferAction::serialnumber() { int InferAction::setbit() { - throw RuntimeError("sls_detector is disabled for command: setbit. Use " - "sls_detector_get or sls_detector_put"); + if (args.size() == 2) { + return slsDetectorDefs::PUT_ACTION; + } + + if (args.size() == 3) { + return slsDetectorDefs::PUT_ACTION; + } + + else { + + throw RuntimeError("Could not infer action: Wrong number of arguments"); + } } int InferAction::settings() {