Package ptolemy.actor.lib.aspect
Class CompositeCommunicationAspect
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.kernel.CompositeEntity
-
- ptolemy.actor.CompositeActor
-
- ptolemy.actor.TypedCompositeActor
-
- ptolemy.actor.lib.aspect.CompositeCommunicationAspect
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,CommunicationAspect
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class CompositeCommunicationAspect extends TypedCompositeActor implements CommunicationAspect, Decorator
This class implements functionality of a composite communication aspect.When an intermediate receiver sends a token to an input port of this communication aspect, the original receiver and the token are encoded in a RecordToken. When such a token arrives at an output port, the original token is extracted and sent to the original receiver. FIXME: Add description of use of DecorationParameters.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Patricia Derler
- Pt.AcceptedRating:
- Red (derler)
- Pt.ProposedRating:
- Yellow (derler)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompositeCommunicationAspect.CompositeCommunicationAspectAttributes
Attributes for ports decorated by this composite communication aspect.-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<IOPort,java.util.List<Attribute>>
_parameters
List of parameters per port.Parameter
justMonitor
This parameter indicates whether the tokens received via the ImmediateReceivers are immediately forwarded to the wrapped receivers or whether they are delayed by this communication aspect and only forwarded through a CommunicationResponsePort.-
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.CommunicationAspect
decoratorHighlightColorName
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description CompositeCommunicationAspect(CompositeEntity container, java.lang.String name)
Construct a CompositeCommunicationAspect with a name and a container.CompositeCommunicationAspect(Workspace workspace)
Construct a CompositeCommunicationAspect in the specified workspace with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
React to the change of the justMonitor attribute by updating internal variables.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.Receiver
createIntermediateReceiver(Receiver receiver)
Create an intermediate receiver that wraps a given receiver.java.util.List<NamedObj>
decoratedObjects()
Return a list of the entities deeply contained by the container of this resource scheduler.void
fire()
Override the fire and change the transferring tokens from and to input/output placeholders.void
initialize()
Initialize actor, reset variables.boolean
isGlobalDecorator()
Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.void
registerListener(CommunicationAspectListener monitor)
Add a communication aspect monitor to the list of listeners.void
reset()
Reset - nothing to do here.void
sendToken(Receiver source, Receiver receiver, Token token)
Initiate a send of the specified token to the specified receiver.void
setContainer(CompositeEntity container)
Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.void
setInputPortName(Port port, java.lang.String inputPortName)
Set the name of the CommunicationRequestPort that will be receiving tokens from this actor port.-
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _destinationTypeConstraints, attributeTypeChanged, isBackwardTypeInferenceEnabled, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, preinitialize, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort, wrapup
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
justMonitor
public Parameter justMonitor
This parameter indicates whether the tokens received via the ImmediateReceivers are immediately forwarded to the wrapped receivers or whether they are delayed by this communication aspect and only forwarded through a CommunicationResponsePort. This parameter is a boolean that defaults to false.
-
-
Constructor Detail
-
CompositeCommunicationAspect
public CompositeCommunicationAspect(Workspace workspace) throws IllegalActionException, NameDuplicationException
Construct a CompositeCommunicationAspect in the specified workspace with no container and 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. You should set the local director or executive director before attempting to send data to the actor or to execute it. Add the actor to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the actor.- Throws:
IllegalActionException
- If the container is incompatible with this actor.NameDuplicationException
- If the name coincides with an actor already in the container.
-
CompositeCommunicationAspect
public CompositeCommunicationAspect(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a CompositeCommunicationAspect with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This actor will have no local director initially, and its executive director will be simply the director of the container.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the container is incompatible with this actor.NameDuplicationException
- If the name coincides with an actor already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to the change of the justMonitor attribute by updating internal variables.- Overrides:
attributeChanged
in classTypedCompositeActor
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If token in attribute cannot be accessed.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classCompositeActor
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- A new CompositeQM.
- Throws:
java.lang.CloneNotSupportedException
- Not thrown here.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
createDecoratorAttributes
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.- Specified by:
createDecoratorAttributes
in interfaceDecorator
- Parameters:
target
- The NamedObj that will be decorated.- Returns:
- The decorated attributes for the target NamedObj, or null if the specified target is not an Actor.
-
createIntermediateReceiver
public Receiver createIntermediateReceiver(Receiver receiver) throws IllegalActionException
Create an intermediate receiver that wraps a given receiver.- Specified by:
createIntermediateReceiver
in interfaceCommunicationAspect
- Parameters:
receiver
- The receiver that is being wrapped.- Returns:
- A new intermediate receiver.
- Throws:
IllegalActionException
- Not thrown in this class but may be thrown in derived classes.
-
decoratedObjects
public java.util.List<NamedObj> decoratedObjects()
Return a list of the entities deeply contained by the container of this resource scheduler.- Specified by:
decoratedObjects
in interfaceDecorator
- Returns:
- A list of the objects decorated by this decorator.
-
initialize
public void initialize() throws IllegalActionException
Initialize actor, reset variables.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classCompositeActor
- Throws:
IllegalActionException
- If there is no director, or if the director's initialize() method throws it, or if the actor is not opaque.
-
fire
public void fire() throws IllegalActionException
Override the fire and change the transferring tokens from and to input/output placeholders.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classCompositeActor
- Throws:
IllegalActionException
- If there is no director, or if the director's fire() method throws it, or if the actor is not opaque.
-
isGlobalDecorator
public boolean isGlobalDecorator()
Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.- Specified by:
isGlobalDecorator
in interfaceDecorator
- Returns:
- True if decorator is global.
-
registerListener
public void registerListener(CommunicationAspectListener monitor)
Add a communication aspect monitor to the list of listeners.- Specified by:
registerListener
in interfaceCommunicationAspect
- Parameters:
monitor
- The communication aspect monitor.
-
reset
public void reset()
Reset - nothing to do here.- Specified by:
reset
in interfaceCommunicationAspect
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.- Overrides:
setContainer
in classCompositeActor
- Parameters:
container
- The container to attach this attribute to..- Throws:
IllegalActionException
- If this attribute is not of the expected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.NameDuplicationException
- If the container already has an attribute with the name of this attribute.- See Also:
ComponentEntity.getContainer()
-
setInputPortName
public void setInputPortName(Port port, java.lang.String inputPortName)
Set the name of the CommunicationRequestPort that will be receiving tokens from this actor port.- Parameters:
port
- The actorport.inputPortName
- The name of the CommunicationRequestPort.
-
sendToken
public void sendToken(Receiver source, Receiver receiver, Token token) throws IllegalActionException
Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.- Specified by:
sendToken
in interfaceCommunicationAspect
- Parameters:
source
- Sender of the token.receiver
- The receiver to send to.token
- The token to send.- Throws:
IllegalActionException
- If the refiring request fails.
-
-