Stateflow | ![]() ![]() |
Transitions to and from Exclusive (OR) States
Example: Processing of One Event
This example shows the semantics of a simple transition focusing on the implications of states being active or inactive.
Initially the Stateflow diagram is asleep. State On
and state Off
are OR states. State On
is active. Event E_one
occurs and awakens the Stateflow diagram. Event E_one
is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:
E_one
. A valid transition from state On
to state Off
is detected.
On
exit actions execute and complete (ExitOn()
).
On
is marked inactive.
E_one
is broadcast as the transition action. The second generation of event E_one
is processed but because neither state is active, it has no effect. (Had a valid transition been possible as a result of the broadcast of E_one
, the processing of the first broadcast of E_one
would be preempted by the second broadcast of E_one.
)
Off
is marked active.
Off
entry actions execute and complete (entOff()
).
This sequence completes the execution of the Stateflow diagram associated with event E_one
when state On
was active.
Example: Processing of a Second Event
Using the same example, what happens when the next event, E_one
, occurs?
Again, initially the Stateflow diagram is asleep. State Off
is active. Event E_one
occurs and awakens the Stateflow diagram. Event E_one
is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:
E_one
. A valid transition from state Off
to state On
is detected.
Off
exit actions execute and complete (exitOff()
).
Off
is marked inactive.
On
is marked active.
On
entry actions execute and complete (entOn()
).
This sequence completes the execution of the Stateflow diagram associated with the second event E_one
when state Off
was active.
Example: Processing of a Third Event
Using the same example, what happens when a third event, E_two
, occurs?
Again, initially the Stateflow diagram is asleep. State On
is active. Event E_two
occurs and awakens the Stateflow diagram. Event E_two
is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:
E_two
. There is none.
On
during actions execute and complete (durOn()
).
This sequence completes the execution of the Stateflow diagram associated with event E_two
when State On
was active.
Example: Transition from a Substate to a Substate
This example shows the semantics of a transition from an OR substate to an OR substate
.
Initially the Stateflow diagram is asleep. State A
.A1
is active. Event E_one
occurs and awakens the Stateflow diagram. Condition C_one
is true. Event E_one
is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:
E_one
. There is a valid transition from state A
.A1
to state B
.B1
. (Condition C_one
is true.)
A
executes and completes during actions (durA()
).
A
.A1
executes and completes exit actions (exitA1()
).
A
.A1
is marked inactive.
A
executes and completes exit actions (exitA()
).
A
is marked inactive.
A
, is executed and completed.
B
is marked active.
B
executes and completes entry actions (entB()
).
B
.B1
is marked active.
B
.B1
executes and completes entry actions (entB1()
).
This sequence completes the execution of this Stateflow diagram associated with event E_one
.
![]() | Semantics of Transitions | Condition Actions | ![]() |