Package ptolemy.actor.lib.aspect
Class CompositeExecutionAspect
- 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.CompositeExecutionAspect
-
- All Implemented Interfaces:
java.lang.Cloneable,Actor,ActorExecutionAspect,Executable,FiringsRecordable,Initializable,TypedActor,Changeable,Debuggable,DebugListener,Decorator,Derivable,Instantiable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class CompositeExecutionAspect extends TypedCompositeActor implements ActorExecutionAspect
This is a composite execution aspect. Actors decorated by this aspect also specify a requestPort. A record token with the actor and its execution time is created on this requestPort whenever the director wants to schedule the actor. When this token is received by a ResourceMappingOutputport inside this CompositeExecutionAspect, the director is informed that the actor can now fire.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Patricia Derler
- Pt.AcceptedRating:
- Red (derler)
- Pt.ProposedRating:
- Red (derler)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompositeExecutionAspect.CompositeExecutionAspectAttributesAttributes for actors decorated by this CompositeExecutionAspects.-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<NamedObj>_actorsActors decorated by this aspect.protected java.util.List<NamedObj>_currentlyExecutingList of currently executing actors.protected java.util.List<ExecutionAspectListener>_executionAspectListenersListeners that want to be informed about execution events.protected boolean_lastActorFinishedTrue if in the last request to schedule an actor, this actor finished execution.ParameterjustMonitorThis 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.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description CompositeExecutionAspect(CompositeEntity container, java.lang.String name)Create a new actor in the specified container with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExecutingListener(ExecutionAspectListener listener)Add schedule listener.voidattributeChanged(Attribute attribute)React to the change of the justMonitor attribute by updating internal variables.java.lang.Objectclone(Workspace workspace)Clone the actor into the specified workspace.DecoratorAttributescreateDecoratorAttributes(NamedObj target)Return the decorated attributes for the target NamedObj.java.util.List<NamedObj>decoratedObjects()Return a list of the entities deeply contained by the container of this ExecutionAspect.doublegetExecutionTime(NamedObj actor)Get the execution time of an actor.voidinitialize()Initialize local variables.voidinitializeDecoratedActors()Iterate through all entities deeply contained by the container, record for each that it is not executing.booleanisGlobalDecorator()Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.booleanisWaitingForResource(Actor actor)Check whether the execution of an actor is handled by this aspect actor.booleanlastScheduledActorFinished()If the last actor that was scheduled finished execution then this method returns true.voidnotifyExecutionListeners(NamedObj entity, java.lang.Double time, ExecutionAspectListener.ExecutionEventType eventType)Notify execution listeners about rescheduling events.booleanpostfire()Iterate through resource mapping output ports and if they contain tokens, inform the director of the actors in the tokens that these actors can resume execution.voidremoveExecutionListener(ExecutionAspectListener listener)Remove schedule listener.Timeschedule(Time environmentTime)Perform rescheduling actions when no new actor requests to be scheduled.Timeschedule(NamedObj actor, Time currentPlatformTime, Time deadline, Time executionTime)Schedule a new actor for execution.voidsetContainer(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.voidsetRequestPort(NamedObj actor, java.lang.String portName)Set the name of the port that will receive scheduling requests for the actor.-
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, fire, 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, 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
fire, isFireFunctional, isStrict, iterate, 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.
-
_actors
protected java.util.List<NamedObj> _actors
Actors decorated by this aspect.
-
_lastActorFinished
protected boolean _lastActorFinished
True if in the last request to schedule an actor, this actor finished execution.
-
_executionAspectListeners
protected java.util.List<ExecutionAspectListener> _executionAspectListeners
Listeners that want to be informed about execution events.
-
_currentlyExecuting
protected java.util.List<NamedObj> _currentlyExecuting
List of currently executing actors.
-
-
Constructor Detail
-
CompositeExecutionAspect
public CompositeExecutionAspect(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.- Parameters:
container- The container.name- The name of this actor within the container.- Throws:
IllegalActionException- If this actor cannot be contained by the proposed container (see the setContainer() method).NameDuplicationException- If the name coincides with an entity already in the container.
-
-
Method Detail
-
addExecutingListener
public void addExecutingListener(ExecutionAspectListener listener) throws IllegalActionException
Add schedule listener. If necessary, initialize list of actors scheduled by this ExecutionAspect.- Specified by:
addExecutingListenerin interfaceActorExecutionAspect- Parameters:
listener- The listener to be added.- Throws:
IllegalActionException- If an error occurs in the initialization of actors scheduled by this ExecutionAspect.
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to the change of the justMonitor attribute by updating internal variables.- Overrides:
attributeChangedin 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:
clonein classCompositeActor- Parameters:
workspace- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException- If a derived class contains an attribute that cannot be cloned.- 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:
createDecoratorAttributesin 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.
-
decoratedObjects
public java.util.List<NamedObj> decoratedObjects()
Return a list of the entities deeply contained by the container of this ExecutionAspect.- Specified by:
decoratedObjectsin interfaceDecorator- Returns:
- A list of the objects decorated by this decorator.
-
getExecutionTime
public double getExecutionTime(NamedObj actor) throws IllegalActionException
Get the execution time of an actor. If the actor does not have an attribute specifying the execution time, return the minimum execution time.- Specified by:
getExecutionTimein interfaceActorExecutionAspect- Parameters:
actor- The actor.- Returns:
- The execution time.
- Throws:
IllegalActionException- Thrown in attribute or token cannot be read.
-
initialize
public void initialize() throws IllegalActionExceptionInitialize local variables.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classCompositeActor- Throws:
IllegalActionException- Thrown if list of actors decorated by this aspect cannot be retrieved.
-
initializeDecoratedActors
public void initializeDecoratedActors() throws IllegalActionExceptionIterate through all entities deeply contained by the container, record for each that it is not executing.- Specified by:
initializeDecoratedActorsin interfaceActorExecutionAspect- Throws:
IllegalActionException- If the decorator parameters cannot be read.
-
isGlobalDecorator
public boolean isGlobalDecorator()
Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.- Specified by:
isGlobalDecoratorin interfaceDecorator- Returns:
- True if decorator is global.
-
isWaitingForResource
public boolean isWaitingForResource(Actor actor)
Check whether the execution of an actor is handled by this aspect actor.- Specified by:
isWaitingForResourcein interfaceActorExecutionAspect- Parameters:
actor- The actor.- Returns:
- True, if the actor execution is handled by this aspect actor.
-
lastScheduledActorFinished
public boolean lastScheduledActorFinished()
If the last actor that was scheduled finished execution then this method returns true.- Specified by:
lastScheduledActorFinishedin interfaceActorExecutionAspect- Returns:
- True if last actor that was scheduled finished execution.
-
notifyExecutionListeners
public void notifyExecutionListeners(NamedObj entity, java.lang.Double time, ExecutionAspectListener.ExecutionEventType eventType)
Notify execution listeners about rescheduling events.- Specified by:
notifyExecutionListenersin interfaceActorExecutionAspect- Parameters:
entity- Entity that is being scheduled.time- Time when entity is being scheduled.eventType- Type of event.
-
postfire
public boolean postfire() throws IllegalActionExceptionIterate through resource mapping output ports and if they contain tokens, inform the director of the actors in the tokens that these actors can resume execution.- Specified by:
postfirein interfaceExecutable- Overrides:
postfirein classCompositeActor- Returns:
- True if the execution can continue into the next iteration.
- Throws:
IllegalActionException- Not explicitly thrown here.
-
schedule
public Time schedule(Time environmentTime) throws IllegalActionException
Perform rescheduling actions when no new actor requests to be scheduled.- Specified by:
schedulein interfaceActorExecutionAspect- Parameters:
environmentTime- The outside time.- Returns:
- Relative time when this aspect has to be executed again to perform rescheduling actions.
- Throws:
IllegalActionException- Thrown in subclasses.
-
schedule
public Time schedule(NamedObj actor, Time currentPlatformTime, Time deadline, Time executionTime) throws IllegalActionException
Schedule a new actor for execution. Find the const actor in the _model that is mapped to this actor and trigger a firing of that one, if the actor is not already in execution. If the actor finished execution, return zero time, otherwise return the next time the model has something to do.- Specified by:
schedulein interfaceActorExecutionAspect- Parameters:
actor- The actor to be scheduled.currentPlatformTime- The current platform time.deadline- The deadline of the event.executionTime- The execution time of the actor.- Returns:
- Relative time when this aspect has to be executed again.
- Throws:
IllegalActionException- Thrown if actor parameters such as execution time or priority cannot be read.
-
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:
setContainerin 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()
-
setRequestPort
public void setRequestPort(NamedObj actor, java.lang.String portName)
Set the name of the port that will receive scheduling requests for the actor.- Parameters:
actor- The actor.portName- The request port.
-
removeExecutionListener
public void removeExecutionListener(ExecutionAspectListener listener)
Remove schedule listener.- Specified by:
removeExecutionListenerin interfaceActorExecutionAspect- Parameters:
listener- The listener to be removed.
-
-