ControlDataReceiver

ControlDataReceiver

A ControlDataReceiver can receive messages from a sender or another ControlDataReceiver using a network connection. It can also connect to and forward the incoming request messages to other receivers. The connections to the sender and the other receivers are controlled by an ISystemControllerInterface instance. The ControlDataReceiver has a receiving or listening side, as well as a sending side. The listening side can listen to one single network port and have multiple ControlDataSenders and ControlDataReceivers connected to that port to receive requests from them. On the sending side of the ControlDataReceiver, it can be connected to the listening side of other ControlDataReceivers, used to forward all incoming messages to that receiver, as well as sending its own requests. More…

#include <ControlDataReceiver.h>

Public Classes

Name
structIncomingRequest
An incoming request to this ControlDataReceiver.
structReceiverResponse
A response message to a request.
structSettings
Settings for a ControlDataReceiver.

Public Functions

Name
ControlDataReceiver()
Default constructor, creates an empty object.
~ControlDataReceiver()
Destructor. Will disconnect from the connected receivers and close the System controller connection.
boolconfigure(const std::shared_ptr< ISystemControllerInterface > & controllerInterface, const Settings & settings)
Configure this ControlDataReceiver and connect it to the System Controller. This method will fail in case the ISystemControllerInterface has already been connected to the controller by another component, as such interface can only be used by one component.
boolsendStatusMessageToSender(const std::vector< uint8_t > & message)
Send a status message to the (directly or indirectly) connected ControlDataSender. In case this ControlDataReceiver has another ControlDataReceiver as sender, that receiver will forward the status message to the sender.
boolsendRequestToReceivers(const std::vector< uint8_t > & request, uint64_t & requestId)
Send a request to the connected ControlDataReceivers asynchronously. This request will only be sent to ControlDataReceivers on the sending side of this receiver. In case a receiver is located between this ControlDataReceiver and the sender, neither of those will see this request. The response will be sent to the response callback asynchronously.
boolsendMultiRequestToReceivers(const std::vector< std::vector< uint8_t » & request, uint64_t & requestId)
Send a multi-message request to the connected ControlDataReceivers asynchronously. This request will only be sent to ControlDataReceivers on the sending side of this receiver. In case a receiver is located between this ControlDataReceiver and the sender, neither of those will see this request. The response will be sent to the response callback asynchronously.
ControlDataReceiver(ControlDataReceiver const & ) =delete
ControlDataReceiver &operator=(ControlDataReceiver const & ) =delete
std::stringgetVersion()
Get application version.
std::stringgetBuildInfo()
Get application build information.

Detailed Description

class ControlDataReceiver;

A ControlDataReceiver can receive messages from a sender or another ControlDataReceiver using a network connection. It can also connect to and forward the incoming request messages to other receivers. The connections to the sender and the other receivers are controlled by an ISystemControllerInterface instance. The ControlDataReceiver has a receiving or listening side, as well as a sending side. The listening side can listen to one single network port and have multiple ControlDataSenders and ControlDataReceivers connected to that port to receive requests from them. On the sending side of the ControlDataReceiver, it can be connected to the listening side of other ControlDataReceivers, used to forward all incoming messages to that receiver, as well as sending its own requests.

Each ControlDataReceiver can be configured to have a certain message delay. This delay parameter is set when the System controller instructs the ControlDataReceiver to start listening for incoming connections from senders (or sending ControlDataReceiver). Each incoming request will then be delayed and delivered according to the parameter, compared to the send timestamp in the message. In case multiple receivers are chained, like sender->receiver1->receiver2, receiver1 will delay the incoming messages from the sender based on when they were sent from the sender. Furthermore, receiver2 will delay them compared to when they were sent from receiver1.

A ControlDataReceiver can send status messages back to the sender. In case of chained receivers, the message will be forwarded back to the sender. A user of the ControlDataReceiver can register callbacks to receive requests and status messages. There is also an optional “preview” callback that is useful in case the incoming messages are delayed (have a delay > 0). This callback will then be called as soon as the request message arrives, to allow the user to prepare for when the actual delayed request callback is called.

Public Functions Documentation

function ControlDataReceiver

ControlDataReceiver()

Default constructor, creates an empty object.

function ~ControlDataReceiver

~ControlDataReceiver()

Destructor. Will disconnect from the connected receivers and close the System controller connection.

function configure

bool configure(
    const std::shared_ptr< ISystemControllerInterface > & controllerInterface,
    const Settings & settings
)

Configure this ControlDataReceiver and connect it to the System Controller. This method will fail in case the ISystemControllerInterface has already been connected to the controller by another component, as such interface can only be used by one component.

Parameters:

Return: True on success, false otherwise

function sendStatusMessageToSender

bool sendStatusMessageToSender(
    const std::vector< uint8_t > & message
)

Send a status message to the (directly or indirectly) connected ControlDataSender. In case this ControlDataReceiver has another ControlDataReceiver as sender, that receiver will forward the status message to the sender.

Parameters:

  • message The status message

Return: True in case the message was sent successfully, false otherwise.

function sendRequestToReceivers

bool sendRequestToReceivers(
    const std::vector< uint8_t > & request,
    uint64_t & requestId
)

Send a request to the connected ControlDataReceivers asynchronously. This request will only be sent to ControlDataReceivers on the sending side of this receiver. In case a receiver is located between this ControlDataReceiver and the sender, neither of those will see this request. The response will be sent to the response callback asynchronously.

Parameters:

  • request The request message
  • requestId The unique identifier of this request. Used to identify the async response.

Return: True if the request was successfully sent, false otherwise

function sendMultiRequestToReceivers

bool sendMultiRequestToReceivers(
    const std::vector< std::vector< uint8_t >> & request,
    uint64_t & requestId
)

Send a multi-message request to the connected ControlDataReceivers asynchronously. This request will only be sent to ControlDataReceivers on the sending side of this receiver. In case a receiver is located between this ControlDataReceiver and the sender, neither of those will see this request. The response will be sent to the response callback asynchronously.

Parameters:

  • request The request message
  • requestId The unique identifier of this request. Used to identify the async response.

Return: True if the request was successfully sent, false otherwise

function ControlDataReceiver

ControlDataReceiver(
    ControlDataReceiver const & 
) =delete

function operator=

ControlDataReceiver & operator=(
    ControlDataReceiver const & 
) =delete

function getVersion

static std::string getVersion()

Get application version.

Return: a string with the current version, e.g. “1.0.0”

function getBuildInfo

static std::string getBuildInfo()

Get application build information.

Return: a string with the current build information such as git hashes of all direct dependencies


Updated on 2023-06-13 at 17:00:17 +0200