fsfw-example-tmtc-common/config/hook_implementation.py

53 lines
1.8 KiB
Python

from typing import Optional, Union
from tmtccmd.com_if.com_interface_base import CommunicationInterface
from tmtccmd.config.definitions import ServiceOpCodeDictT
from tmtccmd.config.hook import TmTcHookBase
from tmtccmd.core.backend import TmTcHandler
from tmtccmd.tc.definitions import TcQueueT
from tmtccmd.utility.obj_id import ObjectIdDictT
from tmtccmd.utility.retval import RetvalDictT
from common_tmtc.config.definitions import TM_SP_IDS
from common_tmtc.pus_tc.cmd_definitions import common_fsfw_service_op_code_dict
class CommonFsfwHookBase(TmTcHookBase):
def pack_service_queue(
self, service: Union[int, str], op_code: str, service_queue: TcQueueT
):
from common_tmtc.pus_tc.tc_packing import common_service_queue_user
common_service_queue_user(
service=service, op_code=op_code, tc_queue=service_queue
)
def __init__(self, json_cfg_path: str):
super().__init__(json_cfg_path=json_cfg_path)
def get_service_op_code_dictionary(self) -> ServiceOpCodeDictT:
return common_fsfw_service_op_code_dict()
def assign_communication_interface(
self, com_if_key: str
) -> Optional[CommunicationInterface]:
from tmtccmd.config.com_if import create_communication_interface_default
return create_communication_interface_default(
com_if_key=com_if_key,
json_cfg_path=self.json_cfg_path,
space_packet_ids=TM_SP_IDS,
)
def perform_mode_operation(self, tmtc_backend: TmTcHandler, mode: int):
print("No custom mode operation implemented")
def get_object_ids(self) -> ObjectIdDictT:
from common_tmtc.config.object_ids import get_object_ids
return get_object_ids()
def get_retval_dict(self) -> RetvalDictT:
return self.get_retval_dict()