Process Events in States Containing Inner Transitions
Process Events with an Inner Transition in an Exclusive (OR) State
This example shows what happens when processing three events using an inner transition in an exclusive (OR) state.
Process One Event in an Exclusive (OR) State
This example shows the behavior of an inner transition.
Initially, the chart is asleep. State A
is active.
Condition [C_one]
is false. Event E_one
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid transition as a result of
E_one
. A potentially valid transition from stateA
to stateB
is detected. However, the transition is not valid, because[C_one]
is false.State
A
during actions (durA()
) execute and complete.State
A
checks its children for a valid transition and detects a valid inner transition.State
A
remains active. The inner transition actionA_two
is executed and completed. Because it is an inner transition, the chart does not execute theexit
andentry
actions for stateA
.The chart goes back to sleep.
This sequence completes the execution of this Stateflow® chart associated with event E_one
.
Process a Second Event in an Exclusive (OR) State
Using the previous example, this example shows what happens when a second
event E_one
occurs.
Initially, the chart is asleep. State A
is still active.
Condition [C_one]
is true. Event E_one
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid transition as a result of
E_one
.The transition from state
A
to stateB
is now valid because[C_one]
is true.State
A
exit actions (exitA()
) execute and complete.State
A
is marked inactive.The transition action
A_one
is executed and completed.State
B
is marked active.State
B
entry actions (entB()
) execute and complete.The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
.
Process a Third Event in an Exclusive (OR) State
Using the previous example, this example shows what happens when a third
event, E_two
, occurs.
Initially, the chart is asleep. State B
is now active.
Condition [C_two]
is false. Event E_two
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid transition as a result of
E_two
.A potentially valid transition from state
B
to stateA
is detected. The transition is not valid because[C_two]
is false. However, active stateB
has a valid self-loop transition.State
B
exit actions (exitB()
) execute and complete.State
B
is marked inactive.The self-loop transition action,
A_four
, executes and completes.State
B
is marked active.State
B
entry actions (entB()
) execute and complete.The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_two
. This example
shows the difference in behavior between inner and self-loop transitions.
Process Events with an Inner Transition to a Connective Junction
This example shows the behavior of handling repeated events using an inner transition to a connective junction.
Process the First Event with an Inner Transition to a Connective Junction
This example shows the behavior of an inner transition to a connective junction for the first event.
Initially, the chart is asleep. State A1
is active.
Condition [C_two]
is true. Event E_one
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid transition at the root level as a result of
E_one
. There is no valid transition.State
A
during actions (durA()
) execute and complete.State
A
checks itself for valid transitions and detects that there is a valid inner transition to a connective junction.The conditions are evaluated to determine whether one of the transitions is valid. Because the segments labeled with a condition are assigned the first and second position in the execution order, they are evaluated before the unlabeled segment. The evaluation starts from a 12 o'clock position on the junction and progresses in a clockwise manner. Because
[C_two]
is true, the inner transition to the junction and then to stateA
.A2
is valid.State
A
.A1
exit actions (exitA1()
) execute and complete.State
A
.A1
is marked inactive.State
A
.A2
is marked active.State
A
.A2
entry actions (entA2()
) execute and complete.The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
when state
A1
is active and condition [C_two]
is
true.
Process a Second Event with an Inner Transition to a Connective Junction
Continuing the previous example, this example shows the behavior of an inner
transition to a junction when a second event E_one
occurs.
Initially, the chart is asleep. State A2
is active.
Condition [C_two]
is true. Event E_one
occurs and awakens the chart, which processes the event from the root down
through the hierarchy:
The chart root checks to see if there is a valid transition at the root level as a result of
E_one
. There is no valid transition.State
A
during actions (durA()
) execute and complete.State
A
checks itself for valid transitions and detects a valid inner transition to a connective junction.The conditions are evaluated to determine whether one of the transitions is valid. Because the segments labeled with a condition are assigned the first and second position in the execution order, they are evaluated before the unlabeled segment. The evaluation starts from a 12 o'clock position on the junction and progresses in a clockwise manner. Because
[C_two]
is true, the inner transition to the junction and then to stateA.A2
is valid.State
A
.A2
exit actions (exitA2()
) execute and complete.State
A
.A2
is marked inactive.State
A
.A2
is marked active.State
A
.A2
entry actions (entA2()
) execute and complete.The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
when state
A2
is active and condition [C_two]
is
true. For a state with a valid inner transition, an active substate can be
exited and reentered immediately.
Inner Transition to a History Junction
This example shows the behavior of an inner transition to a history junction.
Initially, the chart is asleep. State A.A1
is active. History
information exists because superstate A
is active. Event
E_one
occurs and awakens the chart, which processes the event
from the root down through the hierarchy:
The chart root checks to see if there is a valid transition as a result of
E_one
. There is no valid transition.State
A
during actions execute and complete.State
A
checks itself for valid transitions and detects that there is a valid inner transition to a history junction. Based on the history information, the last active state,A.A1
, is the destination state.State
A.A1
exit actions execute and complete.State
A.A1
is marked inactive.State
A.A1
is marked active.State
A.A1
entry actions execute and complete.The chart goes back to sleep.
This sequence completes the execution of this Stateflow chart associated with event E_one
when there is an
inner transition to a history junction and state A.A1
is active.
For a state with a valid inner transition, an active substate can be exited and
reentered immediately.