Overview of Stateflow Objects
Hierarchy of Stateflow Objects
Stateflow® objects are arranged in a hierarchy based on containment. That is, one Stateflow object can contain other Stateflow objects.
The highest object in Stateflow hierarchy is the Stateflow machine. The Stateflow machine contains all of the Stateflow charts in a Simulink® model.
Stateflow charts can contain states, functions, boxes, data, events, messages, transitions, junctions, entry and exit ports, and annotations. States, functions, and boxes can contain other states, functions, boxes, data, events, messages, transitions, junctions, entry and exit ports, and annotations. Levels of nesting can continue indefinitely.
To manage graphical objects, use the Stateflow Editor. This table lists each type of graphical object and the palette icon to use for adding the object. For more information, see Stateflow Editor Operations.
Type of Graphical Object
|Represent Operating Modes by Using States|
||Transition Between Operating Modes|
|Combine Transitions and Junctions to Create Branching Paths|
|Group Chart Objects by Using Boxes|
Simulink based state
|Create and Edit Simulink Based States|
|Reuse Simulink Functions in Stateflow Charts|
|Reuse Logic Patterns by Defining Graphical Functions|
|Reuse MATLAB Code by Defining MATLAB Functions|
Truth table function
|Use Truth Tables to Model Combinatorial Logic|
|Record State Activity by Using History Junctions|
|Exit Junction||Create Entry and Exit Connections Across State Boundaries|
|Entry Junction||Create Entry and Exit Connections Across State Boundaries|
|Annotation||Add Descriptive Comments in a Chart|
||Add Descriptive Comments in a Chart|
You can define data, event, and message objects that do not appear graphically in the Stateflow Editor. To manage nongraphical objects, use the Symbols pane or Model Explorer. For more information, see:
A Stateflow chart stores and retrieves data that it uses to control its execution. Stateflow data resides in its own workspace, but you can also access data that resides externally in the Simulink model or application that embeds the Stateflow machine. You must define any internal or external data that you use in a Stateflow chart.
An event is a Stateflow object that can trigger a whole Stateflow chart or individual actions in a chart. Because Stateflow charts execute by reacting to events, you specify and program events into your charts to control their execution. You can broadcast events to every object in the scope of the object sending the event, or you can send an event to a specific object. You can define explicit events that you specify directly, or you can define implicit events to take place when certain actions are performed, such as entering a state. For more information, see Synchronize Model Components by Broadcasting Events.
Stateflow message objects are queued objects that can carry data. You can send a message from one Stateflow chart to another to communicate between charts. You can also send local messages within a chart. You define the type of message data. You can view the lifeline of a message in the Sequence Viewer block. For more information, see Communicate with Stateflow Charts by Sending Messages.