Class LmcService

Inheritance Relationships

Base Type

  • public ska::pst::lmc::PstLmcService::Service

Class Documentation

class LmcService : public ska::pst::lmc::PstLmcService::Service

Class to handle the local monitoring and control of PST Services.

This is a gRPC service implementation that can be used by remote clients, such as the SMRB.LMC and RECV.LMC, to manage a PST signal processing application. Applications are expected to not extend this class, or implement their own version of the ska::pst::lmc::PstLmcService::Service interface. This will allow for a common interface that the PST.LMC can use and expect the same behaviour no matter what.

Services are expected to provide an implementation of the ska::pst::common::LmcServiceHandler which provides a bridge pattern between instances of this service and what is specific to the signal processing application.

Public Functions

inline LmcService(std::string service_name, std::shared_ptr<ska::pst::common::LmcServiceHandler> handler, int port)

Constructor for the LMC service.

Parameters
  • service_name – the name of this service, used within error reporting back to client.

  • handler – a handler instance that brigdes this service to the application.

  • port – the TCP port that this service is exposed on.

virtual ~LmcService() = default

Default deconstructor of service.

inline std::string service_name()

Return the name of the LMC service.

Returns

std::string the name of the LMC service set in the constructor

void start()

Start the gRPC process in the background.

void stop()

Stops the gRPC service is it is running.

inline bool is_running()

Check if the service is running.

inline int port()

Retrieve port server is running on.

grpc::Status connect(grpc::ServerContext *context, const ska::pst::lmc::ConnectionRequest *request, ska::pst::lmc::ConnectionResponse *response) override

Implements the connect method for the LMC gRPC service.

This method is used by clients to see if they can connect to the service, and is otherwise a no-op method.

grpc::Status configure_beam(grpc::ServerContext *context, const ska::pst::lmc::ConfigureBeamRequest *request, ska::pst::lmc::ConfigureBeamResponse *response) override

Implements the configure beam functionality of the LMC gRPC service.

The implementation of this does not check that the method is directed at the right service, this is delegated to the

If the service has already been configured for beam then this will set the status to being FAILED_PRECONDITION and provide details within a serialised version of a ska::pst::lmc::Status message.

See also

LmcServiceHandler implementation which should assert the method is for the right service.

grpc::Status deconfigure_beam(grpc::ServerContext *context, const ska::pst::lmc::DeconfigureBeamRequest *request, ska::pst::lmc::DeconfigureBeamResponse *response) override

Implements releasing the beam resources of the LMC gRPC service.

This method will ensure that the service is no long using beam resources, such as being connected to ring buffers. It is only valid to call this method if the state of the service is in an IDLE state, meaning it can’t be scanning, configured for a scan or in an aborted state. Failure to meet the required precondition will result in a gRPC status of FAILED_PRECONDITION and provide details within a serialised version of a ska:pst::lmc::Status message.

grpc::Status get_beam_configuration(grpc::ServerContext *context, const ska::pst::lmc::GetBeamConfigurationRequest *request, ska::pst::lmc::GetBeamConfigurationResponse *response) override

Implements getting the current beam configuration of the LMC gRPC service.

Returns the current beam configuration for the service. If the service is not configured for beam then this will return a status with FAILED_PRECONDITION and provide details within the serialised version of a ska::pst::lmc::Status message.

grpc::Status configure_scan(grpc::ServerContext *context, const ska::pst::lmc::ConfigureScanRequest *request, ska::pst::lmc::ConfigureScanResponse *response) override

Implements configuring the service for in preparation for a scan.

This will configure the service in ready for a scan. For COMMON this is effectively a no-op method, though it does assert that the service is in IDLE state (i.e. has been configured for a beam) and afterwards will put the state into READY.

grpc::Status deconfigure_scan(grpc::ServerContext *context, const ska::pst::lmc::DeconfigureScanRequest *request, ska::pst::lmc::DeconfigureScanResponse *response) override

Implements deconfiguring the service so that its not ready for scanning.

This will deconfigure the service in ready for a scan. For COMMON this is effectively a no-op method, though it asserts the service is in a READY state (i.e. is ready for scanning but is not actually scanning). This method would put the service back into and IDLE state (i.e. is still configured for a beam but is not ready for scanning).

