Class AverageOverTime

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

    public class AverageOverTime
    extends DETransformer
    An actor to compute the average of the input values received so far over model time. This actor can fire whenever there is a token at its input port, or the model time has advanced since last firing. It records the last token that it received. In each firing, the produce of the last token and the amount of model time increment is added to a sum variable. The average value received so far is obtained by dividing the sum by the current model time. This average is sent to the output port in each firing. If a token is available at the input port, this actor reads that token and overwrites the last token with it.
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    tfeng
    Pt.AcceptedRating:
    Red (tfeng)
    Pt.ProposedRating:
    Yellow (tfeng)
    • Method Detail

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone this actor into the specified workspace. The new actor is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container. A container must be set before much can be done with this actor.
        Overrides:
        clone in class TypedAtomicActor
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        A new AverageOverTime actor.
        Throws:
        java.lang.CloneNotSupportedException - If cloned ports cannot have as their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • postfire

        public boolean postfire()
                         throws IllegalActionException
        Description copied from class: AtomicActor
        Return true, unless stop() has been called, in which case, return false. Derived classes override this method to define operations to be performed at the end of every iteration of its execution, after one invocation of the prefire() method and any number of invocations of the fire() method. This method typically wraps up an iteration, which may involve updating local state. In derived classes, this method returns false to indicate that this actor should not be fired again.
        Specified by:
        postfire in interface Executable
        Overrides:
        postfire in class AtomicActor<TypedIOPort>
        Returns:
        True if execution can continue into the next iteration.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • prefire

        public boolean prefire()
                        throws IllegalActionException
        Determine whether this actor can fire in the current iteration. Return true if there is at least one token at the input port, or the model time has advanced since last firing.
        Specified by:
        prefire in interface Executable
        Overrides:
        prefire in class AtomicActor<TypedIOPort>
        Returns:
        True if this actor is ready for firing, false otherwise.
        Throws:
        IllegalActionException - If the superclass throws it.