better event handling

This commit is contained in:
Robin Müller 2023-02-18 13:12:12 +01:00
parent 676f851659
commit 201e08afe1
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -41,12 +41,13 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw.printer.file_logger.info(
f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
)
specific_handler = True
specific_handler = False
if info.name == "MODE_TRANSITION_FAILED":
reason = generic_retval_printout(event_def.param1)
for string in reason:
pw.dlog(f"Reason from event parameter 1: {string}")
pw.dlog(f"Mode, sequence or table: {event_def.param2:#08x}")
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,7 +56,9 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
)
pw.dlog(additional_event_info)
pw.dlog(context)
specific_handler = True
if info.name == "MODE_INFO":
specific_handler = True
mode_name = "Unknown"
if obj_name == "ACS_SUBSYSTEM":
acs_mode = AcsMode(event_def.param1)
@ -74,9 +77,11 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
mode_name = "Normal"
elif event_def.param1 == Mode.RAW:
mode_name = "Raw"
pw.dlog(f"Mode Number {event_def.param1}, Mode Name {mode_name}")
pw.dlog(f"Submode: {event_def.param2}")
elif info.name == "VERSION_INFO":
pw.dlog(
f"Mode Number {event_def.param1}, Mode Name {mode_name}, Submode: {event_def.param2}"
)
if info.name == "VERSION_INFO":
specific_handler = True
ver_major = (event_def.param1 >> 24) & 0xFF
ver_minor = (event_def.param1 >> 16) & 0xFF
ver_rev = (event_def.param1 >> 8) & 0xFF
@ -89,24 +94,31 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw.dlog(f"Version {version_string}")
if has_git_sha:
pw.dlog(f"Git SHA first four letters: {git_sha}")
elif info.name == "CLOCK_SET":
if info.name == "CLOCK_SET":
specific_handler = True
old_time = event_def.param1
new_time = event_def.param2
old_time_dt = datetime.datetime.fromtimestamp(old_time, datetime.timezone.utc)
new_time_dt = datetime.datetime.fromtimestamp(new_time, datetime.timezone.utc)
pw.dlog(f"Old time (UTC): {old_time_dt}")
pw.dlog(f"New time (UTC): {new_time_dt}")
elif info.name == "CLOCK_DUMP":
if info.name == "CLOCK_DUMP":
specific_handler = True
# param 1 is timeval seconds, param 2 is timeval subsecond milliseconds
time = event_def.param1 + event_def.param2 / 1000.0
time_dt = datetime.datetime.fromtimestamp(time, datetime.timezone.utc)
pw.dlog(f"Current time: {time_dt}")
elif info.name == "HEALTH_INFO":
if info.name == "HEALTH_INFO":
specific_handler = True
health = FsfwHealth(event_def.param1)
pw.dlog(f"{obj_name}: {health!r}")
else:
specific_handler = False
if info.info != "":
if info.name == "CHANGING_MODE":
mode = event_def.param1
submode = event_def.param2
pw.dlog(
f"Mode Number {mode}, Submode: {submode}"
)
if not specific_handler:
additional_event_info = f"Additional info: {info.info} | P1: {event_def.param1} | P2: {event_def.param2}"
pw.dlog(additional_event_info)
if not specific_handler: