some fixes for rw ass commanding

This commit is contained in:
2022-05-10 18:34:15 +02:00
parent 8891908afa
commit a648b7f76f
4 changed files with 48 additions and 23 deletions

View File

@ -6,7 +6,11 @@
"""
import struct
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
generate_one_diag_command,
make_sid,
)
from tmtccmd.config.globals import add_op_code_entry, add_service_op_code_entry
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
@ -19,7 +23,8 @@ class OpCodesDevs:
ON = ["1", "on"]
NML = ["2", "nml"]
OFF = ["3", "off"]
GET_TM = ["4", "tm"]
GET_STATUS = ["4", "status"]
GET_TM = ["5", "tm"]
class InfoDevs:
@ -27,6 +32,7 @@ class InfoDevs:
ON = "Set On"
NML = "Set Normal"
OFF = "Set Off"
GET_STATUS = "Get Status HK"
GET_TM = "Get TM HK"
@ -81,10 +87,12 @@ def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.NML, keys=OpCodesDevs.NML
)
add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.GET_STATUS, keys=OpCodesDevs.GET_STATUS
)
add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.GET_TM, keys=OpCodesDevs.GET_TM
)
add_service_op_code_entry(
srv_op_code_dict=cmd_dict,
name=CustomServiceList.REACTION_WHEEL_1.value,
@ -156,21 +164,35 @@ def pack_single_rw_test_into(
sid=make_sid(object_id=object_id, set_id=RwSetIds.TM_SET), ssc=0
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.GET_STATUS:
tc_queue.appendleft(
(QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.GET_STATUS}")
)
command = generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=RwSetIds.STATUS_SET_ID), ssc=0
)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str):
if op_code in OpCodesAss.OFF:
data = pack_mode_data(object_id=object_id, mode=Modes.OFF, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data)
cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in OpCodesAss.ON:
data = pack_mode_data(object_id=object_id, mode=Modes.ON, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data)
cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in OpCodesAss.NML:
data = pack_mode_data(object_id=object_id, mode=Modes.NORMAL, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data)
cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple())