Using Stateflow     Search    Help Desk 

Semantic Rules Summary

Entering a Chart

The set of default flow paths is executed (see "Executing a Set of Flow Graphs"). If this does not cause a state entry and the chart has parallel decomposition, then each parallel state is entered (see "Entering a State").

Executing an Active Chart

If the chart has no states, each execution is equivalent to initializing a chart. Otherwise, the active children are executed. Parallel states are executed in the same order that they are entered.

Entering a State

   1.
If the parent of the state is not active, perform steps 1-4 for the parent.
   2.
If this is a parallel state check that all siblings with a higher entry order are active. If not perform all entry steps for these states first.
   3.
Mark the state active.
   4.
Perform any entry actions.
   5.
Perform explicit entry actions, if needed:
  1. If the state contains a history junction and there was an active child of this state at some point after the most recent chart initialization, perform the entry actions for this state. Otherwise, execute the default flow paths for the state.
  2. If this state has parallel decomposition, i.e., has children that are parallel states, perform entry steps 1-5 for each state according to its entry order.
   6.
If this is a parallel state, perform all entry actions for the sibling state next in entry order if one exists.
   7.
If the transition path parent is not the same as the parent of the current state, perform entry steps 6 and 7 for the immediate parent of this state.

Executing an Active State

   1.
The set of outer flow graphs is executed (see "Executing a Set of Flow Graphs"). If this causes a state transition, execution stops. (Note that this step is never required for parallel states)
   2.
During actions and valid on-event actions are preformed.
   3.
The set of inner flow graphs is executed. If this does not cause a state transition, the active children are executed, starting at step 1. Parallel states are executed in the same order that they are entered.

Exiting an Active State

   1.
If this is a parallel state, make sure that all sibling states that were entered after this state have already been exited. Otherwise, perform all exiting steps on these states.
   2.
If there are any active children perform the exit steps on these states in the reverse order they were entered.
   3.
Perform any exit actions.
   4.
Mark the state as inactive.

Executing a Set of Flow Graphs

Flow graphs are executed by starting step 1 below with a set of starting transitions. The starting transitions for inner flow graphs are all transition segments that originate on the respective state and are directed inwards at their source. The starting transitions for outer flow graphs are all transition segments that originate on the respective state and are directed outwards at their source. The starting transitions for default flow graphs are all default transition segments that have starting points with the same parent:

   1.
A set of transition segments is ordered.
   2.
While there are remaining segments to test, a segment is tested for validity. If the segment is invalid, move to the next segment in order. If the segment is valid, execution depends on the destination:
States
  1.     No more transition segments are tested and a transition path is formed by backing up and including the transition segment from each preceding junction until the respective starting transition.
  2. The states that are the immediate children of the parent of the transition path are exited (see "Exiting an Active State").
  3.     The transition actions from the entire transition path are executed in the order they the respective segments were validated.
  4. The destination state is entered (see "Entering a State").
Junction with no outgoing transition segments
Testing stops without any states being exited or entered.
Junctions with outgoing transition segments
Step 1 is repeated with the set of outgoing segments from the junction.
   3.
After testing all outgoing transition segments at a junction, back up the incoming transition segment which brought you to the junction and continue at step 2, starting with the next transition segment after the back up segment. The set of flow graphs is done executing when all starting transitions have been tested.

Executing an Event Broadcast

Output edge trigger event execution is equivalent to changing the value of an output data value. All other events have the following execution:

   1.
If the receiver of the event is active, then it is executed (see "Executing an Active Chart" and "Executing an Active State"). (The event receiver is the parent of the event unless the event was explicitly directed to a receiver using the send() function.)
   2.
Early return logic is performed based on the type of action statement that caused the event.

Action Type
Early Return Logic
State Entry
If the state is no longer active at the end of the event broadcast, any remaining steps in entering a state are not performed.
State Exit
If the state is no longer active at the end of the event broadcast, any remaining exit actions and steps in state transitioning are not performed.
State During
If the state is no longer active at the end of the event broadcast, any remaining steps in executing an active state are not performed.

Condition
If the origin state of the inner or outer flow graph or parent state of the default flow graph is no longer active at the end of the event broadcast, the remaining steps in the execution of the set of flow graphs are not performed.
Transition
If the parent of the transition path is not active or if that parent has an active child, the remaining transition actions and state entry are not performed.



[ Previous | Help Desk | Next ]