CloudOfThingsEventWriter

Description

The CloudOfThingsEventWriter object sends Event objects to the Cloud of Things or stores them, if the connection is temporary lost.

› Inherits:EventOutput

Properties

alarmCategories

This property holds a list of EventCategory objects, which assigned Event objects are treated as alarms. Other events pushed to this output are treated as Cloud of Things events and the severity is ignored.

› Type:List<EventCategory>
› Signal:alarmCategoriesChanged()
› Attributes:Readonly

buffering

This property holds whether Event objects should be stored when CloudOfThingsClient is not connected. If the connection is restored buffered measurements will be sent with an interval of sendStoredDataInterval ms.

› Type:Boolean
› Default:true
› Signal:bufferingChanged()
› Attributes:Writable

client

This property holds the Cloud of Things client. This property can be left blank if CloudOfThingsClient is a parent.

› Type:CloudOfThingsClient
› Signal:clientChanged()
› Attributes:Writable

error

This property holds the most recently occurred error or CloudOfThingsEventWriter.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

errorString

This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.

› Type:String
› Signal:errorStringChanged()
› Attributes:Readonly

eventDatabase

This property holds the event database which buffers the events if no connection is available.

› Type:CloudOfThingsEventDatabase
› Signal:eventDatabaseChanged()
› Attributes:Readonly

sendStoredDataCount

This property holds how many stored events from eventDatabase are sent at once after the connection is restored. The lowest possible value is 1.

› Type:SignedInteger
› Default:1
› Signal:sendStoredDataCountChanged()
› Attributes:Writable

sendStoredDataInterval

This property holds holds the send interval in milliseconds in which stored elements from eventDatabase are sent after the connection is restored. The minimum value is 100.

› Type:SignedInteger
› Default:2000
› Signal:sendStoredDataIntervalChanged()
› Attributes:Writable

Signals

alarmCategoriesDataChanged(SignedInteger index)

This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the alarmCategories list itself emitted the dataChanged() signal.

errorOccurred()

This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.

Enumerations

AlarmSeverity

This enumeration describes the serverity of an alarm in Cloud of Things. A fixed mapping from Event serverity is performed, if the events category is in alarmCategories.

Name Value Description
CloudOfThingsEventWriter.Warning 0 Lowest severity - default if not set otherwise.
CloudOfThingsEventWriter.Minor 1 Minor severity is used when the events severity is Warning.
CloudOfThingsEventWriter.Major 2 Major severity is used when the events severity is Error.
CloudOfThingsEventWriter.Critical 3 Critical severity is used when the events severity is Fatal.

Error

This enumeration describes all errors which can occur in CloudOfThingsEventWriter objects. The most recently occurred error is stored in the error property.

Name Value Description
CloudOfThingsEventWriter.NoError 0 No error occurred or was detected.
CloudOfThingsEventWriter.InvalidClient 1 No CloudOfThingsClient set or found.
CloudOfThingsEventWriter.InvalidIdError 2 Empty or invalid object id.

Example

import InCore.Foundation 2.5
import InCore.CloudOfThings 2.5

Application {

    EventLog {
        outputs: [ eventWriter ]
        EventCategory { id: measurementValueCategory }
        EventGroup {
            Event {
                id: temperatureEvent
                description: "temperature above 70°C"
            }
            Event {
                id: deviceStartedEvent
                description: "device started"
            }
            Event {
                id: measurementValueEvent
                description: "measurement above threshold"
                category: measurementValueCategory
                severity: Event.Error
            }
        }
    }

    //trigger events here

    CloudOfThingsClient {
        id: client
        tenant: "mustercloud"
        transport.tenantForMQTT: "nb-iot"

        registrator {
            isRegistered: true
            password: "y0urAwes@meP4ssword"
        }

        CloudOfThingsEventWriter {
            id: eventWriter
            //events with a category in alarmCategories are sent as alarm, all other as event
            alarmCategories: [ measurementValueCategory ]

            eventDatabase {
                bufferSize: 500
            }
        }
    }
}