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>
Name | |
---|---|
struct | IncomingRequest An incoming request to this ControlDataReceiver. |
struct | ReceiverResponse A response message to a request. |
struct | Settings Settings for a ControlDataReceiver. |
Name | |
---|---|
ControlDataReceiver() Default constructor, creates an empty object. | |
~ControlDataReceiver() Destructor. Will disconnect from the connected receivers and close the System controller connection. | |
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. |
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. |
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 receiving 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::string | getVersion() Get application version. |
std::string | getBuildInfo() Get application build information. |
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.
ControlDataReceiver()
Default constructor, creates an empty object.
~ControlDataReceiver()
Destructor. Will disconnect from the connected receivers and close the System controller connection.
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
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:
Return: True in case the message was sent successfully, false otherwise.
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 receiving 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:
Return: True if the request was successfully sent, false otherwise
ControlDataReceiver(
ControlDataReceiver const &
) =delete
ControlDataReceiver & operator=(
ControlDataReceiver const &
) =delete
static std::string getVersion()
Get application version.
Return: a string with the current version, e.g. “1.0.0”
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 2022-06-22 at 16:53:25 +0200