Stateflow    

State Execution Example

The following example demonstrates the execution semantics (behavior) of event reactive behavior by active and inactive states.

Inactive Diagram Event Reaction

Initially the Stateflow diagram and its states are inactive. This is the semantic sequence that follows an event:

  1. An event occurs and the Stateflow diagram is awakened.
  2. The Stateflow diagram checks to see if there is a valid transition as a result of the event.
  1. A valid default transition to state A is detected.

  1. State A is marked active.
  2. State A entry actions (entA()) execute and complete.
  3. The Stateflow diagram goes back to sleep.

Sleeping Diagram Event Reaction

The Stateflow diagram is now asleep and waiting to be awakened by another event.

  1. Event E_one occurs and the Stateflow diagram is awakened.
  1. State A is active from the preceding steps 1 to 5.

  1. The Stateflow diagram root checks to see if there is a valid transition as a result of E_one. A valid transition is detected from state A to state B.
  2. State A exit actions (exitA()) execute and complete.
  3. State A is marked inactive.
  4. State B is marked active.
  5. State B entry actions (entB()) execute and complete.
  6. The Stateflow diagram goes back to sleep, to be awakened by the next event.


  Exiting an Active State Early Return Logic for Event Broadcasts