public class DDEDirector extends CompositeProcessDirector
In conjunction with the blocking read/write facilities, the DDE domain uses a distributed, local notion of time. In a network of actors governed by a DDEDirector each actor has a local notion of time. Several features of the DDEDirector are intended to facilitate these local notions of time.
All DDE models have a completion time. The completion time is a preset time after which all execution ceases. The completion time for a DDEDirector is specified via the stopTime parameter. The value of the stopTime parameter is passed to the receivers of all actors that the DDEDirector governs via newReceiver() during initialize(). After initialize() has been called, the value of stopTime can not be changed.
The default value of the stopTime parameter is PrioritizedTimedQueue.ETERNITY. Given this value, a DDE model will continue executing without regard for a completion time.
Deadlock due to feedback loops is dealt with via NullTokens. When an actor in a DDE model receives a NullToken, it may advance its local time value even though no computation results directly from consumption of the NullToken. For models with feedback topologies, the FeedBackDelay actor should be used in the feedback loop.
The DDE model of computation assumes that valid time stamps have non-negative values. Three special purpose negative time values are reserved with the following meanings. The value of PrioritizedTimedQueue.INACTIVE is reserved to indicate the termination of a receiver. The value of PrioritizedTimedQueue.ETERNITY is reserved to indicate that a receiver has not begun to participate in a model's execution. The value of PrioritizedTimedQueue.IGNORE is reserved to indicate that the current token at the head of a DDEReceiver should be ignored in favor of the tokens contained in the other receivers of the actor in question. More details of IGNORE can be found in FeedBackDelay.
NOTE: The current implementation of this director does not include an infrastructure for mutations. Hence, ChangeRequest and other facilities for changing the topology of a model are not included in this director.
PNDirector
,
FeedBackDelay
,
NullToken
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
static boolean |
READ_BLOCKED
Indicator that a thread is read blocked.
|
static boolean |
WRITE_BLOCKED
Indicator that a thread is write blocked.
|
_newActorThreadList, _notDone
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
DDEDirector()
Construct a DDEDirector in the default workspace with an empty string as
its name.
|
DDEDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
DDEDirector(Workspace workspace)
Construct a director in the workspace with an empty string as a
name.
|
Modifier and Type | Method and Description |
---|---|
(package private) java.util.Hashtable |
_getInitialTimeTable()
Return the initial time table of this director.
|
protected void |
_incrementLowestCapacityPort()
Increment the port capacity's according to Tom Parks' algorithm.
|
protected ProcessThread |
_newProcessThread(Actor actor,
ProcessDirector director)
Return a new ProcessThread of a type compatible with this director.
|
protected boolean |
_resolveInternalDeadlock()
Apply an algorithm to resolve an internal deadlock and return
true if the algorithm is successful.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
Time |
fireAt(Actor actor,
Time time,
int microstep)
Schedule an actor to be fired at the specified time.
|
double |
getCurrentTime()
Deprecated.
As of Ptolemy II 4.1, replaced by
getModelTime() |
Time |
getModelTime()
Return the current time of the DDEThread that calls this method on behalf
of an actor.
|
void |
initialize()
Initialize this director and the actors it contains and set variables to
their initial values.
|
Receiver |
newReceiver()
Return a new receiver of a type compatible with this director.
|
boolean |
postfire()
Return true if the actors governed by this director can continue
execution, and false otherwise.
|
void |
threadBlocked(java.lang.Thread thread,
ProcessReceiver receiver,
boolean readOrWrite)
Notify the director that the specified thread is blocked on an I/O
operation.
|
void |
threadUnblocked(java.lang.Thread thread,
ProcessReceiver receiver,
boolean readOrWrite)
Notify the director that the specified thread is unblocked on an I/O
operation.
|
_areActorsExternallyBlocked, _areThreadsDeadlocked, _controllerBlocked, _controllerUnBlocked, _isInputControllerBlocked, _isOutputControllerBlocked, _resolveDeadlock, createBranchController, getInputController, getOutputController, prefire, stopInputBranchController, stopOutputBranchController, threadBlocked, threadUnblocked, wrapup
_areAllThreadsStopped, _getActiveThreadsCount, _getBlockedThreadsCount, _getStoppedThreadsCount, _requestFinishOnReceivers, addThread, finish, fire, initialize, isStopFireRequested, isThreadActive, preinitialize, removeThread, stop, stopFire, terminate, threadHasPaused, threadHasResumed, transferInputs, transferOutputs
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, suggestedModalModelDirectors, supportMultirateFiring, suspend, transferOutputs
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_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
public static final boolean READ_BLOCKED
public static final boolean WRITE_BLOCKED
public DDEDirector() throws IllegalActionException, NameDuplicationException
IllegalActionException
- If the director is not
compatible with the specified container.NameDuplicationException
- If thrown while adding a
stopTime parameter.public DDEDirector(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace of this object.IllegalActionException
- If the director is not
compatible with the specified container.NameDuplicationException
- If thrown while adding a
stopTime parameter.public DDEDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container of this director.name
- Name of this director.IllegalActionException
- If the director is not
compatible with the specified container. May be thrown in a
derived class.NameDuplicationException
- If the container not a
CompositeActor and the name collides with an entity in the
container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class CompositeProcessDirector
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public Time fireAt(Actor actor, Time time, int microstep) throws IllegalActionException
NOTE: The current implementation of this method is such that a more appropriate name might be continueAt() rather than fireAt().
fireAt
in class Director
actor
- The actor scheduled to fire.time
- The scheduled time to fire.microstep
- The microstep (ignored by this director).IllegalActionException
- If the specified time is in
the past or if the thread calling this method is a DDEThread
but the specified actor is not contained by the DDEThread.Director.fireAtCurrentTime(Actor)
,
Director.fireContainerAt(Time)
@Deprecated public double getCurrentTime()
getModelTime()
getCurrentTime
in class Director
Director.setCurrentTime(double)
public Time getModelTime()
getModelTime
in class Director
Director.setModelTime(Time)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class CompositeProcessDirector
IllegalActionException
- If there is an error during
the creation of the threads or initialization of the actors.public Receiver newReceiver()
newReceiver
in class CompositeProcessDirector
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class ProcessDirector
IllegalActionException
- Not thrown in this base class.
May be thrown in derived classes.public void threadBlocked(java.lang.Thread thread, ProcessReceiver receiver, boolean readOrWrite)
thread
- The thread.receiver
- The receiver handling the I/O operation, or
null if it is not a specific receiver.readOrWrite
- Either READ_BLOCKED or WRITE_BLOCKED to
indicate whether the thread is blocked on read or write.CompositeProcessDirector.threadBlocked(Thread, ProcessReceiver)
public void threadUnblocked(java.lang.Thread thread, ProcessReceiver receiver, boolean readOrWrite)
thread
- The thread.receiver
- The receiver handling the I/O operation, or
null if it is not a specific receiver.readOrWrite
- Either READ_BLOCKED or WRITE_BLOCKED to
indicate whether the thread is blocked on read or write.CompositeProcessDirector.threadUnblocked(Thread, ProcessReceiver)
protected void _incrementLowestCapacityPort() throws IllegalActionException
IllegalActionException
- If there is an error while
attempting to set the capacity of a DDE receiver.protected ProcessThread _newProcessThread(Actor actor, ProcessDirector director) throws IllegalActionException
_newProcessThread
in class ProcessDirector
actor
- The actor that the new ProcessThread will control.director
- The director that manages the new
ProcessThread.IllegalActionException
- If an error occurs while
instantiating the new ProcessThread.protected boolean _resolveInternalDeadlock() throws IllegalActionException
_resolveInternalDeadlock
in class CompositeProcessDirector
IllegalActionException
- If thrown while incrementing the
lowest capacity port.java.util.Hashtable _getInitialTimeTable()