eive-tmtc/pus_tm/tmtcc_pus_tm_factory_hook.py

30 lines
1.1 KiB
Python

"""
@brief This file transfers control of TM parsing to the user
@details Template configuration file. Copy this folder to the TMTC commander root and adapt
it to your needs.
"""
from tmtc_core.pus_tm.tmtcc_pus_service_8 import Service8TM
from tmtc_core.pus_tm.tmtcc_pus_tm_base import PusTelemetry
from tmtc_core.utility.tmtcc_logger import get_logger
from tmtc_core.pus_tm.tmtcc_tm_service1 import Service1TM
from tmtc_core.pus_tm.tmtcc_tm_service5 import Service5TM
from tmtc_core.pus_tm.tmtcc_tm_service17 import Service17TM
LOGGER = get_logger()
def tm_user_factory_hook(raw_tm_packet: bytearray) -> PusTelemetry:
service_type = raw_tm_packet[7]
if service_type == 1:
return Service1TM(raw_tm_packet)
if service_type == 5:
return Service5TM(raw_tm_packet)
if service_type == 8:
service8tm = Service8TM(raw_tm_packet)
return Service8TM(raw_tm_packet)
if service_type == 17:
return Service17TM(raw_tm_packet)
LOGGER.info("The service " + str(service_type) + " is not implemented in Telemetry Factory")
return PusTelemetry(raw_tm_packet)