ptolemy.domains.de.kernel
Class DEIOPort

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.Port
          extended byptolemy.kernel.ComponentPort
              extended byptolemy.actor.IOPort
                  extended byptolemy.actor.TypedIOPort
                      extended byptolemy.domains.de.kernel.DEIOPort
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, HasTypeConstraints, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, Typeable

public class DEIOPort
extends TypedIOPort

This port can be used by actors that are specialized to the discrete-event (DE) domain. It supports annotations that inform the scheduler about delays and about priorities for handling simultaneous inputs. It also provides two additional methods, overloaded versions of broadcast() and send(). The overloaded versions have a second argument for the time delay, allowing actors to send output data with a time delay (relative to current time).

Actors in the DE domain are not required to use this port. If they use the base class, TypedIOPort, then the data they send is sent with zero delay.

Since:
Ptolemy II 0.2
Version:
$Id: DEIOPort.java,v 1.72 2004/04/13 05:12:45 cxh Exp $
Author:
Lukito Muliadi, Edward A. Lee, Jie Liu
See Also:
Serialized Form
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.actor.TypedIOPort
TYPE
 
Fields inherited from class ptolemy.actor.IOPort
CONFIGURATION, RECEIVERS, REMOTERECEIVERS
 
Fields inherited from class ptolemy.kernel.Port
_insideLinks, _relationsList
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
DEIOPort()
          Construct a DEIOPort with no container and no name that is neither an input nor an output.
DEIOPort(ComponentEntity container, java.lang.String name)
          Construct a DEIOPort with the specified container and name that is neither an input nor an output.
DEIOPort(ComponentEntity container, java.lang.String name, boolean isInput, boolean isOutput)
          Construct a DEIOPort with the specified container and name that is either an input, an output, or both, depending on the third and fourth arguments.
DEIOPort(Workspace workspace)
          Construct a port in the specified workspace with an empty string as a name.
 
Method Summary
 void broadcast(Token token)
          Broadcast a token to all receivers connected to this output port.
 void broadcast(Token token, double delay)
          Broadcast a token to all receivers connected to this output port with the specified time delay.
 java.lang.Object clone(Workspace workspace)
          Clone this port into the specified workspace.
 void delayTo(IOPort output)
          Add the specified port to the set of output ports that have delayed events triggered by this input port.
 java.util.Set getDelayToPorts()
          Return the set of ports that have delayed events triggered by this one (as opposed to instantaneous events).
 void send(int channelIndex, Token token)
          Send a token to the receivers connected on the specified channel with the time stamp equaling to the current time of the director.
 void send(int channelIndex, Token token, double delay)
          Send a token with the specified time delay to the receivers connected on the specified channel.
 
Methods inherited from class ptolemy.actor.TypedIOPort
_checkContainer, _checkLiberalLink, _checkLink, _checkType, _description, addTypeListener, attributeChanged, broadcast, convert, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, send, sendInside, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList
 
Methods inherited from class ptolemy.actor.IOPort
_checkLiberalLink, _exportMoMLContents, _getInsideWidth, _newInsideReceiver, _newReceiver, broadcastClear, createReceivers, deepConnectedInPortList, deepConnectedInPorts, deepConnectedOutPortList, deepConnectedOutPorts, deepGetReceivers, get, get, getCurrentTime, getInside, getInsideReceivers, getReceivers, getReceivers, getReceivers, getRemoteReceivers, getRemoteReceivers, getWidth, getWidthInside, hasRoom, hasRoomInside, hasToken, hasToken, hasTokenInside, insertLink, insideSinkPortList, insideSourcePortList, isInput, isKnown, isKnown, isKnownInside, isMultiport, isOutput, liberalLink, link, numberOfSinks, numberOfSources, sendClear, sendClearInside, setContainer, setInput, setMultiport, setOutput, sinkPortList, sourcePortList, transferInputs, transferOutputs, unlink, unlink, unlinkAll, unlinkAllInside, unlinkInside, unlinkInside
 
Methods inherited from class ptolemy.kernel.ComponentPort
_deepConnectedPortList, _deepConnectedPorts, _deepInsidePortList, _deepInsidePorts, _isInsideLinkable, deepConnectedPortList, deepConnectedPorts, deepInsidePortList, deepInsidePorts, insertInsideLink, insidePortList, insidePorts, insideRelationList, insideRelations, isDeeplyConnected, isInsideLinked, isOpaque, numInsideLinks
 
Methods inherited from class ptolemy.kernel.Port
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isLinked, linkedRelationList, linkedRelations, numLinks, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DEIOPort

public DEIOPort()
Construct a DEIOPort with no container and no name that is neither an input nor an output.


DEIOPort

public DEIOPort(Workspace workspace)
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.

DEIOPort

public DEIOPort(ComponentEntity container,
                java.lang.String name)
         throws IllegalActionException,
                NameDuplicationException
Construct a DEIOPort 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.

DEIOPort

public DEIOPort(ComponentEntity container,
                java.lang.String name,
                boolean isInput,
                boolean isOutput)
         throws IllegalActionException,
                NameDuplicationException
Construct a DEIOPort with the specified container and 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
Broadcast a token to all receivers connected to this output port. The time stamp of the token is the current time of the director. If you want to broadcast a token with a specified delay, use broadcast(token, delay) instead.

Overrides:
broadcast in class TypedIOPort
Parameters:
token - The token to send.
Throws:
IllegalActionException - If the port is not an output.

broadcast

public void broadcast(Token token,
                      double delay)
               throws IllegalActionException
Broadcast a token to all receivers connected to this output port with the specified time delay. The time stamp of of the token is equal to current time plus the specified delay. If the specified delay is zero, then the event is queued to be processed in the next microstep.

Parameters:
token - The token to send.
delay - The delay of the token being broadcast.
Throws:
IllegalActionException - If the port is not an output.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone this port into the specified workspace. Override the base class to clear any ports that may have been specified with the delayTo() method. Note that this means that when cloning an actor that uses this port, you need to respecify delayTo() relationships. The new port is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new port with no connections and no container. The new port will have the same type as this one, but will not have any type listeners and type constraints attached to it.

Overrides:
clone in class TypedIOPort
Parameters:
workspace - The workspace for the cloned object.
Returns:
A new TypedIOPort.
Throws:
java.lang.CloneNotSupportedException - If one or more of the attributes cannot be cloned.

delayTo

public void delayTo(IOPort output)
             throws IllegalActionException
Add the specified port to the set of output ports that have delayed events triggered by this input port.

Parameters:
output - The output port with delayed events.
Throws:
IllegalActionException - If this port is not an input, or if the argument is not an output port.

getDelayToPorts

public java.util.Set getDelayToPorts()
Return the set of ports that have delayed events triggered by this one (as opposed to instantaneous events).


send

public void send(int channelIndex,
                 Token token)
          throws IllegalActionException,
                 NoRoomException
Send a token to the receivers connected on the specified channel with the time stamp equaling to the current time of the director. If you want to send a token with a specified delay, use send(token, delay) instead. If the channel index is out of range, then the token is not sent anywhere.

Overrides:
send in class TypedIOPort
Parameters:
channelIndex - The index of the channel, from 0 to width-1
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 token,
                 double delay)
          throws IllegalActionException
Send a token with the specified time delay to the receivers connected on the specified channel. The time stamp of the token is equal to current time plus the specified delay. If the specified delay is zero, then the event is queued to be processed in the next microstep.

Parameters:
channelIndex - The index of the channel, from 0 to width-1.
token - The token to send.
delay - The time delay of the token being sent.
Throws:
IllegalActionException - If the port is not an output, or if the index is out of range.