Component Process API
Module for providing the base abstract API for the PST.LMC processes.
This API is not a part of the component manager, as the component manager is also concerned with callbacks to the TANGO device and has state model management. This API is expected to be used to call to an external process or be simulated.
- class ska_pst_lmc.component.process_api.PstProcessApi(logger: Logger, component_state_callback: Callable)[source]
Abstract class for the API of the PST.LMC processes like RECV, SMRB, etc.
Initialise the API.
- Parameters
simulator – the simulator instance to use in the API.
logger – the logger to use for the API.
component_state_callback – this allows the API to call back to the component manager / TANGO device to deal with state model changes.
- validate_configure_beam(configuration: Dict[str, Any]) 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.
- configure_beam(configuration: Dict[str, Any], task_callback: Callable) None [source]
Configure beam for service.
- Parameters
configuration – Dictionary of resources to allocate.
task_callback – callable to connect back to the component manager.
- deconfigure_beam(task_callback: Callable) None [source]
Deconfigure beam to release all resources.
- Parameters
task_callback – callable to connect back to the component manager.
- validate_configure_scan(configuration: Dict[str, Any]) 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.
- configure_scan(configuration: Dict[str, Any], task_callback: Callable) None [source]
Configure a scan.
- Parameters
configuration – the scan configuration for the device.
task_callback – callable to connect back to the component manager.
- deconfigure_scan(task_callback: Callable) None [source]
Deconfigure a scan.
- Parameters
task_callback – callable to connect back to the component manager.
- start_scan(args: Dict[str, Any], task_callback: Callable) None [source]
Start a scan.
- Parameters
args – arguments for the scan.
task_callback – callable to connect back to the component manager.
- stop_scan(task_callback: Callable) None [source]
Stop a scan.
- Parameters
task_callback – callable to connect back to the component manager.
- abort(task_callback: Callable) None [source]
Abort a scan.
- Parameters
task_callback – callable to connect back to the component manager.
- reset(task_callback: Callable) None [source]
Reset the component.
- Parameters
task_callback – callable to connect back to the component manager.
- 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.Event
that can be used to signal to stop monitoring. If not set then the background task will create one.
- class ska_pst_lmc.component.process_api.PstProcessApiSimulator(logger: Logger, component_state_callback: Callable, **kwargs: Any)[source]
Abstract class for the Simulated API of the PST.LMC processes like RECV, SMRB, etc.
Initialise the API.
- validate_configure_beam(configuration: Dict[str, Any]) None [source]
Validate configure beam request.
- validate_configure_scan(configuration: Dict[str, Any]) None [source]
Validate configure scan request.
- go_to_fault() None [source]
Set simulator into a FAULT state.
If simulator is scanning then stop scanning.
- 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.Event
that can be used to signal to stop monitoring. If not set then the background task will create one.
- class ska_pst_lmc.component.process_api.PstProcessApiGrpc(client_id: str, grpc_endpoint: str, logger: Logger, component_state_callback: Callable, background_task_processor: Optional[BackgroundTaskProcessor] = None)[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 have to handle the _handle_monitor_response method.
Initialise the API.
- Parameters
client_id – the identification of the client, this should be based off the FQDN of the MGMT device.
grpc_endpoint – the service endpoint to connect to. As the SMRB.RB instances are for each subband this forces this class to be per subband.
logger – the logger to use for the API.
component_state_callback – this allows the API to call back to the component manager / TANGO device to deal with state model changes.
background_task_processor – an optional background processor that will run background tasks like monitor.
- connect() None [source]
Connect to the external process.
Connects to the remote gRPC service. It also establishes a
- disconnect() None [source]
Disconnect from the external process.
This will ensure any monitoring background task has stopped.
- validate_configure_beam(configuration: Dict[str, Any]) None [source]
Validate configuration for a configure_beam request.
- Parameters
configuration – Dictionary of resources to allocate.
- Raises
ValidationError – if there an issue validating the request. The error message contains the details.
- configure_beam(configuration: Dict[str, Any], task_callback: Callable) None [source]
Configure the beam with the resources definted in configuration.
- Parameters
configuration – Dictionary of resources to allocate.
task_callback – callable to connect back to the component manager.
- deconfigure_beam(task_callback: Callable) None [source]
Deconfigure the beam, releasing all resources.
- Parameters
task_callback – callable to connect back to the component manager.
- validate_configure_scan(configuration: Dict[str, Any]) None [source]
Validate a configure_scan request.
- Parameters
configuration – the configuration of for the scan.
- Raises
ValidationError – if there an issue validating the request. The error message contains the details.
- configure_scan(configuration: Dict[str, Any], task_callback: Callable) None [source]
Configure a scan.
For SMRB this is a no-op command. There is nothing on the server that would be performed and executing this will do nothing.
- Parameters
configuration – the configuration of for the scan.
task_callback – callable to connect back to the component manager.
- deconfigure_scan(task_callback: Callable) None [source]
Deconfigure a scan.
- Parameters
task_callback – callable to connect back to the component manager.
- start_scan(args: Dict[str, Any], task_callback: Callable) None [source]
Start scanning.
- Parameters
args – arguments for the scan.
task_callback – callable to connect back to the component manager.
- stop_scan(task_callback: Callable) None [source]
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
task_callback – callable to connect back to the component manager.
- abort(task_callback: Callable) None [source]
Abort a scan.
- Parameters
task_callback – callable to connect back to the component manager.
- reset(task_callback: Callable) None [source]
Reset service.
- Parameters
task_callback – callable to connect back to the component manager.
- go_to_fault() None [source]
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.
- set_log_level(log_level: ska_tango_base.control_model.LoggingLevel) None [source]
Set the LogLevel of the remote gRPC service.
- Parameters
log_level – The required TANGO LoggingLevel.
- Returns
None.
- get_log_level() ska_tango_base.control_model.LoggingLevel [source]
Get the LogLevel of the remote gRPC service.
- monitor(subband_monitor_data_callback: Callable[[...], None], polling_rate: int = 5000, monitor_abort_event: Optional[Event] = None) None [source]
Monitor data of remote service.
- 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.Event
that can be used to signal to stop monitoring. If not set then the background task will create one.