grpc::Status get_scan_configuration(grpc::ServerContext *context, const ska::pst::lmc::GetScanConfigurationRequest *request, ska::pst::lmc::GetScanConfigurationResponse *response) override

Implements getting the current scan configuration.

This is a no-op operation for COMMON. It is only valid to call this when the state is either READY or SCANNING.

grpc::Status start_scan(grpc::ServerContext *context, const ska::pst::lmc::StartScanRequest *request, ska::pst::lmc::StartScanResponse *response) override

Implements start scanning of the gRPC service.

This will put the service into the SCANNING state. This is only valid if the current state of the service is a READY (i.e. it is configured for a beam and has been configured for a scan). If the service is already SCANNING or not in a READY state will result in a gRPC status of FAILED_PRECONDITION and provide details within a serialised version of a ska:pst::lmc::Status message.

grpc::Status stop_scan(grpc::ServerContext *context, const ska::pst::lmc::StopScanRequest *request, ska::pst::lmc::StopScanResponse *response) override

Implements end scanning of the LMC gRPC service.

This will stop a currently running scan and notify any background monitoring to stop. If this completes successfully the state of the service is put back into READY to be able to perform another scan.

grpc::Status get_state(grpc::ServerContext *context, const ska::pst::lmc::GetStateRequest *request, ska::pst::lmc::GetStateResponse *response) override

Implements get the current observation state of the LMC gRPC serivce.

grpc::Status monitor(grpc::ServerContext *context, const ska::pst::lmc::MonitorRequest *request, grpc::ServerWriter<ska::pst::lmc::MonitorResponse> *writer) override

Implements the monitoring of data for the COMMON service.

Statitics of the service during the scanning, such as the read/write statistics for ring buffers (SMRB) or the amount of data received (RECV).

This can only be called if service is in a scanning state. If the client drops the request then this method will shut down gracefully.

grpc::Status abort(grpc::ServerContext *context, const ska::pst::lmc::AbortRequest *request, ska::pst::lmc::AbortResponse *response) override

Implements the aborting of processes for the COMMON service.

For COMMON the only process that needs to be aborted monitoring, as all the other commands are short lived commands. This implementation will update the state of this service to be ABORTED which means other commands can’t do anything until as reset and or restart is sent.

grpc::Status reset(grpc::ServerContext *context, const ska::pst::lmc::ResetRequest *request, ska::pst::lmc::ResetResponse *response) override

Implements the resetting of the service.

This method will move the COMMON service from an aborted/fault state back to IDLE That it is has been put into a configured for a beam state, but is not configured for a scan.

grpc::Status restart(grpc::ServerContext *context, const ska::pst::lmc::RestartRequest *request, ska::pst::lmc::RestartResponse *response) override

Implements the restarting of the service.

This method will move the COMMON service from an aborted/fault state back to EMPTY. This will make sure that the service is deconfigured completely, including releasing ring buffers. If not configured for a beam then this will just move to EMPTY.

grpc::Status go_to_fault(grpc::ServerContext *context, const ska::pst::lmc::GoToFaultRequest *request, ska::pst::lmc::GoToFaultResponse *response) override

Implements putting the service in the FAULT state.

Used by a client to set the service into a FAULT state. This can be due to another part of the logical BEAM being faulty and a call to this method from a client it advising the service to move to the FAULT state.

By moving to the FAULT state the service can be reset or restarted.

grpc::Status get_env(grpc::ServerContext *context, const ska::pst::lmc::GetEnvironmentRequest *request, ska::pst::lmc::GetEnvironmentResponse *response) override

Implements getting the environment values from the service.

This is used by clients to get environment specific to the service, such as the IP addresses and ports that the service exposes.

grpc::Status set_log_level(grpc::ServerContext *context, const ska::pst::lmc::SetLogLevelRequest *request, ska::pst::lmc::SetLogLevelResponse *response) override

Implements setting the log level of the service.

grpc::Status get_log_level(grpc::ServerContext *context, const ska::pst::lmc::GetLogLevelRequest *request, ska::pst::lmc::GetLogLevelResponse *response) override

Implements getting the log level of the service.