starting changing code to new API
This commit is contained in:
@ -7,16 +7,14 @@ import enum
|
||||
|
||||
from config.definitions import CustomServiceList
|
||||
from config.object_ids import get_object_ids
|
||||
from tmtccmd.tc import QueueHelper
|
||||
from tmtccmd.utility.obj_id import ObjectId
|
||||
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
|
||||
from tmtccmd.tc.pus_201_fsfw_health import (
|
||||
pack_set_health_cmd_data,
|
||||
FsfwHealth,
|
||||
Subservices,
|
||||
)
|
||||
from tmtccmd.tc.pus_8_funccmd import generate_action_command
|
||||
from tmtccmd.config.globals import add_service_op_code_entry, add_op_code_entry
|
||||
from tmtccmd.tc.packer import TcQueueT
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
|
||||
|
||||
@ -82,9 +80,9 @@ def add_heater_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
)
|
||||
|
||||
|
||||
def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
|
||||
def pack_heater_cmds(object_id: bytearray, op_code: str, q: QueueHelper):
|
||||
if op_code in OpCodes.HEATER_CMD:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Heater Switching"))
|
||||
q.add_log_cmd("Heater Switching")
|
||||
heater_number = prompt_heater()
|
||||
while True:
|
||||
action = input("Turn switch on or off? (0 - off, 1 - on): ")
|
||||
@ -101,14 +99,13 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
|
||||
else:
|
||||
act_str = "off"
|
||||
debug_string = f"Switching heater {heater_number} {act_str}"
|
||||
tc_queue.appendleft((QueueCommands.PRINT, debug_string))
|
||||
command = pack_switch_heater_command(object_id, heater_number, action)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
q.add_log_cmd(debug_string)
|
||||
q.add_pus_tc(pack_switch_heater_command(object_id, heater_number, action))
|
||||
if op_code in OpCodes.HEATER_EXT_CTRL:
|
||||
heater_number = prompt_heater()
|
||||
obj_id = heater_idx_to_obj(heater_number)
|
||||
health_cmd(
|
||||
tc_queue=tc_queue,
|
||||
q=q,
|
||||
object_id=obj_id,
|
||||
health=FsfwHealth.EXTERNAL_CTRL,
|
||||
health_str="External Control",
|
||||
@ -118,7 +115,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
|
||||
heater_number = prompt_heater()
|
||||
obj_id = heater_idx_to_obj(heater_number)
|
||||
health_cmd(
|
||||
tc_queue=tc_queue,
|
||||
q=q,
|
||||
object_id=obj_id,
|
||||
health=FsfwHealth.FAULTY,
|
||||
health_str="Faulty",
|
||||
@ -128,7 +125,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
|
||||
heater_number = prompt_heater()
|
||||
obj_id = heater_idx_to_obj(heater_number)
|
||||
health_cmd(
|
||||
tc_queue=tc_queue,
|
||||
q=q,
|
||||
object_id=obj_id,
|
||||
health=FsfwHealth.HEALTHY,
|
||||
health_str="Healthy",
|
||||
@ -188,23 +185,19 @@ def prompt_heater() -> int:
|
||||
|
||||
|
||||
def health_cmd(
|
||||
tc_queue: TcQueueT,
|
||||
q: QueueHelper,
|
||||
heater_idx: int,
|
||||
object_id: ObjectId,
|
||||
health: FsfwHealth,
|
||||
health_str: str,
|
||||
):
|
||||
tc_queue.appendleft(
|
||||
(
|
||||
QueueCommands.PRINT,
|
||||
f"Setting Heater {heater_idx} {object_id} to {health_str}",
|
||||
q.add_log_cmd(f"Setting Heater {heater_idx} {object_id} to {health_str}")
|
||||
app_data = pack_set_health_cmd_data(object_id=object_id.as_bytes, health=health)
|
||||
q.add_pus_tc(
|
||||
PusTelecommand(
|
||||
service=201, subservice=Subservices.TC_SET_HEALTH, app_data=app_data
|
||||
)
|
||||
)
|
||||
app_data = pack_set_health_cmd_data(object_id=object_id.as_bytes, health=health)
|
||||
cmd = PusTelecommand(
|
||||
service=201, subservice=Subservices.TC_SET_HEALTH, app_data=app_data
|
||||
)
|
||||
tc_queue.appendleft(cmd.pack_command_tuple())
|
||||
|
||||
|
||||
def pack_switch_heater_command(
|
||||
|
Reference in New Issue
Block a user