eive-tmtc/eive_tmtc/tmtc/acs/mgms.py

64 lines
1.9 KiB
Python
Raw Normal View History

2023-02-01 15:58:34 +01:00
import enum
2022-05-19 14:50:24 +02:00
import struct
2023-02-01 15:58:34 +01:00
import config.object_id as obj_ids
2022-11-29 16:53:29 +01:00
from eive_tmtc.pus_tm.defs import PrintWrapper
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
2023-02-01 15:58:34 +01:00
class MgmLis3SetId(enum.IntEnum):
CORE_HK = 0
class MgmRm3100SetId(enum.IntEnum):
CORE_HK = 0
2022-05-19 13:20:22 +02:00
def handle_mgm_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 13:20:22 +02:00
):
2022-07-04 15:22:53 +02:00
if object_id.as_bytes in [
obj_ids.MGM_0_LIS3_HANDLER_ID,
obj_ids.MGM_2_LIS3_HANDLER_ID,
]:
2022-05-19 14:50:24 +02:00
handle_mgm_lis3_hk_data(object_id, printer, set_id, hk_data)
2022-07-04 15:22:53 +02:00
elif object_id.as_bytes in [
obj_ids.MGM_1_RM3100_HANDLER_ID,
obj_ids.MGM_3_RM3100_HANDLER_ID,
]:
2022-06-03 18:04:59 +02:00
handle_mgm_rm3100_hk_data(object_id, printer, set_id, hk_data)
2022-05-19 13:20:22 +02:00
pass
2022-05-19 14:50:24 +02:00
def handle_mgm_lis3_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 14:50:24 +02:00
):
2023-01-16 14:13:06 +01:00
if set_id == MgmLis3SetId.CORE_HK:
2022-05-19 14:50:24 +02:00
pw = PrintWrapper(printer)
fmt_str = "!ffff"
inc_len = struct.calcsize(fmt_str)
(field_x, field_y, field_z, temp) = struct.unpack(
2022-07-04 15:22:53 +02:00
fmt_str, hk_data[0 : 0 + inc_len]
2022-05-19 14:50:24 +02:00
)
pw.dlog(f"Received MGM LIS3 from object {object_id}")
2022-05-19 18:47:23 +02:00
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)
2022-05-19 14:50:24 +02:00
pw.dlog(f"Temperature {temp} C")
def handle_mgm_rm3100_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 14:50:24 +02:00
):
2023-01-16 14:13:06 +01:00
if set_id == MgmRm3100SetId.CORE_HK:
2022-05-19 14:50:24 +02:00
pw = PrintWrapper(printer)
fmt_str = f"!fff"
inc_len = struct.calcsize(fmt_str)
2022-05-19 18:47:23 +02:00
(field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
2022-05-19 14:50:24 +02:00
pw.dlog(f"Received MGM LIS3 from object {object_id}")
2022-05-19 18:47:23 +02:00
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)