An ISystemControllerInterface is the interface between a component and the System controller controlling the component. The interface allows for two-way communication between the component and the system controller by means of sending requests and getting responses. Classes deriving from the ISystemControllerInterface should provide the component side implementation of the communication with the system controller. This interface can be inherited and implemented by developers to connect to custom system controllers, or to directly control a component programmatically, without the need for connecting to a remote server. An ISystemControllerInterface can have a parent-child relationship with other interfaces, where the children are aware of which their parent interface is. This is useful for components that provides extra features for another component, but where the components are still to be considered as two separate entities with separate connections to the System controller.
#include <ISystemControllerInterface.h>
Inherited by SystemControllerConnection
Name | |
---|---|
struct | Callbacks A struct containing the callbacks that needs to be registered by the component using this interface. |
struct | Response A response to a request, consists of a status code and an (optional) parameters JSON object. |
Name | |
---|---|
enum class uint32_t | StatusCode { SUCCESS = 3001, TOO_MANY_REQUESTS = 3101, UUID_ALREADY_REGISTERED = 3201, FORMAT_ERROR = 3202, ALREADY_CONFIGURED = 3203, OUT_OF_RESOURCES = 3204, NOT_FOUND = 3205, INTERNAL_ERROR = 3206, CONNECTION_FAILED = 3207, TIMEOUT_EXCEEDED = 3208, KEY_MISMATCH = 3209, UNKNOWN_REQUEST = 3210, MALFORMED_REQUEST = 3211, ALREADY_IN_USE = 3212} Status codes used in JSON response messages for Websockets. These are starting at 3000 since the 1000 - 2000 range is taken up by the Spec: https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1. |
Name | |
---|---|
virtual | ~ISystemControllerInterface() =default Virtual destructor. |
virtual Response | sendRequest(const std::string & request, const nlohmann::json & parameters) =0 Send a request with some JSON parameters to the controller and await the response. |
virtual bool | registerRequestCallback(const Callbacks & callbacks) =0 Register the callbacks to call for events in this class. |
virtual bool | connect() =0 Connect to the System controller. |
virtual bool | disconnect() =0 Disconnect from the System controller. |
virtual bool | isConnected() const =0 |
virtual std::string | getUUID() const =0 |
virtual bool | hasParent() const =0 |
virtual std::shared_ptr< ISystemControllerInterface > | getParentInterface() const =0 |
Enumerator | Value | Description |
---|---|---|
SUCCESS | 3001 | 3000-3099 Info/Notifications |
TOO_MANY_REQUESTS | 3101 | 3100-3199 Warnings |
UUID_ALREADY_REGISTERED | 3201 | 3200-3299 Error |
FORMAT_ERROR | 3202 | |
ALREADY_CONFIGURED | 3203 | |
OUT_OF_RESOURCES | 3204 | |
NOT_FOUND | 3205 | |
INTERNAL_ERROR | 3206 | |
CONNECTION_FAILED | 3207 | |
TIMEOUT_EXCEEDED | 3208 | |
KEY_MISMATCH | 3209 | |
UNKNOWN_REQUEST | 3210 | |
MALFORMED_REQUEST | 3211 | |
ALREADY_IN_USE | 3212 |
Status codes used in JSON response messages for Websockets. These are starting at 3000 since the 1000 - 2000 range is taken up by the Spec: https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1.
virtual ~ISystemControllerInterface() =default
Virtual destructor.
virtual Response sendRequest(
const std::string & request,
const nlohmann::json & parameters
) =0
Send a request with some JSON parameters to the controller and await the response.
Parameters:
Return: The response from the controller.
Reimplemented by: SystemControllerConnection::sendRequest
virtual bool registerRequestCallback(
const Callbacks & callbacks
) =0
Register the callbacks to call for events in this class.
Parameters:
Return: True on successful registration, false if some callback is not set or if already connected
Reimplemented by: SystemControllerConnection::registerRequestCallback
virtual bool connect() =0
Connect to the System controller.
Return: True on successful connection, false on error or if already connected
Reimplemented by: SystemControllerConnection::connect
virtual bool disconnect() =0
Disconnect from the System controller.
Return: True on successful disconnection, false on error or if not connected
Reimplemented by: SystemControllerConnection::disconnect
virtual bool isConnected() const =0
Return: True if connected to the System controller, false otherwise
Reimplemented by: SystemControllerConnection::isConnected
virtual std::string getUUID() const =0
Return: The UUID of this interface to the System controller
Reimplemented by: SystemControllerConnection::getUUID
virtual bool hasParent() const =0
Return: True if this component has a parent ISystemControllerInterface, false otherwise
Reimplemented by: SystemControllerConnection::hasParent
virtual std::shared_ptr< ISystemControllerInterface > getParentInterface() const =0
Return: A pointer to parent’s ISystemControllerInterface, if any. Returns nullptr in case there is no parent
Reimplemented by: SystemControllerConnection::getParentInterface
Updated on 2022-11-17 at 15:40:06 +0100