Resume Prior Substate Activity by Using History Junctions
A history junction in a state records the activity of the substates. The first time that a state that contains a history junction becomes active, the state determines which substate is active by executing the default transition. If, after a period of inactivity, the state becomes active again, the state does not execute the default transition. Instead, the substates return to the prior state of activity.
For example, in this chart, the top-level states represent the on and off modes of a lamp.
On contains two substates,
Blinking, which correspond to the two modes of operation for the lamp.
On becomes active for the first time, the state executes the
default transition and substate
Solid becomes active. This substate
represents the default mode of operation for the lamp. The history junction in state
On records which substate is active, so that,
as the chart transitions from
Off and back to
On, the last active substate becomes active once again. In other words,
when you turn on the lamp, it always returns to the previous mode of operation. For more
information on this example, see Design Human-Machine Interface Logic by Using Stateflow Charts.
A history junction can be the destination of a transition. For example, connecting an inner transition to a history junction is equivalent to drawing a self-loop transition on every substate. When the inner transition is valid, the chart exits and then immediately reenters the active substate. For more information, see Inner Transition to a History Junction.
Add a History Junction
To add a history junction to a Stateflow® chart:
Open the chart.
In the object palette, click the History icon .
On the chart canvas, click the location for the new history junction.
After you add a history junction, you can use the Stateflow Editor to change the size and position of the junction:
To move the junction, click and drag the junction.
To resize the junction, right-click the junction, select Junction Size, and choose a junction size from the drop-down list.
Specify Properties for History Junctions
You can modify the properties listed below in the Property Inspector, the Model Explorer, or the History Junction properties dialog box.
To use the Property Inspector:
In the Modeling tab, under Design Data, select Property Inspector.
In the Stateflow Editor, select the history junction.
In the Property Inspector, edit the history junction properties.
To use the Model Explorer:
In the Modeling tab, under Design Data, select Model Explorer.
In the Model Hierarchy pane, select the parent state or chart for the history junction.
In the Contents pane, select the history junction.
In the Dialog pane, edit the history junction properties.
To use the History Junction properties dialog box:
In the Stateflow Editor, right-click the history junction.
In the properties dialog box, edit the history junction properties.
Parent of the history junction. This property is read-only and is not available in the Property Inspector. When you click the parent hyperlink, the Stateflow Editor brings the parent to the foreground.
Description of the history junction.
Link to online documentation for the history junction. You can enter a web URL address or a MATLAB® command that displays documentation as an HTML file or as text in the MATLAB Command Window. When you click the Document link hyperlink, Stateflow evaluates the link and displays the documentation.
- Model Explorer (Simulink)