|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.Relation
ptolemy.kernel.ComponentRelation
ptolemy.actor.IORelation
public class IORelation
This class mediates connections between ports that can send data to one another via message passing. One purpose of this relation is to ensure that IOPorts are only connected to IOPorts. A second purpose is to support the notion of a width to represent something like a bus. By default an IORelation is a bus for which the width will be inferred, which corresponds to a width equal to Auto. In Vergil you can change the width from Auto to a specific value, to explicitly specify the width of a relation. Specifying a width equal to zero will disable the relation. A width equal equal to -1 is equivalent to a width equal to Auto, in which case the width will be inferred (if possible) from the context. In particular, if this relation is linked on the inside to a port with some width, then the width of this relation will be inferred to be the enough so that the widths of all inside linked relations adds up to the outside width of the port. If this IORelation is linked to another instance of IORelation, then the width of the two IORelations is constrained to be the same.
Instances of IORelation can only be linked to instances of IOPort or instances of IORelation. Derived classes may further constrain this to subclasses of IOPort of IORelation. Such derived classes should override the protected methods _checkPort() and _checkRelation() to throw an exception.
To link a IOPort to an IORelation, use the link() or liberalLink() method in the IOPort class. To remove a link, use the unlink() method. To link (unlink) an IORelation to an IORelation, use the link() (unlink()) method of IORelation.
The container for instances of this class can only be instances of CompositeActor. Derived classes may wish to further constrain the container to subclasses of ComponentEntity. To do this, they should override the _checkContainer() method.
Green (acataldo) |
Green (eal) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private Parameter |
_auto
A parameter to be able to set the width to Auto to automatically infer widths. |
private int |
_cachedWidth
|
private int |
_inferredWidth
|
private long |
_inferredWidthVersion
|
private boolean |
_suppressWidthPropagation
|
static boolean |
_USE_NEW_WIDTH_INFERENCE_ALGO
Indicate whether the new or the old width inference algo should be used This is a packaged field. |
static int |
CONFIGURATION
Indicate that the description(int) method should describe the width of the relation, and whether it has been fixed. |
Parameter |
width
The width of this relation. |
static int |
WIDTH_TO_INFER
The value of the width we should infer. |
Fields inherited from class ptolemy.kernel.Relation |
---|
_linkList |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
IORelation()
Construct a relation in the default workspace with an empty string as its name. |
|
IORelation(CompositeEntity container,
java.lang.String name)
Construct a relation with the given name contained by the specified entity. |
|
IORelation(Workspace workspace)
Construct a relation in the specified workspace with an empty string as a name. |
Method Summary | |
---|---|
private Receiver[][] |
_cascade(Receiver[][] array1,
Receiver[][] array2)
Cascade two Receiver arrays to form a new array. |
protected void |
_checkPort(Port port)
Throw an exception if the specified port cannot be linked to this relation (is not of class IOPort). |
protected void |
_checkRelation(Relation relation,
boolean symmetric)
Throw an exception if the specified relation is not an instance of IORelation or if it does not have the same width as this relation. |
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object. |
private int |
_getUserWidth()
Return the width set by the user |
private boolean |
_inferringWidths()
Determine whether widths are currently being inferred or not. |
private int |
_inferWidth()
Infer the width of the port from how it is connected. |
private void |
_init()
Create an initialize the width parameter. |
(package private) void |
_setInferredWidth(int width)
Set the inferred width of this relation. |
private void |
_setWidth(int width)
Set the width of this relation and all relations in its relation group. |
protected boolean |
_skipWidthInference()
Determines whether width inference should be skipped or not. |
void |
attributeChanged(Attribute attribute)
React to a change in an attribute. |
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace. |
Receiver[][] |
deepReceivers(IOPort except)
Return the receivers of all input ports linked to this relation, directly or indirectly through a relation group, except those in the port given as an argument. |
int |
getWidth()
Return the width of the IORelation, which is always at least one. |
boolean |
isWidthFixed()
Return true if the relation has a definite width (i.e., setWidth() has not been called with a value equal to WIDTH_TO_INFER. |
java.util.List<IOPort> |
linkedDestinationPortList()
List the input ports that this relation connects to from the outside, and the output ports that it connects to from the inside. |
java.util.List<IOPort> |
linkedDestinationPortList(IOPort except)
List the input ports that this relation connects to from the outside and the output ports that it connects to from the inside, except the port given as an argument. |
java.util.Enumeration |
linkedDestinationPorts()
Deprecated. Use linkedDestinationPortList() instead. |
java.util.Enumeration |
linkedDestinationPorts(IOPort except)
Deprecated. Use linkDestinationPortList(IOPort) instead. |
java.util.List<IOPort> |
linkedSourcePortList()
List the output ports that this relation connects to from the outside and the input ports that it connects to from the inside. |
java.util.List<IOPort> |
linkedSourcePortList(IOPort except)
List the output ports that this relation connects to from the outside and the input ports that it connects to from the inside, except the port given as an argument. |
java.util.Enumeration |
linkedSourcePorts()
Deprecated. Use linkedSourcePortList() instead. |
java.util.Enumeration |
linkedSourcePorts(IOPort except)
Deprecated. Use linkedSourcePortList(IOPort) instead. |
boolean |
needsWidthInference()
Determine whether for this relation width inference needs to be performed. |
void |
setContainer(CompositeEntity container)
Specify the container, adding the relation to the list of relations in the container. |
void |
setWidth(int widthValue)
Set the width of this relation and all relations in its relation group. |
Methods inherited from class ptolemy.kernel.ComponentRelation |
---|
_checkContainer, _propagateExistence, deepLinkedPortList, deepLinkedPorts, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, unlinkAll |
Methods inherited from class ptolemy.kernel.Relation |
---|
_getContainedObject, link, linkedObjectsList, linkedPortList, linkedPortList, linkedPorts, linkedPorts, numLinks, relationGroupList, unlink |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Parameter width
public static final int CONFIGURATION
public static final int WIDTH_TO_INFER
private Parameter _auto
public static final boolean _USE_NEW_WIDTH_INFERENCE_ALGO
private transient int _inferredWidth
private transient long _inferredWidthVersion
private boolean _suppressWidthPropagation
private int _cachedWidth
Constructor Detail |
---|
public IORelation()
public IORelation(Workspace workspace)
workspace
- The workspace that will list the relation.public IORelation(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the relation.
IllegalActionException
- If the container is incompatible
with this relation.
NameDuplicationException
- If the name coincides with
a relation already in the container.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.
IllegalActionException
- If the change is not acceptable
to this container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class ComponentRelation
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 Receiver[][] deepReceivers(IOPort except) throws InvalidStateException, IllegalActionException
The number of groups (rows) is less than or equal to the width of the relation, which is always at least one. If there are no receivers then return null.
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.
NOTE: This method may have the effect of creating new receivers in the remote input ports and losing the previous receivers in those ports, together with any data they may contain. This occurs only if the topology has changed since the receivers were created, and that change resulting in one of those ports not having the right number of receivers.
This method read-synchronizes on the workspace.
except
- The port to exclude, or null to not
exclude any ports.
IllegalActionException
InvalidStateException
IOPort.getRemoteReceivers()
public int getWidth() throws IllegalActionException
IllegalActionException
setWidth(int)
public boolean isWidthFixed() throws IllegalActionException
IllegalActionException
- If the expression for the width cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.public java.util.List<IOPort> linkedDestinationPortList()
Relation.linkedPorts()
public java.util.List<IOPort> linkedDestinationPortList(IOPort except)
except
- The port not included in the returned list, or
null to not exclude any ports.
Relation.linkedPortList(ptolemy.kernel.Port)
public java.util.Enumeration linkedDestinationPorts()
Relation.linkedPorts()
public java.util.Enumeration linkedDestinationPorts(IOPort except)
except
- The port not included in the returned Enumeration.
Relation.linkedPorts(ptolemy.kernel.Port)
public java.util.List<IOPort> linkedSourcePortList()
Relation.linkedPorts()
public java.util.List<IOPort> linkedSourcePortList(IOPort except)
except
- The port not included in the returned list.
Relation.linkedPortList(ptolemy.kernel.Port)
public java.util.Enumeration linkedSourcePorts()
Relation.linkedPorts()
public java.util.Enumeration linkedSourcePorts(IOPort except)
except
- The port not included in the returned Enumeration.
Relation.linkedPorts(ptolemy.kernel.Port)
public boolean needsWidthInference() throws IllegalActionException
IllegalActionException
- If the expression for the width cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
The container must be an instance of CompositeActor or null, otherwise an exception is thrown. Derived classes may further constrain the class of the container to a subclass of CompositeActor.
This method invalidates the schedule and resolved types of the director of the container, if there is one.
This method is write-synchronized on the workspace.
setContainer
in class ComponentRelation
container
- The proposed container.
IllegalActionException
- If the container is not a
CompositeActor or null, or this entity and the container are not in
the same workspace.
NameDuplicationException
- If the name collides with a name
already on the relations list of the container.ComponentRelation.getContainer()
public void setWidth(int widthValue) throws IllegalActionException
widthValue
- The width of the relation.
IllegalActionException
- If the argument is not zero, one,
or equal to WIDTH_TO_INFER and the relation is linked to a
non-multiport. Or when the argument is less than zero and different
from WIDTH_TO_INFER.Workspace.getWriteAccess()
,
getWidth()
protected void _checkPort(Port port) throws IllegalActionException
_checkPort
in class ComponentRelation
port
- The candidate port to link to.
IllegalActionException
- If the port is not an IOPort.protected void _checkRelation(Relation relation, boolean symmetric) throws IllegalActionException
_checkRelation
in class ComponentRelation
relation
- The relation to link to.symmetric
- If true, the call _checkRelation() on the specified
relation with this as an argument.
IllegalActionException
- If this relation has no container,
or if this relation is not an acceptable relation for the specified
relation, or if this relation and the specified relation do not
have the same width.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 is a field of the form "configuration {width integer ?fixed?}", where the word "fixed" is present if the relation has fixed width, and is absent if the relation is a bus with inferred width (isWidthFixed() returns false). This method is read-synchronized on the workspace.
_description
in class Relation
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).
IllegalActionException
protected boolean _skipWidthInference()
void _setInferredWidth(int width) throws IllegalActionException
width
- The inferred width of the relation.
IllegalActionException
- If the expression for the width cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.private Receiver[][] _cascade(Receiver[][] array1, Receiver[][] array2) throws InvalidStateException, IllegalActionException
IllegalActionException
InvalidStateException
private int _getUserWidth() throws IllegalActionException
IllegalActionException
- If the expression for the width cannot
be parsed or cannot be evaluated, or if the result of evaluation
violates type constraints, or if the result of evaluation is null
and there are variables that depend on this one.private boolean _inferringWidths() throws IllegalActionException
IllegalActionException
- If toplevel not a CompositeActor.private int _inferWidth() throws IllegalActionException
IllegalActionException
private void _init()
private void _setWidth(int width) throws IllegalActionException
width
- The width of the relation.
IllegalActionException
- If the argument is not zero, one,
or equal to WIDTH_TO_INFER and the relation is linked to a
non-multiport. Or when the argument is less than zero and different
from WIDTH_TO_INFER.Workspace.getWriteAccess()
,
getWidth()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |