Class SyntacticPort

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class SyntacticPort
    extends ComponentPort
    Represent ComponentPorts syntactically in SyntacticNodes. Ports in models that can be interpreted as input or output ports can be represented referentially by this object. The semantic information about direction is not retained in the reference but represented by the context of the reference in an input or output list in a SyntacticTerm. Multiports are split into series of SyntacticPorts. Bidirectional ports are split into pairs of SyntacticPorts.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Chris Shaver
    Pt.AcceptedRating:
    red
    Pt.ProposedRating:
    red (shaver)
    • Constructor Detail

      • SyntacticPort

        public SyntacticPort()
        Construct SyntacticPort.
      • SyntacticPort

        public SyntacticPort​(Workspace workspace)
        Construct SyntacticPort with given workspace.
        Parameters:
        workspace - Workspace to add SyntacticPort to.
      • SyntacticPort

        public SyntacticPort​(SyntacticNode container,
                             Port port,
                             boolean direction,
                             java.lang.String name)
                      throws IllegalActionException,
                             NameDuplicationException
        Construct SyntacticPort with given container and name. The caller can associate the syntactic port with an actual port. The caller must determine if the port is input or output and the represented port, if one exist, will be treated inferentially as such.
        Parameters:
        container - SyntacticNode in which this port is added.
        port - Port referred to by this SyntacticPort.
        direction - True if input, false if output.
        name - Name of this port.
        Throws:
        IllegalActionException - If the port is not of an acceptable class for the container.
        NameDuplicationException - If the name coincides with a port already in the container.
    • Method Detail

      • getConnectedPort

        public SyntacticPort getConnectedPort()
        Get the connected port from a given port. If the graph is not made bijective this gives the first. If there are no ports or no SyntacticPorts null is returned.
        Returns:
        An immediately connected port or null.
      • getNode

        public SyntacticNode getNode()
        Get node in which port is contained.
        Returns:
        node in which port is contained or null if none.
      • setChannel

        public void setChannel​(int channel)
        Set the channel of the represented port. Each SyntacticPort only represents a single channel of the represented port.
        Parameters:
        channel - The channel of the represented port.
        See Also:
        getChannel()
      • getRepresentedPort

        public Port getRepresentedPort()
        Get the port represented by the Syntactic Port.
        Returns:
        represented port.
      • getChannel

        public int getChannel()
        Get the channel of the represented port.
        Returns:
        represented channel of the port.
        See Also:
        setChannel(int)
      • isRepresentative

        public boolean isRepresentative()
        Decide whether the port represents an actual port. If false, the port is purely syntactic.
        Returns:
        whether the port is representative.
      • isInput

        public boolean isInput()
        Decide whether the port is representationally an input port.
        Returns:
        whether the port is an input port.
      • isOutput

        public boolean isOutput()
        Decide whether the port is representationally an output port.
        Returns:
        whether the port is an output port.
      • isEmpty

        public boolean isEmpty()
        Decide whether the port is disconnected.
        Returns:
        whether the port is disconnected.
      • getType

        public SyntacticPort.IOType getType()
        Gets the IOType of the port. For ports that represent input/output ports, each SyntacticPort will be set to the appropriate type for the part of the port it represents.
        Returns:
        IOType of the port.
      • portType

        public static SyntacticPort.IOType portType​(Port port)
        Gets the IOType of a given port.
        Parameters:
        port - Port to find the type of.
        Returns:
        IOType of given port.
      • isPortExterior

        public static boolean isPortExterior​(Port port,
                                             CompositeEntity entity)
        Decide whether a port is exterior in the given entity. This should be passed the model during analysis.
        Parameters:
        port - Port to check for exteriority.
        entity - Entity to check inside of.
        Returns:
        whether port is exterior for the given entity.
      • portType

        public static SyntacticPort.IOType portType​(Port port,
                                                    CompositeEntity entity)
        Gets the IOType of a given port with reference to a composite entity. If a port is an exterior port of the entity, its IOType is reversed to reflect the role it plays on the inside of the composite.
        Parameters:
        port - Port to find the type of.
        entity - Entity to check inside of.
        Returns:
        IOType of the port.
      • portWidth

        public static java.lang.Integer portWidth​(Port port)
                                           throws IllegalActionException
        Gets the width of a Port.
        Parameters:
        port - Port to find the width of.
        Returns:
        the width of the port or null if not a port.
        Throws:
        IllegalActionException - If thrown while getting the width.