starting changing code to new API

This commit is contained in:
2022-07-04 15:22:53 +02:00
parent fd5b946810
commit 27edcbd71d
34 changed files with 1472 additions and 1737 deletions

View File

@ -5,14 +5,13 @@
@date 20.06.2021
"""
import struct
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc import QueueHelper
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
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices
from config.definitions import CustomServiceList
@ -130,48 +129,44 @@ def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
def pack_single_rw_test_into(
object_id: bytes, rw_idx: int, tc_queue: TcQueueT, op_code: str
object_id: bytes, rw_idx: int, q: QueueHelper, op_code: str
) -> TcQueueT:
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, f"RW {rw_idx}: {InfoDevs.SPEED}"))
command = pack_set_speed_command(object_id, speed, ramp_time, 40)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.SPEED}")
q.add_pus_tc(pack_set_speed_command(object_id, speed, ramp_time))
if op_code in OpCodesDevs.ON:
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.ON}"))
q.add_log_cmd(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())
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if op_code in OpCodesDevs.NML:
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.NML}"))
q.add_log_cmd(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())
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if op_code in OpCodesDevs.OFF:
tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.OFF}"))
q.add_log_cmd(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())
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if op_code in OpCodesDevs.GET_TM:
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
q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.GET_TM}")
q.add_pus_tc(
generate_one_hk_command(
sid=make_sid(object_id=object_id, set_id=RwSetIds.TM_SET)
)
)
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}")
q.add_log_cmd(f"RW {rw_idx}: {InfoDevs.GET_STATUS}")
q.add_pus_tc(
generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=RwSetIds.STATUS_SET_ID)
)
)
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
return q
def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str):
@ -196,7 +191,7 @@ 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_ms: int, ssc: int
object_id: bytes, speed: int, ramp_time_ms: int
) -> PusTelecommand:
"""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.
@ -204,7 +199,6 @@ def pack_set_speed_command(
specified in 0.1 * RPM
:param ramp_time_ms: The time after which the reaction wheel will reach the commanded speed.
Valid times are 10 - 10000 ms
:param ssc: Source sequence count
"""
if speed > 0:
if speed < 1000 or speed > 65000:
@ -231,5 +225,5 @@ def pack_set_speed_command(
command += object_id + command_id
command = command + struct.pack("!i", speed)
command = command + ramp_time_ms.to_bytes(length=2, byteorder="big")
command = PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=command)
command = PusTelecommand(service=8, subservice=128, app_data=command)
return command