from tmtccmd.tc.definitions import TcQueueT, QueueCommands from config.object_ids import BPX_HANDLER_ID from tmtccmd.tc.service_8_functional_cmd import generate_action_command from tmtccmd.tc.service_3_housekeeping import generate_one_hk_command, make_sid class BpxSetIds: GET_HK_SET = 0 GET_CFG_SET = 5 class BpxActionIds: REBOOT = 2 RESET_COUNTERS = 3 SET_CFG = 4 GET_CFG = 5 class BpxOpCodes: HK = ["0", "hk"] RST_BOOT_CNT = ["1", "rst_boot_cnt"] REQUEST_CFG = ["2", "cfg"] REQUEST_CFG_HK = ["3", "cfg_hk"] REBOOT = ["4", "reboot"] def pack_bpx_commands(tc_queue: TcQueueT, op_code: str): if op_code in BpxOpCodes.HK: tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX battery HK set")) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET) cmd = generate_one_hk_command(sid=sid, ssc=0) tc_queue.appendleft(cmd.pack_command_tuple()) if op_code in BpxOpCodes.RST_BOOT_CNT: tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters")) cmd = generate_action_command( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS ) tc_queue.appendleft(cmd.pack_command_tuple()) if op_code in BpxOpCodes.REQUEST_CFG: tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct")) cmd = generate_action_command( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG ) tc_queue.appendleft(cmd.pack_command_tuple()) if op_code in BpxOpCodes.REQUEST_CFG_HK: tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct HK")) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET) cmd = generate_one_hk_command(sid=sid, ssc=0) tc_queue.appendleft(cmd.pack_command_tuple()) if op_code in BpxOpCodes.REBOOT: tc_queue.appendleft((QueueCommands.PRINT, "Rebooting BPX battery")) cmd = generate_action_command( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT ) tc_queue.appendleft(cmd.pack_command_tuple()) pass