# -*- coding: utf-8 -*- """ @file tmtcc_tc_heater.py @brief Command sequence to test the HeaterHandler @author J. Meier @date 30.01.2021 """ from tmtc_core.core.tmtc_core_definitions import QueueCommands 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. """ on = False # All heaters will be turned on off = True # All heaters will be turned off 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: tc_queue.appendleft((QueueCommands.PRINT, "Testing Heater Switching")) if TestProcedure.on: tc_queue.appendleft((QueueCommands.PRINT, "Switching on heater of payload camera")) 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: tc_queue.appendleft((QueueCommands.PRINT, "Switching off heater of payload camera")) 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