Acl::IControlDataReceiver
Acl::IControlDataReceiver Class Reference
IControlDataReceiver is the interface class for the control data receiver. An IControlDataReceiver can receive messages from a sender or other IControlDataReceivers 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 <IControlDataReceiver.h>
Public Classes
| Name | |
|---|---|
| class | IRequest Interface for a request that can be responded to. |
| struct | RequestData An incoming request to this ControlDataReceiver. |
| struct | Settings Settings for a ControlDataReceiver. |
Public Types
| Name | |
|---|---|
| using std::shared_ptr< IRequest > | IRequestPtr |
Public Functions
| Name | |
|---|---|
| virtual | ~IControlDataReceiver() =default Destructor. |
| virtual bool | configure(const Settings & settings) =0 Configure this instance. |
| virtual std::vector< IRequestPtr > | getRequests(int64_t timestampUs) =0 Get all requests from the control data receiver that has a delivery time prior to the given timestamp. The user should call this function to receive and execute the requests. Before calling this the next time, all returned requests should be responded to, otherwise the control data receiver will consider them as timed out. |
| virtual bool | sendStatusMessageToSender(std::string && message, const ControlDataAddress & address) =0 Send a status message to the (directly or indirectly) connected ControlDataSender(s) according to the address parameter. In case this ControlDataReceiver has another ControlDataReceiver as sender, that receiver will forward the status message to the sender according to the address. If the address parameter, at any part, is an omni UUID, the message will be sent to all connected senders from that level and downwards. |
| virtual bool | sendRequestToReceivers(const std::string & request, uint64_t & requestId) =0 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. |
| virtual size_t | getNumberOfConnectedSenders() =0 Get number of connected senders. |
| virtual size_t | getNumberOfConnectedReceivers() =0 Get number of connected receivers. |
Detailed Description
class Acl::IControlDataReceiver;
IControlDataReceiver is the interface class for the control data receiver. An IControlDataReceiver can receive messages from a sender or other IControlDataReceivers 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.
An IControlDataReceiver 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 Types Documentation
using IRequestPtr
using Acl::IControlDataReceiver::IRequestPtr = std::shared_ptr<IRequest>;
Public Functions Documentation
function ~IControlDataReceiver
virtual ~IControlDataReceiver() =default
Destructor.
function configure
virtual bool configure(
const Settings & settings
) =0
Configure this instance.
Parameters:
- settings The settings to use for this receiver
Return: True on success, false otherwise
function getRequests
virtual std::vector< IRequestPtr > getRequests(
int64_t timestampUs
) =0
Get all requests from the control data receiver that has a delivery time prior to the given timestamp. The user should call this function to receive and execute the requests. Before calling this the next time, all returned requests should be responded to, otherwise the control data receiver will consider them as timed out.
Parameters:
- timestampUs A timestamp in microseconds since the TAI epoch. The function will return all requests that has a delivery timestamp prior to this timestamp.
Return: A vector of all requests that should be executed prior to the given time.
function sendStatusMessageToSender
virtual bool sendStatusMessageToSender(
std::string && message,
const ControlDataAddress & address
) =0
Send a status message to the (directly or indirectly) connected ControlDataSender(s) according to the address parameter. In case this ControlDataReceiver has another ControlDataReceiver as sender, that receiver will forward the status message to the sender according to the address. If the address parameter, at any part, is an omni UUID, the message will be sent to all connected senders from that level and downwards.
Parameters:
- message The status message
- address The address to send the status message to
Return: True in case the message was successfully enqueued for sending, false otherwise.
function sendRequestToReceivers
virtual bool sendRequestToReceivers(
const std::string & request,
uint64_t & requestId
) =0
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 getNumberOfConnectedSenders
virtual size_t getNumberOfConnectedSenders() =0
Get number of connected senders.
Return: The number of connected senders
function getNumberOfConnectedReceivers
virtual size_t getNumberOfConnectedReceivers() =0
Get number of connected receivers.
Return: The number of connected receivers