Source code for ska_pst.lmc.stat.stat_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 STAT 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 .stat_grpc_api_strategy import PstStatGrpcApiStrategy
from .stat_model import StatMonitorData, StatMonitorDataStore
from .stat_simulator import PstStatSimulator
from .stat_util import calculate_stat_subband_resources

__all__ = ["PstStatComponentManager"]


[docs]class PstStatComponentManager( PstProcessApiSubcomponentManager[StatMonitorData, StatMonitorData, StatMonitorDataStore] ): """Component manager for the STAT component for the PST.LMC subsystem.""" def __init__( self: PstStatComponentManager, *, 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[StatMonitorData] :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 STAT component manager with device_name='{device_name}'" + f"and api_endpoint='{process_api_endpoint}'" ) super().__init__( device_name=device_name, subcomponent_name="stat", process_api_endpoint=process_api_endpoint, simulator=PstStatSimulator(), grpc_strategy=PstStatGrpcApiStrategy(), logger=logger, data_store=StatMonitorDataStore(), **kwargs, ) @override def validate_configure_scan(self: PstStatComponentManager, configuration: dict) -> None: """ Validate a ConfigureScan request sent from CSP.LMC to the STAT sub-component. This asserts the request can be converted to STAT 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"] stat_resources = calculate_stat_subband_resources(beam_id=self.beam_id, **configuration) self._api.validate_configure_beam( configuration=stat_resources[1], pst_processing_mode=pst_processing_mode ) self._api.validate_configure_scan(configuration=configuration) @override def _configure_beam(self: PstStatComponentManager, configuration: dict) -> None: """ Configure beam resources in the component. :param configuration: configuration for beam :type configuration: dict """ pst_processing_mode = configuration["pst_processing_mode"] stat_resources = calculate_stat_subband_resources(beam_id=self.beam_id, **configuration) # deal only with subband 1 for now. self.logger.debug(f"Submitting API with stat_resources={stat_resources[1]}") self._api.configure_beam(configuration=stat_resources[1], pst_processing_mode=pst_processing_mode)