from gomspace.gomspace_common import GsInfo from pus_tc.devs.common_power import ( PowerOpCodes, add_pdu1_common_defs, add_pdu2_common_defs, PowerInfo, pdu1_cmds, pdu2_cmds, pdu1_req_hk_cmds, pdu2_req_hk_cmds, ) from config.definitions import CustomServiceList from tmtccmd import get_console_logger from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, P60Info from pus_tc.devs.acu import add_acu_cmds from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tc import DefaultPusQueueHelper LOGGER = get_console_logger() def pack_power_commands(q: DefaultPusQueueHelper, op_code: str): pdu1_cmds(q, op_code) pdu2_cmds(q, op_code) if op_code in PowerOpCodes.INFO_CORE: pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) q.add_wait_seconds(3.0) elif op_code in PowerOpCodes.INFO_AUX: pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) q.add_wait_seconds(3.0) elif op_code in PowerOpCodes.INFO_ALL: pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu1_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) pdu2_req_hk_cmds(q, GomspaceOpCodes.REQUEST_AUX_HK_ONCE[0]) q.add_wait_seconds(3.0) if q.empty(): LOGGER.info(f"Queue is empty, no stack for op code {op_code}") @tmtc_definitions_provider def add_p60_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() oce.add(keys=P60OpCodes.STACK_3V3_ON, info=P60Info.STACK_3V3_ON) oce.add(keys=P60OpCodes.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF) oce.add(keys=P60OpCodes.STACK_5V_ON, info=P60Info.STACK_5V_ON) oce.add(keys=P60OpCodes.STACK_5V_OFF, info=P60Info.STACK_5V_OFF) add_gomspace_cmds(oce) oce.add(keys=P60OpCodes.TEST, info="P60 Tests") defs.add_service( name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce ) @tmtc_definitions_provider def add_power_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() add_pdu1_common_defs(oce) add_pdu2_common_defs(oce) oce.add(keys=PowerOpCodes.INFO_ALL, info=PowerInfo.INFO_ALL) oce.add(keys=PowerOpCodes.INFO_CORE, info=PowerInfo.INFO_CORE) oce.add(keys=PowerOpCodes.INFO_AUX, info=PowerInfo.INFO_AUX) defs.add_service( name=CustomServiceList.POWER.value, info="Power Subsystem", op_code_entry=oce, ) @tmtc_definitions_provider def add_pdu1_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() add_pdu1_common_defs(oce) add_gomspace_cmds(oce) 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.PRINT_SWITCH_V_I, info="PDU1: Print Switches, Voltages, Currents", ) oce.add(keys=GomspaceOpCodes.GET_PARAM, info=GsInfo.GET_PARAMETER) defs.add_service( name=CustomServiceList.PDU1.value, info="PDU1 Device", op_code_entry=oce, ) @tmtc_definitions_provider def add_pdu2_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() add_pdu2_common_defs(oce) add_gomspace_cmds(oce) oce.add( keys=GomspaceOpCodes.PRINT_SWITCH_V_I, info="PDU2: Print Switches, Voltages, Currents", ) oce.add( keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU2: Print Latchups", ) defs.add_service( name="pdu2", info="PDU2 Device", op_code_entry=oce, ) def add_gomspace_cmds(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) def add_pcdu_cmds(defs: TmtcDefinitionWrapper): add_p60_cmds(defs) add_pdu1_cmds(defs) add_pdu2_cmds(defs) add_acu_cmds(defs)