ska_pst.lmc.smrb

This subpackage implements SMRB component for PST.LMC.

class ska_pst.lmc.smrb.PstSmrbComponentManager(*args: Any, **kwargs: Any)[source]

Component manager for the SMRB component for the PST.LMC subsystem.

validate_configure_scan(configuration: dict) None

Validate a ConfigureScan request sent from CSP.LMC to the SMRB sub-component.

This asserts the request can be converted to SMRB resources and then calls the process API to perform the validation.

Parameters

configuration (dict) – configuration that would be used when the configure_beam and configure_scan methods are called.

class ska_pst.lmc.smrb.PstSmrbGrpcApiStrategy[source]

Implementation of the GrpcApiStrategy for the SMRB subcomponent.

get_beam_configuration_msg(*, configuration: dict) ska_pst.grpc.lmc.ska_pst_lmc_pb2.BeamConfiguration[source]

Get the gRPC BeamConfiguration Protobuf message for SMRB.

Parameters

configuration (dict) – the PST beam configuration

Returns

the gRPC BeamConfiguration Protobuf message for SMRB.

Return type

BeamConfiguration

get_scan_configuration_msg(*, configuration: dict) ska_pst.grpc.lmc.ska_pst_lmc_pb2.ScanConfiguration[source]

Get the gRPC ScanConfiguration Protobuf message for SMRB.

Parameters

configuration (dict) – the PST scan configuration

Returns

the gRPC ScanConfiguration Protobuf message for SMRB.

Return type

ScanConfiguration

handle_monitor_response(*, data: ska_pst.grpc.lmc.ska_pst_lmc_pb2.MonitorData, callback: MonitorDataCallback) None[source]

Handle the gRPC monitoring data response.

Parameters
  • data (MonitorData) – the gRPC/Protobuf monitoring data message from server

  • callback (MonitorDataCallback) – the callback used to update the LMC subcomponent model

class ska_pst.lmc.smrb.PstSmrbSimulator(*args: Any, **kwargs: Any)[source]

Class used for simulating SMRB data.

configure_scan(configuration: dict) None

Simulate configuring a scan.

Parameters

configuration (dict) – the configuration to be configured

Raises

AssertionError if length of subband sizes not the same as num_subbands.

get_data() SmrbMonitorData[source]

Get current SMRB data.

Updates the current simulated data and returns the latest data.

Returns

current simulated SMRB data.

Return type

SmrbMonitorData

class ska_pst.lmc.smrb.SmrbMonitorData(ring_buffer_utilisation: float = 0.0, ring_buffer_size: int = 0, ring_buffer_read: int = 0, ring_buffer_written: int = 0, number_subbands: int = 0, subband_ring_buffer_utilisations: ~typing.List[float] = <factory>, subband_ring_buffer_sizes: ~typing.List[int] = <factory>, subband_ring_buffer_read: ~typing.List[int] = <factory>, subband_ring_buffer_written: ~typing.List[int] = <factory>)[source]

A data class for transfer current SMRB data between the process and the component manager.

Variables
  • ring_buffer_utilisation (float) – current utilisation of the overall ring buffer.

  • ring_buffer_size (int) – the size of the ring buffer, in bytes.

  • ring_buffer_read (int) – the amount of data, in bytes, read from ring buffer.

  • ring_buffer_written (int) – the amount of data, in bytes, written to ring buffer.

  • number_subbands (int) – the number of subbands the ring buffer is configured for.

  • subband_ring_buffer_utilisations (List[float]) – a list of utilisation for each subband.

  • subband_ring_buffer_sizes (List[int]) – the allocated size of each subband within the ring buffer, in bytes.

  • subband_ring_buffer_read (int) – the amount of data, in bytes, read from each sub-band.

  • subband_ring_buffer_written (List[int]) – the amount of data, in bytes, written to each sub-band.

number_subbands: int = 0
ring_buffer_read: int = 0
ring_buffer_size: int = 0
ring_buffer_utilisation: float = 0.0
ring_buffer_written: int = 0
subband_ring_buffer_read: List[int]
subband_ring_buffer_sizes: List[int]
subband_ring_buffer_utilisations: List[float]
subband_ring_buffer_written: List[int]
class ska_pst.lmc.smrb.SmrbMonitorDataStore[source]

Data store use to aggregate the subband data.

property monitor_data: SmrbMonitorData

Calculate the aggregate SMRB monitor data.

This step includes rolling up each of the individual sub-band data items to be able to calculate the overall utilisation

Returns

the calculated monitoring data. If there is no subband data this will return a default instance of a SmrbMonitorData.

class ska_pst.lmc.smrb.SmrbSubbandMonitorData(buffer_size: int, num_of_buffers: int, total_written: int = 0, total_read: int = 0, full: int = 0)[source]

A data class used for a specific SMRB subband.

Variables
  • buffer_size (int) – total size of the ring buffer, including header size.

  • total_written (int) – total amount of data, in bytes, written to the ring buffer during scan.

  • total_read (int) – total amount of data, in bytes, read from the ring buffer during scan.

  • full (int) – the number of buffers currently in use. Needed for aggregation for the whole SMRB stats.

  • full – the number of buffers for subband. Needed for aggregation for the whole SMRB stats.

buffer_size: int
full: int = 0
num_of_buffers: int
total_read: int = 0
total_written: int = 0
property utilisation: float

Return the current utilisation of the subband ring buffer.

This is full/num_of_buffers as a percentage.

property utilised_bytes: float

Return the number of utilised bytes.

This is utilisation (as ratio, not percentage) * buffer_size. Which is equivalent to full/num_of_buffers * buffer_size.

ska_pst.lmc.smrb.calculate_smrb_subband_resources(beam_id: int, cbf_pst_config: CbfPstConfig, **kwargs: Any) Dict[int, dict][source]

Calculate the ring buffer (RB) resources from request.

This is a common method used to calculate the keys, number of buffers, and the size of buffers for each subband required for a scan.

Parameters
  • beam_id (int) – the numerical id of the beam that this RB is for.

  • cbf_pst_config (CbfPstConfig) – the CBF/PST configuration for the current request

Returns

a dict of dicts, with the top level key being the subband id, while the second level is the specific parameters. An example would response is as follows:

{
    1: {
        'data_key': "a000",
        'weights_key': "a010",
        'hb_nbufs': 8,
        'hb_bufsz': 4096,
        'db_nbufs': 8,
        'db_bufsz': 1048576,
        'wb_nbufs': 8,
        'wb_bufsz': 8192,
    }
}

ska_pst.lmc.smrb.generate_data_key(beam_id: int, subband_id: int) str[source]

Generate a data header key.

The format of this is a string of 4 chars long. The first two chars is the beam_id represented in hexadecimal with left zero padding, the next is subband_id, and finally a suffix of 0.

Parameters
  • beam_id (int) – the beam_id that this LMC component is for.

  • subband_id (int) – the id of the subband to generate the key for.

Returns

the encoded key to be used for the data header ring buffer.

Return type

str

ska_pst.lmc.smrb.generate_weights_key(beam_id: int, subband_id: int) str[source]

Generate a weights header key.

The format of this is a string of 4 chars long. The first two chars is the beam_id represented in hexadecimal with left zero padding, the next is subband_id, and finally a suffix of 2.

NOTE: the weights key is 2 more than the data key, needed because SMRB.CORE has 2 keys for each ring buffer.

Parameters
  • beam_id (int) – the beam_id that this LMC component is for.

  • subband_id (int) – the id of the subband to generate the key for.

Returns

the encoded key to be used for the data header ring buffer.

Return type

str