Main Content

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.

Supertransition between substates of 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.

Chart modeling a bang-bang controller.

The same supertransition appears inside the subchart.

The On substate.

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

  1. Point to the border of the source state. The pointer changes to a crosshair.

    Chart that contains a state and a subchart.

  2. 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.

    First segment of the supertransition entering the subchart.

  3. Open the subchart by double-clicking it. The arrowhead of the supertransition appears highlighted in red.

    Subchart that contains a substate. The arrowhead of the supertransition appears highlighted in red.

  4. Click the arrowhead and drag the pointer to the desired destination in the subchart.

    Pointer dragging the supertransition arrowhead to the desired destination.

  5. Release the pointer.

    Second segment of the supertransition connects to the substate of the subchart.

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

  1. Draw a transition to a location outside the border of the subchart.

    First segment of the supertransition exiting the subchart.

  2. Navigate to the parent of the subchart. The arrowhead of the supertransition appears highlighted in red.

    Chart that contains a subchart and a substate. The arrowhead of the supertransition appears highlighted in red.

  3. Click the arrowhead and drag the pointer to the desired destination in the chart.

    Pointer dragging the supertransition arrowhead to the desired destination.

  4. Release the pointer.

    Second segment of the supertransition connects to the substate of the chart.

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.

ScenarioRecommendation
Transition between the substates of two sibling states, neither of which is a subchartUse 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.

  • If you use a supertransition, the points where each segment of the supertransition enters or exits different levels of the hierarchy affect one another. For example, moving the point where the supertransition enters the boundary of the subchart also moves the point where the supertransition exits the boundary of the subchart.

  • If you use an entry or exit port, the positions of the port and the matching junction are graphically independent of one another. For example, you can move the port without moving the junction.

Transition to or from a substate of an atomic subchartUse an entry or exit port. Supertransitions cannot cross the boundary of atomic subcharts.

Related Topics