ptolemy.domains.sdf.kernel
Class BaseSDFScheduler

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.sched.Scheduler
              extended by ptolemy.domains.sdf.kernel.BaseSDFScheduler
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
PSDFScheduler, SDFScheduler

public abstract class BaseSDFScheduler
extends Scheduler

This class factors code out of the SDF domain, for use in different schedulers, so that they can be implemented in a consistent fashion.

Since:
Ptolemy II 4.0
Version:
$Id: BaseSDFScheduler.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Stephen Neuendorffer, Shuvra S. Bhattacharyya
See Also:
Serialized Form
Accepted Rating:
Red (neuendor)
Proposed Rating:
Red (neuendor)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
protected static boolean VERBOSE
          If true, then print verbose messages.
 
Fields inherited from class ptolemy.actor.sched.Scheduler
_DEFAULT_SCHEDULER_NAME
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
BaseSDFScheduler()
          Construct a scheduler with no container(director) in the default workspace, the name of the scheduler is "Scheduler".
BaseSDFScheduler(Director container, java.lang.String name)
          Construct a scheduler in the given container with the given name.
BaseSDFScheduler(Workspace workspace)
          Construct a scheduler in the given workspace with the name "Scheduler".
 
Method Summary
protected  void _declareDependency(ConstVariableModelAnalysis analysis, Port port, java.lang.String name, java.util.List dependents)
          Add a DependencyDeclaration (with the name "_SDFRateDependencyDeclaration") to the variable with the given name in the given port that declares the variable is dependent on the given list of variables.
protected  void _saveBufferSizes(java.util.Map minimumBufferSizes)
          Create and set a parameter in each relation according to the buffer sizes calculated for this system.
protected  void _saveContainerRates(java.util.Map externalRates)
          Push the rates calculated for this system up to the contained Actor, but only if the ports do not have a set rates.
protected  void _saveFiringCounts(java.util.Map entityToFiringsPerIteration)
          Create and set a parameter in each actor according to the number of times it will fire in one execution of the schedule.
abstract  void declareRateDependency()
          Declare the rate dependency on any external ports of the model.
 
Methods inherited from class ptolemy.actor.sched.Scheduler
_getSchedule, clone, getSchedule, isValid, setContainer, setValid
 
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, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, 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

VERBOSE

protected static final boolean VERBOSE
If true, then print verbose messages. By default, this variable is set to false. To enable verbose messages, edit the source file and recompile.

See Also:
Constant Field Values
Constructor Detail

BaseSDFScheduler

public BaseSDFScheduler()
Construct a scheduler with no container(director) in the default workspace, the name of the scheduler is "Scheduler".


BaseSDFScheduler

public BaseSDFScheduler(Workspace workspace)
Construct a scheduler in the given workspace with the name "Scheduler". If the workspace argument is null, use the default workspace. The scheduler is added to the list of objects in the workspace. Increment the version number of the workspace.

Parameters:
workspace - Object for synchronization and version tracking.

BaseSDFScheduler

public BaseSDFScheduler(Director container,
                        java.lang.String name)
                 throws IllegalActionException,
                        NameDuplicationException
Construct a scheduler in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

declareRateDependency

public abstract void declareRateDependency()
                                    throws IllegalActionException
Declare the rate dependency on any external ports of the model. SDF directors should invoke this method once during preinitialize.

Throws:
IllegalActionException - If there is a problem setting the rate dependency on an external port.

_declareDependency

protected void _declareDependency(ConstVariableModelAnalysis analysis,
                                  Port port,
                                  java.lang.String name,
                                  java.util.List dependents)
                           throws IllegalActionException
Add a DependencyDeclaration (with the name "_SDFRateDependencyDeclaration") to the variable with the given name in the given port that declares the variable is dependent on the given list of variables. If a dependency declaration with that name already exists, then simply set its dependents list to the given list.

Parameters:
analysis - The ConstVariableModelAnalysis
port - The port that gets the DependencyDeclaration.
name - The name of the DependencyDeclaration.
dependents - The dependents.
Throws:
IllegalActionException - If there is a problem setting the rate dependency on a port

_saveBufferSizes

protected void _saveBufferSizes(java.util.Map minimumBufferSizes)
Create and set a parameter in each relation according to the buffer sizes calculated for this system.

Parameters:
minimumBufferSizes - A map from relation to the minimum possible buffer size of that relation.

_saveContainerRates

protected void _saveContainerRates(java.util.Map externalRates)
                            throws NotSchedulableException,
                                   IllegalActionException
Push the rates calculated for this system up to the contained Actor, but only if the ports do not have a set rates. This allows the container to be properly scheduled if it is in a hierarchical system and the outside system is SDF.

Parameters:
externalRates - A map from external port to the rate of that port.
Throws:
IllegalActionException - If any called method throws it.
NotSchedulableException - If an external port is both an input and an output, or neither an input or an output, or connected on the inside to ports that have different tokenInitProduction.

_saveFiringCounts

protected void _saveFiringCounts(java.util.Map entityToFiringsPerIteration)
Create and set a parameter in each actor according to the number of times it will fire in one execution of the schedule.

Parameters:
entityToFiringsPerIteration - A map from actor to firing count.