2022-08-11 19:12:27 +02:00
|
|
|
from typing import Union
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
2023-01-31 12:56:13 +01:00
|
|
|
from tmtccmd.tc.pus_200_fsfw_mode import Mode
|
2022-08-11 19:12:27 +02:00
|
|
|
from tmtccmd.util import ObjectIdU32, ObjectIdBase
|
2022-05-17 22:11:31 +02:00
|
|
|
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
|
|
|
import eive_tmtc.config.object_ids as obj_ids
|
2022-05-17 10:41:45 +02:00
|
|
|
|
2022-05-22 21:29:09 +02:00
|
|
|
|
2023-01-16 14:13:06 +01:00
|
|
|
class OpCode:
|
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"]
|
2022-05-17 10:41:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Info:
|
2022-05-17 22:11:31 +02:00
|
|
|
THERMAL_CONTROLLER = "Thermal controller"
|
|
|
|
CORE_CONTROLLER = "ACS controller"
|
2022-05-17 10:41:45 +02:00
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_cmd_ctrl_to_prompted_mode(
|
|
|
|
q: DefaultPusQueueHelper, object_id: ObjectIdU32, gui: bool
|
|
|
|
):
|
2022-12-01 14:41:28 +01:00
|
|
|
from eive_tmtc.pus_tc.prompt_parameters import (
|
|
|
|
prompt_parameters_cli,
|
|
|
|
)
|
2022-12-02 11:47:00 +01:00
|
|
|
|
2022-07-05 02:12:54 +02:00
|
|
|
param_list = [
|
|
|
|
{"name": "Mode", "defaultValue": "2"},
|
|
|
|
{"name": "Submode", "defaultValue": "0"},
|
|
|
|
]
|
|
|
|
if gui:
|
2022-12-01 14:41:28 +01:00
|
|
|
from eive_tmtc.pus_tc.prompt_parameters import prompt_parameters_gui
|
2022-12-02 11:47:00 +01:00
|
|
|
|
2022-07-05 02:12:54 +02:00
|
|
|
parameters = prompt_parameters_gui(param_list)
|
|
|
|
else:
|
|
|
|
parameters = prompt_parameters_cli(param_list)
|
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:
|
2022-05-17 22:11:31 +02:00
|
|
|
print("Invalid Mode, defaulting to OFF")
|
|
|
|
mode = 0
|
2022-05-22 21:29:09 +02:00
|
|
|
submode = int(parameters["Submode"])
|
2022-10-04 14:46:00 +02:00
|
|
|
pack_mode_cmd_with_info(
|
2022-05-27 11:53:57 +02:00
|
|
|
object_id=object_id.as_bytes,
|
2022-05-17 22:11:31 +02:00
|
|
|
mode=mode,
|
|
|
|
submode=submode,
|
2022-07-04 17:59:09 +02:00
|
|
|
q=q,
|
2022-05-27 11:53:57 +02:00
|
|
|
info=f"Commanding {object_id} to {mode}, {submode}",
|
2022-05-17 22:11:31 +02:00
|
|
|
)
|
|
|
|
|
2022-05-23 00:20:06 +02:00
|
|
|
|
2022-08-11 19:12:27 +02:00
|
|
|
def pack_cmd_ctrl_to_off(
|
|
|
|
q: DefaultPusQueueHelper, object_id: Union[ObjectIdBase, ObjectIdU32]
|
|
|
|
):
|
2022-10-04 14:46:00 +02:00
|
|
|
pack_mode_cmd_with_info(
|
2022-05-27 11:53:57 +02:00
|
|
|
object_id=object_id.as_bytes,
|
2023-01-16 15:05:33 +01:00
|
|
|
mode=Mode.OFF,
|
2022-05-23 00:20:06 +02:00
|
|
|
submode=0,
|
2022-07-04 17:59:09 +02:00
|
|
|
q=q,
|
2022-05-27 11:53:57 +02:00
|
|
|
info=f"Commanding {object_id} OFF",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_cmd_ctrl_to_on(q: DefaultPusQueueHelper, object_id: ObjectIdU32):
|
2022-10-04 14:46:00 +02:00
|
|
|
pack_mode_cmd_with_info(
|
2022-05-27 11:53:57 +02:00
|
|
|
object_id=object_id.as_bytes,
|
2023-01-16 15:05:33 +01:00
|
|
|
mode=Mode.ON,
|
2022-05-27 11:53:57 +02:00
|
|
|
submode=0,
|
2022-07-04 17:59:09 +02:00
|
|
|
q=q,
|
2022-05-27 11:53:57 +02:00
|
|
|
info=f"Commanding {object_id} ON",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-08-11 19:12:27 +02:00
|
|
|
def pack_cmd_ctrl_to_nml(
|
|
|
|
q: DefaultPusQueueHelper, object_id: Union[ObjectIdBase, ObjectIdU32]
|
|
|
|
):
|
2022-10-04 14:46:00 +02:00
|
|
|
pack_mode_cmd_with_info(
|
2022-05-27 11:53:57 +02:00
|
|
|
object_id=object_id.as_bytes,
|
2023-01-16 15:05:33 +01:00
|
|
|
mode=Mode.NORMAL,
|
2022-05-27 11:53:57 +02:00
|
|
|
submode=0,
|
2022-07-04 17:59:09 +02:00
|
|
|
q=q,
|
2022-05-27 11:53:57 +02:00
|
|
|
info=f"Commanding {object_id} NORMAL",
|
2022-05-23 00:20:06 +02:00
|
|
|
)
|
|
|
|
|
2022-05-22 21:29:09 +02:00
|
|
|
|
2022-05-17 22:11:31 +02:00
|
|
|
def get_object_from_op_code(op_code: str):
|
|
|
|
try:
|
|
|
|
return bytes.fromhex(op_code)
|
2023-06-10 14:42:28 +02:00
|
|
|
except ValueError:
|
2022-05-17 22:11:31 +02:00
|
|
|
pass
|
2023-01-16 14:13:06 +01:00
|
|
|
if op_code in OpCode.THERMAL_CONTROLLER:
|
2022-05-17 22:11:31 +02:00
|
|
|
return obj_ids.THERMAL_CONTROLLER_ID
|
2023-01-16 14:13:06 +01:00
|
|
|
if op_code in OpCode.CORE_CONTROLLER:
|
2022-05-17 22:11:31 +02:00
|
|
|
return obj_ids.CORE_CONTROLLER_ID
|