ptolemy.actor.gt
Class ModelExecutor.Wrapper.WrapperDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.gt.ModelExecutor.Wrapper.WrapperDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Enclosing class:
ModelExecutor.Wrapper

private class ModelExecutor.Wrapper.WrapperDirector
extends Director

The director to be used in the wrapper that handles requests from the directors of the models to be executed.

Since:
Ptolemy II 8.0
Version:
$Id: ModelExecutor.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Thomas Huining Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  java.util.PriorityQueue<TimedEvent> _eventQueue
          The event queue.
 
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
ModelExecutor.Wrapper.WrapperDirector(CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
 
Method Summary
private  boolean _hasToken()
          Test whether there is an input token in any channel of any input port.
 java.lang.Object clone(Workspace workspace)
          Clone the object into the specified workspace.
 void fire()
          Fire the contained actor if there is any token available or if there is an request in the event queue.
 Time fireAt(Actor actor, Time time)
          Handle a fireAt request from the contained actor by recording it in the event queue.
 Time getModelNextIterationTime()
          Return the next time of interest in the model being executed by this director or the director of any enclosing model up the hierarchy.
 Receiver newReceiver()
          Return a new receiver of a type compatible with this director.
 boolean postfire()
          Return false if the contained actor has finished executing.
 boolean prefire()
          Return true if the event queue is not empty or there are input tokens.
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, finish, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, initialize, invalidateResolvedTypes, invalidateSchedule, isFireFunctional, isStopRequested, isStrict, iterate, preinitialize, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, terminate, transferInputs, 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, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_eventQueue

private java.util.PriorityQueue<TimedEvent> _eventQueue
The event queue.

Constructor Detail

ModelExecutor.Wrapper.WrapperDirector

public ModelExecutor.Wrapper.WrapperDirector(CompositeEntity container,
                                             java.lang.String name)
                                      throws IllegalActionException,
                                             NameDuplicationException
Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace. Create the timeResolution parameter.

Parameters:
container - The container.
name - The name of this director.
Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container, or if the time resolution parameter is malformed.
NameDuplicationException - If the container already contains an entity with the specified name.
Method Detail

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an attribute with no container.

Overrides:
clone in class Attribute
Parameters:
workspace - The workspace for the cloned object.
Returns:
The new Attribute.
Throws:
java.lang.CloneNotSupportedException - Not thrown in this base class
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

fire

public void fire()
          throws IllegalActionException
Fire the contained actor if there is any token available or if there is an request in the event queue. Transfer the outputs of the actor to the output ports of this wrapper.

Specified by:
fire in interface Executable
Overrides:
fire in class Director
Throws:
IllegalActionException - If thrown when the actor is fired.

fireAt

public Time fireAt(Actor actor,
                   Time time)
            throws IllegalActionException
Handle a fireAt request from the contained actor by recording it in the event queue.

Overrides:
fireAt in class Director
Parameters:
actor - The actor that requests to be fired.
time - The time to fire the actor.
Returns:
The time at which the actor will be fired.
Throws:
IllegalActionException - Not thrown in this class.
See Also:
Director.fireAtCurrentTime(Actor)

getModelNextIterationTime

public Time getModelNextIterationTime()
Return the next time of interest in the model being executed by this director or the director of any enclosing model up the hierarchy. If this director is at the top level, then this default implementation simply returns the current time, since this director does not advance time. If this director is not at the top level, then return whatever the enclosing director returns.

This method is useful for domains that perform speculative execution (such as CT). Such a domain in a hierarchical model (i.e. CT inside DE) uses this method to determine how far into the future to execute.

Derived classes should override this method to provide an appropriate value, if possible. For example, the DEDirector class returns the time value of the next event in the event queue.

Overrides:
getModelNextIterationTime in class Director
Returns:
The time of the next iteration.
See Also:
Director.getModelTime()

newReceiver

public Receiver newReceiver()
Return a new receiver of a type compatible with this director. In this class, this returns an instance of QueueReceiver.

Overrides:
newReceiver in class Director
Returns:
A new QueueReceiver.

postfire

public boolean postfire()
                 throws IllegalActionException
Return false if the contained actor has finished executing.

Specified by:
postfire in interface Executable
Overrides:
postfire in class Director
Returns:
false if the contained actor has finished executing; true otherwise.
Throws:
IllegalActionException - If the superclass throws it.

prefire

public boolean prefire()
                throws IllegalActionException
Return true if the event queue is not empty or there are input tokens.

Specified by:
prefire in interface Executable
Overrides:
prefire in class Director
Returns:
true if the event queue is not empty or there are input tokens.
Throws:
IllegalActionException - If the availability of input tokens cannot be tested.

_hasToken

private boolean _hasToken()
                   throws IllegalActionException
Test whether there is an input token in any channel of any input port.

Returns:
true if there is an input token; false otherwise.
Throws:
IllegalActionException - If the availability of input tokens cannot be tested.