gRPC LMC Client

Module for providing the gRPC LMC client to external processes.

exception ska_pst_lmc.component.grpc_lmc_client.BaseGrpcException(message: str)[source]

Base exception to capture gRPC related exceptions.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.AlreadyScanningException(message: str)[source]

Exception for when the process is already scanning.

Raised when the server is already scanning and is in the SCANNING ObsState state. If this exception is raised it is likely due to a mismatch in the state model of the LMC and the server, which could be the case if a command line interface has interacted with the server directly.

The LMC can recover from this as it should only be raised when the scan command is called. The LMC should log this happened but can safely go into SCANNING state.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.NotScanningException(message: str)[source]

Exception for when tyring to end scan but component is not scanning.

Raised when the server is not in a scanning state but received an end scan command. Just like AlreadyScanningException it is possible for the LMC to recover from this as this exception is only raised during stop_scan. The LMC should log this happened but can safely go into a READY state.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.ResourcesAlreadyAssignedException(message: str)[source]

Exception for when resources were already assigned.

Raised when the server is already in an assigned resources state and the request should not have been called.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.ResourcesNotAssignedException(message: str)[source]

Exception for when resources have not been assigned.

Raised when the server does not have any resources assigned. This request should not have been called.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.ScanConfiguredAlreadyException(message: str)[source]

Exception for when scan has already been configured.

Raised when the server is in a READY state and is already configured for scan. This request should have not been made.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.NotConfiguredForScanException(message: str)[source]

Exception for when server has no scan configuration.

Raised when the server does not have a scan configuration but as request to deconfigure, scan, or get scan configuration was made but no configuration existed.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.InvalidRequestException(message: str)[source]

Exception with the actual request parameters.

This is raised when the server validates the request and request is not correct, such as the assign resources message has a protobuf Oneof field for resources and the incorrect one was applied.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.ServerError(error_code: int, message: str)[source]

Exception when an exception on the server side happens.

The server raised an exception during the processing of the request and the logs of the server should be checked. The client is not expected to handle this exception.

Initialise exception.

exception ska_pst_lmc.component.grpc_lmc_client.UnknownGrpcException(error_code: int, message: str)[source]

An unknown gRPC exception.

This error occurs due to gRPC itself. The client is not expected to handle this request.

Initialise exception.

class ska_pst_lmc.component.grpc_lmc_client.PstGrpcLmcClient(client_id: str, endpoint: str, logger: Optional[Logger], **kwargs: Any)[source]

The client API that connects to a remote gRPC service.

This client is a wrapper around the PstLmcServiceStub that is generated from the gRPC/Protobuf bindings.

Once fully implemented this class will be able to be used by any of the LMC components PstProcessApi implementations.

Initialise gRPC client.

Parameters
  • client_id – the ID of the client.

  • endpoint – the endpoint of the service that this client is to communicate with.

  • logger – the logger to use within this instance.

connect() bool[source]

Connect client to the remote server.

This is used to let the server know that a client has connected.

configure_beam(request: ska_pst_lmc_proto.ska_pst_lmc_pb2.ConfigureBeamRequest) bool[source]

Call configure_beam on remote gRPC service.

deconfigure_beam() bool[source]

Call deconfigure_beam on remote gRPC service.

get_beam_configuration() ska_pst_lmc_proto.ska_pst_lmc_pb2.GetBeamConfigurationResponse[source]

Call get_beam_configuration on remote gRPC service.

configure_scan(request: ska_pst_lmc_proto.ska_pst_lmc_pb2.ConfigureScanRequest) bool[source]

Call configure_scan on remote gRPC service.

deconfigure_scan() bool[source]

Call deconfigure_scan on remote gRPC service.

get_scan_configuration() ska_pst_lmc_proto.ska_pst_lmc_pb2.GetScanConfigurationResponse[source]

Call get_scan_configuration on remote gRPC service.

start_scan(request: ska_pst_lmc_proto.ska_pst_lmc_pb2.StartScanRequest) bool[source]

Call start_scan on remote gRPC service.

stop_scan() bool[source]

Call stop_scan on remote gRPC service.

go_to_fault() None[source]

Put the gRPC service in to a FAULT state.

get_state() ska_tango_base.control_model.ObsState[source]

Call get_state on remote gRPC service.

get_env() Dict[str, Any][source]

Get the enviroment values from the remote gRPC service.

This will map the Protobuf EnvVal objects to the appropriate Python types.

Returns

the enviroment values from the remote gRPC service.

Return type

Dict[str, Any]

abort() 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.

reset() 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).

monitor(abort_event: Event, polling_rate: int = 5000) Generator[ska_pst_lmc_proto.ska_pst_lmc_pb2.MonitorResponse, None, None][source]

Call monitor on reqmore gRPC service.

Parameters
  • abort_event – a threading.Event that can be used to signal to stop monitoring.

  • polling_rate – the rate, in milliseconds, at which the monitoring should poll. The default value is 5000ms (i.e. 5 seconds).

set_log_level(request: ska_pst_lmc_proto.ska_pst_lmc_pb2.SetLogLevelRequest) None[source]

Set the LogLevel of the remote gRPC service.

Parameters

request – The request containing LogLevel to be set on the remote gRPC service.

Returns

None.

get_log_level(request: ska_pst_lmc_proto.ska_pst_lmc_pb2.GetLogLevelRequest) ska_pst_lmc_proto.ska_pst_lmc_pb2.LogLevel[source]

Get the LogLevel of the remote gRPC service.

Returns

The current LogLevel of the remote gRPC service.

Return type

LogLevel