|On this page…|
Stateflow® charts execute only in response to an event in a cyclical manner.
Because a chart runs on a single thread, actions that take place based on an event are atomic to that event. All activity caused by the event in the chart finishes before execution returns to the activity that was taking place before receiving the event. Once an event initiates an action, the action completes unless interrupted by an early return.
Simulink® events awaken Stateflow charts. You can use events to control the processing of your charts by broadcasting events, as described in Broadcast Events to Synchronize States. For examples using event broadcasting and directed event broadcasting, see:
Events have hierarchy (a parent) and scope. The parent and scope together define a range of access to events. The parent of an event usually determines who can trigger on the event (has receive rights). See the Name and Parent fields for an event in Set Properties for an Event for more information.
Stateflow charts process events from the top down through the chart hierarchy:
Executes during and on event_name actions for the active state
Checks for valid transitions in substates
All events, except for the output edge trigger to a Simulink block (see the following note), have the following execution in a chart:
If the receiver of the event is active, then it executes (see Execution of an Active Chart and Steps for Executing an Active State). (The event receiver is the parent of the event unless a directed event broadcast occurs using the send() function.)
To learn about early return logic, see Early Return Logic for Event Broadcasts.
Note: Output edge-trigger event execution in a Simulink model is equivalent to toggling the value of an output data value between 1 and 0. It is not treated as a Stateflow event. See Define Edge-Triggered Output Events.