diff --git a/.idea/runConfigurations/tmtcclient_Service_17_QEMU.xml b/.idea/runConfigurations/tmtcclient_Service_17_QEMU.xml index 95d5fd3d1b47669870bcc6c7c142b9a990458097..7ea51c07201800ebcb05346185ebe4cb5c6902e0 100644 --- a/.idea/runConfigurations/tmtcclient_Service_17_QEMU.xml +++ b/.idea/runConfigurations/tmtcclient_Service_17_QEMU.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s 17 -c 2 -t 2" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_2_QEMU.xml b/.idea/runConfigurations/tmtcclient_Service_2_QEMU.xml index 30390e9239d5c13399a90ef12b45d9ba05f073c1..dd374950dc37b895e686f27afa139b632f87c112 100644 --- a/.idea/runConfigurations/tmtcclient_Service_2_QEMU.xml +++ b/.idea/runConfigurations/tmtcclient_Service_2_QEMU.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s 2 -c 2 -t 2.5" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_3_QEMU_.xml b/.idea/runConfigurations/tmtcclient_Service_3_QEMU_.xml index 9d4be2a953a8d5822e3a86671c2be0fb2921c9a1..621b333828a97c3da5073d28191f71d6ff92e3f1 100644 --- a/.idea/runConfigurations/tmtcclient_Service_3_QEMU_.xml +++ b/.idea/runConfigurations/tmtcclient_Service_3_QEMU_.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s 3 -c 2 -t 2 --hk" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_5_QEMU_.xml b/.idea/runConfigurations/tmtcclient_Service_5_QEMU_.xml index 2458e895dacff8cc304657fa6793915adcad8492..9d97d32114c666ee252cd8e255c451a9f10a902f 100644 --- a/.idea/runConfigurations/tmtcclient_Service_5_QEMU_.xml +++ b/.idea/runConfigurations/tmtcclient_Service_5_QEMU_.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s 5 -c 2 -t 2" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_Dummy_QEMU.xml b/.idea/runConfigurations/tmtcclient_Service_Dummy_QEMU.xml index 1ca4f2f8ca977c00e9d2a2052f20a9deae6e60ba..f7d6feedef966405ee32a1e4e2154025a7cdee6d 100644 --- a/.idea/runConfigurations/tmtcclient_Service_Dummy_QEMU.xml +++ b/.idea/runConfigurations/tmtcclient_Service_Dummy_QEMU.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s Dummy -c 2 -t 2" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_GPS0_QEMU__.xml b/.idea/runConfigurations/tmtcclient_Service_GPS0_QEMU__.xml index 33ec970f5bfa6cc2fbd05f1bed2c20f30307d2e0..a1e01a69e621608c5dab37f395f2376f0d5cce2a 100644 --- a/.idea/runConfigurations/tmtcclient_Service_GPS0_QEMU__.xml +++ b/.idea/runConfigurations/tmtcclient_Service_GPS0_QEMU__.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s GPS0 -c 2 -t 2.5 --hk" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_GPS1_QEMU___.xml b/.idea/runConfigurations/tmtcclient_Service_GPS1_QEMU___.xml index 8e8b943bf2f82f583614b77cdc5747a1910280cb..74f6c148547b1779ec9c462ca16e58c0f4160f4b 100644 --- a/.idea/runConfigurations/tmtcclient_Service_GPS1_QEMU___.xml +++ b/.idea/runConfigurations/tmtcclient_Service_GPS1_QEMU___.xml @@ -12,7 +12,7 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/core/tmtc_client_core.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtc_client_cli.py" /> <option name="PARAMETERS" value="-m 3 -s GPS1 -c 2 -t 2.5 --hk" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/core/tmtc_backend.py b/core/tmtc_backend.py index 1fb0c8f741d67a4422b6c433cec0b93042668246..22aed0311e4d99c3299529bf57b8a5550216380d 100644 --- a/core/tmtc_backend.py +++ b/core/tmtc_backend.py @@ -48,6 +48,9 @@ class TmTcHandler: LOGGER.info("TM listener will not be started") atexit.register(keyboard_interrupt_handler, com_interface=self.communication_interface) + def start(self): + self.perform_operation() + def perform_operation(self): """ Periodic operation diff --git a/core/tmtc_client_core.py b/core/tmtc_client_core.py index 346e1ab09c52b3e94757ef0a25d8cd5d449e8fb5..296ab082193567d9c31698a9444734109294ac86 100755 --- a/core/tmtc_client_core.py +++ b/core/tmtc_client_core.py @@ -26,12 +26,13 @@ limitations under the License. @manual Run this file with the -h flag to display options. """ -import time +from multiprocessing import Process from tmtc_core.utility.obsw_logger import set_tmtc_logger, get_logger from config.obsw_config import set_globals from core.tmtc_backend import TmTcHandler +from core.tmtc_frontend import TmTcFrontend from utility.obsw_args_parser import parse_input_arguments LOGGER = get_logger() @@ -43,19 +44,25 @@ def run_tmtc_client(use_gui: bool): set_tmtc_logger() LOGGER.info("Starting TMTC Client") - if use_gui: - run_with_gui() - - LOGGER.info("Parsing input arguments") - args = parse_input_arguments() + if not use_gui: + LOGGER.info("Parsing input arguments") + args = parse_input_arguments() - LOGGER.info("Setting global variables") - set_globals(args) + LOGGER.info("Setting global variables") + set_globals(args) LOGGER.info("Starting TMTC Handler") - tmtc_handler = TmTcHandler() - tmtc_handler.perform_operation() + + + if use_gui: + LOGGER.info("Starting TMTC GUI") + tmtc_frontend = TmTcFrontend(tmtc_handler) + frontend_process = Process(target=tmtc_frontend.init_ui()) + frontend_process.start() + tmtc_handler.start() + else: + tmtc_handler.start() # At some later point, the program will run permanently and be able to take commands. # For now we put a permanent loop here so the program @@ -64,13 +71,5 @@ def run_tmtc_client(use_gui: bool): pass -def run_with_gui(): - while True: - print("GUI net fertig") - time.sleep(2) - # tmtcGui = gui.obsw_tmtc_gui.TmTcGUI() - # tmtcGui.run() - # sys.exit() - diff --git a/core/tmtc_frontend.py b/core/tmtc_frontend.py index 3ed6d80b6af784e30147e7928e35c04bb7a1953e..ca4d2fd0a58b2c9031bec6ec3dafb5ec0b9b50fe 100644 --- a/core/tmtc_frontend.py +++ b/core/tmtc_frontend.py @@ -33,11 +33,6 @@ LOGGER = get_logger() # Step 1: Huge Mission Badge in Tkinter window because that is cool. # Step 2: Simple buttons to run servce tests around the badge. -def initialize_frontend(tmtc_backend: TmTcHandler): - tmtc_frontend = TmTcFrontend(tmtc_backend) - frontend_process = Process(target=tmtc_frontend.init_ui()) - frontend_process.start() - class SingleCommandTable(QTableWidget): def __init__(self): super().__init__() @@ -67,13 +62,16 @@ class TmTcFrontend: single_command_ssc: int = 20 single_command_data: bytearray = bytearray([]) - isBusy: bool + is_busy: bool def __init__(self, tmtc_handler: TmTcHandler): self.tmtc_handler = tmtc_handler obsw_config.G_SERVICE = 17 obsw_config.G_COM_IF = obsw_config.ComIF.QEMU + def start(self): + self.init_ui() + def service_index_changed(self, index: int): obsw_config.G_SERVICE = self.serviceList[index] LOGGER.info("service_test_mode_selection updated: " + str(self.serviceList[index])) @@ -124,10 +122,10 @@ class TmTcFrontend: def handle_tm_tc_action(self): LOGGER.info("start tmtc_handler.handle_action") - self.isBusy = True + self.is_busy = True self.set_send_buttons(False) self.tmtc_handler.handle_action() - self.isBusy = False + self.is_busy = False self.set_send_buttons(True) LOGGER.info("finished tmtc_handler.handle_action")