rw cmds cntd

This commit is contained in:
2022-05-05 02:00:18 +02:00
parent bc4099c5bf
commit 510ba82fef
4 changed files with 26 additions and 31 deletions

View File

@ -6,6 +6,7 @@
"""
import struct
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT, OpCodeDictKeys
from tmtccmd.tc.service_3_housekeeping import generate_one_hk_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
@ -121,49 +122,39 @@ def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
def pack_single_rw_test_into(
object_id: bytes, tc_queue: TcQueueT, op_code: str
object_id: bytes, rw_idx: int, tc_queue: TcQueueT, op_code: str
) -> TcQueueT:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"Testing reaction wheel handler with object id: 0x" + object_id.hex(),
)
)
if op_code in OpCodesDevs.SPEED:
speed = int(input("Specify speed [0.1 RPM]: "))
ramp_time = int(input("Specify ramp time [ms]: "))
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Set speed"))
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.SPEED}"))
command = pack_set_speed_command(object_id, speed, ramp_time)
command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.ON:
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Switch to mode on"))
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.ON}"))
mode_data = pack_mode_data(object_id, Modes.ON, 0)
command = PusTelecommand(service=200, subservice=1, ssc=41, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.NML:
tc_queue.appendleft(
(QueueCommands.PRINT, "Reaction Wheel: Switch to mode normal")
)
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.NML}"))
mode_data = pack_mode_data(object_id, Modes.NORMAL, 0)
command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.OFF:
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Switch to mode off"))
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.OFF}"))
mode_data = pack_mode_data(object_id, Modes.OFF, 0)
command = PusTelecommand(service=200, subservice=1, ssc=43, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.GET_TM:
tc_queue.appendleft(
(QueueCommands.PRINT, "Reaction Wheel: Send get-telemetry-command")
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.GET_TM}"))
command = generate_one_hk_command(
sid=make_sid(object_id=object_id, set_id=RwSetIds.TM_SET), ssc=0
)
command = object_id + RwCommandIds.GET_TM
command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
@ -179,10 +170,10 @@ def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str):
def pack_set_speed_command(object_id: bytes, speed: int, ramp_time: int) -> bytearray:
"""With this function a command is packed to set the speed of a reaction wheel
:param object_id The object id of the reaction wheel handler.
:param speed Valid speeds are [-65000, -1000] and [1000, 65000]. Values are
:param object_id: The object id of the reaction wheel handler.
:param speed: Valid speeds are [-65000, -1000] and [1000, 65000]. Values are
specified in 0.1 * RPM
:param ramp_time The time after which the reaction wheel will reached the commanded speed.
:param ramp_time: The time after which the reaction wheel will reached the commanded speed.
Valid times are 10 - 10000 ms
"""
command_id = RwCommandIds.SET_SPEED