Source code for ska_pst.lmc.smrb.smrb_component_manager

# -*- coding: utf-8 -*-
#
# This file is part of the SKA PST project.
#
# Distributed under the terms of the BSD 3-clause new license.
# See LICENSE for more info.
"""This module provides an implementation of the SMRB PST component manager."""

from __future__ import annotations

import logging
from typing import Any

from overrides import override
from ska_pst.lmc.component import PstProcessApiSubcomponentManager

from .smrb_grpc_api_strategy import PstSmrbGrpcApiStrategy
from .smrb_model import SmrbMonitorData, SmrbMonitorDataStore, SmrbSubbandMonitorData
from .smrb_simulator import PstSmrbSimulator
from .smrb_util import calculate_smrb_subband_resources

__all__ = ["PstSmrbComponentManager"]


[docs]class PstSmrbComponentManager( PstProcessApiSubcomponentManager[SmrbSubbandMonitorData, SmrbMonitorData, SmrbMonitorDataStore] ): """Component manager for the SMRB component for the PST.LMC subsystem.""" def __init__( self: PstSmrbComponentManager, *, device_name: str, process_api_endpoint: str, logger: logging.Logger | None = None, **kwargs: Any, ): """ Initialise instance of the component manager. :param device_interface: an abstract interface of the TANGO device. :type device_interface: PstApiDeviceInterface[SmrbMonitorData] :param api: an API object used to delegate functionality to. :type api: `PstProcessApi` :param logger: a logger for this object to use :type logger: `logging.Logger` """ logger = logger or logging.getLogger(__name__) logger.debug( f"Setting up SMRB component manager with device_name='{device_name}'" + f"and api_endpoint='{process_api_endpoint}'" ) super().__init__( device_name=device_name, subcomponent_name="smrb", process_api_endpoint=process_api_endpoint, simulator=PstSmrbSimulator(), grpc_strategy=PstSmrbGrpcApiStrategy(), logger=logger, data_store=SmrbMonitorDataStore(), **kwargs, ) @override def validate_configure_scan(self: PstSmrbComponentManager, configuration: dict) -> None: """ Validate a ConfigureScan request sent from CSP.LMC to the SMRB sub-component. This asserts the request can be converted to SMRB resources and then calls the process API to perform the validation. :param configuration: configuration that would be used when the configure_beam and configure_scan methods are called. :type configuration: dict """ pst_processing_mode = configuration["pst_processing_mode"] smrb_resources = calculate_smrb_subband_resources(beam_id=self.beam_id, **configuration) self._api.validate_configure_beam( configuration=smrb_resources[1], pst_processing_mode=pst_processing_mode ) self._api.validate_configure_scan(configuration=configuration) @override def _configure_beam(self: PstSmrbComponentManager, configuration: dict) -> None: """ Configure beam resources in the component. :param configuration: configuration for beam :type configuration: dict """ pst_processing_mode = configuration["pst_processing_mode"] smrb_resources = calculate_smrb_subband_resources(beam_id=self.beam_id, **configuration) self._api.configure_beam(configuration=smrb_resources[1], pst_processing_mode=pst_processing_mode)