Main Content

Resume Prior Substate Activity by Using History Junctions

Ahistory junctionin 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. The stateOncontains two substates,SolidandBlinking, which correspond to the two modes of operation for the lamp. When stateOnbecomes active for the first time, the state executes the default transition and substateSolidbecomes active. This substate represents the default mode of operation for the lamp. The history junctionin stateOnrecords which substate is active, so that, as the chart transitions fromOntoOffand back toOn, 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, seeDesign Human-Machine Interface Logic by Using Stateflow Charts.

Chart that contains a top-level state with a history junction.

Tip

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, seeInner Transition to a History Junction.

Add a History Junction

添加一个history junction to a Stateflow®chart:

  1. Open the chart.

  2. In the object palette, click the History icon.

  3. 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, selectJunction Size, and choose a junction size from the drop-down list.

Specify Properties for History Junctions

You can specify the properties listed below in theProperty Inspector, the Model Explorer, or the History Junction properties dialog box.

To use theProperty Inspector:

  1. In theModelingtab, underDesign Data, selectProperty Inspector.

  2. In the Stateflow Editor, select the history junction.

  3. In theProperty Inspector, edit the history junction properties.

To use the Model Explorer:

  1. In theModelingtab, underDesign Data, selectModel Explorer.

  2. In theModel Hierarchypane, select the parent state or chart for the history junction.

  3. In theContents窗格中,选择历史结。

  4. In theDialogpane, edit the history junction properties.

To use the History Junction properties dialog box:

  1. In the Stateflow Editor, right-click the history junction.

  2. SelectProperties.

  3. In the properties dialog box, edit the history junction properties.

You can also specify junction properties programmatically by usingStateflow.Junctionobjects. For more information about the Stateflow programmatic interface, seeOverview of the Stateflow API.

Parent

Parent of the history junction. This property is read-only and is not available in theProperty Inspector. When you click the parent hyperlink, the Stateflow Editor brings the parent to the foreground.

Description

Description of the history junction.

Document link

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 theDocument linkhyperlink, Stateflow evaluates the link and displays the documentation.

See Also

Objects

Tools

Related Topics