Skip to content
Snippets Groups Projects
Commit 70a4e4e3 authored by Robin.Mueller's avatar Robin.Mueller
Browse files

some more refactoring

parent 28af57e3
Branches
No related tags found
No related merge requests found
......@@ -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 8 -c 2 -t 2.5" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
......
......@@ -36,7 +36,7 @@ class TmTcHandler:
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
self.one_shot_operation = True
self.tmtc_printer: Union[None, TmTcPrinter] = None
self.communication_interface: Union[None, CommunicationInterface] = None
......@@ -73,23 +73,27 @@ class TmTcHandler:
"""
Periodic operation
"""
while True:
try:
if self.command_received:
self.command_received = False
self.handle_action()
try:
self.core_operation(self.one_shot_operation)
except KeyboardInterrupt:
LOGGER.info("Closing TMTC client.")
sys.exit()
except IOError as e:
LOGGER.exception(e)
LOGGER.info("Closing TMTC client.")
sys.exit()
def core_operation(self, one_shot):
if not one_shot:
while True:
self.handle_action()
if self.mode == g.ModeList.Idle:
LOGGER.info("TMTC Client in idle mode")
time.sleep(5)
elif self.mode == g.ModeList.ListenerMode:
time.sleep(1)
except KeyboardInterrupt:
LOGGER.info("Closing TMTC client.")
sys.exit()
except IOError as e:
LOGGER.exception(e)
LOGGER.info("Closing TMTC client.")
sys.exit()
else:
self.handle_action()
def handle_action(self):
"""
......@@ -104,7 +108,6 @@ class TmTcHandler:
self.tmtc_printer.print_telemetry_queue(self.tm_listener.retrieve_tm_packet_queue())
self.tm_listener.clear_tm_packet_queue()
self.tm_listener.clear_reply_event()
self.command_received = True
elif self.mode == g.ModeList.SingleCommandMode:
if self.single_command_package is None:
......@@ -117,7 +120,6 @@ class TmTcHandler:
tm_listener=self.tm_listener)
LOGGER.info("Performing single command operation")
sender_and_receiver.send_single_tc_and_receive_tm(pus_packet_tuple=pus_packet_tuple)
self.command_received = True
self.mode = g.ModeList.PromptMode
elif self.mode == g.ModeList.ServiceTestMode:
......@@ -133,7 +135,6 @@ class TmTcHandler:
com_interface=self.communication_interface, tmtc_printer=self.tmtc_printer,
tm_listener=self.tm_listener, tc_queue=service_queue)
sender_and_receiver.send_queue_tc_and_receive_tm_sequentially()
self.command_received = True
self.mode = g.ModeList.ListenerMode
elif self.mode == g.ModeList.SoftwareTestMode:
......@@ -152,7 +153,6 @@ class TmTcHandler:
file_uploader = BinaryFileUploader(self.communication_interface, self.tmtc_printer,
self.tm_listener)
file_uploader.perform_file_upload()
self.command_received = True
self.mode = g.ModeList.ListenerMode
elif self.mode == g.ModeList.UnitTest:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment