ptolemy.actor.lib
Class SequenceSource

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Source
                              extended byptolemy.actor.lib.SequenceSource
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, SequenceActor, java.io.Serializable, ptolemy.actor.TypedActor
Direct Known Subclasses:
Interpolator, Pulse, Ramp

public class SequenceSource
extends Source
implements SequenceActor

Base class for sequence sources. A sequence source is a source where the output value is logically a sequence, independent of time, but dependent on the iteration number. For some time-based domains, such as CT, actors of this type probably do not make sense because the number of iterations that the actor experiences per unit time is not easily determined or controlled. This actor has a parameter, firingCountLimit, that optionally limits the number of iterations for which the actor is fired. If this number is n > 0, then the n-th invocation of postfire() returns false, which indicates to the scheduler that it should stop invocations of this actor. The default value of firingCountLimit is zero, which results in postfire always returning true. Derived classes must call super.postfire() for this mechanism to work.

Since:
Ptolemy II 0.3
Version:
$Id: SequenceSource.java,v 1.37 2004/04/13 03:04:17 cxh Exp $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Green (bilung)
Proposed Rating:
Green (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
protected  int _firingCountLimit
          This is the value in parameter firingCountLimit.
protected  int _iterationCount
          The current number of elapsed iterations.
 ptolemy.data.expr.Parameter firingCountLimit
          If greater than zero, then the number of iterations before the actor indicates to the scheduler that it is finished by returning false in its postfire() method.
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
SequenceSource(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          Override the base class to determine which attribute is being specified.
 void initialize()
          Initialize the iteration counter.
 boolean postfire()
          Increment the iteration counter, and if it equals the value of the firingCountLimit parameter, return false.
 
Methods inherited from class ptolemy.actor.lib.Source
fire
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
iterate, prefire, preinitialize, stop, stopFire, terminate, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

firingCountLimit

public ptolemy.data.expr.Parameter firingCountLimit
If greater than zero, then the number of iterations before the actor indicates to the scheduler that it is finished by returning false in its postfire() method.


_firingCountLimit

protected int _firingCountLimit
This is the value in parameter firingCountLimit. It may be convenient for derived classes to read this variable in the iterate() method.


_iterationCount

protected int _iterationCount
The current number of elapsed iterations. It may be convenient for derived classes to read/set this variable in the iterate() method.

Constructor Detail

SequenceSource

public SequenceSource(ptolemy.kernel.CompositeEntity container,
                      java.lang.String name)
               throws ptolemy.kernel.util.NameDuplicationException,
                      ptolemy.kernel.util.IllegalActionException
Construct an actor with the given container and name. The firingCountLimit parameter is also constructed.

Parameters:
container - The container.
name - The name of this actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
                      throws ptolemy.kernel.util.IllegalActionException
Override the base class to determine which attribute is being specified.

Parameters:
attribute - The attribute that changed.
Throws:
ptolemy.kernel.util.IllegalActionException - If the function is not recognized.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Initialize the iteration counter. A derived class must call this method in its initialize() method or the firingCountLimit feature will not work.

Specified by:
initialize in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If the parent class throws it, which could occur if, for example, the director will not accept sequence actors.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Increment the iteration counter, and if it equals the value of the firingCountLimit parameter, return false. Otherwise, return true. Derived classes should call this at the end of their postfire() method and return its returned value.

Specified by:
postfire in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If firingCountLimit has an invalid expression.