| Using Stateflow | Search  Help Desk |
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.
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()).
.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?
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()).
.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?
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()).
.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
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()).
.E_one.