public class IOPort extends ComponentPort
Its receivers are created by a director. It must therefore be contained by an actor that has a director. If it is not, then any attempt to read data or list the receivers will trigger an exception.
If this port is at the boundary of an composite actor, then it can have both inside and outside links, with corresponding inside and outside receivers if it opaque. The inside links are to relations inside the opaque composite actor, whereas the outside links are to relations outside. If it is not specified, then a link is an outside link.
The port has a defaultValue parameter that, by default, is empty. If this parameter is not empty, the port always has a token. The value of the port is initially specified by the defaultValue. Afterwards, the previous token of the port is remembered.
The port has a width, which by default is constrained to be either zero or one. The width is the sum of the widths of the linked relations. A port with a width greater than one behaves as a bus interface, so if the width is w, then the port can simultaneously handle w distinct input or output channels of data.
In general, an input port might have more than one receiver for each channel. This occurs particularly for transparent input ports, which treat the receivers of the ports linked on the inside as its own. This might also occur for opaque ports in some derived classes. Each receiver in the group is sent the same data. Thus, an input port in general will have w distinct groups of receivers, and can receive w distinct channels.
By default, the maximum width of the port is one, so only one channel is handled. A port that allows a width greater than one is called a multiport. Calling setMultiport() with a true argument converts the port to a multiport.
The width of the port is not set directly. It is the sum of the widths of the relations that the port is linked to on the outside. The sum of the widths of the relations linked on the inside can be more or less than the width. If it is more, then the excess inside relations will be treated as if they are unconnected. If it is less, then the excess outside relations will be treated as if they are unconnected.
An IOPort can only link to instances of IORelation. Derived classes may further constrain links to a subclass of IORelation. To do this, they should override the protected methods _checkLink() and _checkLiberalLink() to throw an exception if their arguments are not of the appropriate type. Similarly, an IOPort can only be contained by a class derived from ComponentEntity and implementing the Actor interface. Subclasses may further constrain the containers by overriding the protected method _checkContainer().
Red (neuendor) |
Green (eal) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected int |
_constantLimit
The limit of the number of constant values to return instead
of the received tokens.
|
protected Token |
_constantToken
The constant value to return instead of the received tokens.
|
protected int |
_constantTokensSent
The number of constant tokens that have been sent since the last
call to _setConstant().
|
protected boolean |
_hasPortEventListeners
Flag that is true if there are port event listeners.
|
protected java.util.List<IOPortEventListener> |
_portEventListeners
The list of IOPortEventListeners registered with this object.
|
static int |
CONFIGURATION
Indicate that the description(int) method should include information
about whether the port is an input, output, or multiport, whether it
is opaque, and what is its width.
|
Parameter |
defaultValue
The default value of the port.
|
static int |
RECEIVERS
Indicate that the description(int) method should include receivers
contained by this port (if any).
|
static int |
REMOTERECEIVERS
Indicate that the description(int) method should include receivers
remotely connected to this port (if any).
|
_insideLinks, _relationsList
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
IOPort()
Construct an IOPort with no container and no name that is
neither an input nor an output.
|
IOPort(ComponentEntity container,
java.lang.String name)
Construct an IOPort with a containing actor and a name
that is neither an input nor an output.
|
IOPort(ComponentEntity container,
java.lang.String name,
boolean isInput,
boolean isOutput)
Construct an IOPort with a container and a name that is
either an input, an output, or both, depending on the third
and fourth arguments.
|
IOPort(Workspace workspace)
Construct a port in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkContainer(Entity container)
Check that the specified container implements the Actor interface
(or is null).
|
protected void |
_checkLiberalLink(Relation relation)
Override parent method to ensure compatibility of the relation
and validity of the width of the port.
|
protected void |
_checkLink(Relation relation)
Override parent method to ensure compatibility of the relation
and validity of the width of the port.
|
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object.
|
protected void |
_exportMoMLContents(java.io.Writer output,
int depth)
Write a MoML description of the contents of this object, which
in this class is the attributes plus possibly a special attribute
to indicate whether the port is a multiport.
|
protected int |
_getInsideWidth(IORelation except)
Return the sums of the widths of the relations linked on the
inside, except the specified relation.
|
protected int |
_getOutsideWidth(IORelation except)
Return the sums of the widths of the relations linked on the
outside, except the specified relation.
|
protected Receiver[][] |
_getReceiversLinkedToGroup(IORelation relation,
int occurrence)
If the port is an input, return receivers that handle incoming
channels from the specified relation or any relation in its
relation group.
|
protected Receiver |
_newInsideReceiver()
Create a new receiver compatible with the local director.
|
protected Receiver |
_newInsideReceiver(int channel)
Create a new receiver compatible with the local director.
|
protected Receiver |
_newReceiver()
Create a new receiver compatible with the executive director.
|
protected Receiver |
_newReceiver(int channel)
Create a new receiver compatible with the executive director.
|
protected void |
_notifyPortEventListeners(IOPortEvent event)
Send a PortEvent to all port event listeners that
have registered with this IOPort.
|
protected void |
_removeReceivers(Relation relation)
Remove the receivers associated with the specified
relation, if there are any.
|
protected void |
_setConstant(Token token,
int limit)
Set a constant token so that every call to
get(int)
or get(int,int) replaces the returned token(s) with
this specified token. |
protected Receiver |
_wrapReceiver(Receiver receiver,
int channel)
If this port has parameters whose values are tokens that contain
an object implementing
CommunicationAspect , then wrap the
receiver specified in the argument using those communication aspects. |
void |
addIOPortEventListener(IOPortEventListener listener)
Append a listener to the current set of port event listeners.
|
void |
attributeChanged(Attribute attribute)
If a communication aspect is added, removed or modified,
invalidate the list of communication aspects which is read again
in the preinitialize phase.
|
void |
broadcast(Token token)
Send a token to all connected receivers.
|
void |
broadcast(Token[] tokenArray,
int vectorLength)
Send the specified portion of a token array to all receivers connected
to this port.
|
void |
broadcastClear()
Set all receivers connected on the outside to have no
tokens.
|
void |
checkWidthConstraints()
Check whether the widths constraints are met.
|
java.lang.Object |
clone(Workspace workspace)
Clone this port into the specified workspace.
|
Token |
convert(Token token)
Convert the specified token into a token acceptable to
this port.
|
void |
createReceivers()
Create new receivers for this port, replacing any that may
previously exist, and validate any instances of Settable that
this port may contain.
|
java.util.List<IOPort> |
deepConnectedInPortList()
Return a list of input ports connected to this port on the
outside.
|
java.util.Enumeration |
deepConnectedInPorts()
Deprecated.
Use deepConnectedInPortList() instead.
|
java.util.List<IOPort> |
deepConnectedOutPortList()
Return a list of output ports connected to this port on the
outside.
|
java.util.Enumeration |
deepConnectedOutPorts()
Deprecated.
Use deepConnectedInPortList() instead.
|
Receiver[][] |
deepGetReceivers()
If the port is an input, return the receivers deeply linked on
the inside.
|
Token |
get(int channelIndex)
Get a token from the specified channel.
|
Token[] |
get(int channelIndex,
int vectorLength)
Get an array of tokens from the specified channel.
|
int |
getChannelForReceiver(Receiver receiver)
Return the corresponding channel in this port for the given receiver.
|
java.util.List<CommunicationAspect> |
getCommunicationAspects()
Return the list of communication aspects in this port.
|
double |
getCurrentTime(int channelIndex)
Deprecated.
As Ptolemy II 4.1,
replaced by
getModelTime(int) . |
int |
getDefaultWidth()
Get the default width.
|
Token |
getInside(int channelIndex)
Get a token from the specified inside channel of this port.
|
Receiver[][] |
getInsideReceivers()
If the port is an opaque output port, return the receivers that
receive data from all inside linked relations.
|
Time |
getModelTime(int channelIndex)
Return the current time associated with a certain channel.
|
Receiver[][] |
getReceivers()
If the port is an input, return the receivers that receive data
from all linked relations.
|
Receiver[][] |
getReceivers(IORelation relation)
If the port is an input, return receivers that handle incoming
channels from the specified relation.
|
Receiver[][] |
getReceivers(IORelation relation,
int occurrence)
If the port is an input, return receivers that handle incoming
channels from the specified relation.
|
static int |
getRelationIndex(IOPort port,
Relation relation,
boolean isOutsideRelation)
Retrieve the index of the relation at the port.
|
Receiver[][] |
getRemoteReceivers()
If the port is an output, return the remote receivers that can
receive from the port.
|
Receiver[][] |
getRemoteReceivers(IORelation relation)
If this port is an output, return the remote receivers that can
receive data from this port through the specified relation or
any relation in its relation group.
|
int |
getWidth()
Return the width of the port.
|
int |
getWidthFromConstraints()
Get the width from the constraints put on the width
of this port if the width is fully determined.
|
int |
getWidthInside()
Return the inside width of this port.
|
boolean |
hasNewToken(int channelIndex)
Return true if the specified channel has a new token to deliver
via the get() method.
|
boolean |
hasNewTokenInside(int channelIndex)
Return true if the specified channel has a token to deliver
via the getInside() method.
|
boolean |
hasRoom(int channelIndex)
Return true if the specified channel can accept a token via the
put() method.
|
boolean |
hasRoomInside(int channelIndex)
Return true if the specified channel can accept a token via
the putInside() method.
|
boolean |
hasToken(int channelIndex)
Return true if the port is persistent (@see defaultValue) or
if the specified channel has a token to deliver
via the get() method.
|
boolean |
hasToken(int channelIndex,
int tokens)
Return true if the specified channel has the specified number
of tokens to deliver via the get() method.
|
boolean |
hasTokenInside(int channelIndex)
Return true if the port is persisent or the specified channel
has a token to deliver
via the getInside() method.
|
boolean |
hasWidthConstraints()
Return whether there are constraints on the width of
this port.
|
void |
insertLink(int index,
Relation relation)
Override the base class to invalidate the schedule and resolved
types of the director of the container, if there is one, in addition
to what the base class does.
|
java.util.List<IOPort> |
insideSinkPortList()
Return a list of the ports that may accept data from this port
when it sends on the inside.
|
java.util.List<IOPort> |
insideSourcePortList()
Return a list of the ports that can send data to this port
from the inside.
|
void |
invalidateCommunicationAspects()
Invalidate the communication aspect list.
|
boolean |
isInput()
Return true if the port is an input.
|
boolean |
isInsideConnected()
Return whether the port has relations connected on the inside.
|
boolean |
isKnown()
Return true if all channels of this port have known state; that is,
the tokens on each channel are known, or each channel is known not to
have any tokens.
|
boolean |
isKnown(int channelIndex)
Return true if the specified channel has known state;
that is, the tokens on this channel are known, or this channel
is known not to have any tokens.
|
boolean |
isKnownInside(int channelIndex)
Return true if the specified inside channel has known state;
that is, the tokens on this channel are known, or this channel
is known not to have any tokens.
|
boolean |
isMultiport()
Return true if the port is a multiport.
|
boolean |
isOutput()
Return true if the port is an output.
|
boolean |
isOutsideConnected()
Return whether the port has relations connected on the outside.
|
void |
liberalLink(ComponentRelation relation)
Override the base class to invalidate the schedule and resolved
types of the director of the container, if there is one, in addition
to what the base class does.
|
void |
link(Relation relation)
Override the base class to invalidate the schedule and resolved
types of the director of the container, if there is one, in addition
to what the base class does.
|
int |
numberOfSinks()
Return the number of sink ports that may receive data from this one.
|
int |
numberOfSources()
Return the number of source ports that may send data to this one.
|
void |
removeIOPortEventListener(IOPortEventListener listener)
Unregister a token sent listener.
|
void |
reset()
If port has default value reset the saved persistent value.
|
void |
send(int channelIndex,
Token token)
Send the specified token to all receivers connected to the
specified channel.
|
void |
send(int channelIndex,
Token[] tokenArray,
int vectorLength)
Send the specified portion of a token array to all receivers connected
to the specified channel.
|
void |
sendClear(int channelIndex)
Set all destination receivers connected via the specified to channel
to have no token.
|
void |
sendClearInside(int channelIndex)
Set all destination receivers connected on the inside via the specified
to channel to have no token.
|
void |
sendInside(int channelIndex,
Token token)
Send the specified token to all receivers connected to the
specified inside channel of this port.
|
void |
setContainer(Entity container)
Override the base class to ensure that the proposed container
implements the Actor interface (the base class ensures that the
container is an instance of ComponentEntity) or null.
|
void |
setDefaultWidth(int defaultWidth)
Set the default width.
|
void |
setInput(boolean isInput)
If the argument is true, make the port an input port.
|
void |
setMultiport(boolean isMultiport)
If the argument is true, make the port a multiport.
|
void |
setOutput(boolean isOutput)
If the argument is true, make the port an output port.
|
void |
setWidthEquals(IOPort port,
boolean bidirectional)
Constrain the width of this port to be equal to the width of
the IOPort port.
|
void |
setWidthEquals(Parameter parameter)
Constrain the width of this port to be equal to the parameter.
|
java.util.List<IOPort> |
sinkPortList()
Return a list of the ports that may accept data from this port when
it sends on the outside.
|
java.util.List<IOPort> |
sourcePortList()
Return a list of ports that may send data to this port from the
outside.
|
boolean |
transferInputs()
Deprecated.
Domains should use sendInside directly to
implement their transferInputs method.
|
boolean |
transferOutputs()
Deprecated.
domains should use getInside directly to implement their
transferOutputs method.
|
void |
unlink(int index)
Unlink whatever relation is currently linked at the specified index
number.
|
void |
unlink(Relation relation)
Unlink the specified Relation.
|
void |
unlinkAll()
Unlink all relations that are linked on the outside.
|
void |
unlinkAllInside()
Unlink all relations that are linked on the inside.
|
void |
unlinkInside(int index)
Unlink whatever relation is currently linked on the inside
with the specified index number.
|
void |
unlinkInside(Relation relation)
Unlink the specified Relation on the inside.
|
_deepConnectedPortList, _deepConnectedPorts, _deepInsidePortList, _deepInsidePorts, _isInsideLinkable, deepConnectedPortList, deepConnectedPorts, deepInsidePortList, deepInsidePorts, insertInsideLink, insidePortList, insidePorts, insideRelationList, insideRelations, isDeeplyConnected, isInsideGroupLinked, isInsideLinked, isOpaque, numInsideLinks
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isGroupLinked, isLinked, linkedRelationList, linkedRelations, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, numLinks, setName
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter defaultValue
hasToken(int)
,
hasToken(int, int)
,
and hasTokenInside(int)
always return true, indicating that a token is available.
To determine whether there is a new token, use
hasNewToken(int)
or hasNewTokenInside(int)
.
If this port is an output port, then the persistent value is used only when retrieving a token from the inside. I.e., it will be used only if the output port belongs to an opaque composite actor.
public static final int CONFIGURATION
public static final int RECEIVERS
public static final int REMOTERECEIVERS
protected int _constantLimit
protected Token _constantToken
protected int _constantTokensSent
protected boolean _hasPortEventListeners
protected java.util.List<IOPortEventListener> _portEventListeners
public IOPort()
public IOPort(Workspace workspace) throws IllegalActionException
workspace
- The workspace that will list the port.IllegalActionException
- If thrown by the superclass
or while initializingpublic IOPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of the port.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.public IOPort(ComponentEntity container, java.lang.String name, boolean isInput, boolean isOutput) throws IllegalActionException, NameDuplicationException
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.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.public void addIOPortEventListener(IOPortEventListener listener)
listener
- The listener to which to send token sent messages.removeIOPortEventListener(IOPortEventListener)
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the new color
attribute cannot be created.public void broadcast(Token token) throws IllegalActionException, NoRoomException
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put(), it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put().
token
- The token to sendIllegalActionException
- Not thrown in this base class.NoRoomException
- If a send to one of the channels throws
it.public void broadcast(Token[] tokenArray, int vectorLength) throws IllegalActionException, NoRoomException
Tokens are in general immutable, so each receiver is given a reference to the same token and no clones are made. If the port is not connected to anything, or receivers have not been created in the remote port, or the channel index is out of range, or the port is not an output port, then just silently return. This behavior makes it easy to leave output ports unconnected when you are not interested in the output. The transfer is accomplished by calling the vectorized put() method of the remote receivers. If the port is not connected to anything, or receivers have not been created in the remote port, then just return.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put().
tokenArray
- The token array to sendvectorLength
- The number of elements of the token
array to send.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void broadcastClear() throws IllegalActionException
IllegalActionException
- If a receiver does not support
clear().sendClear(int )
public void checkWidthConstraints() throws IllegalActionException
IllegalActionException
- If the width constraints or not met.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class ComponentPort
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If one or more of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public Token convert(Token token) throws IllegalActionException
token
- The token to convert.IllegalActionException
- If the conversion is
invalid (not thrown in this base class).public void createReceivers() throws IllegalActionException
If the port is an input port, receivers are created as necessary for each relation connecting to the port from the outside. If the port is an output port, receivers are created as necessary for each relation connected to the port from the inside. Note that only composite entities will have relations connecting to ports from the inside.
Note that it is perfectly allowable for a zero width output port to have insideReceivers. This can be used to allow a model to be embedded in a container that does not connect the port to anything.
This method is not write-synchronized on the workspace, so the caller should be.
IllegalActionException
- If this port is not
an opaque input port or if there is no director.public java.util.List<IOPort> deepConnectedInPortList()
ComponentPort.deepConnectedPortList()
@Deprecated public java.util.Enumeration deepConnectedInPorts()
ComponentPort.deepConnectedPorts()
public java.util.List<IOPort> deepConnectedOutPortList()
ComponentPort.deepConnectedPorts()
@Deprecated public java.util.Enumeration deepConnectedOutPorts()
ComponentPort.deepConnectedPorts()
public Receiver[][] deepGetReceivers() throws InvalidStateException, IllegalActionException
IllegalActionException
- If thrown while getting the
deep receivers of the relation or while getting the inside
width.InvalidStateException
- Not thrown in this base classpublic Token get(int channelIndex) throws NoTokenException, IllegalActionException
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a get, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling get().
channelIndex
- The channel index.NoTokenException
- If there is no token.IllegalActionException
- If there is no director, and hence
no receivers have been created, if the port is not an input port, or
if the channel index is out of range.public Token[] get(int channelIndex, int vectorLength) throws NoTokenException, IllegalActionException
If the channel has a group with more than one receiver (something that is possible if this is a transparent port), then this method calls get() on all receivers, but returns only the result from the first in the group. Normally this method is not used on transparent ports. If there are not enough tokens to fill the array, then throw an exception.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a get, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling get.
channelIndex
- The channel index.vectorLength
- The number of valid tokens to get in the
returned array.NoTokenException
- If there is no array of tokens.IllegalActionException
- If there is no director, and hence
no receivers have been created, if the port is not an input port, or
if the channel index is out of range.public int getChannelForReceiver(Receiver receiver) throws IllegalActionException
receiver
- A receiver that is contained in this port or
connected to another receiver contained in this port.IllegalActionException
- If the given receiver does not
take part in any connections pertaining to this port.@Deprecated public double getCurrentTime(int channelIndex) throws IllegalActionException
getModelTime(int)
.getModelTime(int)
method and return a double
representation of the model time.channelIndex
- The channel index.IllegalActionException
- If the channel index
is out of range or if the port is not an input port.public int getDefaultWidth()
setDefaultWidth(int)
public Token getInside(int channelIndex) throws NoTokenException, IllegalActionException
If the channel has a group with more than one receiver (something that is possible if this is a transparent port), then this method calls get() on all receivers, but returns only the first non-null token returned by these calls. Normally this method is not used on transparent ports. If there is no token to return, then throw an exception. This method is usually called only by the director of a composite actor during transferOutputs(), as atomic actors do not normally have relations connected on the inside of their ports.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a get(), it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling get().
channelIndex
- The channel index.NoTokenException
- If there is no token.IllegalActionException
- If there is no director, and hence
no receivers have been created, if the port is not an output port, or
if the channel index is out of range.public Receiver[][] getInsideReceivers()
getInside(int)
public static int getRelationIndex(IOPort port, Relation relation, boolean isOutsideRelation)
port
- The port.relation
- The relation.isOutsideRelation
- A flag that specifies that the
relation is an outside relation of the port.public Time getModelTime(int channelIndex) throws IllegalActionException
if (hasToken(n)) { double time = port.getCurrentTime(n); Token token = port.get(n); }I.e., getCurrentTime() is called before get(). Currently, only the DT domain uses this per-channel time feature.
channelIndex
- The channel index.IllegalActionException
- If the channel index
is out of range or if the port is not an input port.public java.util.List<CommunicationAspect> getCommunicationAspects() throws IllegalActionException
Parameter
whose value is an
ObjectToken
that references an object that implements
the CommunicationAspect
interface.
Update the sequence number of communication aspects.IllegalActionException
- Thrown if the token of the parameter
containing the communication aspect object cannot be retrieved.public Receiver[][] getReceivers()
For a transparent port (a port of a non-opaque entity), this method returns receivers in ports connected to this port on the inside. For an opaque port, the receivers returned are contained directly by this port.
The number of channels (number of groups) is the width of the port.
For each channel, there may be any number of receivers in the group. The individual receivers are selected using the second index of the returned array of arrays. If there are no receivers in the group, then the channel is represented by null. I.e., if the returned array of arrays is x and the channel number is c, then x[c] is null. Otherwise, it is an array, where the size of the array is the number of receivers in the group. If the port is opaque, then the group size is one, so only x[c][0] is defined. If the port is transparent, the group size is arbitrary.
For an opaque port, this method creates receivers by calling _newReceiver() if there are no receivers or the number of receivers does not match the width of the port. In the latter case, previous receivers are lost, together with any data they may contain.
This method is read-synchronized on the workspace. If its cached list of local receivers is not valid, however, then it acquires write synchronization on the workspace to reconstruct it.
public Receiver[][] getReceivers(IORelation relation) throws IllegalActionException
This method is read-synchronized on the workspace.
relation
- Relations that are linked on the outside or inside.IllegalActionException
- If the relation is not linked
from the outside, or if there is no director.public Receiver[][] getReceivers(IORelation relation, int occurrence) throws IllegalActionException
This method is read-synchronized on the workspace.
relation
- Relations that are linked on the outside or inside.occurrence
- The occurrence number that we are interested in,
starting at 0.IllegalActionException
- If the relation is not linked
from the outside.public Receiver[][] getRemoteReceivers() throws IllegalActionException
This method may have the effect of creating new receivers in the remote input ports, if they do not already have the right number of receivers. In this case, previous receivers are lost, together with any data they may contain.
This method is read-synchronized on the workspace.
IllegalActionException
- If thrown while getting the
width of this port, getting the deep receives of a relation or getting the
width of a relation.public Receiver[][] getRemoteReceivers(IORelation relation) throws IllegalActionException
This method may have the effect of creating new receivers in the remote input ports, if they do not already have the right number of receivers. In this case, previous receivers are lost, together with any data they may contain.
This method is read-synchronized on the workspace.
relation
- The specified relation from which the remote
receivers can receive data.IllegalActionException
- If the IORelation is not linked
to the port from the inside.public int getWidth() throws IllegalActionException
IllegalActionException
- If thrown while calling _getWidth()numberOfSinks()
,
numberOfSources()
public int getWidthFromConstraints()
public int getWidthInside() throws IllegalActionException
IllegalActionException
- If thrown while getting the
width of the relations or while creating receivers.public boolean hasNewToken(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an input port, or if the channel index is out
of range.public boolean hasNewTokenInside(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an output port, or if the channel index is out
of range.public boolean hasRoom(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.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.public boolean hasRoomInside(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.IllegalActionException
- If the receivers do not
support this query, if this is not an input port, or if the
channel index is out of range.public boolean hasToken(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an input port, or if the channel index is out
of range.public boolean hasToken(int channelIndex, int tokens) throws IllegalActionException
channelIndex
- The channel index.tokens
- The number of tokens to query the channel for.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an input port, or if the channel index is out
of range.public boolean hasTokenInside(int channelIndex) throws IllegalActionException
channelIndex
- The channel index.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an output port, or if the channel index is out
of range.public boolean hasWidthConstraints()
setWidthEquals(Parameter)
,
setWidthEquals(IOPort, boolean)
public void insertLink(int index, Relation relation) throws IllegalActionException
insertLink
in class ComponentPort
index
- The index at which to insert the link.relation
- The relation to link to this port.IllegalActionException
- If the link would cross levels of
the hierarchy, or the relation is incompatible,
or the port has no container, or the port is not in the
same workspace as the relation, or if this port is not a multiport
and the index is greater than zero or if another link already exists.public java.util.List<IOPort> insideSinkPortList()
deepGetReceivers()
public java.util.List<IOPort> insideSourcePortList()
public void invalidateCommunicationAspects()
public boolean isInput()
public boolean isInsideConnected()
public boolean isKnown() throws IllegalActionException
This method supports domains, such as SR, which have fixed-point semantics. In such domains, an iteration of a model starts with the state of all channels unknown, and the iteration concludes when the state of all channels is known.
IllegalActionException
- If the receivers do not support
this query, or if there is no director, and hence no receivers.isKnown(int)
,
isKnownInside(int)
public boolean isKnown(int channelIndex) throws IllegalActionException
This method supports domains, such as SR, which have fixed-point semantics. In such domains, an iteration of a model starts with the state of all channels unknown, and the iteration concludes when the state of all channels is known.
channelIndex
- The channel index.IllegalActionException
- If the receivers do not support
this query, if there is no director, and hence no receivers,
if the port is not an input port, or if the channel index is out
of range.isKnown()
,
*
public boolean isKnownInside(int channelIndex) throws IllegalActionException
This method supports domains, such as SR, which have fixed-point semantics. In such domains, an iteration of a model starts with the state of all channels unknown, and the iteration concludes when the state of all channels is known.
channelIndex
- The channel index.IllegalActionException
- If the receivers do not
support this query, if there is no director, and hence no
receivers, or if the inside channel index is out of range.public boolean isMultiport()
public boolean isOutput()
public boolean isOutsideConnected()
public void liberalLink(ComponentRelation relation) throws IllegalActionException
liberalLink
in class ComponentPort
relation
- The relation to link to.IllegalActionException
- If the relation does not share
the same workspace, or the port has no container.public void link(Relation relation) throws IllegalActionException
link
in class ComponentPort
relation
- The relation to link to.IllegalActionException
- If the link crosses levels of
the hierarchy, or the port has no container, or the relation
is not an instance of IORelation.public int numberOfSinks()
sinkPortList()
,
numberOfSources()
,
getWidth()
public int numberOfSources()
sourcePortList()
,
numberOfSinks()
,
getWidth()
public void removeIOPortEventListener(IOPortEventListener listener)
listener
- The listener to remove from the list of listeners
to which token sent messages are sent.addIOPortEventListener(IOPortEventListener)
public void reset() throws IllegalActionException
IllegalActionException
- If defaultValue cannot be retrieved.public void send(int channelIndex, Token token) throws IllegalActionException, NoRoomException
If a null token is specified, this is interpreted as an assertion that no token is being sent. For some domains, specifically those that queue tokens such as PN and SDF, this has no effect. For others, specifically those that have a well-defined notion of "absent" inputs such as SR, modal, and Continuous, sending a null token corresponds to asserting that the inputs of destination actors will be absent in this round.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put.
channelIndex
- The index of the channel, from 0 to width-1token
- The token to send, or null to send no token.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void send(int channelIndex, Token[] tokenArray, int vectorLength) throws IllegalActionException, NoRoomException
Tokens are in general immutable, so each receiver is given a reference to the same token and no clones are made. If the port is not connected to anything, or receivers have not been created in the remote port, or the channel index is out of range, or the port is not an output port, then just silently return. This behavior makes it easy to leave output ports unconnected when you are not interested in the output. The transfer is accomplished by calling the vectorized put() method of the remote receivers. If the port is not connected to anything, or receivers have not been created in the remote port, then just return.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put.
channelIndex
- The index of the channel, from 0 to width-1tokenArray
- The token array to sendvectorLength
- The number of elements of of the token
array to send.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void sendClear(int channelIndex) throws IllegalActionException
channelIndex
- The index of the channel, from 0 to width-1IllegalActionException
- If a receiver does not support
clear().broadcastClear()
,
sendClearInside(int)
public void sendClearInside(int channelIndex) throws IllegalActionException
channelIndex
- The index of the channel, from 0 to insideWidth-1.IllegalActionException
- If a receiver does not support
clear().sendClear(int)
public void sendInside(int channelIndex, Token token) throws IllegalActionException, NoRoomException
If a null token is specified, this is interpreted as an assertion that no token is being sent. For some domains, specifically those that queue tokens such as PN and SDF, this has no effect. For others, specifically those that have a well-defined notion of "absent" inputs such as SR, modal, and Continuous, sending a null token corresponds to asserting that the inputs of destination actors will be absent in this round.
Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put.
channelIndex
- The index of the channel, from 0 to width-1token
- The token to send, or null to send no token.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void setContainer(Entity container) throws IllegalActionException, NameDuplicationException
setContainer
in class ComponentPort
container
- The proposed container.IllegalActionException
- If the proposed container is not a
ComponentEntity, doesn't implement Actor, or has no name,
or the port and container are not in the same workspace. Or
it's not nullNameDuplicationException
- If the container already has
a port with the name of this port.Port.getContainer()
,
Port._checkContainer(Entity)
public void setDefaultWidth(int defaultWidth)
defaultWidth
- The default width.getDefaultWidth()
public void setInput(boolean isInput) throws IllegalActionException
isInput
- True to make the port an input.IllegalActionException
- If changing the port status is
not permitted (not thrown in this base class).public void setMultiport(boolean isMultiport) throws IllegalActionException
isMultiport
- True to make the port a multiport.IllegalActionException
- If changing the port status is
not permitted (not thrown in this base class).public void setOutput(boolean isOutput) throws IllegalActionException
isOutput
- True to make the port an output.IllegalActionException
- If changing the port status is
not permitted (not thrown in this base class).public void setWidthEquals(Parameter parameter)
Actors that call this method should have a clone() method that repeats the width constraints that were specified in the constructor.
parameter
- A parameter.public void setWidthEquals(IOPort port, boolean bidirectional)
Actors that call this method should have a clone() method that repeats the width constraints that were specified in the constructor.
port
- A port.bidirectional
- A flag that specifies whether the constraint
work in two directions.public java.util.List<IOPort> sinkPortList()
getRemoteReceivers()
public java.util.List<IOPort> sourcePortList()
@Deprecated public boolean transferInputs() throws IllegalActionException
IllegalActionException
- If this port is not an
opaque input port.@Deprecated public boolean transferOutputs() throws IllegalActionException
IllegalActionException
- If the port is not an opaque
output port.public void unlink(int index)
public void unlink(Relation relation)
unlink
in class ComponentPort
relation
- The relation to unlink.public void unlinkAll()
unlinkAll
in class ComponentPort
public void unlinkAllInside()
unlinkAllInside
in class ComponentPort
public void unlinkInside(int index)
unlinkInside
in class ComponentPort
index
- The index number of the link to remove.public void unlinkInside(Relation relation)
unlinkInside
in class ComponentPort
relation
- The relation to unlink.protected void _checkContainer(Entity container) throws IllegalActionException
_checkContainer
in class ComponentPort
container
- The proposed container.IllegalActionException
- If the container is not of
an acceptable class.protected void _checkLiberalLink(Relation relation) throws IllegalActionException
_checkLiberalLink
in class ComponentPort
relation
- The relation to link to on the inside.IllegalActionException
- If this port has no container or
the relation is not an IORelation, or the port already linked to a
relation and is not a multiport, or the relation has width
not exactly one and the port is not a multiport, or the
relation is incompatible with this port, or the port is not
in the same workspace as the relation.protected void _checkLink(Relation relation) throws IllegalActionException
_checkLink
in class ComponentPort
relation
- The relation to link to.IllegalActionException
- If this port has no container or
the relation is not an IORelation, or the port already linked to a
relation and is not a multiport, or if the relation has width
not exactly one and the port is not a multiport, or the port is
not in the same workspace as the relation.protected java.lang.String _description(int detail, int indent, int bracket) throws IllegalActionException
If the detail argument sets the bit defined by the constant CONFIGURATION, then append to the description a field containing any subset of the words "input", "output", "multiport", and "opaque", separated by spaces, plus a subfield of the form "{width integer}", where the integer is the width of the port. The field keyword is "configuration".
If the detail argument sets the bit defined by the constant RECEIVERS, then append to the description a field containing the receivers contained by this port. The keyword is "receivers" and the format is like the Receivers array, an array of groups, with each group receiving from a channel. Each group is a list of receiver descriptions (it may also be empty). If the detail argument sets the bit defined by the constant REMOTERECEIVERS, then also append to the description a field containing the remote receivers connected to this port. This method is read-synchronized on the workspace.
_description
in class ComponentPort
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).IllegalActionException
- If thrown while getting the
description of subcomponents.protected void _exportMoMLContents(java.io.Writer output, int depth) throws java.io.IOException
_exportMoMLContents
in class NamedObj
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.java.io.IOException
- If an I/O error occurs.NamedObj.exportMoML(Writer, int)
protected int _getInsideWidth(IORelation except) throws IllegalActionException
except
- The relation to exclude.IllegalActionException
- If thrown while checking if a
relation needs width inference, while getting the width of the
relation, while checking if the width or a relation is fixed.protected int _getOutsideWidth(IORelation except) throws IllegalActionException
except
- The relation to exclude.IllegalActionException
- If thrown while checking if a
relation needs width inference, while getting the width of the
relation, while checking if the width or a relation is fixed.protected Receiver[][] _getReceiversLinkedToGroup(IORelation relation, int occurrence) throws IllegalActionException
This method handles relation groups. That is, given any relation in a relation group, it returns the combined receivers of all the relations in the relation group, in the order as returned by the getRelationGroup() method of Receiver.
This method is read-synchronized on the workspace.
relation
- Relations that are linked on the outside or inside.occurrence
- The occurrence number that we are interested in,
starting at 0.IllegalActionException
- If the relation is not linked
from the outside.protected Receiver _newInsideReceiver() throws IllegalActionException
The returned receiver is either the new receiver, or another
receiver wrapping it as specified in _wrapReceiver(Receiver, int)
.
IllegalActionException
- If the port has no container,
or the container is unable to return a new receiver (for example
if it has no local director).protected Receiver _newInsideReceiver(int channel) throws IllegalActionException
The returned receiver is either the new receiver, or another
receiver wrapping it as specified in _wrapReceiver(Receiver, int)
.
channel
- Used to determine source port.IllegalActionException
- If the port has no container,
or the container is unable to return a new receiver (for example
if it has no local director).protected Receiver _newReceiver() throws IllegalActionException
The returned receiver is either the new receiver, or another
receiver wrapping it as specified in _wrapReceiver(Receiver, int)
.
IllegalActionException
- If the port has no container,
or the container is unable to return a new receiver (for example
if it has no executive director).protected Receiver _newReceiver(int channel) throws IllegalActionException
The returned receiver is either the new receiver, or another
receiver wrapping it as specified in _wrapReceiver(Receiver, int)
.
channel
- Channel id used to determine the source port.IllegalActionException
- If the port has no container,
or the container is unable to return a new receiver (for example
if it has no executive director).protected void _removeReceivers(Relation relation)
relation
- The relation.protected final void _notifyPortEventListeners(IOPortEvent event) throws IllegalActionException
event
- The event.IllegalActionException
- If thrown by portEvent().protected void _setConstant(Token token, int limit)
get(int)
or get(int,int)
replaces the returned token(s) with
this specified token. This is a rather specialized piece
of functionality added to be able to support
ConstantPublisherPort
.token
- The token to return instead of received tokens,
or null to cancel this functionality.limit
- If a non-negative number is given here, then
limit the number of constant tokens provided.protected Receiver _wrapReceiver(Receiver receiver, int channel) throws IllegalActionException
CommunicationAspect
, then wrap the
receiver specified in the argument using those communication aspects.
If there are no such parameters, then simply return the specified
receiver. If there is one such parameter, then use the quantity
manager to wrap the specified receiver in a new receiver, and return
that receiver. If there are two such parameters, then use the second
communication aspect to create a receiver that wraps that created by the
first communication aspect. Etc.receiver
- The receiver to wrap.channel
- Channel id used to determine the source port.IllegalActionException
- If any parameter of the port
cannot be evaluated.CommunicationAspect