next up previous contents
Next: 2.5.8 An example of Up: 2.5 More Examples Previous: 2.5.6 An example of   Contents

2.5.7 An example of timed transition

Timed transitions are automatically triggered after a certain state is entered. The time between the execution of the enter actions of that state and the triggering of the transition is the interval of a timed transition. In a textual description, a timed transition is a transition with a T property but no E property as in normal transitions. (It is illegal to specify both T and E for the same transition.)

There are two kinds of timed transitions:

  1. Repeated timed transitions are repeatedly scheduled if the source state S is equal to the new state N;

  2. Once timed transitions are scheduled only once if S is equal to N.

Repeated timed transitions are the default type of timed transitions. This semantics conforms to David Harel's original statecharts. Once timed transitions must be explicitly specified by the designer by giving the [OTT] property to their intervals. (The [RTT] property for repeated timed transitions is negligible.)

The following is an example (timed1.des) of the two kinds of timed transitions:

STATECHART:
    A [DS]
    B

TRANSITION:
    S: A
    N: B
    T: 1 [OTT]
    O: [DUMP("start printing")]

TRANSITION:
    S: B
    N: B
    T: 1  # by default, it is [RTT]
    O: [DUMP("tick")]

The simulation result is below:

['A'] > start printing
tick
tick
tick
tick
tick
tick
tick
tick
tick
exit

When started, this model is in state A, and the first timed transition (with [OTT] property) is scheduled after 1 second. When the transition is triggered, it turns the model to state B, and another timed transition is scheduler every 1 second to print out a ``tick'' message. Note that the current state (['B']) of the model is not printed for timed transitions, which are a kind of internal transitions. As a result, the user can only see the message keep appearing in the console, until the exit command is entered, when the simulation stops.

A timed transition may have a guard that specifies the condition that must be true to trigger the transition. The guard is evaluated after the scheduled time instead of at the time when the transition is scheduled. For example, if a transition is scheduled 1 second later, its guard is evaluated 1 second later. If the guard is false, the transition is not triggered. If the transition is a repeated timed transition, it is re-scheduled and its guard will be evaluated 1 second later again.


next up previous contents
Next: 2.5.8 An example of Up: 2.5 More Examples Previous: 2.5.6 An example of   Contents
Thomas Huining Feng
2004-04-05