ptolemy.domains.giotto.kernel
Class GiottoScheduler

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.giotto.kernel.GiottoScheduler
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class GiottoScheduler
extends Scheduler

This class generates schedules for the actors in a CompositeActor according to the Giotto semantics.

A schedule is represented by a list. Consider the following CompositeActor:

 +-----------------------+
 |           A           |
 +-----------------------+
 +-----------------------+
 |           B           |
 +-----------------------+
 +---------+   +---------+
 |    C    |   |    C    |
 +---------+   +---------+
 
There are three actors A, B, and C, where C runs twice as often as A and B. The list representing the schedule for this CompositeActor looks as follows:
 +-------+                         +-------+
 | | | --------------------------->| | |nil|
 +-|-----+                         +-|-----+
 |                                 |
 V                                 V
 +-------+  +-------+  +-------+   +-------+
 | | | ---->| | | ---->| | |nil|   | | |nil|
 +-|-----+  +-|-----+  +-|-----+   +-|-----+
 |          |          |           |
 V          V          V           V
 +---+      +---+      +---+       +---+
 | A |      | B |      | c |       | c |
 +---+      +---+      +---+       +---+

 

Since:
Ptolemy II 1.0
Version:
$Id: GiottoScheduler.java 59203 2010-09-23 21:41:27Z cxh $
Author:
Christoph Kirsch, Haiyang Zheng
See Also:
Serialized Form
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (cm)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private static int[] _candidateFrequencies
           
protected static int _DEFAULT_GIOTTO_FREQUENCY
          The default Giotto frequency.
private  int _giottoSchedulerTime
           
private  int _lcm
           
 
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
GiottoScheduler()
          Construct a Giotto scheduler with no container (director) in the default workspace.
GiottoScheduler(Workspace workspace)
          Construct a Giotto scheduler in the given workspace.
 
Method Summary
protected  double _getMinTimeStep(double period)
          Return the unit of time increment for director.
protected  Schedule _getSchedule()
          Return the scheduling sequence.
private  int _lcm(int[] array)
           
static int getFrequency(Actor actor)
          Return the frequency of the given actor.
 
Methods inherited from class ptolemy.actor.sched.Scheduler
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

_DEFAULT_GIOTTO_FREQUENCY

protected static final int _DEFAULT_GIOTTO_FREQUENCY
The default Giotto frequency. Actors without a frequency parameter will execute with this frequency.

See Also:
Constant Field Values

_candidateFrequencies

private static int[] _candidateFrequencies

_giottoSchedulerTime

private int _giottoSchedulerTime

_lcm

private int _lcm
Constructor Detail

GiottoScheduler

public GiottoScheduler()
Construct a Giotto scheduler with no container (director) in the default workspace.


GiottoScheduler

public GiottoScheduler(Workspace workspace)
Construct a Giotto scheduler in the given workspace. 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.
Method Detail

getFrequency

public static int getFrequency(Actor actor)
Return the frequency of the given actor. If the actor has a frequency parameter with a valid integer value, return that value. For actors without a frequency parameter, their frequency is _DEFAULT_GIOTTO_FREQUENCY.

Parameters:
actor - An actor.
Returns:
The frequency of the actor.

_getMinTimeStep

protected double _getMinTimeStep(double period)
Return the unit of time increment for director. This method will be called by the director. It should not be called until the director call getSchedule() and the returned schedule is invalid. It is not synchronized on the workspace.

Parameters:
period - Giotto model period given in 'period' parameter of director
Returns:
unit of time increment for director.

_getSchedule

protected Schedule _getSchedule()
                         throws NotSchedulableException
Return the scheduling sequence. This method should not be called directly; rather the getSchedule() method will call it when the schedule is invalid. It is not synchronized on the workspace.

Overrides:
_getSchedule in class Scheduler
Returns:
A schedule.
Throws:
NotSchedulableException - If the model is not schedulable.
See Also:
CompositeEntity.deepEntityList()

_lcm

private int _lcm(int[] array)