ptolemy.actor.lib
Class Interpolator

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
                                  extended byptolemy.actor.lib.Interpolator
All Implemented Interfaces:
Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, SequenceActor, java.io.Serializable, TypedActor

public class Interpolator
extends SequenceSource

Produce an interpolation based on the parameters. This class uses the Interpolation class in the math package to compute the interpolation. The values parameter specifies a sequence of values to produce at the output. The indexes parameter specifies when those values should be produced. The values and indexes parameters must both contain arrays, and have equal lengths or an exception will be thrown. The indexes array must be increasing and non-negative. The values are periodic if the period parameter contains a positive value. In this case, the period must be greater than the largest index, and values within the index range 0 to (period-1) are repeated indefinitely. If the period is zero, the values are not periodic, and the values outside the range of the indexes are considered to be 0.0. The order parameter specifies which order of interpolation to apply whenever the iteration count does not match an index in indexes. The Interpolation class currently supports zero, first, and third order interpolations. The default parameter are those set in the Interpolation class.

This actor counts iterations. Whenever the iteration count matches an entry in the indexes array, the corresponding entry (at the same position) in the values array is produced at the output. Whenever the iteration count does not match a value in the indexes array, an interpolation of the values is produced at the output.

Output type is DoubleToken.

Since:
Ptolemy II 0.3
Version:
$Id: Interpolator.java,v 1.37 2004/04/13 03:03:13 cxh Exp $
Author:
Sarah Packman, Yuhong Xiong
See Also:
Interpolation, Serialized Form
Accepted Rating:
Yellow (yuhong)
Proposed Rating:
Yellow (yuhong)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 Parameter indexes
          The indexes at which the specified values will be produced.
 Parameter order
          The order of interpolation for non-index iterations.
 Parameter period
          The period of the reference values.
 Parameter values
          The values that will be produced at the specified indexes.
 
Fields inherited from class ptolemy.actor.lib.SequenceSource
_firingCountLimit, firingCountLimit
 
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
Interpolator(CompositeEntity container, java.lang.String name)
          Construct an actor with the specified container and name.
 
Method Summary
 void attributeChanged(Attribute attribute)
          Check the validity of the parameter.
 void fire()
          Output the value at the current iteration count.
 void initialize()
          Set the iteration count to zero.
 boolean postfire()
          Update the iteration counter, then call the super class method.
 
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

indexes

public Parameter indexes
The indexes at which the specified values will be produced. This parameter is an array of integers, with default value {0, 1}.


order

public Parameter order
The order of interpolation for non-index iterations. This parameter must contain an IntToken.


period

public Parameter period
The period of the reference values. This parameter must contain an IntToken.


values

public Parameter values
The values that will be produced at the specified indexes. This parameter is an array, with default value {1.0, 0.0}.

Constructor Detail

Interpolator

public Interpolator(CompositeEntity container,
                    java.lang.String name)
             throws NameDuplicationException,
                    IllegalActionException
Construct an actor with the specified container and name.

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

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
Check the validity of the parameter.

Overrides:
attributeChanged in class SequenceSource
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the argument is the values parameter and it does not contain an one dimensional array; or the argument is the indexes parameter and it does not contain an one dimensional array or is not increasing and non-negative; or the argument is the period parameter and is negative; or the argument is the order parameter and the order is not supported by the Interpolation class.

fire

public void fire()
          throws IllegalActionException
Output the value at the current iteration count. The output is one of the reference values if the iteration count matches one of the indexes, or is interpolated otherwise.

Specified by:
fire in interface Executable
Overrides:
fire in class Source
Throws:
IllegalActionException - If the values and indexes parameters do not contain arrays of the same length, or the period is not 0 and not greater than the largest index.

initialize

public void initialize()
                throws IllegalActionException
Set the iteration count to zero.

Specified by:
initialize in interface Executable
Overrides:
initialize in class SequenceSource
Throws:
IllegalActionException - If the super class throws it.

postfire

public boolean postfire()
                 throws IllegalActionException
Update the iteration counter, then call the super class method.

Specified by:
postfire in interface Executable
Overrides:
postfire in class SequenceSource
Returns:
A boolean returned by the super class method.
Throws:
IllegalActionException - If firingCountLimit has an invalid expression.