Classes

srs::App

class App

The primary interface class of SRS-Control.

Application class should be instantiated only once during the whole program. Public setter methods should be called before calling the init() method.

Public Functions

App()

Constructor of the App class.

The constructor contains following actions:

  1. Instantiation of the work guard, which make sure the io_context_ keep accepting new tasks.

  2. Instantiation of strand from the io_context_, which synchronizes the communications among the FECs.

  3. Set the logging format.

  4. Instantiation (memory allocation) of workflow_handler_.

~App() noexcept

Destructor of the App class.

This destructor is called before the destruction of each members. The destructor contains following actions:

  1. Cancel the signal_set_.

  2. Wait for the Status::is_reading to be false, which will be unset from connection::DataReader::close(). The waiting time is set to be common::DEFAULT_STATUS_WAITING_TIME_SECONDS.

  3. Requesting acquisition off to all FEC devices.

  4. Set the Status::is_acq_on to be true.

The exit process of App class also contains the destruction of its member variables. The following order must be kept:

  1. Destruction of connection::DataReader member.

  2. Destruction of workflow::Handler member.

  3. Destruction of internal::AppExitHelper member, which calls end_of_work method.

  4. Destruction of working_thread_ (std::jthread) by waiting for the thread to finish.

  5. Destruction other members. Orders are not important.

  6. Destruction of io_context member. This must be done in the very end.

void init()

Initialization of internal members.

void switch_on()

Establish the communications to the available FECs to start the data acquisition.

void switch_off()

Establish the communications to the available FECs to stop the data acquisition.

void read_data(bool is_non_stop = true)

Start reading the input data stream from the port specified by srs::Config::fec_data_receive_port. If is_non_stop is true, the reading process will not be stopped until an interrupt happens, such as pressing “Ctrl-C” from users. If is_non_stop is false, the reading process will be stopped after one frame of data is read.

Parameters:

is_non_stop – Flag to set non-stop mode.

void start_workflow()

Start data analysis workflow, triggering data conversions.

This function call is executed in the main thread.

void wait_for_finish()

Manually wait for the working thread to finish.

This method is called automatically in the destructor and shouldn’t be called if not necessary. It blocks the program until the working thread exits.

inline void set_fec_data_receiv_port(int port_num)

Set the local listen port number for the communications to FEC devices.

void set_print_mode(common::DataPrintMode mode)

Set the print mode.

void set_output_filenames(const std::vector<std::string> &filenames, std::size_t n_lines = 1)

Set the output filenames.

inline void set_options(Config options)

Set the configuration values.

Private Members

io_context_type io_context_ = {4}

Asio io_context that manages the task scheduling and network IO.

asio::executor_work_guard<io_context_type::executor_type> io_work_guard_

Asio io_context work guard.

std::vector<udp::endpoint> remote_fec_endpoints_

Remote endpoints of FEC devices.

asio::signal_set signal_set_ = {io_context_, SIGINT, SIGTERM}

User signal handler for interrupts.

asio::strand<io_context_type::executor_type> fec_strand_

FEC communication strand for synchronous communications.

std::jthread working_thread_

Main working thread.

std::jthread workflow_thread_

Main thread to run workflow.

internal::AppExitHelper exit_helper_ = {this}

Exit helper for App class. This is called after calling the destructor.

std::unique_ptr<workflow::Handler> workflow_handler_

The handler to the analysis working flow.

std::shared_ptr<connection::DataSocket> data_socket_

Communication to the main input data stream.

srs::Config

class Config

Main configuration struct.

Public Members

int fec_control_local_port = common::FEC_CONTROL_LOCAL_PORT

The port number of the local network that is used for the communication to FECs.

int fec_control_remote_port = common::DEFAULT_SRS_CONTROL_PORT

The port number of the remote network that is used for the communication to FECs.

int fec_data_receive_port = common::FEC_DAQ_RECEIVE_PORT

The port number of the local network that is used for reading the data stream from FECs.

std::size_t data_buffer_size = common::LARGE_READ_MSG_BUFFER_SIZE

The size of data buffer to store the incoming UDP frames.

std::vector<std::string> remote_fec_ips = {std::string{common::DEFAULT_SRS_IP}}

Remote IP addresses of FECs.

srs::connection::DataReader

Warning

doxygenclass: Cannot find class “srs::connection::DataReader” in doxygen xml output for project “srs” from directory: /Users/runner/work/srs-control/srs-control/build/doc/xml

srs::connection::Stopper

class Stopper : public srs::connection::CommandBase

Public Functions

Stopper(const Stopper&) = delete

Deleted copy constructor (rule of 5).

Stopper(Stopper&&) = delete

Deleted move constructor (rule of 5).

Stopper &operator=(const Stopper&) = delete

Deleted copy assignment operator (rule of 5).

Stopper &operator=(Stopper&&) = delete

Deleted move assignment operator (rule of 5).

explicit Stopper(std::string_view name)

Constructor for Stopper connection class.

Parameters:

name – Name of the command

~Stopper() = default

Destructor for Stopper connection class.

The destructor change the Status::is_acq_off to be true

See also

Status

srs::internal::AppExitHelper

class AppExitHelper

An internal exit helper for App class.

Public Functions

inline explicit AppExitHelper(App *app)

Constructor with pointer to srs::App instance.

~AppExitHelper() noexcept

Destructor calling srs::App::end_of_work method.