Class Interpolator

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, SequenceActor, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    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$
    Author:
    Sarah Packman, Yuhong Xiong
    See Also:
    Interpolation
    Pt.AcceptedRating:
    Yellow (yuhong)
    Pt.ProposedRating:
    Yellow (yuhong)
    • 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}.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        Check the validity of the parameter.
        Overrides:
        attributeChanged in class LimitedFiringSource
        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.
      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the actor into the specified workspace. This calls the base class and then initializes private variables. public members to the parameters of the new actor.
        Overrides:
        clone in class TypedAtomicActor
        Parameters:
        workspace - The workspace for the new object.
        Returns:
        A new actor.
        Throws:
        java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • 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.