eive-tmtc/eive_tmtc/config/hook.py
Robin Mueller e23b39e652
All checks were successful
EIVE/-/pipeline/head This commit looks good
EIVE/-/pipeline/pr-main This commit looks good
action reply update
2024-05-16 11:03:55 +02:00

162 lines
6.7 KiB
Python

from typing import Optional
from prompt_toolkit.history import FileHistory
from tmtccmd import CcsdsTmtcBackend, HookBase
from tmtccmd.com import ComInterface
from tmtccmd.config import CmdTreeNode
from tmtccmd.config.hook import History
from tmtccmd.util import ObjectIdDictT, RetvalDictT
from eive_tmtc.config.definitions import SPACE_PACKET_IDS
from eive_tmtc.config.retvals import get_retval_dict
from eive_tmtc.tmtc.acs.acs_board import create_acs_board_node
from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node
from eive_tmtc.tmtc.acs.gps import create_gnss_node
from eive_tmtc.tmtc.acs.gyros import create_gyros_node
from eive_tmtc.tmtc.acs.imtq import create_mgt_node
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,
)
from eive_tmtc.tmtc.acs.star_tracker import create_str_node
from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node
from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node
from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node
from eive_tmtc.tmtc.com.syrlinks_handler import create_syrlinks_node
from eive_tmtc.tmtc.core import create_core_node
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
from eive_tmtc.tmtc.payload.plpcdu import create_pl_pcdu_node
from eive_tmtc.tmtc.payload.scex import create_scex_node
from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node
from eive_tmtc.tmtc.power.acu import create_acu_node
from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node
from eive_tmtc.tmtc.power.p60dock import create_p60_dock_node
from eive_tmtc.tmtc.power.pdu1 import create_pdu1_node
from eive_tmtc.tmtc.power.pdu2 import create_pdu2_node
from eive_tmtc.tmtc.power.power import create_power_node
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
from eive_tmtc.tmtc.tcs.ctrl import create_tcs_ctrl_node
from eive_tmtc.tmtc.tcs.heater import create_heater_node
from eive_tmtc.tmtc.tcs.rtd import create_rtd_node
from eive_tmtc.tmtc.tcs.tmp1075 import create_tmp_sens_node
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
from eive_tmtc.tmtc.wdt import create_wdt_node
class EiveHookObject(HookBase):
def __init__(self, json_cfg_path: str):
super().__init__(json_cfg_path)
def get_command_definitions(self) -> CmdTreeNode:
root_node = CmdTreeNode.root_node()
acs_node = create_acs_subsystem_node()
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())
acs_ctrl = create_acs_ctrl_node()
rw_list = create_reaction_wheels_nodes()
rws = CmdTreeNode("rws", "Reaction Wheel Devices")
for rw in rw_list:
rws.add_child(rw)
rws.add_child(create_reaction_wheel_assembly_node())
star_tracker = create_str_node()
star_tracker_img_helper = CmdTreeNode(
"str_img_helper", "Star Tracker Image Helper"
)
star_tracker.add_child(star_tracker_img_helper)
gnss_devs = create_gnss_node()
acs_node.add_child(acs_brd_assy_node)
acs_node.add_child(acs_ctrl)
acs_node.add_child(rws)
acs_node.add_child(create_mgt_node())
acs_node.add_child(star_tracker)
acs_node.add_child(gnss_devs)
tcs_node = CmdTreeNode("tcs", "TCS Subsystem")
tmp_1075_node = create_tmp_sens_node()
rtds_node = create_rtd_node()
heaters_node = create_heater_node()
tcs_ctrl = create_tcs_ctrl_node()
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)
com_node = create_com_subsystem_node()
com_node.add_child(create_syrlinks_node())
com_node.add_child(create_ccsds_node())
eps_node = create_eps_subsystem_node()
eps_node.add_child(create_pwr_ctrl_node())
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())
eps_node.add_child(create_bpx_batt_node())
payload_node = create_payload_subsystem_node()
payload_node.add_child(create_pl_pcdu_node())
payload_node.add_child(create_scex_node())
payload_node.add_child(create_ploc_mpsoc_node())
payload_node.add_child(create_ploc_supv_node())
obdh_node = CmdTreeNode("obdh", "OBDH Subsystem")
obdh_node.add_child(create_wdt_node())
obdh_node.add_child(create_core_node())
obdh_node.add_child(create_time_node())
obdh_node.add_child(create_persistent_tm_store_node())
root_node.add_child(create_test_node())
root_node.add_child(create_system_node())
root_node.add_child(create_global_health_node())
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]:
from tmtccmd.config.com import (
create_com_interface_cfg_default,
create_com_interface_default,
)
assert self.cfg_path is not None
cfg = create_com_interface_cfg_default(
com_if_key=com_if_key,
json_cfg_path=self.cfg_path,
space_packet_ids=SPACE_PACKET_IDS,
)
assert cfg is not None
return create_com_interface_default(cfg)
def perform_mode_operation(self, tmtc_backend: CcsdsTmtcBackend, mode: int):
from eive_tmtc.config.custom_mode_op import custom_mode_operation
custom_mode_operation(tmtc_backend, mode)
def get_object_ids(self) -> ObjectIdDictT:
from eive_tmtc.config.object_ids import get_object_ids
return get_object_ids()
def get_retval_dict(self) -> RetvalDictT:
return get_retval_dict()
def get_cmd_history(self) -> Optional[History]:
return FileHistory(".tmtc-history.txt")