cleaned up structure a bit
This commit is contained in:
73
pus_tc/devs/tmp1075.py
Normal file
73
pus_tc/devs/tmp1075.py
Normal file
@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@file tmp1075.py
|
||||
@brief TMP1075 tests
|
||||
@author J. Meier
|
||||
@date 06.01.2021
|
||||
"""
|
||||
from tmtccmd.config.definitions import QueueCommands
|
||||
|
||||
from tmtccmd.tc.packer import TcQueueT
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
from pus_tc.service_200_mode import pack_mode_data
|
||||
|
||||
|
||||
class Tmp1075TestProcedure:
|
||||
"""
|
||||
@brief Use this class to define the tests to perform for the Tmp1075.
|
||||
@details Setting all to True will run all tests.
|
||||
Setting all to False will only run the tests set to True.
|
||||
"""
|
||||
|
||||
all = False
|
||||
start_adc_conversion = False
|
||||
get_temp = False
|
||||
set_mode_normal = (
|
||||
True # Setting mode to normal starts continuous temperature reading
|
||||
)
|
||||
set_mode_on = False # If mode is MODE_ON, temperature will only be read on command
|
||||
|
||||
|
||||
class Tmp1075ActionIds:
|
||||
get_temp = bytearray([0x0, 0x0, 0x0, 0x01])
|
||||
start_adc_conversion = bytearray([0x0, 0x0, 0x0, 0x02])
|
||||
|
||||
|
||||
def pack_tmp1075_test_into(
|
||||
object_id: bytearray, op_code: str, tc_queue: TcQueueT
|
||||
) -> TcQueueT:
|
||||
tc_queue.appendleft(
|
||||
(
|
||||
QueueCommands.PRINT,
|
||||
"Testing Tmp1075 Temperature Sensor Handler with object id: 0x"
|
||||
+ object_id.hex(),
|
||||
)
|
||||
)
|
||||
|
||||
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion:
|
||||
tc_queue.appendleft(
|
||||
(QueueCommands.PRINT, "TMP1075: Starting new temperature conversion")
|
||||
)
|
||||
command = object_id + Tmp1075ActionIds.start_adc_conversion
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Read temperature"))
|
||||
command = object_id + Tmp1075ActionIds.get_temp
|
||||
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if Tmp1075TestProcedure.set_mode_normal:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Set Mode Normal"))
|
||||
mode_data = pack_mode_data(object_id, 2, 0)
|
||||
command = PusTelecommand(service=200, subservice=1, ssc=220, app_data=mode_data)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
if Tmp1075TestProcedure.set_mode_on:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Set Mode On"))
|
||||
mode_data = pack_mode_data(object_id, 1, 0)
|
||||
command = PusTelecommand(service=200, subservice=1, ssc=221, app_data=mode_data)
|
||||
tc_queue.appendleft(command.pack_command_tuple())
|
||||
|
||||
return tc_queue
|
Reference in New Issue
Block a user