changed controller commanding to allow more flexibility

This commit is contained in:
2022-05-17 22:11:31 +02:00
parent 73c8e95dce
commit 476066a5ac
2 changed files with 36 additions and 27 deletions

View File

@ -1,35 +1,44 @@
from tmtccmd.tc.definitions import TcQueueT, QueueCommands
from tmtccmd.tc.pus_200_fsfw_modes import Modes
from ast import Pass
from tmtccmd.tc.definitions import TcQueueT
from .common import command_mode
import config.object_ids as obj_ids
class OpCodes:
THERMAL_CONTROLLER_NORMAL = ["0", "thermal-normal"]
THERMAL_CONTROLLER_OFF = ["1", "thermal-off"]
THERMAL_CONTROLLER = [obj_ids.THERMAL_CONTROLLER_ID.hex(), "thermal_controller"]
CORE_CONTROLLER = [obj_ids.CORE_CONTROLLER_ID.hex(), "core_controller"]
class Info:
THERMAL_CONTROLLER_NORMAL = "Switching Thermal Controller into normal"
THERMAL_CONTROLLER_OFF = "Switching Thermal Controller off"
THERMAL_CONTROLLER = "Thermal controller"
CORE_CONTROLLER = "ACS controller"
def pack_controller_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.THERMAL_CONTROLLER_NORMAL:
command_mode(
object_id=obj_ids.THERMAL_CONTROLLER_ID,
mode=Modes.NORMAL,
submode=0,
tc_queue=tc_queue,
info=Info.THERMAL_CONTROLLER_NORMAL,
)
if op_code in OpCodes.THERMAL_CONTROLLER_OFF:
command_mode(
object_id=obj_ids.THERMAL_CONTROLLER_ID,
mode=Modes.OFF,
submode=0,
tc_queue=tc_queue,
info=Info.THERMAL_CONTROLLER_OFF,
)
mode = int(input("Specify mode: (OFF = 0; ON = 1; NORMAL = 2) [2] ") or "2")
print(mode)
if mode < 0 or mode > 2:
print("Invalid Mode, defaulting to OFF")
mode = 0
submode = int(input("Specify submode [0]: ") or "0")
command_mode(
object_id=get_object_from_op_code(op_code),
mode=mode,
submode=submode,
tc_queue=tc_queue,
info=op_code + " to " + str(mode) + "," + str(submode),
)
def get_object_from_op_code(op_code: str):
try:
return bytes.fromhex(op_code)
except:
pass
if op_code in OpCodes.THERMAL_CONTROLLER:
return obj_ids.THERMAL_CONTROLLER_ID
if op_code in OpCodes.CORE_CONTROLLER:
return obj_ids.CORE_CONTROLLER_ID