DatabaseEventWriter
Description
The DatabaseEventWriter object is an EventOutput which stores Event objects in a database whenever triggered. All inserted Events can later be queried using a DatabaseQuery object and assigning the eventTable property to DatabaseQuery.table.
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
database
This property holds the Database in which the Event objects are stored. If left blank a LocalDatabase is created.
- › Type:
- › Signal:
databaseChanged()
- › Attributes:
Writable, Optional
error
This property holds the most recently occurred error or DatabaseEventWriter.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:
- › 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
eventTable
This property holds the DatabaseEventTable object which handles the mapping from Event properties to database table columns. During initialization it is attached to the database held by the database property.
- › Type:
- › Signal:
eventTableChanged()
- › Attributes:
Readonly
Signals
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
Error
This enumeration describes all errors which can occur in DatabaseEventWriter objects. The most recently occurred error is stored in the error property.
Name |
Value |
Description |
|---|---|---|
|
|
No error occurred or was detected. |
|
|
Invalid or no database set. |
|
|
Empty or invalid object ID (only alphanumeric characters allowed). |
Example
import InCore.Foundation 2.5
import InCore.Database 2.5
Application {
EventLog {
outputs: [
DatabaseEventWriter {
id: eventWriter
//property database left blank to create a LocalDatabase
} ]
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
}
}
}
onCompleted: deviceStartedEvent.trigger()
//trigger events here
}