Polling

Description

The Polling object is a property modifier which polls the target property at a given interval. It normally is applied on value properties of sensor, input and fieldbus register objects. Some high level objects also support polling collections of subobjects such as a list of registers or whole hardware entities. If a particular property can’t be polled the error property will be set to Polling.NotSupportedError.

Note

Once a property has been polled it will only be updated by subsequent pollings, i.e. using the Polling modifier or by calling the corresponding poll method for the property. Reading the property in non-declarative code (e.g. event handlers) will return a cached value in order to prevent duplicate operations.

› Inherits:PropertyModifier

Properties

error

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

interval

This property holds the interval in milliseconds in which the property is polled. The minimum value is 1.

› Type:SignedInteger
› Default:1000
› Signal:intervalChanged()
› Attributes:Writable

running

This property holds whether the specified property is polled. This can be used to poll only when the corresponding entity is ready for operation (e.g. connected).

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

synchronize

This property holds whether the internal timer should be synchronized to the system clock. When synchronized the first polling will be delayed such that the polling time is a multiple of interval beginning at midnight UTC.

This property was introduced in InCore 2.7.

› Type:Boolean
› Default:false
› Signal:synchronizeChanged()
› Attributes:Writable

timestamp

This property holds a timestamp in milliseconds of the last successful property polling.

This property was introduced in InCore 2.5.

› Type:SignedBigInteger
› Signal:timestampChanged()
› Attributes:Writable

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 Polling objects. The most recently occurred error is stored in the error property.

Name Value Description
Polling.NoError 0 No error occurred or was detected.
Polling.NotSupportedError 1 Polling not supported for property “”.

Example

import InCore.Foundation 2.5
import InCore.IO 2.5

Application {

    property var aboveThreshold: false

    // this is the output which switches 24V on or off
    DigitalIO {
        id: output
        index: DigitalIO.IO2
        direction: DigitalIO.Output
        value: aboveThreshold ? 1 : 0 // ternary if
    }

    // this input enables the threshold testing
    DigitalIO {
        id: enableInput
        index: DigitalIO.IO1
        direction: DigitalIO.Input
        // poll value in high frequency
        Polling on value {
            interval: 50
        }
    }

    AnalogInput {
        index: AnalogInput.AIN1
        // poll values if enabled
        Polling on value {
            // default interval = 1000
            running: enableInput.value === 1
        }
        onValueChanged: aboveThreshold = value > 1000 ? 1 : 0
    }
}