eive-tmtc/eive_tmtc/config/hook.py

162 lines
6.7 KiB
Python
Raw Normal View History

2022-07-04 18:14:51 +02:00
from typing import Optional
2021-03-19 17:39:52 +01:00
2023-11-28 17:24:25 +01:00
from prompt_toolkit.history import FileHistory
2023-11-22 13:51:33 +01:00
from tmtccmd import CcsdsTmtcBackend, HookBase
2023-01-31 12:56:13 +01:00
from tmtccmd.com import ComInterface
2023-11-22 10:17:05 +01:00
from tmtccmd.config import CmdTreeNode
2023-11-28 16:05:19 +01:00
from tmtccmd.config.hook import History
2023-11-22 13:51:33 +01:00
from tmtccmd.util import ObjectIdDictT, RetvalDictT
2021-05-17 17:59:24 +02:00
2023-11-22 13:51:33 +01:00
from eive_tmtc.config.definitions import SPACE_PACKET_IDS
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.retvals import get_retval_dict
2023-11-29 17:27:24 +01:00
from eive_tmtc.tmtc.acs.acs_board import create_acs_board_node
2023-11-28 17:24:25 +01:00
from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node
from eive_tmtc.tmtc.acs.gps import create_gnss_node
2023-11-29 17:27:24 +01:00
from eive_tmtc.tmtc.acs.gyros import create_gyros_node
2023-11-28 17:24:25 +01:00
from eive_tmtc.tmtc.acs.imtq import create_mgt_node
2023-11-29 17:27:24 +01:00
from eive_tmtc.tmtc.acs.mgms import create_mgms_node
from eive_tmtc.tmtc.acs.reaction_wheels import (
create_reaction_wheel_assembly_node,
create_reaction_wheels_nodes,
)
2023-11-28 17:41:46 +01:00
from eive_tmtc.tmtc.acs.star_tracker import create_str_node
2023-11-22 16:40:27 +01:00
from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node
from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node
2023-11-22 13:51:33 +01:00
from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node
2023-11-22 16:40:27 +01:00
from eive_tmtc.tmtc.com.syrlinks_handler import create_syrlinks_node
2023-11-28 17:24:25 +01:00
from eive_tmtc.tmtc.core import create_core_node
2023-11-22 13:51:33 +01:00
from eive_tmtc.tmtc.health import create_global_health_node
from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node
from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node
2023-11-28 17:34:34 +01:00
from eive_tmtc.tmtc.payload.plpcdu import create_pl_pcdu_node
2023-11-22 13:51:33 +01:00
from eive_tmtc.tmtc.payload.scex import create_scex_node
from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node
2023-11-29 17:04:30 +01:00
from eive_tmtc.tmtc.power.acu import create_acu_node
2023-11-29 17:27:24 +01:00
from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node
from eive_tmtc.tmtc.power.p60dock import create_p60_dock_node
2023-11-29 17:04:30 +01:00
from eive_tmtc.tmtc.power.pdu1 import create_pdu1_node
from eive_tmtc.tmtc.power.pdu2 import create_pdu2_node
2023-11-29 17:27:24 +01:00
from eive_tmtc.tmtc.power.power import create_power_node
2023-11-22 13:51:33 +01:00
from eive_tmtc.tmtc.power.pwr_ctrl import create_pwr_ctrl_node
from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node
from eive_tmtc.tmtc.system import create_system_node
2023-11-28 17:24:25 +01:00
from eive_tmtc.tmtc.tcs.ctrl import create_tcs_ctrl_node
from eive_tmtc.tmtc.tcs.heater import create_heater_node
2023-11-28 17:41:46 +01:00
from eive_tmtc.tmtc.tcs.rtd import create_rtd_node
from eive_tmtc.tmtc.tcs.tmp1075 import create_tmp_sens_node
2023-11-22 13:51:33 +01:00
from eive_tmtc.tmtc.test import create_test_node
from eive_tmtc.tmtc.time import create_time_node
from eive_tmtc.tmtc.tm_store import create_persistent_tm_store_node
2023-11-28 17:34:34 +01:00
from eive_tmtc.tmtc.wdt import create_wdt_node
2021-03-19 17:39:52 +01:00
2023-01-31 12:56:13 +01:00
class EiveHookObject(HookBase):
2022-04-06 11:43:17 +02:00
def __init__(self, json_cfg_path: str):
super().__init__(json_cfg_path=json_cfg_path)
2023-11-22 10:17:05 +01:00
def get_command_definitions(self) -> CmdTreeNode:
root_node = CmdTreeNode.root_node()
2023-11-22 13:51:33 +01:00
acs_node = create_acs_subsystem_node()
2023-11-29 17:27:24 +01:00
acs_brd_assy_node = create_acs_board_node()
acs_brd_assy_node.add_child(create_mgms_node())
acs_brd_assy_node.add_child(create_gyros_node())
2023-11-28 17:24:25 +01:00
acs_ctrl = create_acs_ctrl_node()
2023-11-29 17:27:24 +01:00
rw_list = create_reaction_wheels_nodes()
2023-11-22 10:17:05 +01:00
rws = CmdTreeNode("rws", "Reaction Wheel Devices")
2023-11-29 17:27:24 +01:00
for rw in rw_list:
rws.add_child(rw)
rws.add_child(create_reaction_wheel_assembly_node())
2023-11-28 17:41:46 +01:00
star_tracker = create_str_node()
2023-11-22 10:17:05 +01:00
star_tracker_img_helper = CmdTreeNode(
"str_img_helper", "Star Tracker Image Helper"
)
star_tracker.add_child(star_tracker_img_helper)
2023-11-28 17:24:25 +01:00
gnss_devs = create_gnss_node()
2023-11-22 10:17:05 +01:00
acs_node.add_child(acs_brd_assy_node)
2023-11-22 11:21:26 +01:00
acs_node.add_child(acs_ctrl)
2023-11-22 10:17:05 +01:00
acs_node.add_child(rws)
2023-11-28 17:24:25 +01:00
acs_node.add_child(create_mgt_node())
2023-11-22 10:17:05 +01:00
acs_node.add_child(star_tracker)
acs_node.add_child(gnss_devs)
tcs_node = CmdTreeNode("tcs", "TCS Subsystem")
2023-11-28 17:41:46 +01:00
tmp_1075_node = create_tmp_sens_node()
rtds_node = create_rtd_node()
2023-11-28 17:24:25 +01:00
heaters_node = create_heater_node()
tcs_ctrl = create_tcs_ctrl_node()
2023-11-22 10:17:05 +01:00
tcs_node.add_child(rtds_node)
tcs_node.add_child(tmp_1075_node)
tcs_node.add_child(tcs_ctrl)
tcs_node.add_child(heaters_node)
tcs_brd_assy = CmdTreeNode("tcs_brd_assy", "TCS Board Assembly")
tcs_node.add_child(tcs_brd_assy)
2023-11-22 13:51:33 +01:00
com_node = create_com_subsystem_node()
2023-11-22 16:40:27 +01:00
com_node.add_child(create_syrlinks_node())
com_node.add_child(create_ccsds_node())
2023-11-22 10:17:05 +01:00
2023-11-22 13:51:33 +01:00
eps_node = create_eps_subsystem_node()
eps_node.add_child(create_pwr_ctrl_node())
2023-11-29 17:04:30 +01:00
eps_node.add_child(create_power_node())
eps_node.add_child(create_acu_node())
eps_node.add_child(create_pdu1_node())
eps_node.add_child(create_pdu2_node())
eps_node.add_child(create_p60_dock_node())
2023-11-22 13:51:33 +01:00
eps_node.add_child(create_bpx_batt_node())
2023-11-22 10:17:05 +01:00
2023-11-22 13:51:33 +01:00
payload_node = create_payload_subsystem_node()
2023-11-28 17:34:34 +01:00
payload_node.add_child(create_pl_pcdu_node())
2023-11-22 11:21:26 +01:00
payload_node.add_child(create_scex_node())
payload_node.add_child(create_ploc_mpsoc_node())
payload_node.add_child(create_ploc_supv_node())
2023-11-22 10:17:05 +01:00
obdh_node = CmdTreeNode("obdh", "OBDH Subsystem")
2023-11-28 17:34:34 +01:00
obdh_node.add_child(create_wdt_node())
2023-11-22 16:40:27 +01:00
obdh_node.add_child(create_core_node())
2023-11-22 10:17:05 +01:00
obdh_node.add_child(create_time_node())
2023-11-22 13:51:33 +01:00
obdh_node.add_child(create_persistent_tm_store_node())
2023-11-22 10:17:05 +01:00
2023-11-22 13:51:33 +01:00
root_node.add_child(create_test_node())
root_node.add_child(create_system_node())
root_node.add_child(create_global_health_node())
2023-11-22 10:17:05 +01:00
root_node.add_child(acs_node)
root_node.add_child(tcs_node)
root_node.add_child(com_node)
root_node.add_child(eps_node)
root_node.add_child(payload_node)
root_node.add_child(obdh_node)
return root_node
def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]:
2023-01-31 12:56:13 +01:00
from tmtccmd.config.com import (
2023-11-22 11:21:26 +01:00
create_com_interface_cfg_default,
2023-11-22 13:51:33 +01:00
create_com_interface_default,
2022-08-08 16:32:18 +02:00
)
2022-01-18 14:03:56 +01:00
2023-11-22 10:17:05 +01:00
assert self.cfg_path is not None
2022-08-08 16:32:18 +02:00
cfg = create_com_interface_cfg_default(
2022-01-18 14:03:56 +01:00
com_if_key=com_if_key,
2022-09-16 17:28:19 +02:00
json_cfg_path=self.cfg_path,
2022-05-16 18:35:36 +02:00
space_packet_ids=SPACE_PACKET_IDS,
2021-05-17 17:42:04 +02:00
)
2023-11-22 10:17:05 +01:00
assert cfg is not None
2022-08-08 16:32:18 +02:00
return create_com_interface_default(cfg)
2021-03-19 17:39:52 +01:00
2022-07-04 18:14:51 +02:00
def perform_mode_operation(self, tmtc_backend: CcsdsTmtcBackend, mode: int):
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.custom_mode_op import custom_mode_operation
2022-01-18 14:03:56 +01:00
2022-07-05 02:12:54 +02:00
custom_mode_operation(tmtc_backend, mode)
2021-03-19 17:39:52 +01:00
2022-03-04 14:27:19 +01:00
def get_object_ids(self) -> ObjectIdDictT:
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.object_ids import get_object_ids
2022-03-04 14:44:13 +01:00
2021-05-17 17:42:04 +02:00
return get_object_ids()
2021-03-19 17:39:52 +01:00
2022-03-04 14:27:19 +01:00
def get_retval_dict(self) -> RetvalDictT:
return get_retval_dict()
2023-11-28 16:05:19 +01:00
def get_cmd_history(self) -> Optional[History]:
return FileHistory(".tmtc-history.txt")