Class: AbstractVirtualDevice

iotcs.AbstractVirtualDevice(endpointId, deviceModel)

new AbstractVirtualDevice(endpointId, deviceModel)

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 AbstractVirtualDevice API is identical for 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.

A device model can be obtained by it's afferent URN with the Client if it is registered on the cloud.

An AbstractVirtualDevice can also be created with the appropriate parameters from the Client.

Parameters:
Name Type Description
endpointId string The endpoint id of this device.
deviceModel object The device model, as a JSON object, holding the full description of that device model that this device implements.
See:
  • iotcs.Client#getDeviceModel
  • iotcs.Client#createVirtualDevice

Methods

(static) close()

Close this virtual device and all afferent resources used for monitoring or controlling the device.

(static) getDeviceModel() → {object}

Get the device model of this device object. This is the exact model that was used at construction of the device object.
Returns:
The device model, in JSON format, for this device.
Type
object

(static) getEndpointId() → {string}

Get the endpoint id of the device.
Returns:
The endpoint id of this device as given at construction of the virtual device.
Type
string

(static) update(attributes)

The update call allows more than one value to be set on this Device object and in the end, it is sending the values to the server.

The values are sent to the server when the method is called, which also marks the end of the update transaction.

For example device.update({"min":10, "max":20});

If the virtual device has the onError property set with a callback method or any/all of the attributes given in the update call have the onError attribute set with a callback method, in case of error on update the callbacks will be called with related attribute information. See VirtualDevice description for more info on onError.

Parameters:
Name Type Description
attributes object An object holding a list of attribute name/ value pairs to be updated as part of this transaction, e.g. { "temperature":23, ... }. Note that keys shall refer to device attribute names.
See:
  • iotcs.enterprise.VirtualDevice

Home