From ec1eb80f85433da975851774f8651ac70d66122e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sat, 31 Oct 2020 02:00:47 +0100 Subject: [PATCH] some bugfixes --- config/obsw_config.py | 2 +- core/tmtc_backend.py | 8 ++++---- core/tmtc_client_core.py | 19 ++++++++++++++----- core/tmtc_frontend.py | 33 +++++++++++++++------------------ 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/config/obsw_config.py b/config/obsw_config.py index fad6290..c5b4d38 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -62,7 +62,7 @@ G_PP = pprint.PrettyPrinter() LOGGER = logging.getLogger(G_TMTC_LOGGER_NAME) # General Settings G_SCRIPT_MODE = 1 -G_MODE_ID = 0 +G_MODE_ID: ModeList = ModeList.ListenerMode G_SERVICE = 17 G_OP_CODE = 0 G_DISPLAY_MODE = "long" diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index 7f06ebc..24a6f31 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -5,6 +5,7 @@ import sys from multiprocessing import Process from collections import deque from config import obsw_config as g +from config.obsw_definitions import ModeList from typing import Tuple, Union from tc.obsw_pus_tc_packer import ServiceQueuePacker, create_total_tc_queue @@ -30,8 +31,8 @@ class TmTcHandler: This is the primary class which handles TMTC reception. This can be seen as the backend in case a GUI or front-end is implemented. """ - def __init__(self): - self.mode = g.G_MODE_ID + def __init__(self, init_mode: ModeList = g.ModeList.ListenerMode): + self.mode = init_mode self.com_if = g.G_COM_IF # This flag could be used later to command the TMTC Client with a front-end self.command_received = True @@ -50,8 +51,7 @@ class TmTcHandler: atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface) def prepare_start(self) -> Process: - handler_process = Process(target=self.perform_operation()) - return handler_process + return Process(target=self.perform_operation) def perform_operation(self): """ diff --git a/core/tmtc_client_core.py b/core/tmtc_client_core.py index b7fc889..d699ca8 100755 --- a/core/tmtc_client_core.py +++ b/core/tmtc_client_core.py @@ -26,9 +26,11 @@ limitations under the License. @manual Run this file with the -h flag to display options. """ +from multiprocessing import Process from tmtc_core.utility.obsw_logger import set_tmtc_logger, get_logger from config.obsw_config import set_globals +import config.obsw_config as g from core.tmtc_backend import TmTcHandler from core.tmtc_frontend import TmTcFrontend from utility.obsw_args_parser import parse_input_arguments @@ -50,16 +52,23 @@ def run_tmtc_client(use_gui: bool): set_globals(args) LOGGER.info("Starting TMTC Handler") - tmtc_handler = TmTcHandler() + if use_gui: + tmtc_handler = TmTcHandler() + else: + tmtc_handler = TmTcHandler(g.G_MODE_ID) + tmtc_handler_task = tmtc_handler.prepare_start() - tmtc_frontend = TmTcFrontend(tmtc_handler) - tmtc_frontend_task = tmtc_frontend.prepare_start() + tmtc_frontend_task = Process() + if use_gui: + tmtc_frontend = TmTcFrontend(tmtc_handler) + tmtc_frontend_task = tmtc_frontend.prepare_start() + tmtc_frontend_task.start() tmtc_handler_task.start() - tmtc_frontend_task.start() tmtc_handler_task.join() - tmtc_frontend_task.join() + if use_gui: + tmtc_frontend_task.join() diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py index 796ee5d..99e4008 100644 --- a/core/tmtc_frontend.py +++ b/core/tmtc_frontend.py @@ -5,7 +5,7 @@ @brief This is part of the TMTC client developed by the SOURCE project by KSat @description GUI Testing for TMTC client @manual -@author R. Mueller +@author R. Mueller, P. Scheurenbrand """ from multiprocessing import Process @@ -22,21 +22,6 @@ LOGGER = get_logger() TODO: Make it look nicer. Add SOURCE or KSat logo. """ -class SingleCommandTable(QTableWidget): - def __init__(self): - super().__init__() - self.setRowCount(1) - self.setColumnCount(5) - self.setHorizontalHeaderItem(0, QTableWidgetItem("Service")) - self.setHorizontalHeaderItem(1, QTableWidgetItem("Subservice")) - self.setHorizontalHeaderItem(2, QTableWidgetItem("SSC")) - self.setHorizontalHeaderItem(3, QTableWidgetItem("Data")) - self.setHorizontalHeaderItem(4, QTableWidgetItem("CRC")) - self.setItem(0, 0, QTableWidgetItem("17")) - self.setItem(0, 1, QTableWidgetItem("1")) - self.setItem(0, 2, QTableWidgetItem("20")) - - class TmTcFrontend: # TODO: this list should probably be inside an enum in the obsw_config.py @@ -59,7 +44,7 @@ class TmTcFrontend: obsw_config.G_COM_IF = obsw_config.ComIF.QEMU def prepare_start(self) -> Process: - return Process(target=self.init_ui()) + return Process(target=self.init_ui) def service_index_changed(self, index: int): obsw_config.G_SERVICE = self.serviceList[index] @@ -301,7 +286,19 @@ class TmTcFrontend: app.exec_() - +class SingleCommandTable(QTableWidget): + def __init__(self): + super().__init__() + self.setRowCount(1) + self.setColumnCount(5) + self.setHorizontalHeaderItem(0, QTableWidgetItem("Service")) + self.setHorizontalHeaderItem(1, QTableWidgetItem("Subservice")) + self.setHorizontalHeaderItem(2, QTableWidgetItem("SSC")) + self.setHorizontalHeaderItem(3, QTableWidgetItem("Data")) + self.setHorizontalHeaderItem(4, QTableWidgetItem("CRC")) + self.setItem(0, 0, QTableWidgetItem("17")) + self.setItem(0, 1, QTableWidgetItem("1")) + self.setItem(0, 2, QTableWidgetItem("20")) def com_if_index_changed(index: int): obsw_config.G_COM_IF = obsw_config.ComIF(index) -- GitLab