CloudOfThingsMeasurementWriter¶
Description¶
The CloudOfThingsMeasurementWriter object exports Measurement objects to the Cloud of Things. Measurements grouped in a MeasurementGroup are displayed in one diagram.
› Inherits: | DataObjectWriter |
---|
Properties¶
bufferDatabase¶
This property holds the database to which the measurements are written temporarily when MeasurementBufferDatabase.buffering is set to true
and the Cloud of Things client is offline or not connected.
This property was introduced in InCore 2.5.
› Type: | MeasurementBufferDatabase |
---|---|
› Signal: | bufferDatabaseChanged() |
› Attributes: | Readonly |
client¶
This property holds the Cloud of Things client. This property can be left blank if the parent object is a CloudOfThingsClient.
› Type: | CloudOfThingsClient |
---|---|
› Signal: | clientChanged() |
› Attributes: | Writable |
error¶
This property holds the most recently occurred error or CloudOfThingsMeasurementWriter.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
› Type: | Error |
---|---|
› Signal: | errorChanged() |
› Attributes: | Readonly |
Signals¶
Enumerations¶
Error¶
This enumeration describes all errors which can occur in CloudOfThingsMeasurementWriter objects. The most recently occurred error is stored in the error property.
Name | Value | Description |
---|---|---|
CloudOfThingsMeasurementWriter.NoError |
0 |
No error occurred or was detected. |
CloudOfThingsMeasurementWriter.InvalidClient |
1 |
No CloudOfThingsClient set or found. |
CloudOfThingsMeasurementWriter.InvalidIdError |
2 |
Empty or invalid object id. |
CloudOfThingsMeasurementWriter.InvalidGroupName |
3 |
Invalid name set for measurement group, ‘.’, ‘,’ and ‘$’ not allowed. |
CloudOfThingsMeasurementWriter.InvalidMeasurementName |
4 |
No or invalid name set for measurement, ‘.’, ‘,’ and ‘$’ not allowed. |
CloudOfThingsMeasurementWriter.InvalidUnit |
5 |
Invalid unit, no comma allowed. |
Example¶
import InCore.Foundation 2.5
import InCore.CloudOfThings 2.5
import InCore.Database 2.5
Application {
CloudOfThingsClient {
id: client
tenant: "mustercloud"
transport {
tenantForMQTT: "nb-iot"
cleanSessionMQTT: false
keepAlive: 2000
//set high interval values to reduce traffic
requestOperationsIntervalMQTT: 10 * 60 * 1000
//log important state changes
onConnected: console.log( "Cloud of Things client connected" )
onErrorChanged: console.log( "oh... error occurred", errorString )
}
registrator {
isRegistered: true
password: "y0urAwes@meP4ssword"
}
CloudOfThingsMeasurementWriter {
id: measurementWriter
//buffer data if connection is lost
bufferDatabase {
bufferSize: 5000
transmitOrder: MeasurementBufferDatabase.Descending
}
submitMode: CloudOfThingsMeasurementWriter.SubmitPeriodically
submitInterval: 5000
onErrorChanged: console.log( "writer error", errorString )
Measurement { id: sensor1; name: "sensor1"; data: 1 }
Measurement { id: sensor2; name: "sensor2"; data: 2 }
Measurement { id: temp; name: "Temperature"; data: 0.0; unit: "°C" }
//unlike other databases here no DateTime object needed
//every measurement is send with timestamp automatically
}
}
}