Timed Transitions

By definition, delays are activities that last a certain time. A delay is therefore naturally attached to a state, rather than to a transition — it is represented using a delay activity. The delay activity is interrupted when the expected event takes place. In fact, this event triggers a transition, which allows the state encompassing the delay activity to be exited. The control flow is then transferred to a different state.

The following example illustrates a delay sequence in an automated teller machine. When the flap that accepts deposits is open, the system tells users that they have three minutes to make their deposit. If the deposit is performed within three minutes, the delay activity is interrupted by the triggering of the transition towards state B. Conversely, if the deposit is not performed within the given time, the automatic transition towards the cancellation state is triggered at the end of the delay activity. In both cases, the flap is closed by the exit action of the delay state.

Representation of a timer by combination of a wait activity and an automatic transition

Timers may be represented using a more compact notation, which is directly tied to the transition triggered after the delay. The triggering event has the generic name after, and the parameter specifies the timer duration.

The syntax of a timer event takes the form:

after (timer_duration)

The previous diagram is then transformed in the following way:

State machines provide a formalism that is well adapted to the representation of complex behaviors. In analysis, statechart diagrams capture the expected behavior. During implementation, state machines may be written easily, using tables containing the states and actions to execute at the time of the transitions.

Metamodel Introduction

A state machine represents a behavior resulting from operations executed after a sequence of state changes. A state machine may be displayed according to the point of view of the state (by statechart diagrams) or the action (by activity diagrams). A state machine specifies the behavior of a collaboration.

The execution of a state machine instance cannot be interrupted. At any time, a state machine may react to a particular event that moves it from a stable state to another stable state. The execution of a state machine starts with the initial pseudo-state and continues, event by event, until a final, non-nested pseudo-state is reached.

Simplified metamodel — a state machine is a graph composed of states and transitions.

Events trigger transitions. The triggering of a transition brings the state machine from the source state to the destination state. Along the way, one or more actions may be triggered on one or more objects.

UML defines three different kinds of events:

The following diagram represents transitions, their actions, and the various events that trigger them:

Simplified metamodel representation of the various kinds of events.

© 1997 Editions, Eyrolles, Paris, France . All rights reserved.