DurationConstraint Item

class DurationConstraint

Checks the time between two signal occurrences.

Inherits:Component
Properties:beginOn, duration, enabled endOn, evaluateOnFinished, evaluateOnValidation, maxDuration, minDuration. timedOut, valid
Methods:begin(), end()

Detailed Description

DurationConstraint measures the time between two signals beginOn and endOn. The methods begin() or end() may be used as an alternative if no signals are available. The expected duration is configured with minDuration and maxDuration.

The constraint has two stages: validation and evaluation. Validation happens immediately after the endOn signal has fired. In the same moment, the duration property is updated and shows the measured duration. Whether the duration is within the expected range, can be seen at the property valid.

During the evaluation stage, it is decided whether the test case is aborted. Evaluation can either happen immediately after validation (evaluateOnValidation is true) or just before the Testcase::finished() event (evaluateOnFinished is true). The enabled property switches measurement completely on and off.

Example for measuring the duration between two signals:

import qst 1.0

Testcase {

    ProcessProbe {
        id: process
        command: "sleep"
        arguments: [ 3 ]
    }

    DurationConstraint {
        id: constraint
        minDuration: 2.9
        maxDuration: 3.1

        beginOn: process.started
        endOn: process.finished
    }

    function run() {
        process.start()
        Qst.wait(4000)
    }

Example for monitoring a sequence of actions:

import qst 1.0

Testcase {

    DurationConstraint {
        id: constraint
        minDuration: 5
        maxDuration: 10
    }

    function run() {
        constraint.begin()

        // Now do something very time consuming...
        Qst.wait(20); // will be aborted because constraint
                      // is violated after 10 ms.
    }

Properties

signal beginOn
Default:undefined

Starts a measurement action. This property must either be QML signal or an object that defines a connect() method with a signal handler as parameter. When updating this property, the old signal will be disconnected.

See also: endOn, begin(), end()

double duration
Default:0.0

The measured timed between beginOn and endOn.

bool enabled
Default:true

When false, the signals beginOn and endOn do not have any effect and the constraint is neither validated nor evaluated.

signal endOn
Default:undefined

Ends a measurement cycle and triggers validation. This property must either be QML signal or an object that defines a connect() method with a signal handler as parameter. When updating this property, the old signal will be disconnected.

See also: beginOn, begin(), end()

bool evaluateOnFinished
Default:false

If true, the constraint will be evaluated by Qst just before Testcase::finished().

See also evaluateOnValidation

bool evaluateOnValidation
Default:true

If true, the test case will fail immediately when validation fails. If false, then the constraint will not be evaluated immediately. Instead, it will be evaluated on Testcase::finished().

See also evaluateOnFinished

double maxDuration
Default:0.0

Specifies the maximum allowed time between beginOn and endOn. The value must be greater or equal minDuration.

See also minDuration

double minDuration
Default:0.0

Specifies the minimum allowed time between beginOn and endOn. The value must be less or equal maxDuration.

See also maxDuration

bool timedOut
Default:false

Becomes true when the time between beginOn and endOn exceeds the specified duration range. This property is set back to false on each measurement interval.

bool valid
Default:false

Reflects whether duration is within the specified range.

Methods

void begin()

Equivalent to beginOn. Can be used to start a measurement manually or when no signal is available to attach to.

See also: end(), beginOn, endOn

void end()

Equivalent to beginOn. Can be used to start a measurement manually or when no signal is available to attach to.

See also: begin(), beginOn, endOn