eive-tmtc/eive_tmtc/config/hook.py

171 lines
7.2 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-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-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
from eive_tmtc.tmtc.core import create_core_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-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
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.bpx_batt import create_bpx_batt_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.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
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()
mode_node = CmdTreeNode("mode", "Mode Commands")
hk_node = CmdTreeNode("hk", "HK Commands")
action_node = CmdTreeNode("action", "Action Commands")
param_node = CmdTreeNode("params", "Parameter Commands")
health_node = CmdTreeNode("health", "Health Commands")
dev_node = CmdTreeNode("dev", "Device Commands")
dev_node.add_child(hk_node)
dev_node.add_child(mode_node)
dev_node.add_child(health_node)
dev_node.add_child(param_node)
# Not strictly necessary, but I do not know a single device which does not have actions..
dev_node.add_child(action_node)
assy_node = CmdTreeNode("assy", "Assembly Commands")
assy_node.add_child(mode_node)
2021-05-17 17:42:04 +02:00
2023-11-22 13:51:33 +01:00
acs_node = create_acs_subsystem_node()
2023-11-22 10:17:05 +01:00
acs_brd_assy_node = CmdTreeNode("acs_brd_assy", "ACS Board Assembly")
acs_brd_assy_node.add_child(mode_node)
mgm_devs = CmdTreeNode("mgm_devs", "MGM Devices")
gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices")
acs_brd_assy_node.add_child(mgm_devs)
acs_brd_assy_node.add_child(gyro_devs)
2023-11-22 11:21:26 +01:00
acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller")
acs_ctrl.add_child(mode_node)
acs_ctrl.add_child(action_node)
acs_ctrl.add_child(param_node)
2023-11-22 10:17:05 +01:00
rws = CmdTreeNode("rws", "Reaction Wheel Devices")
rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly")
rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1")
rw_2 = CmdTreeNode("rw_2", "Reaction Wheel 2")
rw_3 = CmdTreeNode("rw_3", "Reaction Wheel 3")
rw_4 = CmdTreeNode("rw_4", "Reaction Wheel 4")
rws.add_child(rw_assy)
rws.add_child(rw_1)
rws.add_child(rw_2)
rws.add_child(rw_3)
rws.add_child(rw_4)
mgt = CmdTreeNode("mgt", "ISIS MGT")
mgt.add_child(dev_node)
mgt.add_child(assy_node)
star_tracker = CmdTreeNode("str", "Star Tracker")
star_tracker_img_helper = CmdTreeNode(
"str_img_helper", "Star Tracker Image Helper"
)
star_tracker.add_child(star_tracker_img_helper)
gnss_devs = CmdTreeNode("gnss", "GNSS Devices")
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(mode_node)
acs_node.add_child(rws)
acs_node.add_child(mgt)
acs_node.add_child(star_tracker)
acs_node.add_child(gnss_devs)
tcs_node = CmdTreeNode("tcs", "TCS Subsystem")
tmp_1075_node = CmdTreeNode("tmp1075_devs", "TMP1075 Devices")
rtds_node = CmdTreeNode("rtd_devs", "RTD Devices")
heaters_node = CmdTreeNode("heaters", "Heater Devices")
tcs_ctrl = CmdTreeNode("tcs_ctrl", "TCS Controller")
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()
2023-11-22 10:17:05 +01:00
acu_node = CmdTreeNode("acu", "PCDU ACU component")
pdu_1_node = CmdTreeNode("pdu1", "PCDU PDU 1 component")
pdu_2_node = CmdTreeNode("pdu2", "PCDU PDU 2 component")
p60_dock_node = CmdTreeNode("p60_dock", "PCDU P60 Dock component")
2023-11-22 13:51:33 +01:00
eps_node.add_child(create_pwr_ctrl_node())
2023-11-22 10:17:05 +01:00
eps_node.add_child(acu_node)
eps_node.add_child(pdu_1_node)
eps_node.add_child(pdu_2_node)
eps_node.add_child(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-22 10:17:05 +01:00
pl_pcdu = CmdTreeNode("pl_pcdu", "Payload PCDU")
payload_node.add_child(pl_pcdu)
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")
xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT")
obdh_node.add_child(xiphos_wdt)
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()