eive-tmtc/pus_tc/devs/bpx_batt.py

57 lines
1.8 KiB
Python
Raw Normal View History

from config.object_ids import BPX_HANDLER_ID
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_8_funccmd import generate_action_command
from tmtccmd.tc.pus_3_fsfw_hk 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
2022-02-03 16:02:55 +01:00
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"]
2022-08-08 16:32:18 +02:00
def pack_bpx_commands(q: DefaultPusQueueHelper, op_code: str):
2022-02-03 16:02:55 +01:00
if op_code in BpxOpCodes.HK:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Requesting BPX battery HK set")
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET)
2022-07-04 15:22:53 +02:00
q.add_pus_tc(generate_one_hk_command(sid=sid))
2022-02-03 16:02:55 +01:00
if op_code in BpxOpCodes.RST_BOOT_CNT:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Resetting reboot counters")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS
)
)
2022-02-03 16:02:55 +01:00
if op_code in BpxOpCodes.REQUEST_CFG:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Requesting configuration struct")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG
)
2022-02-03 15:30:58 +01:00
)
2022-02-03 16:02:55 +01:00
if op_code in BpxOpCodes.REQUEST_CFG_HK:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Requesting configuration struct HK")
2022-02-03 15:30:58 +01:00
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET)
2022-07-04 15:22:53 +02:00
q.add_pus_tc(generate_one_hk_command(sid=sid))
2022-02-03 16:02:55 +01:00
if op_code in BpxOpCodes.REBOOT:
2022-07-04 15:22:53 +02:00
q.add_log_cmd("Rebooting BPX battery")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT
)
2022-02-03 16:02:55 +01:00
)