eive-tmtc/pus_tc/tmtcc_tc_heater.py

60 lines
2.1 KiB
Python
Raw Normal View History

2021-02-06 16:35:53 +01:00
# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_heater.py
@brief Command sequence to test the HeaterHandler
@author J. Meier
@date 30.01.2021
"""
2021-02-11 08:18:42 +01:00
from tmtc_core.core.tmtc_core_definitions import QueueCommands
2021-02-06 16:35:53 +01:00
from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT
from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand
class TestProcedure:
"""
@brief The variables in this class can be used to configure the heater test procedure.
"""
2021-02-11 08:18:42 +01:00
on = False # All heaters will be turned on
off = True # All heaters will be turned off
2021-02-06 16:35:53 +01:00
class SwitchNumbers:
PAYLOAD_CAMERA_HEATER = 0
class SwitchActions:
OFF = 0
ON = 1
class ActionIds:
SWITCH_HEATER = bytearray([0x0, 0x0, 0x0, 0x0])
def pack_heater_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
2021-02-11 08:18:42 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing Heater Switching"))
2021-02-06 16:35:53 +01:00
if TestProcedure.on:
2021-02-11 08:18:42 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Switching on heater of payload camera"))
2021-02-06 16:35:53 +01:00
command = pack_switch_heater_command(object_id, SwitchNumbers.PAYLOAD_CAMERA_HEATER, SwitchActions.ON)
command = PusTelecommand(service=8, subservice=128, ssc=300, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if TestProcedure.off:
2021-02-11 08:18:42 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Switching off heater of payload camera"))
2021-02-06 16:35:53 +01:00
command = pack_switch_heater_command(object_id, SwitchNumbers.PAYLOAD_CAMERA_HEATER, SwitchActions.OFF)
command = PusTelecommand(service=8, subservice=128, ssc=301, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
def pack_switch_heater_command(object_id: bytearray, switch_nr: int, switch_action: int) -> bytearray:
""" Function to generate the command switch a heater
@param object_id The object id of the HeaterHandler object.
@param switch_nr The switch number identifying the heater to switch
@param switch_action Action to perform. 0 - Sets switch off, 1 - Sets switch on.
"""
action_id = ActionIds.SWITCH_HEATER
command = object_id + action_id
command.append(switch_nr)
command.append(switch_action)
return command