To manage multilevel state complexity, use hierarchy in your Stateflow® chart. With hierarchy, you can represent multiple levels of subcomponents in a system.
State Hierarchy Example
In the following example, three levels of hierarchy appear in the chart. Drawing one state within the boundaries of another state indicates that the inner state is a substate (or child) of the outer state (or superstate). The outer state is the parent of the inner state.
In this example, the chart is the parent of the state
Car_done is the parent state of the
Car_shipped states. The state
Car_made is also the
parent of the
Painted states. You
can also say that the states
Painted are children of the
To represent the Stateflow hierarchy textually, use a slash character
(/) to represent
the chart and use a period
(.) to separate each level in the hierarchy of
states. The following list is a textual representation of the hierarchy of objects in the
Objects That a State Can Contain
States can contain all other Stateflow objects. Stateflow chart notation supports the representation of graphical object hierarchy in Stateflow charts with containment. A state is a superstate if it contains other states. A state is a substate if it is contained by another state. A state that is neither a superstate nor a substate of another state is a state whose parent is the Stateflow chart itself.
States can also contain nongraphical data, event, and message objects. The hierarchy of this containment appears in the Model Explorer. You define data, event, and message containment by specifying the parent object.