org.mbari.siam.utils
Class RangeValidator

java.lang.Object
  extended by org.mbari.siam.utils.RangeValidator

public class RangeValidator
extends java.lang.Object

The RangeValidator evaluates the value of its input against a specified range of values. The output is valid if the value is within the specified range. If the input value is outside the valid range, there are several options, set by a member variable: - REJECT : reject the value; do not change output - USE_LAST_VALID : output last valid input value - USE_AVERAGE : average up to _average_n previous valid values - USE_CONSTANT : use the same constant value This class is intended to be immutable: if you want a different one, create a new one.


Field Summary
protected  int _average_n
           
protected  double _constant
           
protected  java.text.NumberFormat _dfmt
           
protected  boolean _includeLower
           
protected  boolean _includeUpper
           
protected  int _index
           
protected  long _invalidCount
           
protected  double[] _lastNValues
           
protected  double _lastValidValue
           
protected static org.apache.log4j.Logger _log4j
          Log4j logger
protected  double _lowerBound
           
protected  double _outputValue
           
protected  int _pastValues
           
protected  int _range_region
           
protected  int _rejectPolicy
           
protected  java.lang.StringBuffer _stringBuffer
           
protected  double _upperBound
           
protected  long _validCount
           
static int DEFAULT_AVERAGE_N
           
static double DEFAULT_CONSTANT
           
static long DEFAULT_INVALID
           
static long DEFAULT_VALID
           
static int RANGE_INSIDE
           
static int RANGE_OUTSIDE
           
static int REJECT
           
static int USE_AVERAGE
           
static int USE_CONSTANT
           
static int USE_LAST_VALID
           
 
Constructor Summary
RangeValidator()
          No-arg constructor
 
Method Summary
 boolean accept(double value)
           
protected  double getAverage()
           
static RangeValidator getAveragingValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, int averageN)
           
static RangeValidator getAveragingValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, int averageN, long validCount, long invalidCount)
           
static RangeValidator getConstantValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, double constant)
           
static RangeValidator getConstantValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, double constant, long validCount, long invalidCount)
           
 long getInvalidCount()
           
static RangeValidator getLastValidValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper)
           
static RangeValidator getLastValidValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, long validCount, long invalidCount)
           
static RangeValidator getRejectingValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper)
           
static RangeValidator getRejectingValidator(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper, long validCount, long invalidCount)
           
 long getSampleCount()
           
 long getValidCount()
           
 double getValidRatio()
           
protected  void setAverageN(int averageN)
           
protected  void setBounds(int region, double lowerBound, double upperBound, boolean includeLower, boolean includeUpper)
           
protected  void setConstant(double constant, boolean allowOutsideRange)
           
protected  void setRejectPolicy(int policy)
           
protected  void storeValue(double value)
           
 java.lang.String toString()
           
 double validate(double value)
          Perform the filter function with the new input value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REJECT

public static final int REJECT
See Also:
Constant Field Values

USE_LAST_VALID

public static final int USE_LAST_VALID
See Also:
Constant Field Values

USE_AVERAGE

public static final int USE_AVERAGE
See Also:
Constant Field Values

USE_CONSTANT

public static final int USE_CONSTANT
See Also:
Constant Field Values

RANGE_INSIDE

public static final int RANGE_INSIDE
See Also:
Constant Field Values

RANGE_OUTSIDE

public static final int RANGE_OUTSIDE
See Also:
Constant Field Values

DEFAULT_AVERAGE_N

public static final int DEFAULT_AVERAGE_N
See Also:
Constant Field Values

DEFAULT_CONSTANT

public static final double DEFAULT_CONSTANT
See Also:
Constant Field Values

DEFAULT_VALID

public static final long DEFAULT_VALID
See Also:
Constant Field Values

DEFAULT_INVALID

public static final long DEFAULT_INVALID
See Also:
Constant Field Values

_log4j

protected static org.apache.log4j.Logger _log4j
Log4j logger


_range_region

protected int _range_region

_includeLower

protected boolean _includeLower

_includeUpper

protected boolean _includeUpper

_lowerBound

protected double _lowerBound

_upperBound

protected double _upperBound

_constant

protected double _constant

_rejectPolicy

protected int _rejectPolicy

_average_n

protected int _average_n

_lastValidValue

protected double _lastValidValue

_lastNValues

protected double[] _lastNValues

_pastValues

protected int _pastValues

_index

protected int _index

_validCount

protected long _validCount

_invalidCount

protected long _invalidCount

_stringBuffer

protected java.lang.StringBuffer _stringBuffer

_outputValue

protected double _outputValue

_dfmt

protected java.text.NumberFormat _dfmt
Constructor Detail

RangeValidator

public RangeValidator()
No-arg constructor

Method Detail

getRejectingValidator

public static RangeValidator getRejectingValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

getAveragingValidator

public static RangeValidator getAveragingValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper,
                                                   int averageN)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

getConstantValidator

public static RangeValidator getConstantValidator(int region,
                                                  double lowerBound,
                                                  double upperBound,
                                                  boolean includeLower,
                                                  boolean includeUpper,
                                                  double constant)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

getLastValidValidator

public static RangeValidator getLastValidValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

getRejectingValidator

public static RangeValidator getRejectingValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper,
                                                   long validCount,
                                                   long invalidCount)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

getAveragingValidator

public static RangeValidator getAveragingValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper,
                                                   int averageN,
                                                   long validCount,
                                                   long invalidCount)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

getConstantValidator

public static RangeValidator getConstantValidator(int region,
                                                  double lowerBound,
                                                  double upperBound,
                                                  boolean includeLower,
                                                  boolean includeUpper,
                                                  double constant,
                                                  long validCount,
                                                  long invalidCount)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

getLastValidValidator

public static RangeValidator getLastValidValidator(int region,
                                                   double lowerBound,
                                                   double upperBound,
                                                   boolean includeLower,
                                                   boolean includeUpper,
                                                   long validCount,
                                                   long invalidCount)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

setBounds

protected void setBounds(int region,
                         double lowerBound,
                         double upperBound,
                         boolean includeLower,
                         boolean includeUpper)
                  throws java.lang.Exception
Throws:
java.lang.Exception

setConstant

protected void setConstant(double constant,
                           boolean allowOutsideRange)
                    throws java.lang.Exception
Throws:
java.lang.Exception

setRejectPolicy

protected void setRejectPolicy(int policy)
                        throws java.lang.Exception
Throws:
java.lang.Exception

setAverageN

protected void setAverageN(int averageN)
                    throws java.lang.Exception
Throws:
java.lang.Exception

storeValue

protected void storeValue(double value)

getAverage

protected double getAverage()

getValidCount

public long getValidCount()

getInvalidCount

public long getInvalidCount()

getSampleCount

public long getSampleCount()

getValidRatio

public double getValidRatio()

accept

public boolean accept(double value)

validate

public double validate(double value)
Perform the filter function with the new input value. Sets member variable _outputValue, which will be passed to the output by triggerOut() if the output gating conditions are met. Overrides base class default.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.