Move Between Levels of Hierarchy by Using Supertransitions
A supertransition is a transition between different levels in a chart. A supertransition can go between a state in a top-level chart and a substate in one of its sibling states, or between substates in different states of the chart. For example, this chart contains a supertransition between the substates of two sibling states.
You can create supertransitions that span any number of levels in your chart. When a
supertransition crosses into or out of a subchart, it consists of multiple transition
segments, each one at a different containment level. For example, this chart model shows a
supertransition leaving the On
subchart.
The same supertransition appears inside the subchart.
You can label any transition segment by using the procedure described in Define Actions in a Transition. The resulting label appears on
each segment of the supertransition. For instance, in the previous example, both segments of
the supertransition have the same label, [warm()]
. If you change the label
on any segment, the change also appears on the other segments.
The points where each segment enters or exits the subchart affect one another. For
example, moving the point where the supertransition exits the boundary of the subchart
On
also moves the point where the supertransition emerges in the
top-level chart.
Tip
Entry and exit ports provide an alternative method to transition across boundaries in the Stateflow® hierarchy. For more information, see Decide Between Supertransitions and Entry and Exit Ports.
Create a Supertransition That Enters a Subchart
Point to the border of the source state. The pointer changes to a crosshair.
Click and drag inside the border of the subchart. A supertransition connects the source state to the subchart. To change where the transition enters the subchart, you can drag the endpoint of the transition segment around the inside boundary of the subchart.
Open the subchart by double-clicking it. The arrowhead of the supertransition appears highlighted in red.
Click the arrowhead and drag the pointer to the desired destination in the subchart.
Release the pointer.
Note
When you draw a supertransition across subchart boundaries, the Undo and Redo buttons are disabled. You cannot undo or redo any prior operations.
Create a Supertransition That Exits a Subchart
Draw a transition to a location outside the border of the subchart.
Navigate to the parent of the subchart. The arrowhead of the supertransition appears highlighted in red.
Click the arrowhead and drag the pointer to the desired destination in the chart.
Release the pointer.
Note
When you draw a supertransition across subchart boundaries, the Undo and Redo buttons are disabled. You cannot undo or redo any prior operations.
Decide Between Supertransitions and Entry and Exit Ports
Both supertransitions and entry and exit ports enable you to move across different levels in the chart hierarchy. Which approach you select depends on your design requirements.
Scenario | Recommendation |
---|---|
Transition between the substates of two sibling states, neither of which is a subchart | Use a supertransition. You can create a supertransition that does not cross any subchart boundaries by simply clicking the boundary of the source state and dragging your pointer to the destination state. |
Transition to or from a substate of a normal subchart | Use either a supertransition or an entry or exit port.
|
Transition to or from a substate of an atomic subchart | Use an entry or exit port. Supertransitions cannot cross the boundary of atomic subcharts. |