rw cmds cntd

This commit is contained in:
Robin Müller 2022-05-05 02:00:18 +02:00
parent bc4099c5bf
commit 510ba82fef
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 26 additions and 31 deletions

View File

@ -6,6 +6,7 @@
""" """
import struct import struct
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT, OpCodeDictKeys 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.config.globals import add_op_code_entry, add_service_op_code_entry
from tmtccmd.tc.packer import TcQueueT from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
@ -121,49 +122,39 @@ def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
def pack_single_rw_test_into( 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: ) -> TcQueueT:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"Testing reaction wheel handler with object id: 0x" + object_id.hex(),
)
)
if op_code in OpCodesDevs.SPEED: if op_code in OpCodesDevs.SPEED:
speed = int(input("Specify speed [0.1 RPM]: ")) speed = int(input("Specify speed [0.1 RPM]: "))
ramp_time = int(input("Specify ramp time [ms]: ")) 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 = pack_set_speed_command(object_id, speed, ramp_time)
command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.ON: 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) mode_data = pack_mode_data(object_id, Modes.ON, 0)
command = PusTelecommand(service=200, subservice=1, ssc=41, app_data=mode_data) command = PusTelecommand(service=200, subservice=1, ssc=41, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.NML: if op_code in OpCodesDevs.NML:
tc_queue.appendleft( tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.NML}"))
(QueueCommands.PRINT, "Reaction Wheel: Switch to mode normal")
)
mode_data = pack_mode_data(object_id, Modes.NORMAL, 0) mode_data = pack_mode_data(object_id, Modes.NORMAL, 0)
command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data) command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.OFF: 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) mode_data = pack_mode_data(object_id, Modes.OFF, 0)
command = PusTelecommand(service=200, subservice=1, ssc=43, app_data=mode_data) command = PusTelecommand(service=200, subservice=1, ssc=43, app_data=mode_data)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.GET_TM: if op_code in OpCodesDevs.GET_TM:
tc_queue.appendleft( tc_queue.appendleft((QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.GET_TM}"))
(QueueCommands.PRINT, "Reaction Wheel: Send get-telemetry-command") 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()) tc_queue.appendleft(command.pack_command_tuple())
return tc_queue 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: 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 """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 object_id: The object id of the reaction wheel handler.
:param speed Valid speeds are [-65000, -1000] and [1000, 65000]. Values are :param speed: Valid speeds are [-65000, -1000] and [1000, 65000]. Values are
specified in 0.1 * RPM 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 Valid times are 10 - 10000 ms
""" """
command_id = RwCommandIds.SET_SPEED command_id = RwCommandIds.SET_SPEED

View File

@ -148,19 +148,19 @@ def pack_service_queue_user(
) )
if service == CustomServiceList.REACTION_WHEEL_1.value: if service == CustomServiceList.REACTION_WHEEL_1.value:
return pack_single_rw_test_into( return pack_single_rw_test_into(
object_id=RW1_ID, tc_queue=service_queue, op_code=op_code object_id=RW1_ID, rw_idx=1, tc_queue=service_queue, op_code=op_code
) )
if service == CustomServiceList.REACTION_WHEEL_2.value: if service == CustomServiceList.REACTION_WHEEL_2.value:
return pack_single_rw_test_into( return pack_single_rw_test_into(
object_id=RW2_ID, tc_queue=service_queue, op_code=op_code object_id=RW2_ID, rw_idx=2, tc_queue=service_queue, op_code=op_code
) )
if service == CustomServiceList.REACTION_WHEEL_3.value: if service == CustomServiceList.REACTION_WHEEL_3.value:
return pack_single_rw_test_into( return pack_single_rw_test_into(
object_id=RW3_ID, tc_queue=service_queue, op_code=op_code object_id=RW3_ID, rw_idx=3, tc_queue=service_queue, op_code=op_code
) )
if service == CustomServiceList.REACTION_WHEEL_4.value: if service == CustomServiceList.REACTION_WHEEL_4.value:
return pack_single_rw_test_into( return pack_single_rw_test_into(
object_id=RW4_ID, tc_queue=service_queue, op_code=op_code object_id=RW4_ID, rw_idx=4, tc_queue=service_queue, op_code=op_code
) )
if service == CustomServiceList.RAD_SENSOR.value: if service == CustomServiceList.RAD_SENSOR.value:
object_id = RAD_SENSOR_ID object_id = RAD_SENSOR_ID

View File

@ -88,6 +88,10 @@ def handle_regular_hk_print(
return handle_pdu_data( return handle_pdu_data(
printer=printer, pdu_idx=2, set_id=set_id, hk_data=hk_data printer=printer, pdu_idx=2, set_id=set_id, hk_data=hk_data
) )
if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
return handle_rw_hk_data(
printer=printer, object_id=object_id, set_id=set_id, hk_data=hk_data
)
if objb == obj_ids.P60_DOCK_HANDLER: if objb == obj_ids.P60_DOCK_HANDLER:
handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data)
if objb == obj_ids.PL_PCDU_ID: if objb == obj_ids.PL_PCDU_ID:
@ -707,10 +711,10 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
def handle_rw_hk_data( def handle_rw_hk_data(
printer: FsfwTmTcPrinter, object_id: ObjectId, set_id: int, hk_data: bytes printer: FsfwTmTcPrinter, object_id: ObjectId, set_id: int, hk_data: bytes
): ):
from pus_tc.devs.rws import SetIds from pus_tc.devs.reaction_wheels import RwSetIds
current_idx = 0 current_idx = 0
if set_id == SetIds.TEMP_SET: if set_id == RwSetIds.TEMPERATURE_SET_ID:
log_to_both( log_to_both(
printer, printer,
f"Received Temperature HK (ID {set_id}) from Reaction Wheel {object_id.name}", f"Received Temperature HK (ID {set_id}) from Reaction Wheel {object_id.name}",
@ -718,7 +722,7 @@ def handle_rw_hk_data(
temp = struct.unpack("!I", hk_data[0:4]) temp = struct.unpack("!I", hk_data[0:4])
log_to_both(printer, f"Temperature {temp}") log_to_both(printer, f"Temperature {temp}")
current_idx += 4 current_idx += 4
if set_id == SetIds.STATUS: if set_id == RwSetIds.STATUS_SET_ID:
log_to_both( log_to_both(
printer, printer,
f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}", f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}",
@ -733,7 +737,7 @@ def handle_rw_hk_data(
printer, printer,
f"Speed {speed} rpm | Reference Speed {ref_speed} rpm | State {state} | CLC Mode {clc_mode}", f"Speed {speed} rpm | Reference Speed {ref_speed} rpm | State {state} | CLC Mode {clc_mode}",
) )
if set_id == SetIds.LAST_RESET: if set_id == RwSetIds.LAST_RESET:
log_to_both( log_to_both(
printer, printer,
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}", f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}",
@ -748,7 +752,7 @@ def handle_rw_hk_data(
printer, printer,
f"Last Reset Status {last_reset_status} | Current Reset Status {curr_reset_status}", f"Last Reset Status {last_reset_status} | Current Reset Status {curr_reset_status}",
) )
if set_id == SetIds.TM_SET: if set_id == RwSetIds.TM_SET:
log_to_both( log_to_both(
printer, printer,
f"Received TM HK (ID {set_id}) from Reaction Wheel {object_id.name}", f"Received TM HK (ID {set_id}) from Reaction Wheel {object_id.name}",

@ -1 +1 @@
Subproject commit ea2992372f1ece7a9dab297ae390a5ab729e8f04 Subproject commit 9f566a739ab91ed8f461cdbb6a3179faf912e4e0