diff --git a/gui/obsw_backend_test.py b/gui/obsw_backend_test.py index fd54da03598903f3b3827b3f6c313b204b6e847b..eff323c4262b95a792f3598359d6ec7646422f80 100644 --- a/gui/obsw_backend_test.py +++ b/gui/obsw_backend_test.py @@ -5,8 +5,10 @@ import logging class TmTcBackend(Process): def __init__(self): + from obsw_tmtc_client import TmTcHandler super(TmTcBackend, self).__init__() self.address = ('localhost', 6000) # family is deduced to be 'AF_INET' + self.tmtc_backend = TmTcHandler() self.listener = Listener(self.address, authkey=None) self.conn = 0 diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index 9a7f76c678f6aebe51b690ef3c7e2e28cf24bd27..66f3bd13662acd3f714ee337ea5caac8a34cc253 100644 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -91,8 +91,20 @@ def main(): set_globals(args) LOGGER.info("Starting TMTC Handler") - tmtc_handler = TmTcHandler() - tmtc_handler.perform_operation() + + if g.G_MODE_ID == g.ModeList.GUIMode: + # Experimental + backend = TmTcBackend() + backend.start() + gui = TmTcGUI() + gui.start() + backend.join() + gui.join() + LOGGER.info("Both processes have closed") + sys.exit() + else: + tmtc_handler = TmTcHandler() + tmtc_handler.perform_operation() # 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 @@ -143,22 +155,15 @@ class TmTcHandler: Command handling. """ tmtc_printer = TmTcPrinter(g.G_DISPLAY_MODE, g.G_PRINT_TO_FILE, True) - if self.mode == g.ModeList.GUIMode: - backend = TmTcBackend() - backend.start() - gui = TmTcGUI() - gui.start() - backend.join() - gui.join() - LOGGER.info("Both processes have closed") - sys.exit() - else: - communication_interface = set_communication_interface(tmtc_printer) - atexit.register(keyboard_interrupt_handler, com_interface=communication_interface) - tm_listener = TmListener( - com_interface=communication_interface, tm_timeout=g.G_TM_TIMEOUT, - tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR) - tm_listener.start() + communication_interface = set_communication_interface(tmtc_printer) + atexit.register(keyboard_interrupt_handler, com_interface=communication_interface) + + tm_listener = TmListener( + com_interface=communication_interface, tm_timeout=g.G_TM_TIMEOUT, + tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR + ) + tm_listener.start() + if self.mode == g.ModeList.ListenerMode: if tm_listener.event_reply_received: # TODO: Test this.