better event handling

This commit is contained in:
Robin Müller 2022-08-22 14:02:07 +02:00
parent 5651475955
commit 3479f5607d
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -29,7 +29,6 @@ def get_event_dict() -> EventDictT:
def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw = PrintWrapper(printer)
tm = Service5Tm.unpack(raw_telemetry=raw_tm)
printer.handle_long_tm_print(packet_if=tm, info_if=tm)
event_dict = get_event_dict()
info = event_dict.get(tm.event_id)
if info is None:
@ -46,6 +45,11 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
generic_event_string = (
f"Object {obj_name} generated Event {tm.event_id} | {info.name}"
)
pw.printer.file_logger.info(
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
)
LOGGER.info(generic_event_string)
specific_handler = True
if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED":
additional_event_info = f"Additional info: {info.info}"
context = (
@ -55,12 +59,11 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw.dlog(additional_event_info)
pw.dlog(context)
else:
specific_handler = False
if info.info != "":
additional_event_info = (
f"Additional info: {info.info} | P1: {tm.param_1} | P2: {tm.param_2}"
)
pw.dlog(additional_event_info)
pw.printer.file_logger.info(
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
)
LOGGER.info(generic_event_string)
if not specific_handler:
printer.handle_long_tm_print(packet_if=tm, info_if=tm)