Heater Commands #63

Merged
muellerr merged 10 commits from mueller/heater-cmds into develop 2022-05-05 14:32:42 +02:00
3 changed files with 66 additions and 32 deletions
Showing only changes of commit 79d6e15c55 - Show all commits

View File

@ -7,6 +7,7 @@ from tmtccmd.config import (
OpCodeDictKeys,
)
from config.definitions import CustomServiceList
from pus_tc.devs.heater import add_heater_cmds
from pus_tc.devs.bpx_batt import BpxOpCodes
@ -26,6 +27,8 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
add_gps_cmds(cmd_dict=service_op_code_dict)
add_str_cmds(cmd_dict=service_op_code_dict)
add_ccsds_cmds(cmd_dict=service_op_code_dict)
add_pdec_cmds(cmd_dict=service_op_code_dict)
add_heater_cmds(cmd_dict=service_op_code_dict)
add_tmp_sens_cmds(cmd_dict=service_op_code_dict)
@ -39,14 +42,6 @@ def add_tmp_sens_cmds(cmd_dict: ServiceOpCodeDictT):
cmd_dict[CustomServiceList.TMP1075_2.value] = service_tuple
def add_heater_cmds(cmd_dict: ServiceOpCodeDictT):
op_code_dict_srv_heater = {
"0": ("Heater Tests", {OpCodeDictKeys.TIMEOUT: 2.0}),
}
service_heater_tuple = ("Heater Device", op_code_dict_srv_heater)
cmd_dict[CustomServiceList.HEATER.value] = service_heater_tuple
def add_pdec_cmds(cmd_dict: ServiceOpCodeDictT):
op_code_dict_srv_pdec_handler = {
"0": ("PDEC Handler: Print CLCW", {OpCodeDictKeys.TIMEOUT: 2.0}),

View File

@ -1,11 +1,14 @@
# -*- coding: utf-8 -*-
"""
@file tmtcc_tc_heater.py
@brief Command sequence to test the HeaterHandler
"""Command sequence to test the HeaterHandler
@author J. Meier
@date 30.01.2021
"""
from tmtccmd.config.definitions import QueueCommands
import enum
from config.definitions import CustomServiceList
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc.service_8_functional_cmd import generate_action_command
from tmtccmd.config.globals import add_service_op_code_entry, add_op_code_entry
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
@ -22,38 +25,74 @@ class SwitchNumbers:
NUMBER_OF_SWITCHES = 8
class ActionIds:
SWITCH_HEATER = bytearray([0x0, 0x0, 0x0, 0x0])
class OpCodes:
HEATER_CMD = ["0", "heater-cmd"]
def pack_heater_test_into(object_id: bytearray, tc_queue: TcQueueT):
tc_queue.appendleft((QueueCommands.PRINT, "Testing Heater Switching"))
class Info:
HEATER_CMD = "Heater Switch Command"
heater_number = int(input("Type number of heater to switch [0-7]: "))
if heater_number >= SwitchNumbers.NUMBER_OF_SWITCHES or heater_number < 0:
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)
class ActionIds(enum.IntEnum):
SWITCH_HEATER = 0
def add_heater_cmds(cmd_dict: ServiceOpCodeDictT):
op_code_dict = dict()
add_op_code_entry(
op_code_dict=op_code_dict, keys=OpCodes.HEATER_CMD, info=Info.HEATER_CMD
)
add_service_op_code_entry(
srv_op_code_dict=cmd_dict,
name=CustomServiceList.HEATER.value,
info="Heater Device",
op_code_entry=op_code_dict,
)
def pack_heater_cmds(object_id: bytearray, tc_queue: TcQueueT):
tc_queue.appendleft((QueueCommands.PRINT, "Heater Switching"))
while True:
heater_number = input("Type number of heater to switch [0-7]: ")
if not heater_number.isdigit():
print("Heater number not a digit")
continue
heater_number = int(heater_number)
if heater_number >= SwitchNumbers.NUMBER_OF_SWITCHES or heater_number < 0:
print("Invalid heater switch number")
continue
break
while True:
action = input("Turn switch on or off? (0 - off, 1 - on): ")
if not action.isdigit():
print("Switch action not valid")
continue
action = int(action)
if action != 0 and action != 1:
print("Invalid action defined. Must be 0 (off) or 1 (on")
continue
break
if action == 1:
act_str = "on"
else:
act_str = "off"
debug_string = f"Switching heater {heater_number} {act_str}"
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())
def pack_switch_heater_command(
object_id: bytearray, switch_nr: int, switch_action: int
) -> bytearray:
object_id: bytes, switch_nr: int, switch_action: int
) -> PusTelecommand:
"""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 = bytearray()
command += object_id + action_id
command.append(switch_nr)
command.append(switch_action)
return command
return generate_action_command(
object_id=object_id, action_id=ActionIds.SWITCH_HEATER, app_data=command
)

View File

@ -26,7 +26,7 @@ from pus_tc.devs.imtq import pack_imtq_test_into
from pus_tc.devs.tmp1075 import pack_tmp1075_test_into
from pus_tc.devs.ploc_mpsoc import pack_ploc_mpsoc_commands
from pus_tc.devs.ploc_supervisor import pack_ploc_supv_commands
from pus_tc.devs.heater import pack_heater_test_into
from pus_tc.devs.heater import pack_heater_cmds
from pus_tc.devs.reaction_wheels import pack_single_rw_test_into
from pus_tc.devs.rad_sensor import pack_rad_sensor_test_into
from pus_tc.devs.ploc_upater import pack_ploc_updater_test_into
@ -134,7 +134,7 @@ def pack_service_queue_user(
)
if service == CustomServiceList.HEATER.value:
object_id = HEATER_ID
return pack_heater_test_into(object_id=object_id, tc_queue=service_queue)
return pack_heater_cmds(object_id=object_id, tc_queue=service_queue)
if service == CustomServiceList.IMTQ.value:
object_id = IMTQ_HANDLER_ID
return pack_imtq_test_into(