added more rw cmds
This commit is contained in:
@ -1,21 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@file reaction_wheels.py
|
||||
"""reaction_wheels.py
|
||||
@brief Tests for the reaction wheel handler
|
||||
@author J. Meier
|
||||
@date 20.06.2021
|
||||
"""
|
||||
import struct
|
||||
from tmtccmd.config.definitions import QueueCommands
|
||||
|
||||
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT, OpCodeDictKeys
|
||||
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 pus_tc.service_200_mode import pack_mode_data
|
||||
from tmtccmd.tc.service_200_mode import pack_mode_data, Modes
|
||||
from config.definitions import CustomServiceList
|
||||
|
||||
|
||||
class OpCodesDevs:
|
||||
SPEED = ["0", "speed"]
|
||||
ON = ["1", "on"]
|
||||
NML = ["2", "nml"]
|
||||
OFF = ["3", "off"]
|
||||
GET_TM = ["4", "tm"]
|
||||
|
||||
|
||||
class InfoDevs:
|
||||
SPEED = "Set speed"
|
||||
ON = "Set On"
|
||||
NML = "Set Normal"
|
||||
OFF = "Set Off"
|
||||
GET_TM = "Get TM HK"
|
||||
|
||||
|
||||
class OpCodesAss:
|
||||
ON = ["0", "on"]
|
||||
NML = ["1", "nml"]
|
||||
OFF = ["2", "off"]
|
||||
|
||||
|
||||
class InfoAss:
|
||||
ON = "Mode On: 3/4 RWs min. on"
|
||||
NML = "Mode Normal: 3/4 RWs min. normal"
|
||||
OFF = "Mode Off: All RWs off"
|
||||
|
||||
|
||||
class RwSetIds:
|
||||
STATUS_SET_ID = 4
|
||||
TEMPERATURE_SET_ID = 8
|
||||
LAST_RESET = 2
|
||||
TM_SET = 9
|
||||
|
||||
|
||||
class RwCommandIds:
|
||||
@ -38,8 +68,60 @@ class RampTime:
|
||||
MS_1000 = 1000
|
||||
|
||||
|
||||
def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
op_code_dict = dict()
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, info=InfoDevs.SPEED, keys=OpCodesDevs.SPEED
|
||||
)
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=InfoDevs.ON, keys=OpCodesDevs.ON)
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, info=InfoDevs.OFF, keys=OpCodesDevs.OFF
|
||||
)
|
||||
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_TM, keys=OpCodesDevs.GET_TM
|
||||
)
|
||||
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.REACTION_WHEEL_1.value,
|
||||
op_code_entry=op_code_dict,
|
||||
info="Reaction Wheel 1",
|
||||
)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.REACTION_WHEEL_2.value,
|
||||
op_code_entry=op_code_dict,
|
||||
info="Reaction Wheel 2",
|
||||
)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.REACTION_WHEEL_3.value,
|
||||
op_code_entry=op_code_dict,
|
||||
info="Reaction Wheel 3",
|
||||
)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.REACTION_WHEEL_4.value,
|
||||
op_code_entry=op_code_dict,
|
||||
info="Reaction Wheel 4",
|
||||
)
|
||||
op_code_dict = dict()
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=InfoAss.ON, keys=OpCodesAss.ON)
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=InfoAss.NML, keys=OpCodesAss.NML)
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=InfoAss.OFF, keys=OpCodesAss.OFF)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.RW_ASSEMBLY.value,
|
||||
op_code_entry=op_code_dict,
|
||||
info="Reaction Wheel Assembly",
|
||||
)
|
||||
|
||||
|
||||
def pack_single_rw_test_into(
|
||||
object_id: bytearray, tc_queue: TcQueueT, op_code: str
|
||||
object_id: bytes, tc_queue: TcQueueT, op_code: str
|
||||
) -> TcQueueT:
|
||||
tc_queue.appendleft(
|
||||
(
|
||||
@ -48,7 +130,7 @@ def pack_single_rw_test_into(
|
||||
)
|
||||
)
|
||||
|
||||
if op_code == "0" or op_code == "1":
|
||||
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"))
|
||||
@ -56,27 +138,27 @@ def pack_single_rw_test_into(
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if op_code == "2":
|
||||
if op_code in OpCodesDevs.ON:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Switch to mode on"))
|
||||
mode_data = pack_mode_data(object_id, 1, 0)
|
||||
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 == "3":
|
||||
if op_code in OpCodesDevs.NML:
|
||||
tc_queue.appendleft(
|
||||
(QueueCommands.PRINT, "Reaction Wheel: Switch to mode normal")
|
||||
)
|
||||
mode_data = pack_mode_data(object_id, 2, 0)
|
||||
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 == "4":
|
||||
if op_code in OpCodesDevs.OFF:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Switch to mode off"))
|
||||
mode_data = pack_mode_data(object_id, 0, 0)
|
||||
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 == "5":
|
||||
if op_code in OpCodesDevs.GET_TM:
|
||||
tc_queue.appendleft(
|
||||
(QueueCommands.PRINT, "Reaction Wheel: Send get-telemetry-command")
|
||||
)
|
||||
@ -86,18 +168,26 @@ def pack_single_rw_test_into(
|
||||
return tc_queue
|
||||
|
||||
|
||||
def pack_set_speed_command(
|
||||
object_id: bytearray, speed: int, ramp_time: int
|
||||
) -> bytearray:
|
||||
def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str):
|
||||
if op_code in OpCodesAss.OFF:
|
||||
pass
|
||||
if op_code in OpCodesAss.ON:
|
||||
pass
|
||||
if op_code in OpCodesAss.NML:
|
||||
pass
|
||||
|
||||
|
||||
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 specified in 0.1 * RPM
|
||||
@param ramp_time The time after which the reaction wheel will reached the commanded speed. Valid times are
|
||||
10 - 10000 ms
|
||||
: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.
|
||||
Valid times are 10 - 10000 ms
|
||||
"""
|
||||
command_id = RwCommandIds.SET_SPEED
|
||||
command = bytearray()
|
||||
command = object_id + command_id
|
||||
command += object_id + command_id
|
||||
command = command + struct.pack("!i", speed)
|
||||
command = command + ramp_time.to_bytes(length=2, byteorder="big")
|
||||
return command
|
||||
|
Reference in New Issue
Block a user