A transition is a line with an arrowhead that links one graphical
object to another. In most cases, a transition represents the passage of the system from one
mode (state) to another. A transition typically connects a source and a destination object.
The source object is where the transition begins and the
destination object is where the transition ends. The following chart
shows a transition from a source state, B
, to a destination state,
A
.
Junctions divide a transition into transition segments. In this case, a full transition consists of the segments taken from the origin to the destination state. Each segment is evaluated in the process of determining the validity of a full transition.
The following example has two segmented transitions: one from state On
to state Off
, and the other from state On
to
itself:
A default transition is a special type of transition that has no source object. See Default Transitions for details.
Transitions cannot contain other objects the way that states can. However, transitions are contained by states. The hierarchy for a transition is described in terms of its parent, source, and destination states. The parent is the lowest level that contains the source and destination of the transition. Consider the parents for the transitions in the following example:
The following table resolves the parentage of each transition in the preceding example.
The /
character represents the chart. Each level in the hierarchy of
states is separated by the period (.
) character.
Transition Label | Transition Parent | Transition Source | Transition Destination |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
A transition label can consist of an event or message, a
condition, a condition action, and a transition action. Each part of the label is optional.
The ?
character is the default transition label. Transition labels have
this overall format:
event_or_message[condition]{condition_action}/transition_action
This example illustrates the parts of a transition label.
Specifies an event or message that causes the transition to occur when the condition
is true. Specify multiple events using the OR logical operator (|
).
Specifying an event or message is optional. The absence of an event or message indicates
that the transition takes place on the occurrence of any event. For more information, see
Synchronize Model Components by Broadcasting Events and Communicate with Stateflow Charts by Sending Messages.
In the previous example, the broadcast of event E
triggers the
transition from On
to Off
if the condition
[off_count==0]
is true.
Specifies a Boolean expression that, when true, validates a transition for the
specified event or message trigger. Enclose the condition in square brackets
([]
). If no condition is specified, an implied condition evaluates to
true. For more information, see Conditions.
In the previous example, when the event E
occurs, the condition
[off_count==0]
must evaluate as true for the transition from
On
to Off
to be valid.
Executes after the condition for the transition is evaluated as true, but before the
transition to the destination is determined to be valid. Enclose the condition action in
curly braces ({}
) following the condition. For more information, see
Condition Action Behavior.
In the previous example, if the event E
occurs and the condition
[off_count==0]
is true, then the condition action {off_count
= off_count + 1}
is immediately executed.
Executes after the transition to the destination is determined to be valid. If the
transition consists of multiple segments, then the transition action is executed when the
entire transition path to the final destination is determined to be valid. Transition
actions occur after the exit actions of the source state and before the entry actions of
the destination state. Precede the transition action with a /
. For more
information, see Condition and Transition Action Behavior.
In the preceding example, if the event E
occurs and the condition
[off_count==0]
is true, then the transition action
{Light_off()}
is executed when the transition from
On
to Off
is determined to be valid. The
transition action occurs after On
becomes inactive, but before
Off
becomes active.
Transition actions are supported only in Stateflow® charts in Simulink® models.
Usually, a transition is valid when the source state of the transition is active and the transition label is valid. Default transitions are different because there is no source state. Validity of a default transition to a substate is evaluated when there is a transition to its superstate, assuming the superstate is active. This labeling criterion applies to both default transitions and general case transitions. The following table lists possible combinations of valid transition labels.
Transition Label | Is Valid If... |
---|---|
Event only | That event occurs |
Event and condition | That event occurs and the condition is true |
Message only | That message occurs |
Message and condition | That message occurs and the condition is true |
Condition only | Any event occurs and the condition is true |
Action only | Any event occurs |
Not specified | Any event occurs |
This example shows simple transitions to and from exclusive (OR) states.
The following transition... | Is valid when... |
---|---|
B to A | State B is active and the event E1
occurs. |
A1 to A2 | State A1 is active and event E2
occurs. |
See Transition Between Exclusive States for more information on the semantics of this notation.
The following chart shows transitions to and from connective junctions.
The chart uses temporal logic to determine when the input u
equals
1.
If the input equals 1... | A transition occurs from... |
---|---|
Before t = 2 | Start to Fast |
Between t = 2 and t = 5 | Start to Good |
After t = 5 | Start to Slow |
For more information about temporal logic, see Control Chart Execution by Using Temporal Logic. For more information on the semantics of this notation, see Transition from a Common Source to Multiple Destinations.
This example shows transitions to and from an exclusive (OR) superstate and the use of a default transition.
The chart has two states at the highest level in the hierarchy,
Power_off
and Power_on
. By default,
Power_off
is active. The event Switch
toggles the
system between the Power_off
and Power_on
states.
Power_on
has three substates: First
,
Second
, and Third
. By default, when
Power_on
becomes active, First
also becomes
active. When Shift
equals 1, the system transitions from
First
to Second
, Second
to
Third
, Third
to First
, for each
occurrence of the event Switch
, and then the pattern repeats.
For more information on the semantics of this notation, see Control Chart Execution by Using Default Transitions.
The following example shows transitions to and from exclusive (OR) substates.
For details on how this chart works, see Debounce Signals with Fault Detection. For information on the semantics of this notation, see Transition from a Substate to a Substate with Events.