Create Entry and Exit Connections Across State Boundaries
Entry and exit ports represent connections into and out of states and subcharts. Like supertransitions, entry and exit ports create transition paths across boundaries in the Stateflow® hierarchy. However, because entry and exit ports isolate the transition logic for entering and exiting states, they can be used in atomic subcharts. Entry and exit ports are not supported in standalone Stateflow charts in MATLAB®.
In the Stateflow Editor, entry and exit ports appear as arrows on the boundary of a state or
subchart. Each port has a matching junction that marks the entry or exit point inside the
state or subchart. The entry junction icon and the exit junction icon indicate the junction. A transition path that leads to an
entry port continues along the transition connected to the matching entry junction. Similarly,
a transition path that leads to an exit junction continues along the transition connected to
the matching exit port. For example, in this chart, the exit port labeled
turnOff
represents the exit connection out of the subchart
On
.
In the subchart, the transition path leading to the exit junction defines the logic for
exiting the subchart. In this example, the function warm
must evaluate to
true
on two consecutive time steps before the chart makes the transition
out of the On
state.
For more information about this example, see Model Bang-Bang Temperature Control System. For other examples that use entry and exit ports, see Robot Trajectory Planning with Reusable Components and Model a Launch Abort System.
Add Entry and Exit Ports
To create an entry or exit port, add an entry or exit junction inside a state or subchart.
In the object palette, click the Entry icon or the Exit icon .
On the chart canvas, click the location for the new entry or exit junction. A matching entry or exit port appears on the boundary of the state or subchart that contains the new entry or exit junction.
Enter a label for the junction and matching port. See Add Labels to Identify Matching Junctions and Ports.
Guidelines for Using Entry and Exit Ports
Add Entry and Exit Junctions Only to Exclusive (OR) States and Atomic Subcharts
Entry and exit junctions are supported only in exclusive (OR) states and atomic subcharts. Do not add entry or exit junctions to top level charts, parallel (AND) states, or boxes.
Add Labels to Identify Matching Junctions and Ports
Labels on entry and exit ports indicate which junction connects to which port. Adding a label is optional when a state contains only one entry or exit junction. Unique labels are required when a state contains more than one entry junction or more than one exit junction.
Prevent Backtracking Through Entry and Exit Ports
To ensure that the chart successfully enters or exits a state without backtracking, each entry junction and exit port must have a path that is not guarded by a condition or triggered by an event. Transition paths from entry junctions and exit ports must lead to states and must not contain terminal junctions.
Isolate the Transition Logic for Entry and Exit Junctions
Transition paths that start at entry junctions or end at exit junctions must be contained in the parent state.
Do Not Enter and Exit States in the Same Time Step
Default and inner transition paths must not connect to an exit junction.
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. |
Specify Properties for Entry and Exit Ports
You can modify the properties listed below in the Property Inspector, the Model Explorer, or the Entry Port, Exit Port, Entry Junction, or Exit 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 port or junction.
In the Property Inspector, edit the properties for the port or junction.
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 port or junction.
In the Contents pane, select the port or junction.
In the Dialog pane, edit the properties for the port or junction.
To use the Entry Port, Exit Port, Entry Junction, or Exit Junction properties dialog box:
In the Stateflow Editor, right-click the port or junction.
Select Properties.
In the properties dialog box, edit the properties for the port or junction.
You can also modify port or junction properties programmatically by using Stateflow.Port
objects. For more information about the Stateflow programmatic interface, see Overview of the Stateflow API.
Parent
Parent of the port or 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.
Home
Home state or subchart of the entry or exit port. The home of an entry or exit port is the state or subchart whose boundary contains the port. This property is read-only and is not available in the Property Inspector. When you click the home hyperlink, the Stateflow Editor brings the home state or subchart to the foreground.
Label
The label for the port or junction. This property is read-only for entry or exit ports. For more information, see Define Actions in a Transition.
Description
Description of the port or junction.
Document link
Link to online documentation for the port or 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.
See Also
Objects
Tools
- Model Explorer (Simulink)