diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index 1b16d201144dc1fc9fe002fcc3e2711230ce41a1..1fb0c8f741d67a4422b6c433cec0b93042668246 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -40,7 +40,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]] + self.single_command_package: Tuple[bytearray, Union[None, PusTcInfo]] = bytearray(), None if self.communication_interface.valid: self.tm_listener.start() else: diff --git a/gui/obsw_tmtc_gui.py b/core/tmtc_frontend.py similarity index 85% rename from gui/obsw_tmtc_gui.py rename to core/tmtc_frontend.py index 240af41886df222fa2d4de1250d990e117cc4bb4..3ed6d80b6af784e30147e7928e35c04bb7a1953e 100644 --- a/gui/obsw_tmtc_gui.py +++ b/core/tmtc_frontend.py @@ -1,8 +1,6 @@ #!/usr/bin/python3.7 -# -*- coding: utf-8 -*- """ -@file - obsw_tmtc_gui.py +@file tmtc_frontend.py @date 01.11.2019 @brief @@ -13,9 +11,9 @@ @author: R. Mueller """ -from PyQt5 import QtCore -from PyQt5.QtWidgets import * +from multiprocessing import Process +from PyQt5.QtWidgets import * from core.tmtc_backend import TmTcHandler from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand from tmtc_core.utility.obsw_logger import get_logger @@ -37,7 +35,8 @@ LOGGER = get_logger() def initialize_frontend(tmtc_backend: TmTcHandler): tmtc_frontend = TmTcFrontend(tmtc_backend) - tmtc_frontend.init_ui() + frontend_process = Process(target=tmtc_frontend.init_ui()) + frontend_process.start() class SingleCommandTable(QTableWidget): def __init__(self): @@ -55,20 +54,18 @@ class SingleCommandTable(QTableWidget): class TmTcFrontend: - from core.tmtc_client_core import TmTcHandler - tmtc_handler: TmTcHandler # TODO: this list should probably be inside an enum in the obsw_config.py serviceList = [ 2, 3, 5, 8, 9, 17, 20, 200, "Dummy", "GPS0", "GPS1" ] # , "Error"] - serviceTest_button: QPushButton - singleCommand_button: QPushButton - commandTable: QTableWidget + service_test_button: QPushButton + single_command_button: QPushButton + command_table: QTableWidget - singleCommandService: int = 17 - singleCommandSubService: int = 1 - singleCommandSSC: int = 20 - singleCommandData: bytearray = bytearray([]) + single_command_service: int = 17 + single_command_sub_service: int = 1 + single_command_ssc: int = 20 + single_command_data: bytearray = bytearray([]) isBusy: bool @@ -82,13 +79,13 @@ class TmTcFrontend: LOGGER.info("service_test_mode_selection updated: " + str(self.serviceList[index])) def single_command_set_service(self, value): - self.singleCommandService = value + self.single_command_service = value def single_command_set_sub_service(self, value): - self.singleCommandSubService = value + self.single_command_sub_service = value def single_command_set_ssc(self, value): - self.singleCommandSSC = value + self.single_command_ssc = value def start_service_test_clicked(self): LOGGER.info("start service test button pressed") @@ -106,9 +103,9 @@ class TmTcFrontend: #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)) + LOGGER.info("service: " + str(self.single_command_service) + + ", subservice: " + str(self.single_command_sub_service) + + ", ssc: " + str(self.single_command_ssc)) # TODO: data needs to be parsed in a different way # data = int(self.commandTable.item(0, 3).text()) @@ -116,7 +113,8 @@ class TmTcFrontend: # create a command out of the parsed table command = PusTelecommand( - service=self.singleCommandService, subservice=self.singleCommandSubService, ssc=self.singleCommandSSC) + service=self.single_command_service, subservice=self.single_command_sub_service, + ssc=self.single_command_ssc) self.tmtc_handler.single_command_package = command.pack_command_tuple() self.tmtc_handler.mode = obsw_config.ModeList.SingleCommandMode @@ -134,8 +132,8 @@ class TmTcFrontend: LOGGER.info("finished tmtc_handler.handle_action") def set_send_buttons(self, state: bool): - self.serviceTest_button.setEnabled(state) - self.singleCommand_button.setEnabled(state) + self.service_test_button.setEnabled(state) + self.single_command_button.setEnabled(state) def init_ui(self): app = QApplication([]) @@ -240,10 +238,10 @@ class TmTcFrontend: comboBox.currentIndexChanged.connect(self.service_index_changed) grid.addWidget(comboBox, row, 0, 1, 1) - self.serviceTest_button = QPushButton() - self.serviceTest_button.setText("Start Service Test") - self.serviceTest_button.clicked.connect(self.start_service_test_clicked) - grid.addWidget(self.serviceTest_button, row, 1, 1, 1) + self.service_test_button = QPushButton() + self.service_test_button.setText("Start Service Test") + self.service_test_button.clicked.connect(self.start_service_test_clicked) + grid.addWidget(self.service_test_button, row, 1, 1, 1) row += 1 # single command operation @@ -260,7 +258,7 @@ class TmTcFrontend: row += 1 spin_service = QSpinBox() - spin_service.setValue(self.singleCommandService) + spin_service.setValue(self.single_command_service) # TODO: set sensible min/max values spin_service.setMinimum(0) spin_service.setMaximum(99999) @@ -268,7 +266,7 @@ class TmTcFrontend: singleCommandGrid.addWidget(spin_service, row, 0, 1, 1) spin_sub_service = QSpinBox() - spin_sub_service.setValue(self.singleCommandSubService) + spin_sub_service.setValue(self.single_command_sub_service) # TODO: set sensible min/max values spin_sub_service.setMinimum(0) spin_sub_service.setMaximum(99999) @@ -276,7 +274,7 @@ class TmTcFrontend: singleCommandGrid.addWidget(spin_sub_service, row, 1, 1, 1) spin_ssc = QSpinBox() - spin_ssc.setValue(self.singleCommandSSC) + spin_ssc.setValue(self.single_command_ssc) # TODO: set sensible min/max values spin_ssc.setMinimum(0) spin_ssc.setMaximum(99999) @@ -300,10 +298,10 @@ class TmTcFrontend: #self.commandTable = SingleCommandTable() #grid.addWidget(self.commandTable, row, 0, 1, 2) row += 1 - self.singleCommand_button = QPushButton() - self.singleCommand_button.setText("Send single command") - self.singleCommand_button.clicked.connect(self.send_single_command_clicked) - grid.addWidget(self.singleCommand_button, row, 0, 1, 2) + self.single_command_button = QPushButton() + self.single_command_button.setText("Send single command") + self.single_command_button.clicked.connect(self.send_single_command_clicked) + grid.addWidget(self.single_command_button, row, 0, 1, 2) row += 1 win.setLayout(grid) diff --git a/gui/__init__.py b/gui/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000