Table of Contents

ISequenceQuery

Namespace
ZAux
Extends
Inherited Methods
INTERFACE ISequenceQuery EXTENDS ZAux.ISequenceQuery2

This interface is returned by the BeginQuery method of a sequence. It can be used to chain conditions together in order to advance through the steps of a sequence in a fluent way.

A simple example for the fluent way is shown in the following snippet

BeginQuery().
  Await(obj1).
  Await(obj2).
  OnErrorGoTo(step:=50).
  Await(obj3).
  OnDoneGoTo(step:=10).
EndQuery()

Here, if obj1 or obj2 have an error, go to step 50 to recover from the error. However, if obj3 has an error the sequence error flag will be set to TRUÈ since there is no OnErrorGoTo method call after Await(obj3). If obj1, obj2 and obj3 are done (not busy and no error) the sequence's step is set to 10.

The fluent api covers even more complicated use cases, such as

BeginQuery().
  WithTimeout(180). // everything has to be completed in 180s or there will be a timeout error
  WithRetry(3). // if there is a timeout or any other error (obj1, obj2, obj3) the current step is retried 3 times
  WithRisingTrigger(io.IsEnabled()). // in order to continue there has to be a risingedge of the io signal
  Await(obj1).
  Await(obj2).
  Await(obj3).
  OnDoneGoTo(step:=10).
EndQuery()

Another usecase is to do repetitions of the current step, which can be done as follows

BeginQuery().
  WithRepetition(3).
  Await(obj1).
  OnDoneGoTo(step:=10).
EndQuery()

Here the current step is repeated 3 times and only at the forth iteration the step is advanced to 10.

Methods

WithAnyTrigger

METHOD WithAnyTrigger (
 [input] on : BOOL) : ISequenceQuery

Even if all objects of this query have been awaited for, the step of the sequence will not changed until any edge of the signal with is passed as parameter is detected. This mechanism can be used to make an operator toggle a button in order to advance through the sequence.

The following code snippet will only advance the sequence to step=20 if obj.Done = TRUE and after that, a button is toggled from FALSE to TRUE of TRUE to FALSE

BeginQuery().
  WithAnyTrigger(button).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

on BOOL

Returns

ISequenceQuery

WithButtonPressed

METHOD WithButtonPressed (
 [input] input : REFERENCE TO BOOL) : ISequenceQuery

Even if all objects of this query have been awaited for, the step of the sequence will not changed until the boolean ìnput is set to TRUE. After calling this method input is set to FALSE again. This mechanism is usually used to continue only if a button on the HMI has been pressed.

The following code snippet will only advance the sequence to step=20 if obj.Done = TRUE and after that, a button is set to TRUE. Note that button=FALSE after the call to WithButtonPressed has been made, no matter the intial value.

BeginQuery().
  WithButtonPressed(button).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

input REFERENCE TO BOOL

Returns

ISequenceQuery

WithCondition

METHOD WithCondition (
 [input] condition : BOOL) : ISequenceQuery

Even if all objects of this query have been awaited for, the step of the sequence will not changed until the passed condition is TRUE.

The following code snippet will only advance the sequence to step=20 if obj.Done = TRUE and after the passed condition is fulfilled

BeginQuery().
  WithCondition(value > 10).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

condition BOOL

Returns

ISequenceQuery

WithFallingTrigger

METHOD WithFallingTrigger (
 [input] on : BOOL) : ISequenceQuery

Even if all objects of this query have been awaited for, the step of the sequence will not changed until a falling edge of the signal with is passed as parameter is detected. This mechanism can be used to make an operator press a button in order to advance through the sequence.

The following code snippet will only advance the sequence to step=20 if obj.Done = TRUE and after that, a falling edge of button is detected.

BeginQuery().
  WithFallingTrigger(button).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

on BOOL

Returns

ISequenceQuery

WithRepetition

METHOD WithRepetition (
 [input] repetition : INT) : ISequenceQuery

If the query is successful the current step of the sequence is repeated repetition times. Only after these repetitions, the step of the sequence is advanced.

The following code snipped will repeat the current step of the sequence 2 times, after every time that obj1.Done = TRUE. Only after the second repetition, the step is advanced to 20.

BeginQuery().
  WithRepetition(2).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

repetition INT

Returns

ISequenceQuery

WithRetry

METHOD WithRetry (
 [input] retries : INT) : ISequenceQuery

If the query fails for any reason, which includes

  • Errors of objects (Await, Assert)
  • Timeouts when using (WithTimeout), the current step of the sequence is repeated retries times. Only after these repetitions, the error flag of the sequence is actually set to true and the object which caused the error will be used as the error source.

The following code snipped will repeat the current step of the sequence 2 times if obj1 caused any error. Only if after 2 retries obj1 is still causing errors the sequence is aborted.

BeginQuery().
  WithRetry(2).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

retries INT

Returns

ISequenceQuery

WithRisingTrigger

METHOD WithRisingTrigger (
 [input] on : BOOL) : ISequenceQuery

Even if all objects of this query have been awaited for, the step of the sequence will not changed until a rising edge of the signal with is passed as parameter is detected. This mechanism can be used to make an operator press a button in order to advance through the sequence.

The following code snippet will only advance the sequence to step=20 if obj.Done = TRUE and after that, a rising edge of button is detected.

BeginQuery().
  WithRisingTrigger(button).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

on BOOL

Returns

ISequenceQuery

WithTimeout

METHOD WithTimeout (
 [input] timeout : LREAL) : ISequenceQuery

If other conditions of the query are taking longer than timeout seconds, the sequence's error flag will be set to true

The following code snippet will abort the sequence if obj does not complete its current task within 120 seconds.

BeginQuery().
  WithTimeout(120).
  Await(obj1).
  OnDoneGoTo(20).
EndQuery();

Inputs

timeout LREAL

in seconds

Returns

ISequenceQuery