new Alert(virtualDevice, formatUrn)
The Alert is an object that represents an alert type message format defined in the formats
section of the device model. Alerts can be used to send alert messages to the server.
The Alert API is specific to the device client library and the alerts can be created by the
VirtualDevice objects or using them. For setting the fields of the alert as defined in the
model, the fields property of the alert will be used e.g.:
alert.fields.temp = 50;
The constructor of the Alert should not be used directly but the
iotcs.device.VirtualDevice#createAlert
method should be used for creating alert objects.
Parameters:
Name | Type | Description |
---|---|---|
virtualDevice |
iotcs.device.VirtualDevice | The virtual device that has in it's device model the alert specification. |
formatUrn |
string | The URN format of the alert spec. |
- See:
-
iotcs.device.VirtualDevice#createAlert
Members
(readonly) description :string
The description of this Alert.
Type:
- string
(readonly) fields :object
The fields object for this Alert. Specific fields can be referenced by referencing
the field name from the fields object. For example, to reference a field named
'myName', use 'alertName.fields.myName'.
Type:
- object
(readonly) name :string
The name of this Alert.
Type:
- string
(nullable) onError :iotcs.device.Alert~onErrorCallback
(Optional)
Callback function called when there is an error sending the Alert. May be set to null to
un-set the callback.
Type:
(readonly) urn :string
The URN of this Alert. This is the Alert's device model URN.
Type:
- string
Methods
(static) raise()
This method is used to actually send the alert message to the server. The default severity for
the alert sent is SIGNIFICANT. 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 VirtualDevice.onError handler, if set.
After a successful raise all the values are reset so to raise again the values must be first set.
Type Definitions
onErrorCallback(error)
Callback function called when there is an error sending the Alert.
Parameters:
Name | Type | Description |
---|---|---|
error |
string | The error which occurred when sending this Alert. |