from .defs import CtrlSetId from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import TCS_CONTROLLER, TCS_SUBSYSTEM_ID from eive_tmtc.tmtc.common import pack_mode_cmd_with_info from eive_tmtc.tmtc.tcs.brd_assy import pack_tcs_ass_cmds from tmtccmd.config.tmtc import ( tmtc_definitions_provider, TmtcDefinitionWrapper, OpCodeEntry, ) from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_announce_mode_recursive_command from tmtccmd.tc.pus_3_fsfw_hk import ( make_sid, generate_one_hk_command, create_enable_periodic_hk_command_with_interval, create_request_one_diag_command, ) class OpCodeSys: OFF = ["off"] NML = ["nml"] REQUEST_PRIMARY_TEMP_SET = ["temp"] ENABLE_TEMP_SET = "enable_temp_set" REQUEST_DEVICE_TEMP_SET = ["temp_devs"] REQUEST_DEVICE_SUS_SET = ["temp_sus"] REQUEST_HEATER_INFO = "heater_info" ANNOUNCE_MODES = "announce_modes" class InfoSys: OFF = "Switch TCS subsystem OFF" NML = "Switch TCS subsystem NORMAL (nominal)" ENABLE_TEMP_SET = "Enable Primary Temperature Set" REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures" REQUEST_DEVICE_TEMP_SET = "Request HK set of device sensor temperatures" REQUEST_DEVICE_SUS_SET = "Request HK set of the SUS temperatures" REQUEST_HEATER_INFO = "Request heater information" ANNOUNCE_MODES = "Announce Modes recursively" def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str): if op_code in OpCodeSys.REQUEST_PRIMARY_TEMP_SET: sensor_set_sid = make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS) q.add_log_cmd(InfoSys.REQUEST_PRIMARY_TEMP_SET) q.add_pus_tc(generate_one_hk_command(sensor_set_sid)) if op_code in OpCodeSys.REQUEST_DEVICE_TEMP_SET: q.add_log_cmd(InfoSys.REQUEST_DEVICE_TEMP_SET) q.add_pus_tc( generate_one_hk_command(make_sid(TCS_CONTROLLER, CtrlSetId.DEVICE_SENSORS)) ) if op_code in OpCodeSys.REQUEST_DEVICE_SUS_SET: q.add_log_cmd(InfoSys.REQUEST_DEVICE_SUS_SET) q.add_pus_tc( generate_one_hk_command( make_sid(TCS_CONTROLLER, CtrlSetId.SUS_TEMP_SENSORS) ) ) if op_code == OpCodeSys.REQUEST_HEATER_INFO: q.add_log_cmd(InfoSys.REQUEST_HEATER_INFO) q.add_pus_tc( create_request_one_diag_command( make_sid(TCS_CONTROLLER, CtrlSetId.HEATER_INFO) ) ) if op_code in OpCodeSys.OFF: q.add_log_cmd(InfoSys.OFF) pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.OFF, 0, q, InfoSys.OFF) if op_code in OpCodeSys.NML: q.add_log_cmd(InfoSys.NML) pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.NORMAL, 0, q, InfoSys.OFF) if op_code == OpCodeSys.ENABLE_TEMP_SET: interval_seconds = float(input("Please specify interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval( False, make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS), interval_seconds ) for cmd in cmds: q.add_pus_tc(cmd) if op_code == OpCodeSys.ANNOUNCE_MODES: q.add_log_cmd(InfoSys.ANNOUNCE_MODES) q.add_pus_tc(create_announce_mode_recursive_command(TCS_SUBSYSTEM_ID)) pack_tcs_ass_cmds(q, op_code) @tmtc_definitions_provider def add_tcs_subsystem_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() oce.add(keys=OpCodeSys.OFF, info=InfoSys.OFF) oce.add(keys=OpCodeSys.NML, info=InfoSys.NML) oce.add( keys=OpCodeSys.REQUEST_PRIMARY_TEMP_SET, info=InfoSys.REQUEST_PRIMARY_TEMP_SET ) oce.add( keys=OpCodeSys.REQUEST_DEVICE_TEMP_SET, info=InfoSys.REQUEST_DEVICE_TEMP_SET ) oce.add(keys=OpCodeSys.REQUEST_DEVICE_SUS_SET, info=InfoSys.REQUEST_DEVICE_SUS_SET) oce.add(keys=OpCodeSys.REQUEST_HEATER_INFO, info=InfoSys.REQUEST_HEATER_INFO) oce.add(keys=OpCodeSys.ANNOUNCE_MODES, info=InfoSys.ANNOUNCE_MODES) oce.add(keys=OpCodeSys.ENABLE_TEMP_SET, info=InfoSys.ENABLE_TEMP_SET) defs.add_service( name=CustomServiceList.TCS, info="TCS", op_code_entry=oce, )