CPP Device Virtualization API Reference for Oracle Internet of Things Cloud Service Client Software Library. Release 21.1.1.0.0-3. E92477-09
|
AbstractVirtualDevice is a representation of a device model implemented by an endpoint. More...
#include <AbstractVirtualDevice.hpp>
Public Member Functions | |
virtual | ~AbstractVirtualDevice () |
Destructor. | |
virtual const DeviceModel & | getDeviceModel ()=0 |
Get the device model of this device object. More... | |
virtual const std::string & | getEndpointId () const =0 |
Get the endpoint id of the device. More... | |
template<typename T > | |
V & | set (const std::string &attributeName, T &value) |
Set the value of an attribute. More... | |
template<typename T > | |
T | get (const std::string &attributeName) |
Get the value of an attribute. More... | |
virtual V & | update (void)=0 |
Set a mark for beginning an update transaction. More... | |
virtual void | finish (void)=0 |
Causes the values set in an update transaction to be sent to the server and clears the update-transaction mark. More... | |
virtual void | setOnChange (const ChangeCallback *callback)=0 |
Set a callback that is invoked when the value of any attribute in the device model is changed from the outside. More... | |
virtual void | setOnError (const ErrorCallback *callback)=0 |
Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model, or an error occurs when raising an. More... | |
virtual void | setOnChange (const std::string &attributeName, const ChangeCallback *callback)=0 |
Set a callback that is invoked when the value of the given attribute in the device model is changed from the outside. More... | |
virtual void | setOnError (const std::string &attributeName, const ErrorCallback *callback)=0 |
Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model or an error occurs when raising an. More... | |
AbstractVirtualDevice is a representation of a device model implemented by an endpoint.
A device model is a specification of the attributes, formats, and resources available on the endpoint.
The iotdcl::AbstractVirtualDevice API is common to both the enterprise client and the device client. The semantics of the API are also the same. The processing model on the enterprise client is different, however, from the processing model on the device client.
On the enterprise client, an enterprise application calls the iotdcl::AbstractVirtualDevice set methods in order to affect a change on the physical device. The enterprise client application receives confirmation of that the change was accepted via a iotdcl::ChangeCallback. The iotdcl::ChangeCallback indicates to the enterprise client that the value of the attribute on the device has changed. This callback may come as a result of the enterprise client calling set() on the attribute, or it may come unsolicited as a result of the device-client updating the value from the physical device.
The enterprise client may also receive an iotdcl::ErrorCallback if the attribute value change was not accepted. This could be because the request timed out, the connection failed, or the change was explicitly rejected. The iotdcl::ErrorCallback indicates to the enterprise client that it should roll-back the attribute value to the last known value.
On the device client, the application will call set() on a iotdcl::AbstractVirtualDevice attribute. This will cause a message to be sent to the server. The iotdcl::ErrorCallback is invoked if there is an error sending the message to the server. Any enterprise application that is monitoring the device will be notified via the iotdcl::ChangeCallback that the value has changed. When the client-library receives a request from the server, the request is forwarded to a handler which invokes the iotdcl::ChangeCallback on the requested attribute. A GET request simply calls get() on the attribute.
|
pure virtual |
Causes the values set in an update transaction to be sent to the server and clears the update-transaction mark.
|
inline |
Get the value of an attribute.
This method returns the current value held by the virtual device model. For an enterprise client, no REST API call is made to the server. For a device client, no call is made to the physical device.
attributeName | the name of an attribute from the device type model |
|
pure virtual |
Get the device model of this device object.
|
pure virtual |
Get the endpoint id of the device.
|
inline |
Set the value of an attribute.
This method is used by the application to synchronize the iotdcl::AbstractVirtualDevice state with the physical device. This results in a REST API call to the server. For an enterprise client, an endpoint resource REST API call is made to the server. For a device client, an endpoint DATA message REST API call is made to the server. The value is validated according to the constraints in the device model.
attributeName | the name of an attribute from the device type model |
value | the value to set |
|
pure virtual |
Set a callback that is invoked when the value of any attribute in the device model is changed from the outside.
Local attribute changes don't provoke the callback invocation.
Note that it is possible to set a callback for all attributes and to set a callback for a specific attribute via setOnChange(const std::string&,const ChangeCallback*). If there is a callback for the specific attribute and for all attributes, both callbacks will be invoked.
callback | a callback to invoke when an attribute value changes, if NULL, the existing callback will be removed |
|
pure virtual |
Set a callback that is invoked when the value of the given attribute in the device model is changed from the outside.
Local attribute changes don't provoke the callback invocation. This is a convenience for calling
Note that it is possible to set a callback for a specific attribute and to set a callback for all attributes via setOnChange(const ChangeCallback *). If there is a callback for the specific attribute and for all attributes, both callbacks will be invoked.
attributeName | the name of an attribute from the device type model |
callback | a callback to invoke when an attribute value changes, if NULL, the existing callback will be removed |
|
pure virtual |
Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model, or an error occurs when raising an.
.
Note that it is possible to set a callback for all attributes and to set a callback for a specific attribute via setOnError(const std::string &, const ErrorCallback*). If there is a callback for the specific attribute and for all attributes, both callbacks will be invoked.
callback | a callback to invoke when there is an error setting a value, if NULL, the existing callback will be removed |
|
pure virtual |
Set a callback that is invoked if an error occurs when setting the value of any attribute in the device model or an error occurs when raising an.
. This is a convenience for calling
Note that it is possible to set a callback for a specific attribute and to set a callback for all attributes via setOnError(const ErrorCallback*). If there is a callback for the specific attribute and for all attributes, both callbacks will be invoked.
attributeName | the name of an attribute from the device type model |
callback | a callback to invoke when there is an error setting the attribute value, if NULL, the existing callback will be removed |
|
pure virtual |
Set a mark for beginning an update transaction.
By default, each call to "set" automatically sends the value to the server. The update() call allows more than one value to be set on this iotdcl::AbstractVirtualDevice object without sending values to the server. The values are sent to the server when the finish() method is called, which also marks the end of the update transaction. For example