This commit is contained in:
Robin Müller 2022-05-23 18:33:35 +02:00
parent 623e1cc37e
commit c9f5a5652e
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 42 additions and 32 deletions

View File

@ -1,5 +1,11 @@
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QGroupBox, QGridLayout, QLineEdit QDialog,
QDialogButtonBox,
QVBoxLayout,
QLabel,
QGroupBox,
QGridLayout,
QLineEdit,
) )
from PyQt5 import QtCore from PyQt5 import QtCore
@ -22,6 +28,7 @@ class Parameter:
self.widget.setPlaceholderText(self.defaultValue) self.widget.setPlaceholderText(self.defaultValue)
self.widget.setText("") self.widget.setText("")
class ParameterDialog(QDialog): class ParameterDialog(QDialog):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -59,7 +66,6 @@ class ParameterDialog(QDialog):
self.parameters[name] = parameter self.parameters[name] = parameter
def _reset(self): def _reset(self):
for value in self.parameters.values(): for value in self.parameters.values():
value.reset() value.reset()
@ -80,14 +86,13 @@ class ParameterDialog(QDialog):
super().reject() super().reject()
"""Prompt the user to specify additional Parameters """Prompt the user to specify additional Parameters
:param parameterList: array of dictionaries with name and defaultValue attributes :param parameterList: array of dictionaries with name and defaultValue attributes
:return: dict with all names as key and user supplied input as value string :return: dict with all names as key and user supplied input as value string
""" """
def prompt_parameters(parameterList): def prompt_parameters(parameterList):
gui = get_global(CoreGlobalIds.GUI) gui = get_global(CoreGlobalIds.GUI)
mode = get_global(CoreGlobalIds.MODE) mode = get_global(CoreGlobalIds.MODE)
@ -98,6 +103,7 @@ def prompt_parameters(parameterList):
else: else:
return _cli_prompt(parameterList) return _cli_prompt(parameterList)
def _gui_prompt(parameterList): def _gui_prompt(parameterList):
dialog = ParameterDialog() dialog = ParameterDialog()
for parameter in parameterList: for parameter in parameterList:
@ -105,10 +111,13 @@ def _gui_prompt(parameterList):
dialog.exec_() dialog.exec_()
return dialog.getParameters() return dialog.getParameters()
def _cli_prompt(parameterList): def _cli_prompt(parameterList):
result = {} result = {}
for parameter in parameterList: for parameter in parameterList:
userInput = input("Specify {} [{}]: ".format(parameter["name"], parameter["defaultValue"])) userInput = input(
"Specify {} [{}]: ".format(parameter["name"], parameter["defaultValue"])
)
if userInput == "": if userInput == "":
userInput = parameter["defaultValue"] userInput = parameter["defaultValue"]
result[parameter["name"]] = userInput result[parameter["name"]] = userInput

View File

@ -18,8 +18,12 @@ class Info:
def pack_controller_commands(tc_queue: TcQueueT, op_code: str): def pack_controller_commands(tc_queue: TcQueueT, op_code: str):
parameters = prompt_parameters([{"name": "Mode", "defaultValue": "2"}, { parameters = prompt_parameters(
"name": "Submode", "defaultValue": "0"}]) [
{"name": "Mode", "defaultValue": "2"},
{"name": "Submode", "defaultValue": "0"},
]
)
mode = int(parameters["Mode"]) mode = int(parameters["Mode"])
if mode < 0 or mode > 2: if mode < 0 or mode > 2:
print("Invalid Mode, defaulting to OFF") print("Invalid Mode, defaulting to OFF")

View File

@ -1,6 +1,7 @@
from tmtccmd.config import QueueCommands from tmtccmd.config import QueueCommands
from tmtccmd.tc.definitions import TcQueueT from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.tc.pus_3_fsfw_hk import * from tmtccmd.tc.pus_3_fsfw_hk import *
""" """
from config.object_ids import ( from config.object_ids import (
BPX_HANDLER_ID, BPX_HANDLER_ID,
@ -66,8 +67,6 @@ PROC_INFO_DICT = {
KAI.TCS_FT_ON[0]: [OpCodes.TCS_FT_ON, KAI.TCS_FT_ON[1], 120.0, 10.0], KAI.TCS_FT_ON[0]: [OpCodes.TCS_FT_ON, KAI.TCS_FT_ON[1], 120.0, 10.0],
KAI.TCS_FT_OFF[0]: [OpCodes.TCS_FT_OFF, KAI.TCS_FT_OFF[1], 120.0, 10.0], KAI.TCS_FT_OFF[0]: [OpCodes.TCS_FT_OFF, KAI.TCS_FT_OFF[1], 120.0, 10.0],
KAI.ACS_FT[0]: [OpCodes.ACS_FT, KAI.ACS_FT[1], 120.0, 10.0], KAI.ACS_FT[0]: [OpCodes.ACS_FT, KAI.ACS_FT[1], 120.0, 10.0],
} }
@ -293,7 +292,6 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
tc_queue=tc_queue, proc_key=key, sid=sid, diag=False tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
) )
# mgt 1: imtq und hk # mgt 1: imtq und hk
# mgt 2.: imtq + dual side + dipole # mgt 2.: imtq + dual side + dipole
@ -301,7 +299,6 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
key = KAI.MGT_FT[0] key = KAI.MGT_FT[0]
pack_acs_command(tc_queue=tc_queue, op_code="acs-a") pack_acs_command(tc_queue=tc_queue, op_code="acs-a")
sid = make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET) sid = make_sid(oids.IMTQ_HANDLER_ID, ImtqSetIds.ENG_HK_SET)
pack_generic_hk_listening_cmds( pack_generic_hk_listening_cmds(
tc_queue=tc_queue, proc_key=key, sid=sid, diag=False tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
@ -315,7 +312,6 @@ def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
tc_queue=tc_queue, proc_key=key, sid=sid, diag=False tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
) )
pack_acs_command(tc_queue=tc_queue, op_code="acs-off") pack_acs_command(tc_queue=tc_queue, op_code="acs-off")

View File

@ -7,6 +7,7 @@ from tmtccmd.config.args import (
parse_gui_input_arguments, parse_gui_input_arguments,
) )
def main(): def main():
hook_obj = tmtcc_pre_args() hook_obj = tmtcc_pre_args()
arg_parser = create_default_args_parser() arg_parser = create_default_args_parser()