Default Transitions

What Is a Default Transition?

A default transition specifies which exclusive (OR) state to enter when there is ambiguity among two or more neighboring exclusive (OR) states. A default transition has a destination but no source object. For example, a default transition specifies which substate of a superstate with exclusive (OR) decomposition the system enters by default, in the absence of any other information such as a history junction. A default transition can also specify that a junction should be entered by default.

Drawing Default Transitions

Click the Default transition button in the toolbar, and click a location in the drawing area close to the state or junction you want to be the destination for the default transition. Drag the mouse to the destination object to attach the default transition. In some cases, it is useful to label default transitions.

A common programming mistake is to create multiple exclusive (OR) states without a default transition. In the absence of the default transition, there is no indication of which state becomes active by default. Note that this error is flagged when you simulate the model using the Debugger with the State Inconsistencies option enabled.

This table shows the button icon and briefly describes a default transition.

Name

Button Icon

Description

Default transition

Use a default transition to indicate, when entering this level in the hierarchy, which object becomes active by default.

Labeling Default Transitions

In some circumstances, you might want to label default transitions. You can label default transitions as you would other transitions. For example, you might want to specify that one state or another should become active depending upon the event that has occurred. In another situation, you might want to have specific actions take place that are dependent upon the destination of the transition.

Default Transition Examples

The following examples show the use of default transitions in Stateflow charts:

Default Transition to a State Example

This example shows a use of default transitions.

When the Stateflow chart first wakes up, it must decide whether to activate state S or state B since they are exclusive (OR) states. The answer is given by the default transition to superstate S, which is taken if valid. Because there are no conditions on this default transition, it is taken.

State S, which is now active, has two substates, A and D. Which substate becomes active? Only one of them can be active because they are exclusive (OR) states. The answer is given by the default transition to substate D, which is taken if valid. Because there are no conditions on this default transition, it is taken.

Suppose at a different execution point, the Stateflow chart is awakened by the occurrence of event d and state B is active. The transition from state B to state S is valid. When the system enters state S, it enters substate D because the default transition is defined.

See Default Transition Examples for more information on the semantics of this notation.

The default transitions are required for the Stateflow chart to execute. Without the default transition to state S, when the Stateflow chart wakes up, none of the states becomes active. You can detect this situation at run-time by checking for state inconsistencies. See Animating Stateflow® Charts in Normal Mode for more information.

Default Transition to a Junction Example

This example shows a default transition to a connective junction.

In this example, the default transition to the connective junction defines that upon entering the Counting state, the destination is determined by the condition on each transition segment.

See Default Transition to a Junction Example for more information on the semantics of this notation.

Default Transition with a Label Example

The following example shows the labeling of default transitions.

If state A is initially active and either e1 or e2 occurs, the transition from state A to superstate B is valid. The substates B1 and B2 both have default transitions. The default transitions are labeled to specify the event that triggers the transition. If event e1 occurs, the transition A to B1 is valid. If event e2 occurs, the transition A to B2 is valid.

See Labeled Default Transitions Example for more information on the semantics of this notation.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS