Class Receiver
Defined in File Receiver.h
Inheritance Relationships
Base Type
public ska::pst::common::ApplicationManager(Class ApplicationManager)
Derived Types
public ska::pst::recv::UDPReceiveDB(Class UDPReceiveDB)public ska::pst::recv::UDPReceiver(Class UDPReceiver)
Class Documentation
-
class Receiver : public ska::pst::common::ApplicationManager
Abstract base class that provides methods for receiving data streams.
Subclassed by ska::pst::recv::UDPReceiveDB, ska::pst::recv::UDPReceiver
Public Functions
-
Receiver(std::string host, int port)
Construct a new Receiver object that is configured to receive data at the host:port UDP endpoint.
- Parameters
host – IPv4 address on which to receive UDP data streams
port – UDP port on which to receive UDP data streams
-
Receiver(std::string host)
Construct a new Receiver object that is configured to receive data on the specified IPv4 address. Note that the port on which to receive the data streams must then be provided in the beam configuration.
- Parameters
host – IPv4 address on which to receive UDP data streams
-
void read_mac_addr()
Set the data_mac attribute to the MAC address of the data_host.
This method should be called by the constructor and will determine the MAC address of the local network device that is configured with the data_host IPv4 address.
If the data_host is set to the loopback network address (i.e. 127.0.0.1), this method will configure the MAC address to be 00:00:00:00:00:00.
-
virtual void validate_configure_beam(const ska::pst::common::AsciiHeader &config, ska::pst::common::ValidationContext *context) override
Validate requested beam configuration.
- Parameters
config – AsciiHeader containing Beam Configuration
context – A validation context where errors should be added.
-
virtual void validate_configure_scan(const ska::pst::common::AsciiHeader &config, ska::pst::common::ValidationContext *context) override
Validate requested scan configuration.
- Parameters
config – AsciiHeader containing Scan Configuration
context – A validation context where errors should be added.
-
virtual void validate_start_scan(const ska::pst::common::AsciiHeader &config) override
Validate requested start scan configuration.
- Parameters
config – AsciiHeader containing Start Scan Configuration
-
virtual void perform_initialise() override
Initialisation callback.
-
void start_receiving()
Signal to start data acquisition.
-
void stop_receiving()
Signal to stop data acquisition.
-
void parse_beam_config()
Parse the configuration provided to the Receiver in the configure_beam method Raises a runtime_error if configuration is invalid.
-
void parse_scan_config()
Parse the header provided to the Receiver in the configure_scan method Raises a runtime_error if the header is invalid.
-
void monitor_method()
Monitor the data receive performance whilst the control_state is Recording.
-
virtual void perform_stop_scan() override
StopScan callback that is called by ska::pst::common::ApplicationManager::main. Contains the instructions required prior to transitioning the state from Scanning to ScanConfigured.
-
void check_config_value_patterns(const std::string &config_name, const ska::pst::common::AsciiHeader &config, const std::map<std::string, std::string> &config_value_patterns, ska::pst::common::ValidationContext *context)
Validates existence of configuration keys. Check found key value patterns. Throws all missing keys and non conforming value patterns.
-
virtual uint64_t get_data_bufsz() = 0
Return the size of the data buffer that is receiving the streams.
- Returns
uint64_t size of the data buffer in bytes
-
uint64_t get_scan_id()
Get the scan_id of the Receiver.
If currently not configured for a scan this will return UINT64_MAX value. Callers to this method should ensure that they are in a scanning state.
- Returns
uint64_t scan_id
-
inline virtual const std::string get_data_host()
Get the configured data_host.
-
inline virtual const int get_data_port()
Get the configured data_port.
-
inline virtual const std::string get_data_mac()
Get the configured data_mac.
-
inline void set_start_scan_psn_offset(uint32_t new_offset)
Set the PSN offset to be applied to the first accepted packet at start of the scan.
- Parameters
new_offset – start scan PSN offset
-
inline uint32_t get_start_scan_psn_offset() const
Get the PSN offset to be applied to the start of the scan.
- Returns
int start scan PSN offset
-
inline ska::pst::common::Time get_utc_start() const
Get the Time object corresponding to the utc_start.
- Returns
ska::pst::common::Time timestamp of the start of data
Public Static Functions
-
static inline void reset_accounting_meta(db_accounting_t *acc)
Reset the accounting metadata, configure the curr, next and last byte offsets to their default values and resetting the number bytes in the curr and next buffers.
- Parameters
acc – accounting metadata structure to reset.
-
static inline void rotate_accounting_meta(db_accounting_t *acc)
Rotate the accounting metadata, incrementing the curr, next and last byte offsets by the bufsz. Rotates the bytes_next_buf to bytes_curr_buf and resets bytes_next_buf.
- Parameters
acc – accounting metadata structure to rotate.
-
static inline void rotate_accounting_buffers(db_accounting_t *acc)
Rotate the accounting data pointers, switching the curr and next buffers.
- Parameters
acc – accounting data to rotate
-
static inline void advance_accounting_buffers(db_accounting_t *acc)
Advance the accounting data points, setting the curr buffer to the next buffer and resetting the next buffer to nullptr.
- Parameters
acc –
Protected Functions
-
void set_config_value_patterns(std::map<std::string, std::string> beam_config, std::map<std::string, std::string> scan_config, std::map<std::string, std::string> start_scan_config)
convenience method to set the beam, scan and start_scan configuration value patterns.
- Parameters
beam_config – map of the beam configuration value patterns
scan_config – map of the scan configuration value patterns
start_scan_config – map of the start_scan configuration value patterns
Protected Attributes
-
ska::pst::common::mac_address data_mac = {}
MAC address of the network device wit the data_host IPv4 address.
-
UDPStats stats
List of UDPStats objects, one for each source. These classes record the UDP acquisition statistics for each source.
-
unsigned nchan = {0}
Number of channels in the input data streams.
-
unsigned nbit = {0}
Number of bits per sample in the input data streams. The number of bits corresponds to each datum. So a complex sample (8b real + 8b imag) would be represented as nbit=8.
-
unsigned npol = {0}
Number of polarisations in the input data streams.
-
unsigned ndim = {0}
Number of dimensions in the input data streams. Real data ndim=1, Complex data: ndim=2.
-
double tsamp = {0}
Sampling interval of the input data streams in units of microseconds.
-
double bw = {0}
Critical bandwidth of the input data streams in units of MegaHertz.
-
double freq = {0}
Centre frequency of the input data streams in units of Megahertz.
-
unsigned start_channel = {0}
First input channel to be acquired.
-
unsigned end_channel = {0}
Last input channel to be acquired.
-
double bytes_per_second = {0}
Number of bytes per second in the inputs data streams.
-
unsigned start_delay = {2}
Delay, in seconds, to apply in the Receiver before data acquisition commences.
-
db_accounting_t data = {}
pointers and offsets for the data output
-
db_accounting_t weights = {}
pointers and offsets for the weights output
-
int timeout = {0}
time out to use during beam configuration
-
uint32_t start_scan_psn_offset = {0}
offset to apply to the scan start time, based on the first valid packet received, in seconds
-
std::map<std::string, std::string> beam_config_value_patterns{{"", ""}}
configuration value patterns to use in validate_configure_beam
-
std::map<std::string, std::string> scan_config_value_patterns{{"", ""}}
configuration value patterns to use in validate_configure_scan
-
std::map<std::string, std::string> start_scan_config_value_patterns{{"", ""}}
configuration value patterns to use in validate_start_scan
-
std::unique_ptr<std::thread> monitor_thread = {nullptr}
Thread identifier for the monitoring thread.
-
bool keep_receiving = {false}
flag that indicates whether the packet receive loops should continue to acquire packets
-
Receiver(std::string host, int port)