ska_pst.lmc.component
This package is for common component classes for PST.LMC.
- class ska_pst.lmc.component.MonitorDataHandler(data_store: MonitorDataStore[SubbandMonitorDataType, MonitorDataType], monitor_data_callback: Callable[[MonitorDataType], None])[source]
Generic monitor data handler for subband.
This handler needs to be constructed with a
MonitorDataStorethat takes subband monitoring data (type S) and can aggregate that data to return a combined monitoring data object (type T).Since monitoring happens in the background and asynchronously the updates to the data store is guarded by a threading lock.
There should be no need to override any of these methods.
- handle_subband_data(subband_id: int, subband_data: SubbandMonitorDataType) None[source]
Handle subband monitoring data.
This will call the data store’s
MonitorDataStore.update_subband()within a write lock. After updating the data store it will call the monitoring callback with the latest monitoring data from the data store.
- property monitor_data: MonitorDataType
Get current monitor data.
- class ska_pst.lmc.component.MonitorDataStore[source]
Generic monitoring data store that handles subband data.
This is an abstract class that other classes should extend to allow following for a contract about how to handle subband data.
- property monitor_data: MonitorDataType
Return the current calculated monitoring data.
Implementations of this should aggregate the monitoring data to be what is the current snapshot of data.
- Returns
current monitoring data.
- update_subband(subband_id: int, subband_data: SubbandMonitorDataType) None[source]
Update the stored subband data for a given subband id.
This just updates an internal dictionary. Subclasses should only override this method if there is a specific reason to handle a subband, as the monitor_data method should be the main place to handle aggregation.
- Parameters
subband_id – the subband that is being updated.
subband_data – the data for the current subband.
- class ska_pst.lmc.component.PstBaseDevice(*args: Any, **kwargs: Any)[source]
Base class for all the TANGO devices in PST.LMC.
This extends from
CspSubElementObsDevicebut is also generic in the type of the component manager.The CspSubElementObsDevice class is used as a base rather than a SKASubarray due to the fact this PST is a software subelement within CSP.
- class ConfigureScanCommand(*args: Any, **kwargs: Any)[source]
A class for the ObsDevice ConfigureScan command.
This overrides the constructor to ensure that the correct validator is used. The base CSP ObsDevice ConfigureScanCommand doesn’t allow passing through a validator.
- property beam_id: int
Get the ID of the beam this device belongs to.
- property component_manager: T
Get component manager.
Overrides the super class property of component_manager to be typesafe.
- Returns
the component manager casted to type T.
- create_component_manager() T[source]
Create and return a component manager for this device.
- Raises
NotImplementedError – for no implementation
- delete_device() None[source]
Delete resources allocated in init_device.
This method allows for any memory or other resources allocated in the init_device method to be released. This method is called by the device destructor and by the device Init command.
- property device_name: str
Get the name of the device.
This is the relative device name (e.g. low_psi/beam/01) and not the FQDN which can include the Tango DB in a URL.
- property facility: TelescopeFacilityEnum
Get the facility that this device is being used for.
- handle_attribute_value_update(attribute_name: str, value: Any) None[source]
Handle update of a device attribute value.
- Parameters
attribute_name (str) – the name of the attribute to update.
value (Any) – the new value of the attribute to update to.
- handle_communication_state_change(communication_state: ska_control_model.CommunicationStatus) None[source]
Handle a change in device’s communication state.
This just calls the SKABaseDevice._communication_state_changed method
- handle_component_state_change(*args: Any, **kwargs: Any) None[source]
Handle change in this device’s state.
This overrides the
PstDeviceInterfaceand calls _component_state_changed on this class.
- init_device() None[source]
Initialise the attributes and properties of the device.
This overrides the
SKABaseDevice.
- property obs_state: ska_control_model.ObsState
Get the current observing state of the device.
- Returns
the current observing state of the device.
- Return type
ObsState
- set_logging_level(value: ska_control_model.LoggingLevel) None[source]
Set the logging level for the device.
Both the Python logger and the TANGO logger are updated.
This calls
SKABaseDevice.set_logging_level()then delegates to the component manager to perform necessary updates. This is used by having the BEAM.MGMT to update the subordinate Tango devices, which in turn update the core apps.- Parameters
value – Logging level for logger
- Raises
LoggingLevelError – for invalid value
- simulationMode(value: ska_control_model.SimulationMode) None
Set the simulation mode.
- Parameters
value – The simulation mode, as a SimulationMode value
- property subsystem_id: str
Get the sub-system id where device is deployed.
- class ska_pst.lmc.component.PstComponentManager(*args: Any, **kwargs: Any)[source]
Base Component Manager for the PST.LMC. subsystem.
This base class is used to provide the common functionality of the PST TANGO components, such as providing the the communication with processes that are running (i.e. RECV, DSP, or SMRB).
This class also helps abstract away calling out to whether we’re using a simulated process or a real subprocess.
This component manager extends from the
CspObsComponentManager. For more details about this check the CSP obs component manager docs.- property beam_id: int
Return the beam id for the current component.
This value is set during the construction of the component manager, and is injected from the DeviceID property of the TANGO device.
- property config_id: str
Return the configuration id.
- configure_beam(task_callback: Optional[Callable[[...], Any]] = None, **kwargs: Any) Tuple[ska_tango_base.executor.TaskStatus, str][source]
Configure the beam specific configuration of the component.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
kwargs (dict) – configuration for beam
- configure_scan(task_callback: Optional[Callable[[...], Any]] = None, **kwargs: Any) Tuple[ska_tango_base.executor.TaskStatus, str]
Configure the component for a scan.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
kwargs (dict) – the configuration to be configured
- deconfigure_beam(task_callback: Optional[Callable[[...], Any]] = None) Tuple[ska_tango_base.executor.TaskStatus, str][source]
Deconfigure the component’s beam configuration.
This will release all the resources associated with the component, including the SMRBs.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
- deconfigure_scan(task_callback: Optional[Callable[[...], Any]] = None) Tuple[ska_tango_base.executor.TaskStatus, str][source]
Deconfigure this component for current scan configuration.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
- property device_name: str
Get the name of the current device.
- go_to_fault(fault_msg: str, task_callback: Optional[Callable[[...], Any]] = None) Tuple[ska_tango_base.executor.TaskStatus, str][source]
Set the component into a FAULT state.
For BEAM this will make the sub-devices be put into a FAULT state. For API backed component managers it is expected that the service backing that API should be put into a FAULT state.
- obsreset(task_callback: Optional[Callable[[...], Any]] = None) Tuple[ska_tango_base.executor.TaskStatus, str]
Reset the component to unconfigured but do not release resources.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
- property scan_id: int
Return the scan id.
- set_logging_level(log_level: ska_control_model.LoggingLevel) None[source]
Set LoggingLevel.
- Parameters
log_level – The required TANGO LoggingLevel
- Returns
None.
- property simulation_mode: ska_control_model.SimulationMode
Get value of simulation mode state.
- Returns
current simulation mode state.
- start_communicating() None
Establish communication with the component, then start monitoring.
This is the place to do things like:
Initiate a connection to the component (if your communication is connection-oriented)
Subscribe to component events (if using “pull” model)
Start a polling loop to monitor the component (if using a “push” model)
- stop_communicating() None
Cease monitoring the component, and break off all communication with it.
For example,
If you are communicating over a connection, disconnect.
If you have subscribed to events, unsubscribe.
If you are running a polling loop, stop it.
- class ska_pst.lmc.component.PstDeviceInterface[source]
A purely abstract class to be implemented by TANGO device classes.
This class is used to abstract away any TANGO functionality that component managers need to callback to the TANGO device and in turn allow passing of the TANGO device itself to the component manager but is abstracted. This class itself can be extended for a particular device/component_manager combination where there is a need for more specific functionality but without the need of exposing a callback.
By being an abstract class this can be mocked to be used in testing.
- property beam_id: int
Get the beam id for the current device.
- property device_name: str
Get the name of the device.
- property facility: TelescopeFacilityEnum
Get the facility that this device is being used for.
- handle_attribute_value_update(attribute_name: str, value: Any) None[source]
Handle update of a device attribute value.
- Parameters
attribute_name (str) – the name of the attribute to update.
value (Any) – the new value of the attribute to update to.
- handle_communication_state_change(communication_state: ska_control_model.CommunicationStatus) None[source]
Handle a change in device’s communication state.
- handle_component_state_change(*args: Any, **kwargs: Any) None[source]
Handle a change in the component’s state.
- property health_check_interval: int
Get the health check interval, in milliseconds.
- property monitoring_polling_rate_ms: int
Get the monitoring polling rate, in milliseconds.
- property obs_state: ska_control_model.ObsState
Get the current observing state of the device.
- Returns
the current observing state of the device.
- Return type
ObsState
- property subsystem_id: str
Get the sub-system id where device is deployed.
- class ska_pst.lmc.component.PstGrpcLmcClient(client_id: str, endpoint: str, default_timeout: float = 60.0, logger: Optional[Logger] = None, **kwargs: Any)[source]
The client API that connects to a remote gRPC service.
This client is a wrapper around the
PstLmcServiceStubthat is generated from the gRPC/Protobuf bindings.Once fully implemented this class will be able to be used by any of the LMC components
PstProcessApiimplementations.- abort(timeout: Optional[float] = None, **kwargs: Any) None[source]
Abort scanning.
This method is to be used by the LMC device that needs to abort a long running action, in particular scan. The ObsState model allows for this to be called if in IDLE (resources assigned), CONFIGURING (configuring a scan), READY (configured for a scan but not scanning), SCANNING (a scan is running), or RESETTING (is trying to reset from ABORTED/FAULT state).
After this call the state of the service should be ABORTED.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- configure_beam(request: ska_pst.grpc.lmc.ska_pst_lmc_pb2.ConfigureBeamRequest, timeout: Optional[float] = None, **kwargs: Any) None[source]
Call configure_beam on remote gRPC service.
- Parameters
request (ConfigureBeamRequest) – the configure beam request object.
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- configure_scan(request: ska_pst.grpc.lmc.ska_pst_lmc_pb2.ConfigureScanRequest, timeout: Optional[float] = None) None[source]
Call configure_scan on remote gRPC service.
- Parameters
request (ConfigureScanRequest) – the configure can request object for the remote gRPC service.
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- connect(timeout: Optional[float] = None, **kwargs: Any) None[source]
Connect client to the remote gRPC service.
This is used to let the server know that a client has connected.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- deconfigure_beam(timeout: Optional[float] = None, **kwargs: Any) None[source]
Call deconfigure_beam on remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- deconfigure_scan(timeout: Optional[float] = None, **kwargs: Any) None[source]
Call deconfigure_scan on remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- get_beam_configuration(timeout: Optional[float] = None) ska_pst.grpc.lmc.ska_pst_lmc_pb2.GetBeamConfigurationResponse[source]
Call get_beam_configuration on remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout- Returns
the current beam configuration on the remote gRPC service.
- Return type
GetBeamConfigurationResponse
- get_env(timeout: Optional[float] = None, **kwargs: Any) dict[source]
Get the environment values from the remote gRPC service.
This will map the Protobuf EnvVal objects to the appropriate Python types.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout- Returns
the environment values from the remote gRPC service.
- Return type
dict
- get_log_level(timeout: Optional[float] = None, **kwargs: Any) ska_pst.grpc.lmc.ska_pst_lmc_pb2.LogLevel[source]
Get the LogLevel of the remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout- Returns
The current LogLevel of the remote gRPC service.
- Return type
LogLevel
- get_scan_configuration(timeout: Optional[float] = None) ska_pst.grpc.lmc.ska_pst_lmc_pb2.GetScanConfigurationResponse[source]
Call get_scan_configuration on remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout- Returns
the current scan configuration on the remote gRPC service
- Return type
GetScanConfigurationResponse
- get_state(timeout: Optional[float] = None, **kwargs: Any) ska_control_model.ObsState[source]
Call get_state on remote gRPC service.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout- Returns
the current observation state of the remote gRPC service
- Return type
ObsState
- go_to_fault(timeout: Optional[float] = None, **kwargs: Any) None[source]
Put the gRPC service in to a FAULT state.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- monitor(abort_event: Event, *, polling_rate: int = 5000) Generator[ska_pst.grpc.lmc.ska_pst_lmc_pb2.MonitorResponse, None, None][source]
Call monitor on remote gRPC service.
This method is not decorated with the
grpc_requestas it handles timeout differently but this does handle the gRPC errors just like thegrpc_requestdecorator does.- Parameters
abort_event (Event) – a
threading.Eventthat can be used to signal to stop monitoring.polling_rate (int, optional) – the rate, in milliseconds, at which the monitoring should poll. The default value is 5000ms (i.e. 5 seconds).
- Yield
the current monitoring state from the remote gRPC service
- Return type
Generator[MonitorResponse, None, None]
- perform_health_check(abort_event: Event, *, health_check_interval: int = 1000) Generator[ska_pst.grpc.lmc.ska_pst_lmc_pb2.HealthCheckResponse, None, None][source]
Perform health check on remote gRPC service.
This method is not decorated with the
grpc_requestas it handles timeout differently but this does handle the gRPC errors just like thegrpc_requestdecorator does.- Parameters
abort_event (Event) – a
threading.Eventthat can be used to signal to stop performing the health check of the remote gRPC service.health_check_interval (int, optional) – the interval, in milliseconds, to expect a response back from the remote gRPC service, defaults to 1000
- Yield
the current health check response
- Return type
Generator[HealthCheckResponse, None, None]
- reset(timeout: Optional[float] = None, **kwargs: Any) None[source]
Reset service.
This method is to be used by the LMC device that is currently in an ABORTED or FAULT state to reset the service. After this call the state of the service should be in IDLE (resources assigned and not configured for a scan).
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- restart(timeout: Optional[float] = None) None[source]
Restart service.
This method is to be used by the LMC device to restart a service regardless of its ObsState. After this call the state of the service should be in IDLE (resources assigned and not configured for a scan).
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- set_log_level(request: ska_pst.grpc.lmc.ska_pst_lmc_pb2.SetLogLevelRequest, timeout: Optional[float] = None, **kwargs: Any) None[source]
Set the LogLevel of the remote gRPC service.
- Parameters
request (SetLogLevelRequest) – The request containing LogLevel to be set on the remote gRPC service.
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- start_scan(request: ska_pst.grpc.lmc.ska_pst_lmc_pb2.StartScanRequest, timeout: Optional[float] = None, **kwargs: Any) None[source]
Call start_scan on remote gRPC service.
- Parameters
request (StartScanRequest) – the start scan request to send to the remote gRPC service
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
self.default_timeout
- class ska_pst.lmc.component.PstObsStateMachine(callback: Optional[Callable] = None, initial_state: str = 'IDLE', **extra_kwargs: Any)[source]
State machine for observation state.
This class to be used in place of the
ska_control_model._ObsStateMachinestate machine to allow for the specifics of the state machine needed for the PST Process sub-devices (i.e. SMRB.MGMT, DSP.MGMT, RECV.MGMT, etc)This is based off the SKA ObsStateModel
The full list of supported states are:
IDLE: PST has not been configured for a scan
- CONFIGURING_IDLE: PST is in the process of configuring a scan;
it is currently performing a configure scan operation
CONFIGURING_READY: PST is in the process of configuring a scan; and is currently finishing the configure scan operation
READY: PST is configured for a scan
SCANNING: PST is scanning
ABORTING: PST is aborting
ABORTED: PST has aborted
RESETTING: PST is resetting to IDLE
FAULT: PST has faulted and needs to be reset
A diagram of the state machine is shown below. Reflexive transitions and transitions to FAULT obs state are omitted to simplify the diagram.
Diagram of PST subdevice state machine
- class ska_pst.lmc.component.PstObsStateModel(*args: Any, **kwargs: Any)[source]
Implements the observation state model for a PST Device.
The implemented states are:
IDLE: the device is unconfigured.
CONFIGURING: transitional state to report device configuration is in progress.
READY: the device is configured and is ready to perform observations
SCANNING: the device is performing the observation.
ABORTING: the device is processing an abort.
ABORTED: the device has completed the abort request.
RESETTING: the device is resetting all the device back to IDLE
FAULT: the device component has experienced an error from which it can be recovered only via manual intervention invoking a reset command that force the device to the base state (IDLE).
- class ska_pst.lmc.component.PstProcessApi(*args: Any, **kwargs: Any)[source]
Abstract class for the API of the PST.LMC processes like RECV, SMRB, etc.
- configure_beam(configuration: dict) None[source]
Configure beam for service.
- Parameters
configuration – Dictionary of resources to allocate.
- configure_scan(configuration: dict) None[source]
Configure a scan.
- Parameters
configuration – the scan configuration for the device.
- go_to_fault() None[source]
Set remote service in a FAULT state.
This doesn’t take a callback as we want a synchronous call.
- monitor(subband_monitor_data_callback: Callable[[...], None], polling_rate: int = 5000, monitor_abort_event: Optional[Event] = None) None[source]
Monitor data of remote service.
This needs to be implemented as a background task
- Parameters
subband_monitor_data_callback – callback to use when there is an update of the sub-band monitor data.
polling_rate – the rate, in milliseconds, at which the monitoring should poll. The default value is 5000ms (i.e. 5 seconds).
monitor_abort_event – a
threading.Eventthat can be used to signal to stop monitoring. If not set then the background task will create one.
- perform_health_check(health_check_handler: HealthCheckHandler, health_check_interval: int = 1000, health_check_abort_event: Optional[Event] = None) None[source]
Perform health check of a process in the background.
- Parameters
health_check_handler (HealthCheckHandler) – an object that implements the
HealthCheckHandlerprotocol. Any health check state object that is returned from the service is delegated to this handler to be handled.health_check_interval (int, optional) – the interval, in milliseconds, at which health check should be perform, defaults to 1000 (i.e. 1 second).
health_check_abort_event (Optional[threading.Event], optional) – a threading primitive to be used to stop the health check by an external mechanism, defaults to None
- set_log_level(log_level: ska_control_model.LoggingLevel) None[source]
Set the LogLevel of the service.
- Parameters
log_level – The required TANGO LoggingLevel
- Returns
None.
- start_scan(scan_id: int, **kwargs: Any) None[source]
Start a scan.
- Parameters
scan_id (int) – the ID for the scan.
kwargs (dict) – additional arguments, needed to allow for future proofing of scan request coming from TM / CSP.
- validate_configure_beam(configuration: dict) None[source]
Validate a configure beam for service.
- Parameters
configuration – Dictionary of resources to allocate.
- Raises
ValidationError – if there an issue validating the request. The error message contains the details.
- validate_configure_scan(configuration: dict) None[source]
Validate a configure_scan request.
- Parameters
configuration – the scan configuration for the device.
- Raises
ValidationError – if there an issue validating the request. The error message contains the details.
- class ska_pst.lmc.component.PstProcessApiGrpc(*args: Any, **kwargs: Any)[source]
Helper class to be used by subclasses of PstProcessApi that use gRPC.
This class should be added as a parent class of gRPC client APIs. Common logic of methods can be refactored to this class. This also means that requests that have empty request messages can be handled by this class specifically. Where request parameters need to be converted to the appropriate protobuf message, then subclasses of this class need to implement the _get_<method_name>_request.
For monitoring the subclasses must implement the _handle_monitor_response method.
- abort() None
Abort a scan.
- configure_beam(configuration: dict, timeout: Optional[float] = None) None
Configure the beam with the resources defined in configuration.
- Parameters
configuration (dict) – Dictionary of resources to allocate.
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
default_timeoutattribute of the gRPC API client.
- Raises
BaseGrpcException – if there was a un-recoverable server server error.
- configure_scan(configuration: dict) None
Configure a scan.
- Parameters
configuration (dict) – the configuration for the scan.
- connect() None
Connect to the remote gRPC service.
- deconfigure_beam() None
Deconfigure the beam, releasing all resources.
- deconfigure_scan() None
Deconfigure a scan.
- disconnect() None
Disconnect from the external process.
This will ensure any monitoring background task has stopped.
- get_env() dict
Get the environment properties from the remote gRPC service.
- get_log_level() ska_control_model.LoggingLevel[source]
Get the LogLevel of the remote gRPC service.
- go_to_fault() None
Put remote service into FAULT state.
This is used to put the remote service into a FAULT state to match the status of the LMC component.
- monitor
- perform_health_check
- reset() None
Reset service.
- restart() None
Restart service.
- set_log_level(log_level: ska_control_model.LoggingLevel) None
Set the LogLevel of the remote gRPC service.
- Parameters
log_level – The required TANGO LoggingLevel.
- Returns
None.
- start_scan(scan_id: int, **kwargs: Any) None
Start scanning.
- Parameters
scan_id (int) – the ID for the scan.
kwargs (dict) – additional arguments, needed to allow for future proofing of scan request coming from TM / CSP.
- stop_health_check() None
Stop performing health check of service.
- stop_monitoring() None
Stop background monitoring.
- stop_scan(timeout: float = 60.0) None
End a scan.
This will call out to the remote service to end a scan. It will also stop monitoring as monitoring is only valid if the service is in a scan.
- Parameters
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
default_timeoutattribute of the gRPC API client.
- validate_configure_beam(configuration: dict, timeout: Optional[float] = None) None
Validate configuration for a configure_beam request.
- Parameters
configuration (dict) – Dictionary of resources to allocate.
timeout (float | None, optional) – the timeout, in seconds, for the request, defaults to
default_timeoutattribute of the gRPC API client.
- Raises
ValidationError – if there is an issue validating the request. The error message contains the details.
TimeoutException – if the request took longer than expected.
- validate_configure_scan(configuration: dict) None
Validate a configure_scan request.
- Parameters
configuration (dict) – the configuration for the scan.
- Raises
ValidationError – if there is an issue validating the request. The error message contains the details.
- class ska_pst.lmc.component.PstProcessApiSimulator(*args: Any, **kwargs: Any)[source]
Abstract class for the Simulated API of the PST.LMC processes like RECV, SMRB, etc.
- abort() None
Abort a scan.
- configure_beam(configuration: dict) None
Configure the beam.
- Parameters
configuration – dictionary of parameters to be configured and their requested values
- configure_scan(configuration: dict) None
Configure a scan.
- Parameters
configuration – the configuration for the scan.
- connect() None
Connect to the external process.
- deconfigure_beam() None
Deconfigure the beam.
The default implementation of this does nothing.
- deconfigure_scan() None
Deconfigure a scan.
- disconnect() None
Disconnect from the external process.
- get_env() dict
Get the environment properties for the service.
- go_to_fault() None
Set simulator into a FAULT state.
If simulator is scanning then stop scanning.
- monitor
- perform_health_check(health_check_handler: HealthCheckHandler, health_check_interval: int = 1000, health_check_abort_event: Optional[Event] = None) None
Perform health check of a process in the background.
The simulator process doesn’t perform health check. This may change in the future to simulate errors.
- Parameters
health_check_handler (HealthCheckHandler) – an object that implements the
HealthCheckHandlerprotocol. Any health check state object that is returned from the service is delegated to this handler to be handled.health_check_interval (int, optional) – the interval, in milliseconds, at which health check should be perform, defaults to 1000 (i.e. 1 second).
health_check_abort_event (Optional[threading.Event], optional) – a threading primitive to be used to stop the health check by an external mechanism, defaults to None
- reset() None
Reset service when in ABORTED / FAULT state.
- restart() None
Restart service in any state.
- set_log_level(log_level: ska_control_model.LoggingLevel) None
Set simulator LoggingLevel of the PST.LMC processes like RECV, SMRB, etc.
- Parameters
log_level – The required TANGO LoggingLevel
- Returns
None.
- start_scan(scan_id: int, **kwargs: Any) None
Start a scan.
- Parameters
scan_id (int) – the ID for the scan.
kwargs (dict) – additional arguments, needed to allow for future proofing of scan request coming from TM / CSP.
- stop_health_check() None
Stop performing health check of service.
As the simulator API doesn’t perform health check this method does nothing.
- stop_monitoring() None
Stop the monitoring background thread by setting event.
- stop_scan() None
Stop a scan.
- validate_configure_beam(configuration: dict) None
Validate configure beam request.
- Parameters
configuration (dict) – Dictionary of resources to allocate.
- Raises
ValidationError – if there is an issue validating the request. The error message contains the details.
- validate_configure_scan(configuration: dict) None
Validate configure scan request.
- class ska_pst.lmc.component.PstProcessApiSubcomponentManager(*args: Any, **kwargs: Any)[source]
A base subcomponent Manager for the PST.LMC that uses an API.
This extends from the
PstBaseSubcomponentManager- connect() None
Establish connection to API subcomponent.
- deconfigure_beam() None
Deconfigure the subcomponent’s beam configuration.
This will release all the resources associated with the subcomponent, including the SMRBs.
- disconnect() None
Disconnect from API subcomponent.
- handle_health_check_state(state: HealthCheckState, **kwargs: Any) None[source]
Handle a health check state from the subcomponent.
This is an implementation of the
ska_pst.lmc.health_check.HealthCheckHandlerprotocol.- Parameters
state (HealthCheckState) – the current health check state of subcomponent.
- property health_check_state_mismatch_count: int
Get the number of times that the health check state was not the expected state.
- property monitor_data: MonitorDataType
Get the current monitoring data.
- property obs_state: ska_control_model.ObsState
Get the current observing state of sub-component.
- Returns
the current observing state of sub-component.
- Return type
ObsState
- start_health_check() None
Start performing health check on subcomponent in the background.
The background health check processing is delegated to the process API.
- stop_health_check() None
Stop background health check on subcomponent.
- validate_configure_scan(configuration: dict) None
Validate configure scan request with the specific configuration of the subcomponent.
Note this is for the whole ConfigureScan request for a PST BEAM subcomponent, which includes checking both the beam and scan configuration is correct. This is due to the fact that a client of BEAM.MGMT only exposes a ConfigureScan request as it’s an Obs device.
- Parameters
configuration (dict) – the configuration to validate.
- class ska_pst.lmc.component.PstSimulator(*args: Any, **kwargs: Any)[source]
A base class for simulators used when the BEAM is in simulation mode.
A simulator class is needed for each subcomponent. This class is generic over the subband monitoring data type and a monitoring data store.
This is an abstract class and sub-classes of this are expected to implement the
_update()method.- abort() None
Tell the component to abort whatever it was doing.
- configure_scan(configuration: dict) None[source]
Simulate configuring a scan.
- Parameters
configuration (dict) – the configuration to be configured
- deconfigure_scan() None
Simulate deconfiguring of a scan.
- get_subband_data() Dict[int, SubbandMonitorDataType]
Get simulated subband data.
- start_scan(**kwargs: Any) None
Simulate start scanning.
- Param
the scan arguments.
- stop_scan() None
Simulate stop scanning.
- class ska_pst.lmc.component.PstSubcomponentManager(*args: Any, **kwargs: Any)[source]
An abstract base sub component manager.
This class is used as a base class for all the PST subcomponents that are managed by the PST BEAM.MGMT TANGO device. For specific components such as RECV.CORE, SMRB.CORE, DSP.DISK, DSP.FT, etc, the sub-component managers should extend from the
PstProcessApiSubcomponentManagerwhich uses a process API to manage the core application.In the case of the DSP sub-components an umbrella DSP subcomponent manager should be used to orchestrate the requests going to a specific sub-component depending on the scan configuration and the processing mode.
- abort() None[source]
Abort current process.
The only long lived process for API based devices is that of SCANNING. However, if another system fails this can be used to put all the subsystems into an ABORTED state.
- property beam_id: int
Get beam ID for the current subcomponent.
- configure_beam(configuration: dict) None[source]
Configure the beam specific configuration of the component.
- Parameters
configuration (dict) – configuration for beam
- configure_scan(configuration: dict) None[source]
Configure the component for a scan.
- Parameters
configuration (dict) – the configuration to be configured
- deconfigure_beam() None[source]
Deconfigure the component’s beam configuration.
This will release all the resources associated with the component, including the SMRBs.
- deconfigure_scan() None[source]
Deconfigure this component for current scan configuration.
- Parameters
task_callback (Callback) – callback for background processing to update device status.
- property fault_msg: str | None
Get the current fault message.
- go_to_fault(fault_msg: str) None[source]
Set the component into a FAULT state.
For BEAM this will make the sub-devices be put into a FAULT state. For API backed component managers it is expected that the service backing that API should be put into a FAULT state.
- property health_check_interval: int
Get the current health check interval, in milliseconds.
- Returns
the current health check interval, in milliseconds.
- Return type
int
- property health_state: ska_control_model.HealthState
Get the current health state of the sub-component.
- Returns
the current health state of the sub-component.
- Return type
HealthState
- property monitoring_polling_rate_ms: int
Get the current monitoring polling rate, in milliseconds.
- property obs_state: ska_control_model.ObsState
Get the current observing state of sub-component.
- Returns
the current observing state of sub-component.
- Return type
ObsState
- obsreset() None[source]
Reset service.
This is used to reset a service in ABORTED or FAULT states back to an EMPTY state. This will deconfigure a scan and beam.
- restart_health_check() None[source]
Restart the health check background process for the current subcomponent.
- scan(scan_id: int, **kwargs: Any) None[source]
Start scanning.
The kwargs of this method is scan request. By using the kwargs allow for forward compatibility of accepting other parameters for the starting of the scan.
- Parameters
scan_id (int) – the scan ID
kwargs (dict) – scan request as a dict
- set_logging_level(log_level: ska_control_model.LoggingLevel) None[source]
Set LoggingLevel.
- Parameters
log_level – The required TANGO LoggingLevel
- Returns
None.
- property simulation_mode: ska_control_model.SimulationMode
Get value of simulation mode state.
- Returns
current simulation mode state.
- validate_configure_scan(configuration: dict) None[source]
Validate configure scan request with the specific configuration of the component.
Note this is for the whole ConfigureScan request for a PST BEAM component, which includes checking both the beam and scan configuration is correct. This is due to the fact that clients of BEAM.MGMT only exposes a ConfigureScan request as it’s an Obs device.
- Parameters
configuration (dict) – the configuration to validate.
- class ska_pst.lmc.component.SubcomponentEventMessage(*, subcomponent_name: str, health_state: ska_control_model.HealthState, obs_state: ska_control_model.ObsState)[source]
A data class used for passing events messages from subcomponents around.
When an event, such as health state change or going into a FAULT state, a subcomponent can create a message of this type and place it on the event queue that the BEAM component manager can listen to.
This class is designed to avoid the anti-pattern of callback hell. Rather than the BEAM component manager having to pass multiple callable functions to subcomponents or providing a reference to itself in the subcomponent managers, only a
queue.Queueis needed to be shared and the BEAM component manger can handle the events with a background task.- health_state: ska_control_model.HealthState
The current health state of the subcomponent.
- obs_state: ska_control_model.ObsState
The current observing state of the subcomponent.
- subcomponent_name: str
The name of the subcomponent that created the event.
- ska_pst.lmc.component.as_device_attribute_name(attr_name: str) str[source]
Convert attribute name to a TANGO device attribute name.
Device attribute names should be in lower camel case (i.e. availableDiskSpace) not Python’s snake case (i.e. available_disk_space). This is a utility method that makes the conversion easier.
- Parameters
attr_name (str) – the attribute name to convert from snake case.
- Returns
the lower camel case version of input string.
- Return type
str
- ska_pst.lmc.component.ascii_header_to_protobuf(ascii_header: ska_pydada.AsciiHeader) ska_pst.grpc.lmc.ska_pst_lmc_pb2.AsciiHeaderProto[source]
Convert an
AsciiHeaderinstance to a protobuf equivalent message.The protobuf AsciiHeader message uses the NewType pattern to wrap a string which allows for type safety on both the Python and C++ side of the LMC.
- Parameters
ascii_header (AsciiHeader) – input ascii header that will be converted a protobuf message.
- Returns
a protobuf message equivalent of the input AsciiHeader.
- Return type
AsciiHeaderProto
- ska_pst.lmc.component.protobuf_to_ascii_header(msg: ska_pst.grpc.lmc.ska_pst_lmc_pb2.AsciiHeaderProto) ska_pydada.AsciiHeader[source]
Convert a protobuf AsciiHeader message to a Python
AsciiHeader.- Parameters
msg (AsciiHeaderProto) – input protobuf message.
- Returns
the input message as an
AsciiHeaderinstance.- Return type
AsciiHeader