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-03-19 17:39:52 +01:00
|
|
|
from tmtccmd.core.definitions import QueueCommands
|
|
|
|
from tmtccmd.pus_tc.packer import TcQueueT
|
|
|
|
from tmtccmd.pus_tc.base import PusTelecommand
|
2021-02-06 16:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
class SwitchNumbers:
|
2021-02-14 09:37:28 +01:00
|
|
|
HEATER_0 = 0
|
|
|
|
HEATER_1 = 1
|
|
|
|
HEATER_2 = 2
|
|
|
|
HEATER_3 = 3
|
|
|
|
HEATER_4 = 4
|
|
|
|
HEATER_5 = 5
|
|
|
|
HEATER_6 = 6
|
|
|
|
HEATER_7 = 7
|
|
|
|
NUMBER_OF_SWITCHES = 8
|
2021-02-06 16:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ActionIds:
|
|
|
|
SWITCH_HEATER = bytearray([0x0, 0x0, 0x0, 0x0])
|
|
|
|
|
|
|
|
|
2021-03-19 17:39:52 +01:00
|
|
|
def pack_heater_test_into(object_id: bytearray, tc_queue: 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
|
|
|
|
2021-02-14 09:37:28 +01:00
|
|
|
heater_number = int(input("Type number of heater to switch: "))
|
|
|
|
if heater_number >= SwitchNumbers.NUMBER_OF_SWITCHES:
|
|
|
|
print("Invalid heater switch number")
|
|
|
|
return
|
|
|
|
action = int(input("Turn switch on or off? (0 - off, 1 - on): "))
|
|
|
|
if action != 0 and action != 1:
|
|
|
|
print("Invalid action defined. Must be 0 (off) or 1 (on")
|
|
|
|
debug_string = "Switching heater " + str(heater_number)
|
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, debug_string))
|
|
|
|
command = pack_switch_heater_command(object_id, heater_number, action)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=300, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2021-02-06 16:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|