eive-tmtc/eive_tmtc/tmtc/obj_prompt.py

87 lines
2.5 KiB
Python
Raw Normal View History

2023-03-06 12:03:51 +01:00
from eive_tmtc.config.object_ids import (
ACS_SUBSYSTEM_ID,
IMTQ_HANDLER_ID,
2023-04-03 18:54:12 +02:00
GPS_0_HEALTH_DEV,
2023-03-06 14:25:04 +01:00
GYRO_0_ADIS_HANDLER_ID,
GYRO_1_L3G_HANDLER_ID,
2023-12-01 13:01:14 +01:00
GYRO_2_ADIS_HANDLER_ID,
2023-03-06 12:03:51 +01:00
ACS_BOARD_ASS_ID,
RW_ASSEMBLY,
SUS_BOARD_ASS_ID,
2023-03-24 17:25:10 +01:00
MGM_0_LIS3_HANDLER_ID,
2023-03-26 20:00:34 +02:00
MGM_1_RM3100_HANDLER_ID,
2023-04-05 14:41:17 +02:00
SUS_0_N_LOC_XFYFZM_PT_XF,
2023-04-06 19:08:04 +02:00
SUS_6_R_LOC_XFYBZM_PT_XF,
RW1_ID,
RW2_ID,
2023-04-11 20:43:39 +02:00
RTD_0_PLOC_HSPD,
2023-07-06 16:00:10 +02:00
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,
2023-07-19 14:41:19 +02:00
STR_ASSEMBLY,
STAR_TRACKER_ID,
2023-03-06 12:03:51 +01:00
)
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),
2023-07-13 10:53:42 +02:00
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),
2023-12-01 13:01:14 +01:00
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),
2023-03-06 12:03:51 +01:00
}
2023-04-11 20:43:39 +02:00
TCS_OBJ_DICT = {
0: ("RTD 0", RTD_0_PLOC_HSPD),
2023-07-06 16:00:10 +02:00
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),
2023-04-11 20:43:39 +02:00
}
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: "))
2023-04-11 22:08:05 +02:00
name_and_obj_id = lut[obj_key]
if name_and_obj_id is None:
2023-04-11 20:43:39 +02:00
raise ValueError("invalid key")
2023-04-11 22:08:05 +02:00
return name_and_obj_id[1]
2023-04-11 20:43:39 +02:00
2023-03-06 12:03:51 +01:00
def prompt_object() -> bytes:
2023-03-06 13:58:52 +01:00
for k, v in SUBSYSTEM_DICT.items():
2023-03-06 12:03:51 +01:00
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":
2023-04-11 20:43:39 +02:00
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()