eive-tmtc/config/hook.py

45 lines
1.5 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
2022-05-16 18:35:36 +02:00
from config.definitions import SPACE_PACKET_IDS
2022-07-04 18:14:51 +02:00
from tmtccmd import TmTcCfgHookBase, CcsdsTmtcBackend
from tmtccmd.com_if import ComInterface
from tmtccmd.config import TmtcDefinitionWrapper
2021-05-17 17:59:24 +02:00
2022-03-04 14:27:19 +01:00
from config.retvals import get_retval_dict
2022-05-03 18:36:28 +02:00
from pus_tc.cmd_definitions import get_eive_service_op_code_dict
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdDictT, RetvalDictT
2021-03-19 17:39:52 +01:00
2022-07-04 18:14:51 +02:00
class EiveHookObject(TmTcCfgHookBase):
2022-04-06 11:43:17 +02:00
def __init__(self, json_cfg_path: str):
super().__init__(json_cfg_path=json_cfg_path)
def get_tmtc_definitions(self) -> TmtcDefinitionWrapper:
2022-05-17 11:13:32 +02:00
return get_eive_service_op_code_dict()
2021-05-17 17:42:04 +02:00
2022-07-04 18:14:51 +02:00
def assign_communication_interface(self, com_if_key: str) -> Optional[ComInterface]:
2022-08-08 16:32:18 +02:00
from tmtccmd.config.com_if import (
create_com_interface_default,
create_com_interface_cfg_default,
)
2022-01-18 14:03:56 +01:00
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-04-06 11:43:17 +02:00
json_cfg_path=self.json_cfg_path,
2022-05-16 18:35:36 +02:00
space_packet_ids=SPACE_PACKET_IDS,
2021-05-17 17:42:04 +02:00
)
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):
2021-03-19 17:39:52 +01:00
from 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:
2021-05-17 17:42:04 +02:00
from 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()