ptolemy.domains.sdf.kernel
Class BaseSDFScheduler

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

public abstract class BaseSDFScheduler
extends ptolemy.actor.sched.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,v 1.18 2004/04/13 05:12:36 cxh Exp $
Author:
Stephen Neuendorffer, Shuvra S. Bhattacharyya
See Also:
Serialized Form
Accepted Rating:
Red (neuendor)
Proposed Rating:
Red (neuendor)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Field Summary
protected static boolean VERBOSE
           
 
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, _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(ptolemy.actor.Director container, java.lang.String name)
          Construct a scheduler in the given container with the given name.
BaseSDFScheduler(ptolemy.kernel.util.Workspace workspace)
          Construct a scheduler in the given workspace with the name "Scheduler".
 
Method Summary
protected  void _declareDependency(ptolemy.actor.util.ConstVariableModelAnalysis analysis, ptolemy.kernel.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  int _getChannel(ptolemy.actor.IOPort port, ptolemy.actor.Receiver receiver)
          Find the channel number of the given port that corresponds to the given receiver.
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
_getContainedObject, _propagateExistence, getContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, 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
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(ptolemy.kernel.util.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(ptolemy.actor.Director container,
                        java.lang.String name)
                 throws ptolemy.kernel.util.IllegalActionException,
                        ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
ptolemy.kernel.util.NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

declareRateDependency

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

Throws:
ptolemy.kernel.util.IllegalActionException

_declareDependency

protected void _declareDependency(ptolemy.actor.util.ConstVariableModelAnalysis analysis,
                                  ptolemy.kernel.Port port,
                                  java.lang.String name,
                                  java.util.List dependents)
                           throws ptolemy.kernel.util.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.

Throws:
ptolemy.kernel.util.IllegalActionException

_getChannel

protected int _getChannel(ptolemy.actor.IOPort port,
                          ptolemy.actor.Receiver receiver)
                   throws ptolemy.kernel.util.IllegalActionException
Find the channel number of the given port that corresponds to the given receiver. If the receiver is not contained within the port, throw an InternalErrorException.

Throws:
ptolemy.kernel.util.IllegalActionException

_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 ptolemy.actor.sched.NotSchedulableException,
                                   ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If any called method throws it.
ptolemy.actor.sched.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.