public class StaticSchedulingDirector extends Director
This class does not directly implement a scheduling algorithm, but defers to its contained scheduler. The contained scheduler creates an instance of the Schedule class which determines the number of times each actor should be fired and their firing order. This allows new scheduling algorithms to be easily created for existing domains.
This class is generally useful for statically scheduled domains where a schedule can be constructed once and used to repeatedly execute the model. The Scheduler class caches the schedule until the model changes so that the schedule does not have to be recomputed.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_postfireReturns
The value that the postfire method will return.
|
protected boolean |
_prefire
The value returned by the prefire() method.
|
_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 |
---|
StaticSchedulingDirector()
Construct a director in the default workspace with an empty string
as its name.
|
StaticSchedulingDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
StaticSchedulingDirector(Workspace workspace)
Construct a director in the workspace with an empty name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_setScheduler(Scheduler scheduler)
Set the local scheduler for execution of this Director.
|
void |
addDebugListener(DebugListener listener)
Override the base class to also listen to the scheduler, if there
is one.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
fire()
Calculate the current schedule, if necessary, and iterate the
contained actors in the order given by the schedule.
|
Scheduler |
getScheduler()
Return the scheduler that is responsible for scheduling the
directed actors.
|
void |
initialize()
Initialize local variables.
|
void |
invalidateSchedule()
Indicate that a schedule for the model may no longer be valid.
|
boolean |
isScheduleValid()
Return true if the current (cached) schedule is valid.
|
boolean |
postfire()
Return true if the director wishes to be scheduled for another
iteration.
|
boolean |
prefire()
Return true if the director is ready to fire.
|
void |
removeDebugListener(DebugListener listener)
Override the base class to also remove the listener from the scheduler,
if there is one.
|
void |
resumeActor(NamedObj actor)
Resume the execution of an actor that was previously blocked because
it didn't have all the resources it needed for execution.
|
void |
setScheduler(Scheduler scheduler)
Set the scheduler for this StaticSchedulingDirector.
|
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getErrorTolerance, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, newReceiver, notifyTokenSentToCommunicationAspect, preinitialize, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferInputs, transferOutputs, transferOutputs, wrapup
_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, 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, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
protected boolean _postfireReturns
protected boolean _prefire
public StaticSchedulingDirector() throws IllegalActionException, NameDuplicationException
NameDuplicationException
- If construction of Time objects fails.IllegalActionException
- If construction of Time objects fails.public StaticSchedulingDirector(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace of this object.NameDuplicationException
- If construction of Time objects fails.IllegalActionException
- If construction of Time objects fails.public StaticSchedulingDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container of this director.name
- Name of this director.IllegalActionException
- Not thrown in this base class.
May be thrown in the derived classes if the director
is not compatible with the specified container.NameDuplicationException
- If the name collides with
an attribute that already exists in the given container.public void addDebugListener(DebugListener listener)
addDebugListener
in interface Debuggable
addDebugListener
in class NamedObj
listener
- The listener to which to send debug messages.removeDebugListener(DebugListener)
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Director
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- Thrown by super class.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Director
IllegalActionException
- If any actor executed by this
actor return false in prefire.InvalidStateException
- If this director does not have a
container.public Scheduler getScheduler()
setScheduler(Scheduler)
public void invalidateSchedule()
invalidateSchedule
in class Director
public boolean isScheduleValid() throws IllegalActionException
IllegalActionException
- If there's no scheduler.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- Not thrown in this base class.public void resumeActor(NamedObj actor) throws IllegalActionException
resumeActor
in class Director
actor
- The actor that resumes execution.IllegalActionException
- Not thrown here but in derived classes.public boolean prefire() throws IllegalActionException
In this base class, assume that the director is always ready to be fired, and so return true. Domain directors should probably override this method to provide domain-specific operation. However, they should call super.prefire() if they wish to propagate time as done here.
prefire
in interface Executable
prefire
in class Director
IllegalActionException
- Not thrown in this base class.public void removeDebugListener(DebugListener listener)
removeDebugListener
in interface Debuggable
removeDebugListener
in class NamedObj
listener
- The listener to remove from the list of listeners
to which debug messages are sent.addDebugListener(DebugListener)
public void setScheduler(Scheduler scheduler) throws IllegalActionException, NameDuplicationException
scheduler
- The scheduler that this director will use.IllegalActionException
- Not thrown in this base class,
but derived classes may throw it if the scheduler is not compatible.NameDuplicationException
- Not thrown in this base class,
but derived classes may throw it if the scheduler is not compatible.getScheduler()
protected void _setScheduler(Scheduler scheduler)
scheduler
- The Scheduler responsible for execution.