public class SDFDirector extends StaticSchedulingDirector implements PeriodicDirector
Actors are assumed to consume and produce exactly one token per channel on
each firing. Actors that do not follow this convention should set
the appropriate parameters on input and output ports to declare the number
of tokens they produce or consume. See the
SDFScheduler
for more information.
The SampleDelay
actor is usually used
in a model to specify the delay across a relation.
The allowDisconnectedGraphs parameter of this director determines whether disconnected graphs are permitted. A model may have two or more graphs of actors that are not connected. The schedule can jump from one graph to another among the disconnected graphs. There is nothing to force the scheduler to finish executing all actors on one graph before firing actors on another graph. However, the order of execution within an graph should be correct. Usually, disconnected graphs in an SDF model indicates an error. The default value of the allowDisconnectedGraphs parameter is a BooleanToken with the value false.
The iterations parameter of this director corresponds to a limit on the number of times the director will fire its hierarchy before it returns false in postfire. If this number is not greater than zero, then no limit is set and postfire will always return true. The default value of the iterations parameter is an IntToken with value one.
If any actor's postfire() method returns false during an iteration, then at the conclusion of the iteration, this director's postfire() method will return false. This will normally result in termination of the execution. The reasoning for this behavior is that the model cannot continue executing without the participation of all actors, and if any actor returns false in postfire(), then it is indicating that it wishes to not continue executing.
The vectorizationFactor parameter of this director sets the number of times that the basic schedule is executed during each firing of this director. This might allow the director to execute the model more efficiently, by combining multiple firings of each actor. The default value of the vectorizationFactor parameter is an IntToken with value one.
The SDF director has a period parameter which specifies the amount of model time that elapses per iteration. If the value of period is 0.0 (the default), then it has no effect, and this director never increments time nor calls fireAt() on the enclosing director. If the period is greater than 0.0, then if this director is at the top level, it increments time by this amount in each invocation of postfire(). If it is not at the top level, then it calls fireAt(currentTime + period) in postfire().
This behavior gives an interesting use of SDF within DE: You can "kick start" an SDF submodel with a single event, and then if the director of that SDF submodel has a period greater than 0.0, then it will continue to fire periodically with the specified period.
If period is greater than 0.0 and the parameter
synchronizeToRealTime is set to true
,
then the prefire() method stalls until the real time elapsed
since the model started matches the period multiplied by
the iteration count.
This ensures that the director does not get ahead of real time. However,
of course, this does not ensure that the director keeps up with real time.
SDFScheduler
,
SDFReceiver
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
_allowDisconnectedGraphs
Cache of the value of allowDisconnectedGraphs.
|
protected int |
_iterationCount
The iteration count.
|
protected PeriodicDirectorHelper |
_periodicDirectorHelper
Helper class supporting the period parameter.
|
Parameter |
allowDisconnectedGraphs
A parameter representing whether disconnected graphs are
permitted.
|
Parameter |
allowRateChanges
A parameter representing whether dynamic rate changes are
permitted.
|
static IntToken |
AUTO_INTTOKEN
The value used to signify special behavior for the
iterations parameter.
|
static java.lang.String |
AUTO_NAME
The name of the AUTO iterations parameter choice: "AUTO".
|
Parameter |
constrainBufferSizes
If true, then buffer sizes are fixed according to the schedule,
and attempts to write to the buffer that cause the buffer to
exceed the schedule size result in an exception.
|
Parameter |
iterations
A Parameter representing the number of times that postfire may be
called before it returns false.
|
static java.lang.String |
ITERATIONS_NAME
The name of the iterations parameter: "iterations".
|
Parameter |
period
The time period of each iteration.
|
Parameter |
synchronizeToRealTime
Specify whether the execution should synchronize to the
real time.
|
static IntToken |
UNBOUNDED_INTTOKEN
The UNBOUNDED iterations choice is equivalent to IntToken.ZERO.
|
static java.lang.String |
UNBOUNDED_NAME
The name of the UNBOUNDED iterations parameter choice: "UNBOUNDED".
|
Parameter |
vectorizationFactor
A Parameter representing the requested vectorization factor.
|
_postfireReturns, _prefire
_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 |
---|
SDFDirector()
Construct a director in the default workspace with an empty string
as its name.
|
SDFDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
SDFDirector(Workspace workspace)
Construct a director in the workspace with an empty name.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
createSchedule()
Create the SDF schedule for this director.
|
void |
fire()
Call super.fire() and reset the _prefire flag.
|
Time |
fireAt(Actor actor,
Time time,
int microstep)
Request a firing of the given actor at the given absolute
time, and return the time at which the specified will be
fired.
|
int |
getIterations()
Return the number of iterations.
|
Time |
getModelNextIterationTime()
Return the time value of the next iteration.
|
void |
initialize()
Initialize the actors associated with this director and then
set the iteration count to zero.
|
Receiver |
newReceiver()
Return a new receiver consistent with the SDF domain.
|
double |
periodValue()
Return the value of the period as a double.
|
boolean |
postfire()
Return false if the system has finished executing, either by
reaching the iteration limit, or having an actor in the system return
false in postfire.
|
boolean |
prefire()
Check the input ports of the container composite actor (if there
are any) to see whether they have enough tokens, and return true
if they do.
|
void |
preinitialize()
Preinitialize the actors associated with this director and
compute the schedule.
|
java.lang.String[] |
suggestedModalModelDirectors()
Return an array of suggested ModalModel directors to use with
SDFDirector.
|
boolean |
supportMultirateFiring()
Return true to indicate that a ModalModel under control
of this director supports multirate firing.
|
boolean |
transferInputs(IOPort port)
Override the base class method to transfer enough tokens to
complete an internal iteration.
|
boolean |
transferOutputs(IOPort port)
Override the base class method to transfer enough tokens to
fulfill the output production rate.
|
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, resumeActor, setScheduler
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suspend, terminate, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isEmbedded
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
addInitializable, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public Parameter allowDisconnectedGraphs
public Parameter allowRateChanges
public Parameter constrainBufferSizes
public Parameter iterations
If the number of iterations is -1, which is the value of the AUTO choice in the UI, then if the container of the director is the the top level then one iteration will occur before postfire() returns false.
If the number of iterations is -1 and and the container of the director is not at the top level then postfire() will always return true and execution will continue forever.
The default value is an IntToken with the value AUTO, which is -1. The UI has a second choice: UNBOUNDED, which is 0.public Parameter period
public Parameter synchronizeToRealTime
public Parameter vectorizationFactor
public static final IntToken AUTO_INTTOKEN
public static final java.lang.String AUTO_NAME
public static final IntToken UNBOUNDED_INTTOKEN
public static final java.lang.String UNBOUNDED_NAME
public static final java.lang.String ITERATIONS_NAME
protected int _iterationCount
protected PeriodicDirectorHelper _periodicDirectorHelper
boolean _allowDisconnectedGraphs
public SDFDirector() throws IllegalActionException, NameDuplicationException
IllegalActionException
- If the name has a period in it, or
the director is not compatible with the specified container.NameDuplicationException
- If the container already contains
an entity with the specified name.public SDFDirector(Workspace workspace) throws IllegalActionException, NameDuplicationException
workspace
- The workspace for this object.IllegalActionException
- If the name has a period in it, or
the director is not compatible with the specified container.NameDuplicationException
- If the container already contains
an entity with the specified name.public SDFDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- Container of the 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 is not a
CompositeActor and the name collides with an entity in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class Director
attribute
- The changed parameter.IllegalActionException
- If the parameter set is not valid.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class StaticSchedulingDirector
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 createSchedule() throws IllegalActionException
createSchedule
in class Director
IllegalActionException
- If the schedule can't be created.public int getIterations() throws IllegalActionException
The number of iterations returned depends on the value of
the iterations parameter and whether the container
of the director is at the top level.
See the iterations
documentation for details.
Code that uses SDFDirector should call getIterations() instead of directly referring to the value of the iterations parameter.
IllegalActionException
- If thrown while getting the
value of the iterations parameter.public Time getModelNextIterationTime() throws IllegalActionException
getModelNextIterationTime
in class Director
IllegalActionException
- If time objects cannot be created.Director.getModelTime()
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class StaticSchedulingDirector
IllegalActionException
- Thrown by super class.public Time fireAt(Actor actor, Time time, int microstep) throws IllegalActionException
fireAt
in class Director
actor
- The actor scheduled to be fired.time
- The requested time.microstep
- The microstep (ignored by this director).IllegalActionException
- If the operation is not
permissible (e.g. the given time is in the past).Director.fireAtCurrentTime(Actor)
,
Director.fireContainerAt(Time)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class StaticSchedulingDirector
IllegalActionException
- If the initialize() method of
one of the associated actors throws it, or if there is no
scheduler.public Receiver newReceiver()
newReceiver
in class Director
public double periodValue() throws IllegalActionException
periodValue
in interface PeriodicDirector
IllegalActionException
- If the period parameter
cannot be evaluatedpublic boolean prefire() throws IllegalActionException
This method also implements the functionality of synchronizeToRealTime by waiting for real time to elapse if the parameter value is true.
prefire
in interface Executable
prefire
in class StaticSchedulingDirector
IllegalActionException
- If port methods throw it.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If the preinitialize() method of
one of the associated actors throws it.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class StaticSchedulingDirector
IllegalActionException
- If the iterations parameter
does not contain a legal value.public java.lang.String[] suggestedModalModelDirectors()
suggestedModalModelDirectors
in class Director
Director.suggestedModalModelDirectors()
public boolean supportMultirateFiring()
supportMultirateFiring
in class Director
public boolean transferInputs(IOPort port) throws IllegalActionException
transferInputs
in class Director
port
- The port to transfer tokens from.IllegalActionException
- If the port is not an opaque
input port, or if there are not enough input tokens available.public boolean transferOutputs(IOPort port) throws IllegalActionException
transferOutputs
in class Director
port
- The port to transfer tokens from.IllegalActionException
- If the port is not an opaque
output port.