Class StatLmcServiceHandler
Defined in File StatLmcServiceHandler.h
Inheritance Relationships
Base Type
public ska::pst::common::LmcServiceHandler
(Class LmcServiceHandler)
Class Documentation
-
class StatLmcServiceHandler : public ska::pst::common::LmcServiceHandler
Class to act as a bridge between the local monitoring and control service of STAT.CORE and the ska::pst::stat::StatApplicationManager.
Public Functions
-
virtual ~StatLmcServiceHandler() = default
-
virtual void validate_beam_configuration(const ska::pst::lmc::BeamConfiguration &configuration) override
Validate a beam configuration.
Validate a beam configuration for correctness but does not apply the configuration.
- Throws
std::exception – if there is a problem with the beam configuration of the service.
ska::pst::common::pst_validation_error – if there are validation errors in the request.
-
virtual void validate_scan_configuration(const ska::pst::lmc::ScanConfiguration &configuration) override
Validate a scan configuration.
Validate a scan configuration for correctness but does not apply the configuration.
- Throws
std::exception – if there is a problem with the beam configuration of the service.
ska::pst::common::pst_validation_error – if there are validation errors in the request.
-
virtual void configure_beam(const ska::pst::lmc::BeamConfiguration &resources) override
Handle configuring the service to be a part of a beam.
This implementation expects that there is an stat sub-field in the resources request and calls the StatApplicationManager::configure_beam method, which expects keys for the data and weights ring buffers.
- Parameters
configuration – the configuration for the beam. This message has oneof field should be the stat sub-field message.
- Throws
ska::pst::common::LmcServiceException – if resources had already been assigned.
-
virtual void deconfigure_beam() override
Handle deconfiguring the service from a beam.
This calles the StatApplicationManager::deconfigure_beam to detach from the ring buffers. This method checks to see the manager has beam configuration.
- Throws
ska::pst::common::LmcServiceException – if manager is not beam configured.
-
virtual void get_beam_configuration(ska::pst::lmc::BeamConfiguration *resources) override
Handle getting the current beam configuration for the service.
This will return the current beam configuration for the stat application manager.
- Parameters
resources – the out protobuf message to used to return beam configuration details.
- Throws
ska::pst::common::LmcServiceException – if manager is not beam configured.
-
virtual bool is_beam_configured() const noexcept override
Check if this service is configured for a beam.
Will return true if the StatApplicationManager has beam configuration.
-
virtual void configure_scan(const ska::pst::lmc::ScanConfiguration &configuration) override
Handle configuring the service for a scan.
This will configure the StatApplicationManager for a scan. This implementation expects that the stat sub-message is set on the configuration parameter.
- Parameters
configuration – a protobuf message that should have the stat sub-message set.
- Throws
ska::pst::common::LmcServiceException – if manager is not beam configured, configuration parameter doesn’t have a a stat sub-message, or that the stat application manager is already configured for a scan.
-
virtual void deconfigure_scan() override
Handle deconfiguring service for a scan.
This will deconfigure the StatApplicationManager for a scan.
- Throws
ska::pst::common::LmcServiceException – if manager is configured for a scan.
-
virtual void get_scan_configuration(ska::pst::lmc::ScanConfiguration *configuration) override
Handle getting the current scan configuration for the service.
This will return a stat sub-field message with the current scan configuration.
- Parameters
configuration – the out protobuf message to used to return scan configuration details.
- Throws
ska::pst::common::LmcServiceException – if manager is configured for a scan.
-
virtual bool is_scan_configured() const noexcept override
Check if the service has been configured for a scan.
- Returns
This will return true if StatApplicationManager is configured for a scan.
-
virtual void start_scan(const ska::pst::lmc::StartScanRequest &request) override
Handle initiating a scan.
This will call StatApplicationManager::start_scan that will initial a scan, including reading the ring buffers and computing and publishing statistics.
- Throws
ska::pst::common::LmcServiceException – if manager is configured for a scan, or is already scanning.
-
virtual void stop_scan() override
Handle ending a scan.
This will call StatApplicationManager::stop_scan if the service is already scanning.
- Throws
ska::pst::common::LmcServiceException – if service is not scanning.
-
virtual void reset() override
Handle resetting State into Idle.
This ties the states between LmcService ObsState::EMPTY with ApplicationManager State::Idle
-
virtual bool is_scanning() const noexcept override
Check if the service is currenting performing a scan.
- Returns
true if the StatApplicationManager is scanning.
-
virtual void get_monitor_data(ska::pst::lmc::MonitorData *data) override
Handle getting the monitoring data for the service.
This will get the current monitoring data for STAT.CORE. This includes the following scalar statistics: mean_frequency_avg, mean_frequency_avg_rfi_excised, variance_frequency_avg, variance_frequency_avg_rfi_excised, num_clipped_samples, and num_clipped_samples_rfi_excised.
- Parameters
data – Pointer to the protobuf message to return. This will set the stat sub-message with the monitoring data.
- Throws
ska::pst::common::LmcServiceException – if service is not scanning.
-
virtual void get_env(ska::pst::lmc::GetEnvironmentResponse *response) noexcept override
Return environment variables back to the client.
This implementation returns mean_frequency_avg, mean_frequency_avg_rfi_excised, variance_frequency_avg, variance_frequency_avg_rfi_excised, num_clipped_samples, and num_clipped_samples_rfi_excised.
- Parameters
data – Pointer to a protobuf message message that includes the a map to populate.
-
inline virtual ska::pst::common::State get_application_manager_state() override
Get the StatApplicationManager state.
- Returns
ska::pst::common::State returns current the enum State of the StatApplicationManager
-
inline virtual std::exception_ptr get_application_manager_exception() override
Get the StatApplicationManager exception pointer.
- Returns
std::exception_ptr returns the current captured exception caught by the StatApplicationManager
-
virtual void go_to_runtime_error(std::exception_ptr exc) override
Put application into a runtime error state.
- Parameters
exception – an exception pointer to store on the application manager.
Public Static Functions
-
template<typename T>
static inline size_t flatten_2d_vec(const std::vector<std::vector<T>> &vec, std::vector<T> &data) Helper method for flattening a 2D vector into a 1D vector.
This function takes a 2D vector and flattens it into a 1D vector of elements type T. It checks for empty vectors, dimensions, and inner vector sizes and logs warnings when data integrity issues are detected. The number of elements in the flattened vector is available as vector<T>::size
- Template Parameters
T – The type of elements in the input vector.
- Parameters
vec – The 2D vector to be flattened.
data – The output 1D vector to store the flattened data.
-
virtual ~StatLmcServiceHandler() = default