Acl::ControlDataSender
Acl::ControlDataSender Class Reference
A ControlDataSender can send control signals to one or more receivers using a network connection. A single ControlDataSender can connect to multiple receivers, all identified by a UUID. The class is controlled using an ISystemControllerInterface; this interface is responsible for setting up connections to receivers. The ControlDataSender can send asynchronous requests to (all) the receivers and get a response back. Each response is identified with a request ID as well as the UUID of the responding receiver. The ControlDataSender can also receive status messages from the receivers.
#include <ControlDataSender.h>
Public Classes
| Name | |
|---|---|
| struct | Settings Settings for a ControlDataSender. |
Public Types
| Name | |
|---|---|
| enum class | SendRequestStatus { kSuccess, kFailed, kSendFailedForSome, kSenderNotConfigured, kNoConnectedReceiver, kInternalError} |
Public Functions
| Name | |
|---|---|
| ControlDataSender() Default constructor, creates an empty object. | |
| ~ControlDataSender() 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 ControlDataSender 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. |
| SendRequestStatus | sendRequestToReceivers(const std::string & request, uint64_t & requestId, const UUID & requester =UUID::kNilUUID, int8_t hops =-1) Send a request to all the connected ControlDataReceivers asynchronously. The responses will be sent to the response callback. |
| std::vector< UUID > | getDirectlyConnectedReceivers() const Get a list of the UUIDs of all receivers that are directly connected to this ControlDataSender. Useful for checking if this ControlDataSender is connected to something that will receive the control commands sent. |
| ControlDataSender(ControlDataSender const & ) =delete | |
| ControlDataSender & | operator=(ControlDataSender const & ) =delete |
| std::string | getVersion() Get application version. |
Public Types Documentation
enum SendRequestStatus
| Enumerator | Value | Description |
|---|---|---|
| kSuccess | Request was successfully sent. | |
| kFailed | Failed to send the request to any connected receivers. | |
| kSendFailedForSome | Multiple receivers are connected but not all received the message. | |
| kSenderNotConfigured | Cannot send messages before sender is configured. | |
| kNoConnectedReceiver | There is no connected receiver. | |
| kInternalError | Check the logs for error. |
Public Functions Documentation
function ControlDataSender
ControlDataSender()
Default constructor, creates an empty object.
function ~ControlDataSender
~ControlDataSender()
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 ControlDataSender 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:
- controllerInterface The interface to the System controller, used for communicating with this ControlDataSender
- settings The Settings to use for this ControlDataSender
Return: True on success, false otherwise
function sendRequestToReceivers
SendRequestStatus sendRequestToReceivers(
const std::string & request,
uint64_t & requestId,
const UUID & requester =UUID::kNilUUID,
int8_t hops =-1
)
Send a request to all the connected ControlDataReceivers asynchronously. The responses will be sent to the response callback.
Parameters:
- request The request message
- requestId The unique identifier of this request. Used to identify the async responses.
- requester UUID that identifies the entity that sent the request, can be used if the ControlDataSender serves multiple clients and need to distinguish between them when receiving responses. A value of the nil UUID indicates that the requester field will not be used.
- hops The number of hops the message should be delivered/forwarded. A value of 1 means to all connected receivers, but not further. A value of 2 means all connected receivers to this sender, and all connected receivers to those, but not further, and so on. A value of -1 means infinity.
Return: True if the request was successfully sent, false otherwise
function getDirectlyConnectedReceivers
std::vector< UUID > getDirectlyConnectedReceivers() const
Get a list of the UUIDs of all receivers that are directly connected to this ControlDataSender. Useful for checking if this ControlDataSender is connected to something that will receive the control commands sent.
Return: A list of all receivers that are connected directly to this ControlDataSender
function ControlDataSender
ControlDataSender(
ControlDataSender const &
) =delete
function operator=
ControlDataSender & operator=(
ControlDataSender const &
) =delete
function getVersion
static std::string getVersion()
Get application version.
Return: a string with the current version, e.g. “6.0.0-39-g60a35937”