Stateflow    

Directed Event Broadcasting

Example: Directed Event Broadcast Using send

This example shows the semantics of directed event broadcast using send(event_name,state_name) in a transition action.

Initially the Stateflow diagram is asleep. Parallel substates A.A1 and B.B1 are active. By definition, this implies parallel (AND) superstates A and B are active. An event occurs and awakens the Stateflow diagram. The condition [data1==1] is true. The event is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:

  1. The Stateflow diagram root checks to see if there is a valid transition as a result of the event. There is no valid transition.
  2. State A checks for any valid transitions as a result of the event. Since the condition [data1==1] is true, there is a valid transition from state A.A1 to state A.A2.
  3. State A.A1 exit actions execute and complete (exitA1()).

Start of E_one Event Processing

  1. State A.A1 is marked inactive.
  2. The transition action, send(E_one,B) is executed and completed.
    1. The broadcast of event E_one awakens state B. (This is a nested event broadcast.) Since state B is active, the directed broadcast is received and state B checks to see if there is a valid transition. There is a valid transition from B.B1 to B.B2.
    2. State B.B1 executes and completes exit actions (exitB1()).
    3. State B.B1 is marked inactive.
    4. State B.B2 is marked active.
    5. State B.B2 executes and completes entry actions (entB2()).

End of Event E_one Processing

  1. State A.A2 is marked active.
  2. State A.A2 entry actions execute and complete (entA2()).

This sequence completes the execution of this Stateflow diagram associated with an event broadcast and the directed event broadcast to a parallel state of event E_one.

Example: Directed Event Broadcasting Using Qualified Event Names

This example shows the semantics of directed event broadcast using a qualified event name in a transition action.

Initially the Stateflow diagram is asleep. Parallel substates A.A1 and B.B1 are active. By definition, this implies parallel (AND) superstates A and B are active. An event occurs and awakens the Stateflow diagram. The condition [data1==1] is true. The event is processed from the root of the Stateflow diagram down through the hierarchy of the Stateflow diagram:

  1. The Stateflow diagram root checks to see if there is a valid transition as a result of the event. There is no valid transition.
  2. State A checks for any valid transitions as a result of the event. Since the condition [data1==1] is true, there is a valid transition from state A.A1 to state A.A2.
  3. State A.A1 exit actions execute and complete (exitA1()).
  4. State A.A1 is marked inactive.
  5. The transition action, a qualified event broadcast of event E_one to state B (represented by the notation B.E_one), is executed and completed.
    1. The broadcast of event E_one awakens state B. (This is a nested event broadcast.) Since state B is active, the directed broadcast is received and state B checks to see if there is a valid transition. There is a valid transition from B.B1 to B.B2.
    2. State B.B1 executes and completes exit actions (exitB1()).
    3. State B.B1 is marked inactive.
    4. State B.B2 is marked active.
    5. State B.B2 executes and completes entry actions (entB2()).
  6. State A.A2 is marked active.
  7. State A.A2 entry actions execute and complete (entA2()).

This sequence completes the execution of this Stateflow diagram associated with an event broadcast using a qualified event name to a parallel state.


 Parallel (AND) States Execution Order