Class CoroutineDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.domains.coroutine.kernel.CoroutineDirector
-
- All Implemented Interfaces:
java.lang.Cloneable,Executable,Initializable,Continuation,Changeable,Debuggable,DebugListener,Derivable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class CoroutineDirector extends Director implements Continuation
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- shaver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCoroutineDirector.InternalEntryLocationclassCoroutineDirector.InternalExitLocation-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description ParameterentryMappingParameterexitMappingParameterinitContinuationNameParameternextMapping-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
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 CoroutineDirector()CoroutineDirector(CompositeEntity container, java.lang.String name)CoroutineDirector(Workspace workspace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]_extractMapSpec(Token t, int n)Continuation_getContinuation(java.lang.String name)protected void_resetAllReceivers()Reset all receivers to unknown status and clear out variables used to track which actors fired in the last iteration.voidbuildEntryMapFromParameter()voidbuildExitMapFromParameter()voidbuildMapFromConnections()voidbuildMapFromParameter()ControlExitTokencontrolEnter(ControlEntryToken entry)ControlExitTokencontrolEnterAt(ControlEntryToken.EntryLocation location)ControlExitTokencontrolInit()ControlExitTokencontrolResume()voiddebugShowMap()java.util.List<ControlEntryToken.EntryLocation>entryLocations()Returns the set of exposed Entry Locations.java.util.List<ControlExitToken.ExitLocation>exitLocations()Returns the set of exposed Exit Locations.voidfire()Iterate all the deeply contained actors of the container of this director exactly once.voidinitialize()Initialize the model controlled by this director.ReceivernewReceiver()Return a new receiver of a type compatible with this director.booleanpostfire()Return true if the director wishes to be scheduled for another iteration.voidpreinitialize()Validate the attributes and then invoke the preinitialize() methods of all its deeply contained actors.booleantransferInputs(IOPort port)Transfer data from an input port of the container to the ports it is connected to on the inside.booleantransferOutputs(IOPort port)Transfer data from an output port of the container to the ports it is connected to on the outside.-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, clone, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, prefire, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferOutputs, wrapup
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _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
-
-
-
-
Constructor Detail
-
CoroutineDirector
public CoroutineDirector() throws IllegalActionException, NameDuplicationException
-
CoroutineDirector
public CoroutineDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
-
CoroutineDirector
public CoroutineDirector(Workspace workspace) throws IllegalActionException, NameDuplicationException
-
-
Method Detail
-
fire
public void fire() throws IllegalActionExceptionDescription copied from class:DirectorIterate all the deeply contained actors of the container of this director exactly once. This method is not functional, since an iteration of the deeply contained actors may change state in their postfire() method. The actors are iterated in the order that they appear on the list returned by deepEntityList(), which is normally the order in which they were created.This method is not synchronized on the workspace, so the caller should be.
In this base class, an attempt is made to fire each actor exactly once, in the order they were created. Prefire is called once, and if prefire returns true, then fire is called once, followed by postfire. The return value from postfire is ignored. If the container is not an instance of CompositeActor, however, then this method does nothing.
- Specified by:
firein interfaceExecutable- Overrides:
firein classDirector- Throws:
IllegalActionException- If any called method of one of the associated actors throws it.
-
initialize
public void initialize() throws IllegalActionExceptionDescription copied from class:DirectorInitialize the model controlled by this director. Set the current time to the start time or the current time of the executive director, and then invoke the initialize() method of this director on each actor that is controlled by this director. If the container is not an instance of CompositeActor, do nothing. This method should typically be invoked once per execution, after the preinitialization phase, but before any iteration. It may be invoked in the middle of an execution, if reinitialization is desired. Since type resolution has been completed and the current time is set, the initialize() method of a contained actor may produce output or schedule events. If stop() is called during this methods execution, then stop initializing actors immediately. This method is not synchronized on the workspace, so the caller should be.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classDirector- Throws:
IllegalActionException- If the initialize() method of one of the associated actors throws it.
-
buildMapFromParameter
public void buildMapFromParameter() throws IllegalActionException- Throws:
IllegalActionException
-
buildEntryMapFromParameter
public void buildEntryMapFromParameter() throws IllegalActionException- Throws:
IllegalActionException
-
buildExitMapFromParameter
public void buildExitMapFromParameter() throws IllegalActionException- Throws:
IllegalActionException
-
buildMapFromConnections
public void buildMapFromConnections()
-
debugShowMap
public void debugShowMap()
-
_extractMapSpec
public java.lang.String[] _extractMapSpec(Token t, int n)
-
_getContinuation
public Continuation _getContinuation(java.lang.String name)
-
postfire
public boolean postfire() throws IllegalActionExceptionDescription copied from class:DirectorReturn true if the director wishes to be scheduled for another iteration. This method is called by the container of this director to see whether the director wishes to execute anymore. It should not, in general, call postfire() on the contained actors.In this base class, return the false if stop() has been called since preinitialize(), and true otherwise. Derived classes that override this method need to respect this semantics. The protected variable _stopRequested indicates whether stop() has been called.
- Specified by:
postfirein interfaceExecutable- Overrides:
postfirein classDirector- Returns:
- True to continue execution, and false otherwise.
- Throws:
IllegalActionException- Not thrown in this base class.
-
preinitialize
public void preinitialize() throws IllegalActionExceptionDescription copied from class:DirectorValidate the attributes and then invoke the preinitialize() methods of all its deeply contained actors. This method is invoked once per execution, before any iteration, and before the initialize() method. Time is not set during this stage. So preinitialize() method of actors should not make use of time. They should wait until the initialize phase of the execution.This method also resets the protected variable _stopRequested to false, so if a derived class overrides this method, then it should also do that.
This method is not synchronized on the workspace, so the caller should be.
- Specified by:
preinitializein interfaceInitializable- Overrides:
preinitializein classDirector- Throws:
IllegalActionException- If the preinitialize() method of one of the associated actors throws it.
-
controlEnter
public ControlExitToken controlEnter(ControlEntryToken entry) throws IllegalActionException
- Specified by:
controlEnterin interfaceContinuation- Throws:
IllegalActionException
-
controlInit
public ControlExitToken controlInit() throws IllegalActionException
- Specified by:
controlInitin interfaceContinuation- Throws:
IllegalActionException
-
controlResume
public ControlExitToken controlResume() throws IllegalActionException
- Specified by:
controlResumein interfaceContinuation- Throws:
IllegalActionException
-
controlEnterAt
public ControlExitToken controlEnterAt(ControlEntryToken.EntryLocation location) throws IllegalActionException
- Specified by:
controlEnterAtin interfaceContinuation- Throws:
IllegalActionException
-
entryLocations
public java.util.List<ControlEntryToken.EntryLocation> entryLocations()
Description copied from interface:ContinuationReturns the set of exposed Entry Locations. Some internal entry locations may exist that are not exposed to the interface.- Specified by:
entryLocationsin interfaceContinuation
-
exitLocations
public java.util.List<ControlExitToken.ExitLocation> exitLocations()
Description copied from interface:ContinuationReturns the set of exposed Exit Locations. Some internal exit locations may exist that are not exposed to the interface.- Specified by:
exitLocationsin interfaceContinuation
-
transferInputs
public boolean transferInputs(IOPort port) throws IllegalActionException
Description copied from class:DirectorTransfer data from an input port of the container to the ports it is connected to on the inside. The implementation in this base class transfers at most one token. Derived classes may override this method to transfer a domain-specific number of tokens.- Overrides:
transferInputsin classDirector- Parameters:
port- The port to transfer tokens from.- Returns:
- True if at least one data token is transferred.
- Throws:
IllegalActionException- If the port is not an opaque input port.
-
transferOutputs
public boolean transferOutputs(IOPort port) throws IllegalActionException
Description copied from class:DirectorTransfer data from an output port of the container to the ports it is connected to on the outside. The implementation in this base class transfers at most one token, but derived classes may transfer more than one token.- Overrides:
transferOutputsin classDirector- Parameters:
port- The port to transfer tokens from.- Returns:
- True if at least one data token is transferred.
- Throws:
IllegalActionException- If the port is not an opaque output port.
-
newReceiver
public Receiver newReceiver()
Description copied from class:DirectorReturn a new receiver of a type compatible with this director. In this base class, this returns an instance of Mailbox.- Overrides:
newReceiverin classDirector- Returns:
- A new Mailbox.
-
_resetAllReceivers
protected void _resetAllReceivers()
Reset all receivers to unknown status and clear out variables used to track which actors fired in the last iteration.
-
-