Class Comparator

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

    public class Comparator
    extends TypedAtomicActor
    Compare two double-valued inputs, and output the boolean result of the comparison.

    The exact comparison performed is given by the comparison attribute, which can take any of the following values:

    • >: left > right
    • >=: left >= right
    • <: left < right
    • <=: left <= right
    • ==: left == right

    The default is ">". The input ports are named left and right to indicate which side of the comparison operator their value appears on.

    The tolerance parameter, which defaults to zero, defines an error tolerance. That is, the actor may produce true even if the specified test is not exactly satisfied, but rather is almost satisfied, within the specified tolerance.

    Note that this actor will work with any data type that can be losslessly converted to doubles, such as integers.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Green (neuendor)
    Pt.ProposedRating:
    Green (eal)
    • Field Detail

      • left

        public TypedIOPort left
        The left input port, which has type double.
      • right

        public TypedIOPort right
        The right input port, which has type double.
      • output

        public TypedIOPort output
        The output port, which has type boolean.
      • comparison

        public StringAttribute comparison
        The comparison operator. This is a string-valued attribute that defaults to ">".
      • tolerance

        public Parameter tolerance
        The tolerance for the comparison. This has type double, and defaults to 0.0.
    • Constructor Detail

      • Comparator

        public Comparator​(CompositeEntity container,
                          java.lang.String name)
                   throws NameDuplicationException,
                          IllegalActionException
        Construct an actor with the given container and name. Set the comparison to the default (">"). Set the types of the input ports to double, and the type of the output port to boolean.
        Parameters:
        container - The container.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the actor cannot be contained by the proposed container.
        NameDuplicationException - If the container already has an actor with this name.