improved some event printout handling
This commit is contained in:
parent
820bd9e428
commit
d51fb53f0e
@ -2,6 +2,7 @@ import logging
|
||||
import os.path
|
||||
from datetime import datetime
|
||||
from config.object_ids import get_object_ids
|
||||
from pus_tm.defs import PrintWrapper
|
||||
|
||||
from tmtccmd.tm import Service5Tm
|
||||
from tmtccmd.logging import get_console_logger
|
||||
@ -25,12 +26,10 @@ def get_event_dict() -> EventDictT:
|
||||
return __EVENT_DICT
|
||||
|
||||
|
||||
def handle_event_packet(
|
||||
raw_tm: bytes, printer: FsfwTmTcPrinter, file_logger: logging.Logger
|
||||
) -> str:
|
||||
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)
|
||||
additional_event_info = ""
|
||||
event_dict = get_event_dict()
|
||||
info = event_dict.get(tm.event_id)
|
||||
if info is None:
|
||||
@ -48,20 +47,17 @@ def handle_event_packet(
|
||||
f"Object {obj_name} generated Event {tm.event_id} | {info.name}"
|
||||
)
|
||||
if info.name == "SUPV_UPDATE_PROGRESS":
|
||||
additional_event_info = (
|
||||
f"Additional info: {info.info} | "
|
||||
f"Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} | Bytes Written: {tm.param_2}"
|
||||
)
|
||||
additional_event_info = f"Additional info: {info.info}"
|
||||
context = f"Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} | Bytes Written: {tm.param_2}"
|
||||
pw.dlog(additional_event_info)
|
||||
pw.dlog(context)
|
||||
else:
|
||||
if info.info != "":
|
||||
additional_event_info = (
|
||||
f"Additional info: {info.info} | P1: {tm.param_1} | P2: {tm.param_2}"
|
||||
)
|
||||
file_logger.info(
|
||||
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 additional_event_info != "":
|
||||
file_logger.info(additional_event_info)
|
||||
print(additional_event_info)
|
||||
return generic_event_string + " | " + additional_event_info
|
||||
|
@ -35,7 +35,6 @@ def pus_factory_hook(
|
||||
LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
|
||||
return
|
||||
service = tm_packet.service
|
||||
file_logger = printer.file_logger
|
||||
obj_id_dict = get_object_ids()
|
||||
dedicated_handler = True
|
||||
if service == 1:
|
||||
@ -43,7 +42,7 @@ def pus_factory_hook(
|
||||
elif service == 3:
|
||||
handle_hk_packet(printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict)
|
||||
elif service == 5:
|
||||
handle_event_packet(raw_tm=packet, printer=printer, file_logger=file_logger)
|
||||
handle_event_packet(raw_tm=packet, printer=printer)
|
||||
elif service == 8:
|
||||
handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict)
|
||||
elif service == 17:
|
||||
|
Loading…
Reference in New Issue
Block a user