This commit is contained in:
@ -1,23 +1,19 @@
|
||||
import enum
|
||||
import struct
|
||||
|
||||
from eive_tmtc.pus_tm.defs import PrintWrapper
|
||||
from spacepackets.ecss import PusTelecommand
|
||||
|
||||
from eive_tmtc.config.definitions import CustomServiceList
|
||||
from eive_tmtc.config.object_ids import BPX_HANDLER_ID
|
||||
from tmtccmd.config.tmtc import (
|
||||
tmtc_definitions_provider,
|
||||
TmtcDefinitionWrapper,
|
||||
OpCodeEntry,
|
||||
CmdTreeNode,
|
||||
)
|
||||
from tmtccmd.tmtc import service_provider
|
||||
from tmtccmd.tmtc.decorator import ServiceProviderParams
|
||||
from tmtccmd.pus.s8_fsfw_action import create_action_cmd
|
||||
from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid
|
||||
from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode
|
||||
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices
|
||||
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
|
||||
from tmtccmd.pus.s8_fsfw_action import create_action_cmd
|
||||
from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_data
|
||||
from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices
|
||||
from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid
|
||||
from tmtccmd.tmtc import DefaultPusQueueHelper
|
||||
|
||||
from eive_tmtc.config.object_ids import BPX_HANDLER_ID
|
||||
from eive_tmtc.pus_tm.defs import PrintWrapper
|
||||
|
||||
|
||||
class BpxSetId(enum.IntEnum):
|
||||
@ -54,38 +50,38 @@ class BpxOpCode:
|
||||
REBOOT = "reboot"
|
||||
|
||||
|
||||
@tmtc_definitions_provider
|
||||
def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys=BpxOpCode.ON, info="On command")
|
||||
oce.add(keys=BpxOpCode.OFF, info="Off command")
|
||||
oce.add(keys=BpxOpCode.HK, info="Request BPX HK")
|
||||
oce.add(keys=BpxOpCode.RST_BOOT_CNT, info="Reset Boot Count")
|
||||
oce.add(keys=BpxOpCode.RST_CFG, info="Reset Config to stored default settings")
|
||||
oce.add(keys=BpxOpCode.SET_CFG, info="Set BPX configuration")
|
||||
oce.add(keys=BpxOpCode.MAN_HEATER_ON, info="Manual heater on")
|
||||
oce.add(keys=BpxOpCode.MAN_HEATER_OFF, info="Manual heater off")
|
||||
oce.add(keys=BpxOpCode.REQUEST_CFG, info="Request Configuration Struct (Step 1)")
|
||||
oce.add(
|
||||
keys=BpxOpCode.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)"
|
||||
def create_bpx_batt_node() -> CmdTreeNode:
|
||||
node = CmdTreeNode("bat", "BPX battery device")
|
||||
node.add_child(CmdTreeNode(BpxOpCode.ON, "ON command"))
|
||||
node.add_child(CmdTreeNode(BpxOpCode.OFF, "OFF command"))
|
||||
node.add_child(CmdTreeNode(BpxOpCode.HK, "HK command"))
|
||||
node.add_child(CmdTreeNode(BpxOpCode.RST_BOOT_CNT, "Reset boot count"))
|
||||
node.add_child(
|
||||
CmdTreeNode(BpxOpCode.RST_CFG, "Reset Config to stored default settings")
|
||||
)
|
||||
oce.add(keys=BpxOpCode.REBOOT, info="Reboot Command")
|
||||
defs.add_service(
|
||||
name=CustomServiceList.BPX_BATTERY.value,
|
||||
info="BPX Battery Handler",
|
||||
op_code_entry=oce,
|
||||
node.add_child(CmdTreeNode(BpxOpCode.SET_CFG, "Set BPX configuration"))
|
||||
node.add_child(CmdTreeNode(BpxOpCode.MAN_HEATER_ON, "Manual heater on"))
|
||||
node.add_child(CmdTreeNode(BpxOpCode.MAN_HEATER_OFF, "Manual heater off"))
|
||||
node.add_child(
|
||||
CmdTreeNode(BpxOpCode.REQUEST_CFG, "Request Configuration Struct (Step 1)")
|
||||
)
|
||||
node.add_child(
|
||||
CmdTreeNode(
|
||||
BpxOpCode.REQUEST_CFG_HK, "Request Configuration Struct HK (Step 2)"
|
||||
)
|
||||
)
|
||||
node.add_child(CmdTreeNode(BpxOpCode.REBOOT, "Reboot Command"))
|
||||
return node
|
||||
|
||||
|
||||
@service_provider(CustomServiceList.BPX_BATTERY.value)
|
||||
def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is okay here.
|
||||
op_code = p.op_code
|
||||
q = p.queue_helper
|
||||
if op_code == BpxOpCode.HK:
|
||||
def pack_bpx_commands(
|
||||
q: DefaultPusQueueHelper, cmd_str: str
|
||||
): # noqa C901: Complexity is okay here.
|
||||
if cmd_str == BpxOpCode.HK:
|
||||
q.add_log_cmd("Requesting BPX battery HK set")
|
||||
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_HK_SET)
|
||||
q.add_pus_tc(generate_one_hk_command(sid=sid))
|
||||
if op_code == BpxOpCode.OFF:
|
||||
if cmd_str == BpxOpCode.OFF:
|
||||
q.add_log_cmd("Off mode")
|
||||
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.OFF, 0)
|
||||
q.add_pus_tc(
|
||||
@ -95,7 +91,7 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
|
||||
app_data=mode_cmd,
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.ON:
|
||||
if cmd_str == BpxOpCode.ON:
|
||||
q.add_log_cmd("On mode")
|
||||
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.ON, 0)
|
||||
q.add_pus_tc(
|
||||
@ -105,21 +101,21 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
|
||||
app_data=mode_cmd,
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.RST_BOOT_CNT:
|
||||
if cmd_str == BpxOpCode.RST_BOOT_CNT:
|
||||
q.add_log_cmd("Resetting reboot counters")
|
||||
q.add_pus_tc(
|
||||
create_action_cmd(
|
||||
object_id=BPX_HANDLER_ID, action_id=BpxActionId.RESET_COUNTERS
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.RST_CFG:
|
||||
if cmd_str == BpxOpCode.RST_CFG:
|
||||
q.add_log_cmd("Reset BPX configuration")
|
||||
q.add_pus_tc(
|
||||
create_action_cmd(
|
||||
object_id=BPX_HANDLER_ID, action_id=BpxActionId.CONFIG_CMD
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.SET_CFG:
|
||||
if cmd_str == BpxOpCode.SET_CFG:
|
||||
q.add_log_cmd("Setting BPX configuration")
|
||||
user_data = bytearray()
|
||||
batt_mode = BpxHeaterModeSelect(
|
||||
@ -137,21 +133,21 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
|
||||
user_data=user_data,
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.REQUEST_CFG:
|
||||
if cmd_str == BpxOpCode.REQUEST_CFG:
|
||||
q.add_log_cmd("Requesting configuration struct")
|
||||
q.add_pus_tc(
|
||||
create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.GET_CFG)
|
||||
)
|
||||
if op_code == BpxOpCode.REQUEST_CFG_HK:
|
||||
if cmd_str == BpxOpCode.REQUEST_CFG_HK:
|
||||
q.add_log_cmd("Requesting configuration struct HK")
|
||||
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_CFG_SET)
|
||||
q.add_pus_tc(generate_one_hk_command(sid=sid))
|
||||
if op_code == BpxOpCode.REBOOT:
|
||||
if cmd_str == BpxOpCode.REBOOT:
|
||||
q.add_log_cmd("Rebooting BPX battery")
|
||||
q.add_pus_tc(
|
||||
create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.REBOOT)
|
||||
)
|
||||
if op_code == BpxOpCode.MAN_HEATER_ON:
|
||||
if cmd_str == BpxOpCode.MAN_HEATER_ON:
|
||||
q.add_log_cmd("BPX manual heater on with seconds burntime")
|
||||
burn_time = int(input("BPX heater burn time in seconds [1-65535]: "))
|
||||
if burn_time < 1 or burn_time > 65535:
|
||||
@ -163,7 +159,7 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
|
||||
user_data=struct.pack("!H", burn_time),
|
||||
)
|
||||
)
|
||||
if op_code == BpxOpCode.MAN_HEATER_OFF:
|
||||
if cmd_str == BpxOpCode.MAN_HEATER_OFF:
|
||||
q.add_log_cmd("BPX manual heater off")
|
||||
q.add_pus_tc(
|
||||
create_action_cmd(
|
||||
|
Reference in New Issue
Block a user