Main Content

Stateflow.Port

Entry or exit port in state or atomic subchart

    Description

    Use Stateflow.Port objects to create ports and junctions that provide entry and exit connections across boundaries in the Stateflow® hierarchy. Entry and exit ports improve componentization by isolating the transition logic for entering and exiting states. Unlike supertransitions, they can be used in atomic subcharts. For more information, see Create Entry and Exit Connections Across State Boundaries.

    Entry and exit ports are located on the boundary of a state or atomic subchart. Each port has a matching junction that marks the entry or exit point inside the state or atomic subchart. The port and junction are represented by separate Stateflow.Port objects.

    Creation

    Description

    example

    port = Stateflow.Port(parent,portType) creates a Stateflow.Port object of the specified port type in the parent. The function creates a second Stateflow.Port object for the matching entry or exit port on the boundary of the parent. To identify the matching Stateflow.Port object, use the function Stateflow.findMatchingPort.

    Input Arguments

    expand all

    Parent for the new entry or exit junction, specified as a Stateflow.State object or as a Stateflow.Chart object that is the subchart of a Stateflow.AtomicSubchart object.

    Type of junction, specified as 'EntryJunction' or 'ExitJunction'.

    Properties

    expand all

    Stateflow API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    Label for the port or junction, specified as a character vector. Changing this property automatically sets the LabelString property for the matching Stateflow.Port object to the same value.

    This property is read-only.

    Type of port or junction, specified as one of these values:

    • 'EntryJunction' — Entry junction inside a state or atomic subchart

    • 'EntryPort' — Entry port on the boundary of a state or atomic subchart

    • 'ExitJunction' — Exit junction inside a state or atomic subchart

    • 'ExitPort' — Exit port on the boundary of a state or atomic subchart

    Whether to comment out the junction and port pair, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true is equivalent to right-clicking the entry or exit junction and selecting Comment Out. This property applies only to entry and exit junctions. Attempting to set this property on an entry or exit port results in an error. For more information, see Commenting Stateflow Objects in a Chart.

    This property is read-only.

    Whether the port or junction is implicitly commented out, specified as a numeric or logical 1 (true) or 0 (false). The port or junction is implicitly commented out when you comment out a state, box, or function that contains it. Additionally, entry and exit ports are implicitly commented out when you comment out their matching entry or exit junction.

    Comment text added to the entry or exit junction, specified as a character vector. This property applies only to entry and exit junctions when the IsExplicitlyCommented property is true. In the Stateflow Editor, when you point to the comment badge on the junction, the text appears as a tooltip. When you set the IsExplicitlyCommented property to false, the value of CommentText reverts to ''.

    Graphical Appearance

    Position and size of the port or junction, specified as a Stateflow.PortPosition object with these properties:

    • Center — Position of the center of the port or junction, specified as a two-element numeric vector [x y] of coordinates relative to the upper left corner of the chart.

    • Radius — Radius of the port or junction, specified as a scalar.

    Example: port.Position.Center = [31.41 27.18];

    Example: port.Position.Radius = 16.18;

    Position and size of the port or junction label, specified as a four-element numeric vector of the form [left top width height].

    Size of incoming transition arrows, specified as a scalar.

    Hierarchy

    This property is read-only.

    Chart that contains the port or junction, specified as a Stateflow.Chart object.

    This property is read-only.

    Subviewer for the port or junction, specified as a Stateflow.Chart, Stateflow.State, or Stateflow.Box object. The subviewer is the chart or subchart where you can graphically view the port.

    This property is read-only.

    Home state or subchart, specified as a Stateflow.State or Stateflow.AtomicSubchart object. The home of an entry or exit port is the state or subchart whose boundary contains the port. This property applies only to entry and exit ports.

    This property is read-only.

    Machine that contains the port or junction, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the port or junction in the model hierarchy, specified as a character vector.

    This property is read-only.

    Whether the port or junction has a matching junction or port, specified as a numeric or logical 1 (true) or 0 (false). This property is used to detect internal inconsistencies in the chart.

    Identification

    Description for the port or junction, specified as a character vector.

    Document link for the port or junction, specified as a character vector.

    User-defined tag for the port or junction, specified as data of any type.

    This property is read-only.

    Session-independent identifier, specified as an integer scalar. Use this property to distinguish the port or junction from other objects in the model.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Unlike SSIdNumber, the value of this property is reassigned every time you start a new MATLAB® session and may be recycled after an object is deleted.

    Object Functions

    getParentIdentify parent of object
    sinkedTransitionsIdentify transitions with specified destination
    sourcedTransitionsIdentify transitions with specified source
    dialogOpen properties dialog box
    isCommentedDetermine if graphical object is commented out
    viewDisplay object in editing environment
    highlightHighlight graphical object
    fitToViewZoom in on graphical object

    Examples

    collapse all

    Find the Stateflow.AtomicSubchart object that corresponds to the atomic subchart A in the chart ch.

    atomicSubchart = find(ch,'-isa','Stateflow.AtomicSubchart','Name','A');

    Add an exit junction to the atomic subchart. Use the Subchart property of the atomic subchart as the parent of the exit junction. Display the value of the PortType property of the exit junction.

    exitJunction = Stateflow.Port(atomicSubchart.Subchart,'ExitJunction');
    exitJunction.PortType
    ans =
    
        'ExitJunction'

    Set the label of the exit junction to 'exit'.

    exitJunction.labelString = 'exit';

    Find the Stateflow.Port object for the matching exit port. Display the value of the PortType property of the exit port.

    exitPort = Stateflow.findMatchingPort(exitJunction);
    exitPort.PortType
    ans =
    
        'ExitPort'

    Display the label of the exit port.

    exitPort.labelString
    ans =
    
        'exit'

    Tips

    • If you move an entry or exit junction to a different parent, Stateflow deletes the Stateflow.Port object for the matching port and creates a Stateflow.Port object on the new parent. To identify the new matching port, use the Stateflow.findMatchingPort function.

    Introduced in R2021b