IBM
Contents Index Previous Next



Timer Statements


TTCN timers are used to test timer events in the IUT. This is usually done by timing an expected response from the IUT using the START timer operation and the TIMEOUT event. The CANCEL timer operation is used to stop and reset a running or expired timer.All timers are declared in the Timer Declarations table. The duration is the period of time that will pass from the moment a timer is started to the moment it expires. Duration is measured in one of the following units:

Figure 58 : Declaration of timers

The Timeout List

TTCN maintains a timeout list. If a timer expires its name is added to the timeout list. Three things can remove the name of the timer from the timeout list:

The TIMEOUT Statement

The test suite specifier may state that a named timer be checked to see if it has timed-out. This is denoted by:

When this statement is encountered while processing a statement line the TIMEOUT will match if the named timer is in the timeout list, otherwise the TIMEOUT fails.

An alternative use of TIMEOUT is simply:

i.e. no TimerIdentifier is given. In this case the TIMEOUT statement will succeed as long as the timeout list is not empty.

The TIMEOUT statement may be qualified and it may be followed by an ASSIGNMENT_LIST and/or TIMER_OPERATION. The order in which these statements may appear in the statement line is fixed, as shown below; the square brackets indicate that the presence of the statement in the statement line is optional:

Note:

TIMEOUT should not be used to guard against a faulty IUT not sending a required response. It is the responsibility of the test system to implement detection of such an occurrence.

Timer Snapshots

We have already mentioned that at the beginning of each cycle through a set of alternatives a snapshot is taken of the incoming PCO queues. The alternatives are then checked against this snapshot. The same thing is done for the timeout list. A snapshot is taken of this list at the start of each cycle and if a TIMEOUT alternative is encountered in the set of alternatives it is checked against the timeout snapshot rather than the actual timeout list. This means that the expiry of a timer during processing of a set of alternatives is not registered until the timer snapshot is updated.

The START Timer Operation

A named timer is started using the START timer operation. This is denoted by:

The duration for this timer is taken from the timer declaration. Alternatively, an explicit duration may be given, which overrides the declared duration:

If the timer is already running when the START is invoked then the timer is cancelled, reset and then started, i.e. the timer is re-started.

If the timer has expired then its name is removed from the timeout list before it is re-started.

The START_TIMER statement may be qualified and it may be followed by an ASSIGNMENT_LIST. The order in which these statements may appear in the statement line is fixed, as shown below:

Figure 59 : Using START and TIMEOUT in a behavior tree

The CANCEL Timer Operation

A named timer is cancelled using the CANCEL operation. This is denoted by:

An alternative use of CANCEL is simply:

i.e. no TimerIdentifier is given. In this case all running timers are cancelled and reset and the timeout list is cleared.

Cancelling a timer that is expired will result in the timer being reset and its identifier is removed from the timeout list.

The CANCEL_TIMER statement may be qualified and it may be followed by an ASSIGNMENT_LIST. The order in which these statements may appear in the statement line is fixed, as shown below:

Figure 60 : Execution of an alternative that contains a stand-alone timer operation


http://www.ibm.com/rational
Contents Index Previous Next