From 75102e0f66208678a23fccd0cb020b96da43dd6f Mon Sep 17 00:00:00 2001 From: Patrick S <st140926@stud.uni-stuttgart.de> Date: Sun, 11 Oct 2020 18:14:22 +0200 Subject: [PATCH] updated single command gui and updated client to support packages from the gui --- config/obsw_config.py | 4 +- gui/obsw_tmtc_gui.py | 85 ++++++++++++++++++++++++++++++++++++++----- obsw_tmtc_client.py | 9 ++++- 3 files changed, 84 insertions(+), 14 deletions(-) diff --git a/config/obsw_config.py b/config/obsw_config.py index f1421d6..7adbb6d 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -11,6 +11,7 @@ import struct import pprint import logging from socket import INADDR_ANY + from config.obsw_definitions import ModeList, ComIF """ @@ -108,14 +109,11 @@ G_TM_LISTENER = None G_COM_INTERFACE = None G_TMTC_PRINTER = None - # noinspection PyUnusedLocal def set_globals(args): global G_ETHERNET_RECV_ADDRESS, G_ETHERNET_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, G_DISPLAY_MODE,\ G_COM_IF, G_COM_PORT, G_SERIAL_TIMEOUT, G_TM_TIMEOUT, G_TC_SEND_TIMEOUT_FACTOR, \ G_PRINT_TO_FILE, G_PRINT_HK_DATA, G_PRINT_RAW_TM, G_PRINT_TM - if args.mode == 0: - LOGGER.info("GUI mode not implemented yet !") if args.shortDisplayMode: G_DISPLAY_MODE = "short" else: diff --git a/gui/obsw_tmtc_gui.py b/gui/obsw_tmtc_gui.py index 39e9e3d..ba7985f 100644 --- a/gui/obsw_tmtc_gui.py +++ b/gui/obsw_tmtc_gui.py @@ -72,6 +72,11 @@ class Application: singleCommand_button: QPushButton commandTable: QTableWidget + singleCommandService: int = 17 + singleCommandSubService: int = 1 + singleCommandSSC: int = 20 + singleCommandData: bytearray = bytearray([]) + isBusy: bool def __init__(self): @@ -125,6 +130,15 @@ class Application: LOGGER.info("board ip changed: " + value) obsw_config.G_SEND_ADDRESS = (value, 7) + def single_command_set_service(self, value): + self.singleCommandService = value + + def single_command_set_sub_service(self, value): + self.singleCommandSubService = value + + def single_command_set_ssc(self, value): + self.singleCommandSSC = value + def start_service_test_clicked(self): LOGGER.info("start service test button pressed") LOGGER.info("start testing service: " + str(obsw_config.G_SERVICE)) @@ -137,16 +151,22 @@ class Application: LOGGER.info("send single command pressed") # parse the values from the table - service = int(self.commandTable.item(0, 0).text()) - subservice = int(self.commandTable.item(0, 1).text()) - ssc = int(self.commandTable.item(0, 2).text()) + #service = int(self.commandTable.item(0, 0).text()) + #subservice = int(self.commandTable.item(0, 1).text()) + #ssc = int(self.commandTable.item(0, 2).text()) + + LOGGER.info("service: " + str(self.singleCommandService) + + ", subservice: " + str(self.singleCommandSubService) + + ", ssc: " + str(self.singleCommandSSC)) + # TODO: data needs to be parsed in a different way # data = int(self.commandTable.item(0, 3).text()) # crc = int(self.commandTable.item(0, 4).text()) # create a command out of the parsed table - command = PusTelecommand(service=service, subservice=subservice, ssc=ssc) - obsw_config.G_PUS_PACKET_TUPLE = command.pack_command_tuple() + command = PusTelecommand( + service=self.singleCommandService, subservice=self.singleCommandSubService, ssc=self.singleCommandSSC) + self.tmtc_handler.single_command_package = command.pack_command_tuple() self.tmtc_handler.mode = obsw_config.ModeList.SingleCommandMode # start the action in a new process @@ -279,8 +299,55 @@ class Application: grid.addWidget(QLabel("Single Command Operation:"), row, 0, 1, 1) row += 1 - self.commandTable = SingleCommandTable() - grid.addWidget(self.commandTable, row, 0, 1, 2) + singleCommandGrid = QGridLayout() + singleCommandGrid.setSpacing(5) + + singleCommandGrid.addWidget(QLabel("Service:"), row, 0, 1, 1) + singleCommandGrid.addWidget(QLabel("SubService:"), row, 1, 1, 1) + singleCommandGrid.addWidget(QLabel("SSC:"), row, 2, 1, 1) + + row += 1 + + spin_service = QSpinBox() + spin_service.setValue(self.singleCommandService) + # TODO: set sensible min/max values + spin_service.setMinimum(0) + spin_service.setMaximum(99999) + spin_service.valueChanged.connect(self.single_command_set_service) + singleCommandGrid.addWidget(spin_service, row, 0, 1, 1) + + spin_sub_service = QSpinBox() + spin_sub_service.setValue(self.singleCommandSubService) + # TODO: set sensible min/max values + spin_sub_service.setMinimum(0) + spin_sub_service.setMaximum(99999) + spin_sub_service.valueChanged.connect(self.single_command_set_sub_service) + singleCommandGrid.addWidget(spin_sub_service, row, 1, 1, 1) + + spin_ssc = QSpinBox() + spin_ssc.setValue(self.singleCommandSSC) + # TODO: set sensible min/max values + spin_ssc.setMinimum(0) + spin_ssc.setMaximum(99999) + spin_ssc.valueChanged.connect(self.single_command_set_ssc) + singleCommandGrid.addWidget(spin_ssc, row, 2, 1, 1) + + row += 1 + + singleCommandGrid.addWidget(QLabel("Data:"), row, 0, 1, 3) + + row += 1 + + # TODO: how should this be converted to the byte array? + singleCommandDataBox = QTextEdit() + singleCommandGrid.addWidget(singleCommandDataBox, row, 0, 1, 3) + + grid.addItem(singleCommandGrid, row, 0, 1, 2) + + row += 1 + + #self.commandTable = SingleCommandTable() + #grid.addWidget(self.commandTable, row, 0, 1, 2) row += 1 self.singleCommand_button = QPushButton() self.singleCommand_button.setText("Send single command") @@ -293,7 +360,7 @@ class Application: win.show() # resize table columns to fill the window width - for i in range(0, 5): - self.commandTable.setColumnWidth(i, int(self.commandTable.width() / 5) - 3) + #for i in range(0, 5): + # self.commandTable.setColumnWidth(i, int(self.commandTable.width() / 5) - 3) app.exec_() \ No newline at end of file diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index d57cc01..dbeb01f 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -55,7 +55,6 @@ import gui.obsw_tmtc_gui LOGGER = get_logger() - def main(): """ Main method, reads input arguments, sets global variables and start TMTC handler. @@ -114,6 +113,7 @@ class TmTcHandler: com_interface=self.communication_interface, tm_timeout=g.G_TM_TIMEOUT, tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR ) + self.single_command_package : Tuple[bytearray, Union[None, PusTcInfo]] if self.communication_interface.valid: self.tm_listener.start() else: @@ -159,7 +159,12 @@ class TmTcHandler: self.command_received = True elif self.mode == g.ModeList.SingleCommandMode: - pus_packet_tuple = command_preparation() + if self.single_command_package is None: + pus_packet_tuple = command_preparation() + else: + LOGGER.info("send package from gui") + pus_packet_tuple = self.single_command_package + sender_and_receiver = SingleCommandSenderReceiver( com_interface=self.communication_interface, tmtc_printer=self.tmtc_printer, tm_listener=self.tm_listener) -- GitLab