new Data(virtualDevice, formatUrn)
The Data is an object that represents a set of custom data fields (key/value pairs)
defined in the formats section of the device model. Data can be used
to send these fields to the server.
The Data API is specific to the device client iotcsrary and the data fields
can be created by the VirtualDevice objects or using them.
For setting the fields of the data object as defined in the model, the fields
property of the data object will be used e.g.:
data.fields.temp = 50;
The constructor of the Data object should not be used directly but the
iotcs.device.VirtualDevice#createData
method should be used
for creating data objects.
Parameters:
Name | Type | Description |
---|---|---|
virtualDevice |
iotcs.device.VirtualDevice | The virtual device that has in it's device model the custom format specification. |
formatUrn |
string | The urn format of the custom data fields spec. |
- See:
-
iotcs.device.VirtualDevice#createData
Members
(readonly) description :string
The description of this Data.
Type:
- string
(readonly) fields :object
The fields object for this Data. Specific fields can be referenced by referencing
the field name from the fields object. For example, to reference a field named
'myName', use 'dataName.fields.myName'.
Type:
- object
(readonly) name :string
The name of this Data.
Type:
- string
(nullable) onError :iotcs.device.Data~onErrorCallback
(Optional)
Callback function called when there is an error sending the Data. May be set to
null
to un-set the callback.
Type:
(readonly) urn :string
The URN of this Data. This is the Data's device model URN.
Type:
- string
Methods
(static) submit()
This method is used to actually send the custom data fields to the server. All mandatory
fields (according to the device model definition) must be set before sending, otherwise an
error will be thrown. Any error that can arise while sending will be handled by the Data.
onError handler, if set.
After a successful send all the values are reset so to send again the values must be first set.
Type Definitions
onErrorCallback(error)
Callback function called when there is an error sending the Data.
Parameters:
Name | Type | Description |
---|---|---|
error |
string | The error which occurred when sending this Data. |