52.9.6 Wait For

The "Wait For" activity can be used to:

Wait for a scheduled point in time. The schedule can be set up in a number of ways. See section "Waiting For a Scheduled Point in Time" below.

Wait for another activity to finish with a predetermined outcome. See section "Waiting For a Given Outcome of an Activity1".

Wait for a particular kind of event to occur. This is straightforward; see the reference section "Wait For" for the fine points. A special case is Wait For with periodic events: see section "Wait For with Periodic Events".

52.9.6.1. Waiting For a Scheduled Point in Time

Suppose we want a device to dial a short voice call once every 10 minutes. This can be accomplished by putting the voice call inside a while loop which also contains a Wait For activity, providing a timing mechanism.

Create a "While" loop and set its termination condition to whatever you like.

At the top of the loop, put a "Wait For" with Trigger = Schedule.

If you just want to start the dialing as soon as the script starts, set Start to Immediately.

You can also specify that the calls should begin, for example, at the turn of the hour ("On the Hour") or at an arbitrary time ("Time of Day").

To make the loop execute with the desired frequency, continue by setting Repeat to Yes and Repeat Interval to 10 minutes. The loop will then pause at the Wait For activity each time until 10 minutes have passed since the previous turn. This pattern will repeat until the while loop terminates.

Add activities for the voice call ("Dial", "Wait", "Hang Up") just as in section "Basics of Creating Scripts (with Voice)". In the screenshots below, the call duration has been set to 2 minutes.

Left: While loop controlled by "Wait For" with Start = Immediately.
Right: While loop controlled by "Wait For" with Start = Time of Day.

52.9.6.2. Waiting For a Given Outcome of an Activity1

Instead of collecting data continuously, an alternative ("event-driven") approach to data collection is to wait until something interesting happens and trigger recording only then.
Again taking CS voice as a simple use case, suppose that the voice service is tested by dialing one call after another. If a call proceeds normally, we do not log any data, but if a call is blocked, we want to start a logfile recording to capture what happens over the following one-minute period.

Create a "Parallel" structure with two branches.

In the left-hand branch, insert a "While" loop repeating voice calls. Configure the "Dial" activity to abort if the call is blocked (Abort property set to On Event with "Blocked Call" selected as trigger).

In the right-hand branch, put a "Wait For" activity at the top monitoring the voice calls. Set the Trigger property to Activity Result and stipulate that it should equal "Stopped by Event". Then add activities for logfile recording beneath the Wait For: "Start Recording" followed by a "Wait" with Duration = 1 min and finally "Stop Recording".

If any call failures are of interest, and not only blocks, then set Activity Result to the catch-all value "Failed" instead. Recording will then be triggered by any voice call that does not complete normally.

52.9.6.3. Wait For with Periodic Events

Suppose we want to perform some kind of task whenever a given condition is satisfied.
We can then construct a user-defined event for the condition and make that event periodic, which means that it is generated repeatedly at fixed intervals as long as the condition is true (see section "Setting Up a User-defined Event").
Next, a script is written containing a while loop, at the start of which a "Wait For" activity listens for the periodic event. The rest of the loop contains the task to be performed.
If and when the periodic event is generated, the execution will proceed through the rest of the while loop, so that the device performs its task once. Then the execution returns to the Wait For and waits for the event to be generated again, etc.
Note that user-defined events are prefixed with the string "User Defined:" in the Events drop-down box. See the image below.

Left: While loop with "Wait For" having event as trigger.
Right: Selection of periodic event as "Wait For" trigger.2