2021-07-01 11:52:25 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file rad_sensor.py
|
|
|
|
@brief Tests for the radiation sensor handler
|
|
|
|
@author J. Meier
|
|
|
|
@date 01.07.2021
|
|
|
|
"""
|
2022-03-31 11:36:50 +02:00
|
|
|
import struct
|
|
|
|
|
2021-07-01 11:52:25 +02:00
|
|
|
from tmtccmd.config.definitions import QueueCommands
|
|
|
|
|
2021-07-24 14:58:47 +02:00
|
|
|
from tmtccmd.tc.packer import TcQueueT
|
2021-10-01 10:55:56 +02:00
|
|
|
from spacepackets.ecss.tc import PusTelecommand
|
2022-05-05 16:23:17 +02:00
|
|
|
from pus_tc.service_200_mode import pack_mode_data, Modes
|
2021-07-01 11:52:25 +02:00
|
|
|
|
|
|
|
|
2022-03-31 11:36:50 +02:00
|
|
|
class CommandIds:
|
|
|
|
START_CONVERSIONS = 2
|
|
|
|
READ_CONVERSIONS = 3
|
|
|
|
ENABLE_DEBUG_OUTPUT = 4
|
|
|
|
DISABLE_DEBUG_OUTPUT = 5
|
|
|
|
|
|
|
|
|
2022-03-04 11:56:42 +01:00
|
|
|
def pack_rad_sensor_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
|
2021-07-01 11:52:25 +02:00
|
|
|
tc_queue.appendleft(
|
2022-01-18 14:03:56 +01:00
|
|
|
(
|
|
|
|
QueueCommands.PRINT,
|
|
|
|
"Testing radiation sensor handler with object id: 0x" + object_id.hex(),
|
|
|
|
)
|
2021-07-01 11:52:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if op_code == "0":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode on"))
|
2022-05-05 16:23:17 +02:00
|
|
|
mode_data = pack_mode_data(object_id, Modes.ON, 0)
|
2021-07-01 11:52:25 +02:00
|
|
|
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"))
|
2022-05-05 16:23:17 +02:00
|
|
|
mode_data = pack_mode_data(object_id, Modes.NORMAL, 0)
|
2021-07-01 11:52:25 +02:00
|
|
|
command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
|
|
|
|
if op_code == "2":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Switch to mode off"))
|
2022-05-05 16:23:17 +02:00
|
|
|
mode_data = pack_mode_data(object_id, Modes.OFF, 0)
|
2021-07-01 11:52:25 +02:00
|
|
|
command = PusTelecommand(service=200, subservice=1, ssc=42, app_data=mode_data)
|
2022-01-18 14:03:56 +01:00
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-31 11:36:50 +02:00
|
|
|
|
|
|
|
if op_code == "3":
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Start conversions"))
|
2022-04-04 13:53:26 +02:00
|
|
|
command = object_id + struct.pack("!I", CommandIds.START_CONVERSIONS)
|
2022-03-31 11:36:50 +02:00
|
|
|
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"))
|
2022-04-04 13:53:26 +02:00
|
|
|
command = object_id + struct.pack("!I", CommandIds.READ_CONVERSIONS)
|
2022-03-31 11:36:50 +02:00
|
|
|
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"))
|
2022-04-04 13:53:26 +02:00
|
|
|
command = object_id + struct.pack("!I", CommandIds.ENABLE_DEBUG_OUTPUT)
|
2022-03-31 11:36:50 +02:00
|
|
|
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"))
|
2022-04-04 13:53:26 +02:00
|
|
|
command = object_id + struct.pack("!I", CommandIds.DISABLE_DEBUG_OUTPUT)
|
2022-03-31 11:36:50 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|