2022-05-18 16:02:23 +02:00
|
|
|
"""HK Handling for EIVE OBSW"""
|
2023-02-01 11:17:04 +01:00
|
|
|
import logging
|
|
|
|
|
2023-03-14 10:11:01 +01:00
|
|
|
from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data
|
2023-06-28 10:43:11 +02:00
|
|
|
from eive_tmtc.tmtc.internal_err_reporter import handle_ier_hk_data
|
2023-05-04 14:50:38 +02:00
|
|
|
from eive_tmtc.tmtc.payload.ploc_mpsoc import handle_ploc_mpsoc_hk_data
|
2023-03-14 10:11:01 +01:00
|
|
|
from eive_tmtc.tmtc.tcs.rtd import RTD_NAMES, handle_rtd_hk
|
2023-03-12 12:54:12 +01:00
|
|
|
from eive_tmtc.tmtc.acs.star_tracker import handle_str_hk_data
|
2023-02-01 16:25:17 +01:00
|
|
|
from eive_tmtc.tmtc.power.plpcdu import handle_plpcdu_hk
|
|
|
|
from eive_tmtc.tmtc.payload.rad_sensor import handle_rad_sensor_data
|
|
|
|
from eive_tmtc.tmtc.acs.sus import handle_sus_hk
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.tmtc.payload.ploc_supervisor import handle_supv_hk_data
|
|
|
|
from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data
|
2023-01-25 14:14:22 +01:00
|
|
|
from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data
|
2023-01-16 17:11:20 +01:00
|
|
|
from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data
|
2023-06-18 13:30:45 +02:00
|
|
|
from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data
|
2023-03-14 18:09:52 +01:00
|
|
|
from spacepackets.ecss import PusTelemetry
|
2022-05-18 16:02:23 +02:00
|
|
|
from tmtccmd.tm.pus_3_fsfw_hk import (
|
|
|
|
Service3Base,
|
|
|
|
HkContentType,
|
|
|
|
Service3FsfwTm,
|
|
|
|
)
|
2022-07-08 16:25:46 +02:00
|
|
|
from tmtccmd.util.obj_id import ObjectIdU32, ObjectIdDictT
|
2022-05-18 16:02:23 +02:00
|
|
|
|
2023-02-01 16:25:17 +01:00
|
|
|
from eive_tmtc.tmtc.power.bpx_batt import handle_bpx_hk_data
|
|
|
|
from eive_tmtc.tmtc.acs.gps import handle_gps_data
|
2023-02-01 15:58:34 +01:00
|
|
|
from eive_tmtc.tmtc.acs.gyros import handle_gyros_hk_data
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.tmtc.power.tm import (
|
|
|
|
handle_pdu_data,
|
|
|
|
handle_p60_hk_data,
|
|
|
|
handle_acu_hk_data,
|
2022-12-22 16:12:31 +01:00
|
|
|
handle_pcdu_hk,
|
2022-11-29 16:53:29 +01:00
|
|
|
)
|
|
|
|
from eive_tmtc.tmtc.acs.imtq import (
|
2023-02-19 13:25:12 +01:00
|
|
|
handle_imtq_hk,
|
2022-10-21 11:28:33 +02:00
|
|
|
)
|
2023-05-23 09:54:51 +02:00
|
|
|
from eive_tmtc.pus_tm.defs import FsfwTmTcPrinter, PrintWrapper
|
2023-01-11 14:19:47 +01:00
|
|
|
from eive_tmtc.tmtc.core import handle_core_hk_data
|
2023-02-01 15:58:34 +01:00
|
|
|
from eive_tmtc.tmtc.acs.mgms import handle_mgm_hk_data
|
2022-11-29 16:53:29 +01:00
|
|
|
import eive_tmtc.config.object_ids as obj_ids
|
2022-05-18 16:02:23 +02:00
|
|
|
|
|
|
|
|
2023-02-01 11:17:04 +01:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2022-05-18 16:02:23 +02:00
|
|
|
|
|
|
|
|
2022-08-19 14:48:10 +02:00
|
|
|
FORWARD_SENSOR_TEMPS = False
|
|
|
|
|
|
|
|
|
2022-05-18 16:02:23 +02:00
|
|
|
def handle_hk_packet(
|
2023-07-10 16:25:44 +02:00
|
|
|
raw_tm: bytes, obj_id_dict: ObjectIdDictT, printer: FsfwTmTcPrinter, hk_level: int
|
2022-05-18 16:02:23 +02:00
|
|
|
):
|
|
|
|
tm_packet = Service3FsfwTm.unpack(raw_telemetry=raw_tm, custom_hk_handling=False)
|
|
|
|
named_obj_id = obj_id_dict.get(tm_packet.object_id.as_bytes)
|
|
|
|
if named_obj_id is None:
|
|
|
|
named_obj_id = tm_packet.object_id
|
|
|
|
if tm_packet.subservice == 25 or tm_packet.subservice == 26:
|
|
|
|
hk_data = tm_packet.tm_data[8:]
|
2023-07-19 14:41:19 +02:00
|
|
|
|
2022-05-18 16:02:23 +02:00
|
|
|
printer.generic_hk_tm_print(
|
|
|
|
content_type=HkContentType.HK,
|
|
|
|
object_id=named_obj_id,
|
|
|
|
set_id=tm_packet.set_id,
|
|
|
|
hk_data=hk_data,
|
|
|
|
)
|
2023-07-19 14:41:19 +02:00
|
|
|
|
2022-05-23 14:04:34 +02:00
|
|
|
try:
|
2023-07-10 16:03:08 +02:00
|
|
|
if hk_level == 1:
|
2023-06-28 13:10:10 +02:00
|
|
|
pass
|
2023-07-10 16:03:08 +02:00
|
|
|
elif hk_level > 1:
|
2023-06-22 14:52:28 +02:00
|
|
|
handle_regular_hk_print(
|
|
|
|
printer=printer,
|
|
|
|
object_id=named_obj_id,
|
|
|
|
hk_packet=tm_packet,
|
|
|
|
tm=tm_packet.pus_tm,
|
|
|
|
hk_data=hk_data,
|
|
|
|
)
|
2022-05-23 14:04:34 +02:00
|
|
|
except ValueError as e:
|
2023-02-01 11:17:04 +01:00
|
|
|
_LOGGER.exception(
|
2022-05-23 14:04:34 +02:00
|
|
|
f"{e} error when parsing HK data coming from {named_obj_id}"
|
|
|
|
)
|
2022-05-18 16:02:23 +02:00
|
|
|
if tm_packet.subservice == 10 or tm_packet.subservice == 12:
|
2023-02-01 11:17:04 +01:00
|
|
|
_LOGGER.warning("HK definitions printout not implemented yet")
|
2022-05-18 16:02:23 +02:00
|
|
|
|
2022-05-19 13:20:22 +02:00
|
|
|
|
2023-06-19 17:16:00 +02:00
|
|
|
def handle_regular_hk_print( # noqa C901: Complexity okay here
|
2022-05-18 16:02:23 +02:00
|
|
|
printer: FsfwTmTcPrinter,
|
2022-07-05 02:12:54 +02:00
|
|
|
object_id: ObjectIdU32,
|
2022-05-18 16:02:23 +02:00
|
|
|
hk_packet: Service3Base,
|
2023-03-14 18:09:52 +01:00
|
|
|
tm: PusTelemetry,
|
2022-05-18 16:02:23 +02:00
|
|
|
hk_data: bytes,
|
|
|
|
):
|
|
|
|
objb = object_id.as_bytes
|
|
|
|
set_id = hk_packet.set_id
|
2023-03-14 18:09:52 +01:00
|
|
|
packet_dt = tm.time_provider.as_date_time()
|
2023-05-23 09:54:51 +02:00
|
|
|
pw = PrintWrapper(printer.file_logger)
|
2022-05-18 16:02:23 +02:00
|
|
|
"""This function is called when a Service 3 Housekeeping packet is received."""
|
2022-07-05 02:12:54 +02:00
|
|
|
if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
|
2023-05-23 09:54:51 +02:00
|
|
|
return handle_rw_hk_data(pw, object_id, set_id, hk_data)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.SYRLINKS_HANDLER_ID:
|
2023-05-23 09:54:51 +02:00
|
|
|
return handle_syrlinks_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.IMTQ_HANDLER_ID:
|
2023-05-23 09:54:51 +02:00
|
|
|
return handle_imtq_hk(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.GPS_CONTROLLER:
|
2023-08-04 15:39:40 +02:00
|
|
|
return handle_gps_data(
|
|
|
|
pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt
|
|
|
|
)
|
2022-12-22 16:12:31 +01:00
|
|
|
elif objb == obj_ids.PCDU_HANDLER_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_pcdu_hk(pw=pw, set_id=set_id, hk_data=hk_data)
|
2022-05-27 14:32:58 +02:00
|
|
|
elif objb == obj_ids.BPX_HANDLER_ID:
|
2023-05-24 13:50:37 +02:00
|
|
|
return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, pw=pw)
|
2022-05-27 14:32:58 +02:00
|
|
|
elif objb == obj_ids.CORE_CONTROLLER_ID:
|
2023-05-24 13:50:37 +02:00
|
|
|
return handle_core_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.PDU_1_HANDLER_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_pdu_data(pw=pw, pdu_idx=1, set_id=set_id, hk_data=hk_data)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.PDU_2_HANDLER_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_pdu_data(pw=pw, pdu_idx=2, set_id=set_id, hk_data=hk_data)
|
2023-05-04 14:50:38 +02:00
|
|
|
elif objb == obj_ids.PLOC_MPSOC_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_ploc_mpsoc_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.ACU_HANDLER_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_acu_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2023-06-28 10:43:11 +02:00
|
|
|
elif objb == obj_ids.INTERNAL_ERROR_REPORTER_ID:
|
|
|
|
return handle_ier_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.RAD_SENSOR_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_rad_sensor_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
|
2022-05-18 16:02:23 +02:00
|
|
|
return handle_rw_hk_data(
|
2023-05-24 13:44:45 +02:00
|
|
|
pw=pw, object_id=object_id, set_id=set_id, hk_data=hk_data
|
2022-05-18 16:02:23 +02:00
|
|
|
)
|
2022-05-27 09:54:06 +02:00
|
|
|
if objb in [
|
|
|
|
obj_ids.SUS_0_N_LOC_XFYFZM_PT_XF,
|
|
|
|
obj_ids.SUS_1_N_LOC_XBYFZM_PT_XB,
|
|
|
|
obj_ids.SUS_2_N_LOC_XFYBZB_PT_YB,
|
|
|
|
obj_ids.SUS_3_N_LOC_XFYBZF_PT_YF,
|
|
|
|
obj_ids.SUS_4_N_LOC_XMYFZF_PT_ZF,
|
|
|
|
obj_ids.SUS_5_N_LOC_XFYMZB_PT_ZB,
|
|
|
|
obj_ids.SUS_6_R_LOC_XFYBZM_PT_XF,
|
|
|
|
obj_ids.SUS_7_R_LOC_XBYBZM_PT_XB,
|
|
|
|
obj_ids.SUS_8_R_LOC_XBYBZB_PT_YB,
|
|
|
|
obj_ids.SUS_9_R_LOC_XBYBZB_PT_YF,
|
|
|
|
obj_ids.SUS_10_R_LOC_XMYBZF_PT_ZF,
|
|
|
|
obj_ids.SUS_11_R_LOC_XBYMZB_PT_ZB,
|
|
|
|
]:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_sus_hk(object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id)
|
2023-03-14 10:11:01 +01:00
|
|
|
elif objb in RTD_NAMES.keys():
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_rtd_hk(object_id=objb, hk_data=hk_data, pw=pw)
|
2022-05-27 14:32:58 +02:00
|
|
|
elif objb == obj_ids.P60_DOCK_HANDLER:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_p60_hk_data(pw=pw, set_id=set_id, hk_data=hk_data)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb in [
|
2022-05-19 13:58:43 +02:00
|
|
|
obj_ids.GYRO_0_ADIS_HANDLER_ID,
|
|
|
|
obj_ids.GYRO_1_L3G_HANDLER_ID,
|
|
|
|
obj_ids.GYRO_2_ADIS_HANDLER_ID,
|
|
|
|
obj_ids.GYRO_3_L3G_HANDLER_ID,
|
2022-05-19 13:20:22 +02:00
|
|
|
]:
|
2023-02-17 02:04:43 +01:00
|
|
|
return handle_gyros_hk_data(
|
2023-05-24 13:44:45 +02:00
|
|
|
object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id
|
2022-05-19 13:20:22 +02:00
|
|
|
)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb in [
|
2022-05-19 13:58:43 +02:00
|
|
|
obj_ids.MGM_0_LIS3_HANDLER_ID,
|
|
|
|
obj_ids.MGM_1_RM3100_HANDLER_ID,
|
|
|
|
obj_ids.MGM_2_LIS3_HANDLER_ID,
|
|
|
|
obj_ids.MGM_3_RM3100_HANDLER_ID,
|
2022-05-19 13:20:22 +02:00
|
|
|
]:
|
2023-02-17 02:04:43 +01:00
|
|
|
return handle_mgm_hk_data(
|
2023-05-24 13:44:45 +02:00
|
|
|
object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id
|
2022-05-19 13:20:22 +02:00
|
|
|
)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.PL_PCDU_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_plpcdu_hk(set_id=set_id, hk_data=hk_data, pw=pw)
|
2022-05-24 01:49:57 +02:00
|
|
|
elif objb == obj_ids.THERMAL_CONTROLLER_ID:
|
2023-02-17 02:04:43 +01:00
|
|
|
return handle_thermal_controller_hk_data(
|
2023-05-24 13:44:45 +02:00
|
|
|
object_id=object_id, pw=pw, set_id=set_id, hk_data=hk_data
|
2022-05-19 13:20:22 +02:00
|
|
|
)
|
2023-03-08 19:57:28 +01:00
|
|
|
elif objb == obj_ids.STAR_TRACKER_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_str_hk_data(set_id=set_id, hk_data=hk_data, pw=pw)
|
2022-08-19 14:48:10 +02:00
|
|
|
elif objb == obj_ids.PLOC_SUPV_ID:
|
2023-05-24 13:44:45 +02:00
|
|
|
return handle_supv_hk_data(set_id=set_id, hk_data=hk_data, pw=pw)
|
2023-06-18 13:30:45 +02:00
|
|
|
elif objb in [
|
|
|
|
obj_ids.TMP1075_HANDLER_TCS_BRD_0_ID,
|
|
|
|
obj_ids.TMP1075_HANDLER_TCS_BRD_1_ID,
|
|
|
|
obj_ids.TMP1075_HANDLER_IF_BRD_ID,
|
|
|
|
obj_ids.TMP1075_HANDLER_PLPCDU_0_ID,
|
2023-06-19 17:59:14 +02:00
|
|
|
obj_ids.TMP1075_HANDLER_PLPCDU_1_ID,
|
2023-06-18 13:30:45 +02:00
|
|
|
]:
|
|
|
|
return handle_tmp_1075_hk_data(set_id=set_id, hk_data=hk_data, pw=pw)
|
2022-08-16 11:48:53 +02:00
|
|
|
elif objb == obj_ids.ACS_CONTROLLER:
|
2023-03-14 18:09:52 +01:00
|
|
|
return handle_acs_ctrl_hk_data(
|
2023-05-24 13:44:45 +02:00
|
|
|
pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt
|
2023-03-14 18:09:52 +01:00
|
|
|
)
|
2022-05-18 16:02:23 +02:00
|
|
|
else:
|
2023-02-01 11:17:04 +01:00
|
|
|
_LOGGER.info(
|
2022-05-25 10:37:38 +02:00
|
|
|
f"Service 3 TM: Parsing for object {object_id} and set ID {set_id} "
|
2023-09-12 13:48:38 +02:00
|
|
|
"has not been implemented."
|
2022-05-25 10:37:38 +02:00
|
|
|
)
|