eive-tmtc/pus_tc/system/controllers.py

83 lines
2.1 KiB
Python
Raw Normal View History

from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.config import QueueCommands
2022-05-27 11:53:57 +02:00
from tmtccmd.tc.pus_200_fsfw_modes import Modes
from tmtccmd.utility import ObjectId
from .common import command_mode
import config.object_ids as obj_ids
2022-05-22 21:29:09 +02:00
from pus_tc.prompt_parameters import prompt_parameters
class OpCodes:
2022-05-27 11:53:57 +02:00
THERMAL_CONTROLLER = [obj_ids.THERMAL_CONTROLLER_ID.hex(), "ctrl-th"]
CORE_CONTROLLER = [obj_ids.CORE_CONTROLLER_ID.hex(), "ctrl-core"]
class Info:
THERMAL_CONTROLLER = "Thermal controller"
CORE_CONTROLLER = "ACS controller"
2022-05-27 11:53:57 +02:00
def pack_cmd_ctrl_to_prompted_mode(tc_queue: TcQueueT, object_id: ObjectId):
2022-05-23 18:25:25 +02:00
parameters = prompt_parameters(
[
{"name": "Mode", "defaultValue": "2"},
{"name": "Submode", "defaultValue": "0"},
]
)
2022-05-22 21:29:09 +02:00
mode = int(parameters["Mode"])
2022-05-19 13:20:22 +02:00
if mode < 0 or mode > 2:
print("Invalid Mode, defaulting to OFF")
mode = 0
2022-05-22 21:29:09 +02:00
submode = int(parameters["Submode"])
command_mode(
2022-05-27 11:53:57 +02:00
object_id=object_id.as_bytes,
mode=mode,
submode=submode,
tc_queue=tc_queue,
2022-05-27 11:53:57 +02:00
info=f"Commanding {object_id} to {mode}, {submode}",
)
2022-05-27 11:53:57 +02:00
def pack_cmd_ctrl_to_off(tc_queue: TcQueueT, object_id: ObjectId):
command_mode(
2022-05-27 11:53:57 +02:00
object_id=object_id.as_bytes,
mode=Modes.OFF,
submode=0,
tc_queue=tc_queue,
2022-05-27 11:53:57 +02:00
info=f"Commanding {object_id} OFF",
)
def pack_cmd_ctrl_to_on(tc_queue: TcQueueT, object_id: ObjectId):
command_mode(
object_id=object_id.as_bytes,
mode=Modes.ON,
submode=0,
tc_queue=tc_queue,
info=f"Commanding {object_id} ON",
)
def pack_cmd_ctrl_to_nml(tc_queue: TcQueueT, object_id: ObjectId):
command_mode(
object_id=object_id.as_bytes,
mode=Modes.NORMAL,
submode=0,
tc_queue=tc_queue,
info=f"Commanding {object_id} NORMAL",
)
2022-05-22 21:29:09 +02:00
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