Class WirelessIOPort

  • All Implemented Interfaces:
    java.lang.Cloneable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    ChannelPort

    public class WirelessIOPort
    extends TypedIOPort
    This port communicates via channels without wired connections. Channels are instances of WirelessChannel. The port references channels by name, where the name is specified by the outsideChannel or insideChannel parameter.

    This port can be used on the boundary of wireless domain models. A port is outside wireless if an outside channel name is given and a wireless channel with the given name is contained by the container of the port's container (transparent hierarchy is not supported). Specially, it will use the specified wireless channel to communicate on the outside. A port is inside wireless if an inside channel name is given and a wireless channel with the given name is contained by the container of this port. It will use the specified wireless channel to communicate on the inside. If no outside channel or inside channel name is given or the named channel does not exist, then the behavior of the port reverts to that of the base class. Specifically, it will only communicate if it is wired.

    It is valid for a model using the wireless director to have both wireless communication and wired communication, i.e. it may contain actors with ports using wireless communication (by specifying a wireless channel) and actors with ports using wired communication. If a port is outside/inside wireless(a wireless channel is specified), it will ignore all the communication through the wired connections to it if there is any on the outside/inside of it.

    The width of this port on either side that is using wireless communication is fixed at one. Otherwise, it depends on the number of links to the port.

    When this port is used for wireless communications, nothing is connected to it. Consequently, methods that access the topology such as connectedPortList() and deepConnectedInPortList() return an empty list. There are no deeply connected ports. However, sinkPortList() returns the port of the specified wireless channel. A consequence of this is that type constraints are automatically set up between ports that send on the channel and the channel port.

    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Edward A. Lee and Xiaojun Liu
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Green (cxh)
    • Field Detail

      • insideChannel

        public StringParameter insideChannel
        The name of the inside channel. This is a string that defaults to the empty string, indicating that communication is not wireless.
      • insideTransmitProperties

        public Parameter insideTransmitProperties
        The transmit properties of this port for inside transmissions. This field may be used by the channel to determine transmission range or other properties of the transmission. By default, this has no value, which indicates to channels to use their default properties, whatever those might be. When its value is set, it is required to be a record type.
      • outsideChannel

        public StringParameter outsideChannel
        The name of the outside channel. This is a string that defaults to the empty string, indicating that communication is not wireless.
      • outsideTransmitProperties

        public Parameter outsideTransmitProperties
        The transmit properties of this port for outside transmissions. This field may be used by the channel to determine transmission range or other properties of the transmission. By default, this has no value, which indicates to channels to use their default properties, whatever those might be. When its value is set, it is required to be a record type.
    • Constructor Detail

      • WirelessIOPort

        public WirelessIOPort​(Workspace workspace)
                       throws IllegalActionException,
                              NameDuplicationException
        Construct a port in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the workspace directory. Increment the version number of the workspace.
        Parameters:
        workspace - The workspace that will list the port.
        Throws:
        IllegalActionException - If creating the parameters of this port throws it.
        NameDuplicationException - If creating the parameters of this port throws it.
      • WirelessIOPort

        public WirelessIOPort​(ComponentEntity container,
                              java.lang.String name)
                       throws IllegalActionException,
                              NameDuplicationException
        Construct a port with the specified container and name that is neither an input nor an output. The specified container must implement the Actor interface, or an exception will be thrown.
        Parameters:
        container - The container actor.
        name - The name of the port.
        Throws:
        IllegalActionException - If the port is not of an acceptable class for the container, or if the container does not implement the Actor interface.
        NameDuplicationException - If the name coincides with a port already in the container.
      • WirelessIOPort

        public WirelessIOPort​(ComponentEntity container,
                              java.lang.String name,
                              boolean isInput,
                              boolean isOutput)
                       throws IllegalActionException,
                              NameDuplicationException
        Construct a port with a container and a name that is either an input, an output, or both, depending on the third and fourth arguments. The specified container must implement the Actor interface or an exception will be thrown.
        Parameters:
        container - The container actor.
        name - The name of the port.
        isInput - True if this is to be an input port.
        isOutput - True if this is to be an output port.
        Throws:
        IllegalActionException - If the port is not of an acceptable class for the container, or if the container does not implement the Actor interface.
        NameDuplicationException - If the name coincides with a port already in the container.
    • Method Detail

      • broadcast

        public void broadcast​(Token token)
                       throws IllegalActionException
        Override the base class to delegate to the channel if there is one. If there is no outside channel, then defer to the base class.
        Overrides:
        broadcast in class TypedIOPort
        Parameters:
        token - The token to send.
        Throws:
        IllegalActionException - If the port is not an output, or if the outsideChannel parameter cannot be evaluated or if the transmit() method throws an IllegalActionException.
      • broadcast

        public void broadcast​(Token[] tokenArray,
                              int vectorLength)
                       throws IllegalActionException,
                              NoRoomException
        Override the base class to delegate to the channel if there is one. If there is no outside channel, then defer to the base class.
        Overrides:
        broadcast in class TypedIOPort
        Parameters:
        tokenArray - The token array to send
        vectorLength - The number of elements of the token array to send.
        Throws:
        NoRoomException - If there is no room in the receiver.
        IllegalActionException - If the tokens to be sent cannot be converted to the type of this port
      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there).
        Overrides:
        clone in class TypedIOPort
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        The new Attribute.
        Throws:
        java.lang.CloneNotSupportedException - Not thrown in this base class
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • createReceivers

        public void createReceivers()
                             throws IllegalActionException
        Override the base class to create receivers for WirelessIOPort. If there is an outside channel, create a receiver for outside communication. If there is an inside channel, create a receiver for inside communication.
        Overrides:
        createReceivers in class IOPort
        Throws:
        IllegalActionException - If this port is not an opaque input port or if there is no director.
      • getInsideChannel

        public WirelessChannel getInsideChannel()
                                         throws IllegalActionException
        Get the channel specified by the insideChannel parameter. The channel is contained by the container of this port. Transparent hierarchy is ignored in getting the inside channel.
        Returns:
        A wireless channel, or null if no channel is specified or if the specified channel does not exist.
        Throws:
        IllegalActionException - If the insideChannel parameter value cannot be evaluated.
      • getInsideReceivers

        public Receiver[][] getInsideReceivers()
        Override the base class to return the inside receiver for wireless communication if wireless communication is being used. Otherwise, defer to the base class.
        Overrides:
        getInsideReceivers in class IOPort
        Returns:
        The local inside receivers, or an empty array if there are none.
        See Also:
        IOPort.getInside(int)
      • getOutsideChannel

        public WirelessChannel getOutsideChannel()
                                          throws IllegalActionException
        Get the channel specified by the outsideChannel parameter. The channel is contained by the container of the container of this port. Transparent hierarchy is ignored in getting the outside channel.
        Returns:
        A wireless channel, or null if no channel is specified or if the specified channel does not exist.
        Throws:
        IllegalActionException - If the outsideChannel parameter value cannot be evaluated.
      • getProperties

        public Token getProperties​(int channelIndex)
        Get the properties token associated with the data token most recently retrieved using get().
        Parameters:
        channelIndex - The channel index.
        Returns:
        The properties token of the most recently received data token, or null if there hasn't been one.
        See Also:
        IOPort.get(int), IOPort.get(int, int)
      • getPropertiesInside

        public Token getPropertiesInside​(int channelIndex)
        Get the properties token associated with the data token most recently retrieved using getInside().
        Parameters:
        channelIndex - The channel index.
        Returns:
        The properties token of the most recently received data token, or null if there hasn't been one.
        See Also:
        IOPort.getInside(int)
      • getReceivers

        public Receiver[][] getReceivers()
        Override the base class to return the outside receiver for wireless communication if wireless communication is being used. Otherwise, defer to the base class.
        Overrides:
        getReceivers in class IOPort
        Returns:
        The local receivers, or an empty array if there are none.
      • getWidthInside

        public int getWidthInside()
                           throws IllegalActionException
        Return the inside width of this port. If the inside is wireless, then the width is always 1. Otherwise, the width is determined by the number of links to the port.
        Overrides:
        getWidthInside in class IOPort
        Returns:
        The inside width of this port.
        Throws:
        IllegalActionException - If thrown by getWidthInside().
      • hasRoom

        public boolean hasRoom​(int channelIndex)
                        throws IllegalActionException
        Override the base class to always return true if there is a wireless channel, and otherwise, defer to the base class. For wireless channels, if a particular receiver does not have room, the channel treats it as if it were not in range.
        Overrides:
        hasRoom in class IOPort
        Parameters:
        channelIndex - The channel index.
        Returns:
        True if there is room for a token in the channel.
        Throws:
        IllegalActionException - If the receivers do not support this query, if this is not an output port, or if the channel index is out of range.
      • hasRoomInside

        public boolean hasRoomInside​(int channelIndex)
                              throws IllegalActionException
        Override the base class to always return true if there is a wireless channel, and otherwise, defer to the base class. For wireless channels, if a particular receiver does not have room, the channel treats it as if it were not in range.
        Overrides:
        hasRoomInside in class IOPort
        Parameters:
        channelIndex - The channel index.
        Returns:
        True if there is room for a token in the channel.
        Throws:
        IllegalActionException - If the receivers do not support this query, if this is not an output port, or if the channel index is out of range.
      • insideSinkPortList

        public java.util.List insideSinkPortList()
        Return a list of the ports that can potentially accept data from this port when it sends on the inside. If the port is inside wireless, then this includes only the wireless channel port. Otherwise, this includes opaque input ports that are connected on the outside to this port and opaque output ports that are connected on the inside to this one.
        Overrides:
        insideSinkPortList in class IOPort
        Returns:
        A list of IOPort objects.
        See Also:
        IOPort.deepGetReceivers()
      • insideSourcePortList

        public java.util.List insideSourcePortList()
        Return a list of the ports that can potentially send data to this port from the inside. If the port is inside wireless, then this includes only the wireless channel port. Otherwise, this includes opaque output ports that are connected on the outside to this port and opaque input ports that are connected on the inside to this one.
        Overrides:
        insideSourcePortList in class IOPort
        Returns:
        A list of IOPort objects.
      • send

        public void send​(int channelIndex,
                         Token token)
                  throws IllegalActionException,
                         NoRoomException
        Override the base class to delegate to the wireless channel if the port is outside wireless. If there is no outside channel, then defer to the base class.
        Overrides:
        send in class TypedIOPort
        Parameters:
        channelIndex - The index of the channel, from 0 to width-1. If there is an outside channel, then this argument is ignored.
        token - The token to send.
        Throws:
        IllegalActionException - If the port is not an output, or if the token to be sent cannot be converted to the type of this port, or if the token is null.
        NoRoomException - If there is no room in the receiver. This should not occur in the DE domain.
      • send

        public void send​(int channelIndex,
                         Token[] tokenArray,
                         int vectorLength)
                  throws IllegalActionException,
                         NoRoomException
        Override the base class to delegate to the wireless channel if the port is outside wireless. If there is no outside channel, then defer to the base class.
        Overrides:
        send in class TypedIOPort
        Parameters:
        channelIndex - The index of the channel, from 0 to width-1 If there is an outside channel, then this argument is ignored.
        tokenArray - The token array to send
        vectorLength - The number of elements of the token array to send.
        Throws:
        NoRoomException - If there is no room in the receiver.
        IllegalActionException - If the tokens to be sent cannot be converted to the type of this port, or if the vectorLength argument is greater than the length of the tokenArray argument.
      • sendClear

        public void sendClear​(int channelIndex)
                       throws IllegalActionException
        Override the base class to delegate to the wireless channel if the port is outside wireless. If there is no outside channel, then defer to the base class.
        Overrides:
        sendClear in class IOPort
        Parameters:
        channelIndex - The index of the channel, from 0 to width-1. If there is an outside channel, then this argument is ignored.
        Throws:
        IllegalActionException - If a receiver does not support clear().
        See Also:
        IOPort.broadcastClear(), IOPort.sendClearInside(int)
      • sendClearInside

        public void sendClearInside​(int channelIndex)
                             throws IllegalActionException
        Override the base class to delegate to the wireless channel if the port is inside wireless. If there is no inside channel, then defer to the base class.
        Overrides:
        sendClearInside in class IOPort
        Parameters:
        channelIndex - The index of the channel, from 0 to width-1. If there is an inside channel, then this argument is ignored.
        Throws:
        IllegalActionException - If a receiver does not support clear().
        See Also:
        IOPort.sendClear(int)
      • sendInside

        public void sendInside​(int channelIndex,
                               Token token)
                        throws IllegalActionException,
                               NoRoomException
        Override the base class to delegate to the wireless channel if the port is inside wireless. If there is no inside channel, then defer to the base class.
        Overrides:
        sendInside in class TypedIOPort
        Parameters:
        channelIndex - The index of the channel, from 0 to width-1. If there is an inside channel, then this argument is ignored.
        token - The token to send
        Throws:
        NoRoomException - If there is no room in the receiver.
        IllegalActionException - If conversion to the type of the destination port cannot be done.
      • sinkPortList

        public java.util.List sinkPortList()
        Return a list of the ports that can potentially accept data from this port when it sends on the outside. If the port is outside wireless, then this includes only the channel port. Otherwise, this includes opaque input ports that are connected on the outside to this port and opaque output ports that are connected on the inside to this one.
        Overrides:
        sinkPortList in class IOPort
        Returns:
        A list of IOPort objects.
        See Also:
        IOPort.getRemoteReceivers()
      • sourcePortList

        public java.util.List sourcePortList()
        Return a list of the ports that can potentially send data to this port from the outside. If the port is outside wireless, then this includes only the channel port. Otherwise, this includes opaque output ports that are connected on the outside to this port and opaque input ports that are connected on the inside to this one.
        Overrides:
        sourcePortList in class IOPort
        Returns:
        A list of IOPort objects.
      • _insideIsWireless

        protected boolean _insideIsWireless()
        Return true if the port is inside wireless.
        Returns:
        True if the inside is wireless.
      • _outsideIsWireless

        protected boolean _outsideIsWireless()
        Return true if the port is outside wireless.
        Returns:
        True if the outside is wireless.