from gomspace.gomspace_common import ( pack_set_param_command, Channel, GomspaceOpCodes, GsInfo, GomspaceDeviceActionIds, prompt_and_pack_set_param_command, prompt_and_pack_get_param_command, pack_request_config_command, ) from gomspace.gomspace_pdu_definitions import PDU_CONFIG_LIST from tmtccmd.config import OpCodeEntry from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_3_fsfw_hk import ( make_sid, generate_one_diag_command, generate_one_hk_command, ) from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd from tmtccmd.util import ObjectIdU32 class PowerInfo: INFO_CORE = "Core Information" INFO_AUX = "Auxiliary Information" INFO_ALL = "All Information" class PowerOpCodes: # PDU 1 TCS_ON = ["tcs-on"] TCS_OFF = ["tcs-off"] SYRLINKS_ON = ["syrlinks-on"] SYRLINKS_OFF = ["syrlinks-off"] STAR_TRACKER_ON = ["str-on"] STAR_TRACKER_OFF = ["str-off"] MGT_ON = ["mgt-on"] MGT_OFF = ["mgt-off"] SUS_N_ON = ["sus-nom-on"] SUS_N_OFF = ["sus-nom-off"] SCEX_ON = ["scex-on"] SCEX_OFF = ["scex-off"] PLOC_ON = ["ploc-on"] PLOC_OFF = ["ploc-off"] ACS_A_ON = ["acs-a-on"] ACS_A_OFF = ["acs-a-off"] # PDU 2 PL_PCDU_VBAT_NOM_ON = ["plpcdu-vbat-nom-on"] PL_PCDU_VBAT_NOM_OFF = ["plpcdu-vbat-nom-off"] RW_ON = ["rw-on"] RW_OFF = ["rw-off"] HEATER_ON = ["heater-on"] HEATER_OFF = ["heater-off"] SUS_R_ON = ["sus-red-on"] SUS_R_OFF = ["sus-red-off"] SOLAR_ARRAY_DEPL_ON = ["sa-depl-on"] SOLAR_ARRAY_DEPL_OFF = ["sa-depl-off"] PL_PCDU_VBAT_RED_ON = ["plpcdu-vbat-red-on"] PL_PCDU_VBAT_RED_OFF = ["plpcdu-vbat-red-off"] ACS_B_ON = ["acs-b-on"] ACS_B_OFF = ["acs-b-off"] PL_CAM_ON = ["cam-on"] PL_CAM_OFF = ["cam-off"] INFO_CORE = ["info"] INFO_AUX = ["info_aux"] INFO_ALL = ["info_all"] def add_gomspace_cmds( prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): objb = object_id.as_bytes if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: q.add_log_cmd(f"{prefix}: {GsInfo.PRINT_SWITCH_V_I}") q.add_pus_tc( make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) ) if op_code in GomspaceOpCodes.PRINT_LATCHUPS: q.add_log_cmd(f"{prefix}: {GsInfo.PRINT_LATCHUPS}") q.add_pus_tc( make_fsfw_action_cmd( object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS ) ) if op_code in GomspaceOpCodes.SET_PARAM: q.add_log_cmd(f"{prefix}: {GsInfo.SET_PARAMETER}") prompt_and_pack_set_param_command(q, object_id) if op_code in GomspaceOpCodes.GET_PARAM: q.add_log_cmd(f"{prefix}: {GsInfo.GET_PARAMETER}") prompt_and_pack_get_param_command(q, object_id) if op_code in GomspaceOpCodes.REQUEST_CONFIG_TABLE: q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_CONFIG_TABLE}") q.add_pus_tc(pack_request_config_command(object_id.as_bytes)) def req_hk_cmds( prefix: str, q: DefaultPusQueueHelper, op_code: str, obj_id: bytes, set_id_pair: [int, int], ): if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_CORE_HK_ONCE}") hk_sid = make_sid(object_id=obj_id, set_id=set_id_pair[0]) q.add_pus_tc(generate_one_diag_command(sid=hk_sid)) if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: q.add_log_cmd(f"{prefix}: {GsInfo.REQUEST_AUX_HK_ONCE}") hk_sid = make_sid(object_id=obj_id, set_id=set_id_pair[1]) q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) def generic_on_cmd( object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): q.add_log_cmd(info_str + " on") q.add_pus_tc( pack_set_param_command( object_id, PDU_CONFIG_LIST[out_idx].parameter_address, PDU_CONFIG_LIST[out_idx].parameter_size, Channel.on, ) ) def generic_off_cmd( object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): q.add_log_cmd(info_str + " off") q.add_pus_tc( pack_set_param_command( object_id, PDU_CONFIG_LIST[out_idx].parameter_address, PDU_CONFIG_LIST[out_idx].parameter_size, Channel.off, ) ) def add_gomspace_cmd_defs(oce: OpCodeEntry): oce.add( keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info=GsInfo.REQUEST_CORE_HK_ONCE, ) oce.add( keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, info=GsInfo.REQUEST_AUX_HK_ONCE, ) oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER) oce.add(keys=GomspaceOpCodes.PRINT_LATCHUPS, info=GsInfo.PRINT_LATCHUPS) oce.add(keys=GomspaceOpCodes.SET_PARAM, info=GsInfo.SET_PARAMETER) oce.add(keys=GomspaceOpCodes.REQUEST_CONFIG_TABLE, info=GsInfo.REQUEST_CONFIG_TABLE)