rad sensor reading works
This commit is contained in:
@ -7,17 +7,39 @@
|
||||
"""
|
||||
import struct
|
||||
|
||||
from tmtccmd.config.definitions import QueueCommands
|
||||
from config.definitions import CustomServiceList
|
||||
from tmtccmd.config import add_op_code_entry, add_service_op_code_entry
|
||||
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT, OpCodeDictKeys
|
||||
|
||||
from tmtccmd.tc.packer import TcQueueT
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
from pus_tc.service_200_mode import pack_mode_data, Modes
|
||||
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
|
||||
from tmtccmd.utility import ObjectId
|
||||
|
||||
|
||||
class SetIds:
|
||||
HK = 3
|
||||
|
||||
|
||||
class OpCodes:
|
||||
ON = ["0", "on"]
|
||||
NORMAL = ["1", "normal"]
|
||||
OFF = ["2", "off"]
|
||||
REQ_HK_ONCE = ["3", "hk-os"]
|
||||
DEBUG_ON = ["10", "dbg-on"]
|
||||
DEBUG_OFF = ["11", "dbg-off"]
|
||||
|
||||
|
||||
class Info:
|
||||
ON = "Switch Rad Sensor on"
|
||||
NORMAL = "Switch Rad Sensor normal"
|
||||
OFF = "Switch Rad sensor off"
|
||||
REQ_OS_HK = "Request one-shot HK"
|
||||
DEBUG_ON = "Switch debug output on"
|
||||
DEBUG_OFF = "Switch debug output off"
|
||||
|
||||
|
||||
class CommandIds:
|
||||
START_CONVERSIONS = 2
|
||||
READ_CONVERSIONS = 3
|
||||
@ -25,52 +47,64 @@ class CommandIds:
|
||||
DISABLE_DEBUG_OUTPUT = 5
|
||||
|
||||
|
||||
def pack_rad_sensor_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
|
||||
tc_queue.appendleft(
|
||||
(
|
||||
QueueCommands.PRINT,
|
||||
"Testing radiation sensor handler with object id: 0x" + object_id.hex(),
|
||||
)
|
||||
def add_rad_sens_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
|
||||
op_code_dict = dict()
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=Info.ON, keys=OpCodes.ON)
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=Info.OFF, keys=OpCodes.OFF)
|
||||
add_op_code_entry(op_code_dict=op_code_dict, info=Info.NORMAL, keys=OpCodes.NORMAL)
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, info=Info.REQ_OS_HK, keys=OpCodes.REQ_HK_ONCE
|
||||
)
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, info=Info.DEBUG_ON, keys=OpCodes.DEBUG_ON
|
||||
)
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, info=Info.DEBUG_OFF, keys=OpCodes.DEBUG_OFF
|
||||
)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
name=CustomServiceList.RAD_SENSOR.value,
|
||||
info="Radiation Sensor",
|
||||
op_code_entry=op_code_dict,
|
||||
)
|
||||
|
||||
if op_code == "0":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode 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 == "1":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode normal"))
|
||||
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())
|
||||
def pack_rad_sensor_test_into(object_id: ObjectId, tc_queue: TcQueueT, op_code: str):
|
||||
tc_queue.appendleft(
|
||||
(QueueCommands.PRINT, f"Commanding Radiation sensor handler {object_id}")
|
||||
)
|
||||
|
||||
if op_code == "2":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode off"))
|
||||
mode_data = pack_mode_data(object_id, Modes.OFF, 0)
|
||||
command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data)
|
||||
if op_code in OpCodes.ON:
|
||||
rad_sensor_mode_cmd(object_id, Modes.ON, Info.ON, tc_queue)
|
||||
if op_code in OpCodes.NORMAL:
|
||||
rad_sensor_mode_cmd(object_id, Modes.NORMAL, Info.NORMAL, tc_queue)
|
||||
if op_code in OpCodes.OFF:
|
||||
rad_sensor_mode_cmd(object_id, Modes.OFF, Info.OFF, tc_queue)
|
||||
if op_code in OpCodes.REQ_HK_ONCE:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, f"Rad sensor: {Info.REQ_OS_HK}"))
|
||||
cmd = generate_one_hk_command(
|
||||
sid=make_sid(object_id.as_bytes, set_id=SetIds.HK), ssc=0
|
||||
)
|
||||
tc_queue.appendleft(cmd.pack_command_tuple())
|
||||
if op_code in OpCodes.DEBUG_ON:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, f"Rad sensor: {Info.DEBUG_ON}"))
|
||||
command = object_id.as_bytes + struct.pack("!I", CommandIds.ENABLE_DEBUG_OUTPUT)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if op_code == "3":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Start conversions"))
|
||||
command = object_id + struct.pack("!I", CommandIds.START_CONVERSIONS)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if op_code == "4":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Read conversions"))
|
||||
command = object_id + struct.pack("!I", CommandIds.READ_CONVERSIONS)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if op_code == "5":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Enable debug output"))
|
||||
command = object_id + struct.pack("!I", CommandIds.ENABLE_DEBUG_OUTPUT)
|
||||
if op_code in OpCodes.DEBUG_OFF:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, f"Rad sensor: {Info.DEBUG_OFF}"))
|
||||
command = object_id.as_bytes + struct.pack(
|
||||
"!I", CommandIds.DISABLE_DEBUG_OUTPUT
|
||||
)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if op_code == "6":
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Disable debug output"))
|
||||
command = object_id + struct.pack("!I", CommandIds.DISABLE_DEBUG_OUTPUT)
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
def rad_sensor_mode_cmd(
|
||||
object_id: ObjectId, mode: Modes, info: str, tc_queue: TcQueueT
|
||||
):
|
||||
tc_queue.appendleft((QueueCommands.PRINT, f"Rad sensor: {info}"))
|
||||
mode_data = pack_mode_data(object_id.as_bytes, mode, 0)
|
||||
command = PusTelecommand(service=200, subservice=1, ssc=41, app_data=mode_data)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
Reference in New Issue
Block a user