|On this page…|
These guidelines ensure proper chart behavior in event-driven systems:
Stateflow® charts run on a single thread. Therefore, charts must interrupt current activity to process events. Activity based on an event broadcast from a state or transition action can conflict with the current activity. Charts resolve these conflicts by using early return logic for event broadcasts as follows:
Early Return Logic
If the state is no longer active at the end of the event broadcast, the chart does not perform remaining steps for entering a state.
If the state is no longer active at the end of the event broadcast, the chart does not perform remaining exit actions or transitions from state to state.
If the state is no longer active at the end of the event broadcast, the chart does not perform remaining steps for executing an active state.
If the origin state of the inner or outer flow chart — or parent state of the default flow chart — are no longer active at the end of the event broadcast, the chart does not perform remaining steps for executing the flow chart.
If the parent of the transition path is not active — or if that parent has an active child — the chart does not perform remaining transition actions and state entry actions.
In this example, assume that state A is initially active. Event E occurs, causing the following behavior:
Event F interrupts the transition from A to B.
State C is now the only active child of its chart. The Stateflow chart cannot return to the transition from state A to state B and continue after the condition action that broadcast event F (step 3). First, its source, state A, is no longer active. Second, if the chart allowed the transition, state B would become the second active child of the chart. This behavior violates the guideline that a state (or chart) with exclusive (OR) decomposition can never have more than one active child. Therefore, the chart uses early return logic and halts the transition from state A to state B.
Tip Avoid using undirected local event broadcasts, which can cause unwanted recursive behavior in your chart. Use the send operator for directed local event broadcasts. For more information, see Broadcast Events to Synchronize States.
You can set the diagnostic level for detecting undirected local event broadcasts. In the Model Configuration Parameters dialog box, go to the Diagnostics > Stateflow pane and set the Undirected event broadcasts diagnostic to none, warning, or error. The default setting is warning.