eive-tmtc/eive_tmtc/tmtc/obj_prompt.py
2023-12-01 13:01:14 +01:00

87 lines
2.5 KiB
Python

from eive_tmtc.config.object_ids import (
ACS_SUBSYSTEM_ID,
IMTQ_HANDLER_ID,
GPS_0_HEALTH_DEV,
GYRO_0_ADIS_HANDLER_ID,
GYRO_1_L3G_HANDLER_ID,
GYRO_2_ADIS_HANDLER_ID,
ACS_BOARD_ASS_ID,
RW_ASSEMBLY,
SUS_BOARD_ASS_ID,
MGM_0_LIS3_HANDLER_ID,
MGM_1_RM3100_HANDLER_ID,
SUS_0_N_LOC_XFYFZM_PT_XF,
SUS_6_R_LOC_XFYBZM_PT_XF,
RW1_ID,
RW2_ID,
RTD_0_PLOC_HSPD,
TMP1075_HANDLER_TCS_BRD_1_ID,
TMP1075_HANDLER_TCS_BRD_0_ID,
TMP1075_HANDLER_PLPCDU_0_ID,
TMP1075_HANDLER_PLPCDU_1_ID,
TMP1075_HANDLER_IF_BRD_ID,
STR_ASSEMBLY,
STAR_TRACKER_ID,
)
SUBSYSTEM_DICT = {
0: "acs",
1: "tcs",
2: "com",
}
ACS_OBJ_DICT = {
0: ("Subsystem", ACS_SUBSYSTEM_ID),
1: ("SUS Assembly", SUS_BOARD_ASS_ID),
2: ("ACS Board Assembly", ACS_BOARD_ASS_ID),
3: ("RW Assembly", RW_ASSEMBLY),
4: ("STR Assembly", STR_ASSEMBLY),
5: ("iMTQ MGT", IMTQ_HANDLER_ID),
6: ("GYR 0 ADIS", GYRO_0_ADIS_HANDLER_ID),
7: ("GYR 1 L3G", GYRO_1_L3G_HANDLER_ID),
8: ("GYR 2 ADIS", GYRO_2_ADIS_HANDLER_ID),
9: ("MGM 0 LIS3", MGM_0_LIS3_HANDLER_ID),
10: ("MGM 1 RM3100", MGM_1_RM3100_HANDLER_ID),
11: ("GPS 0 Health Device", GPS_0_HEALTH_DEV),
12: ("SUS 0", SUS_0_N_LOC_XFYFZM_PT_XF),
13: ("SUS 6", SUS_6_R_LOC_XFYBZM_PT_XF),
14: ("RW 1", RW1_ID),
15: ("RW 2", RW2_ID),
16: ("STR", STAR_TRACKER_ID),
}
TCS_OBJ_DICT = {
0: ("RTD 0", RTD_0_PLOC_HSPD),
1: ("TMP1075 PL PCDU 0", TMP1075_HANDLER_PLPCDU_0_ID),
2: ("TMP1075 PL PCDU 1", TMP1075_HANDLER_PLPCDU_1_ID),
3: ("TMP1075 TCS 0", TMP1075_HANDLER_TCS_BRD_0_ID),
4: ("TMP1075 TCS 1", TMP1075_HANDLER_TCS_BRD_1_ID),
5: ("TMP1075 IF BOARD", TMP1075_HANDLER_IF_BRD_ID),
}
def get_obj_if_from_dict(lut: dict) -> bytes:
for k, v in lut.items():
print(f"{k}: {v[0]}")
obj_key = int(input("Please specify target object by key: "))
name_and_obj_id = lut[obj_key]
if name_and_obj_id is None:
raise ValueError("invalid key")
return name_and_obj_id[1]
def prompt_object() -> bytes:
for k, v in SUBSYSTEM_DICT.items():
print(f"{k}: {v}")
subsystem_key = int(input("Please specify target subsystem by key: "))
subsystem = SUBSYSTEM_DICT[subsystem_key]
if subsystem is None:
raise ValueError("invalid key")
if subsystem == "acs":
return get_obj_if_from_dict(ACS_OBJ_DICT)
elif subsystem == "tcs":
return get_obj_if_from_dict(TCS_OBJ_DICT)
else:
print(f"No object for subsystem {subsystem}")
return bytes()