Class DefaultAverageMeter

All Implemented Interfaces:
Comparable<NamedBean>, AnalogIO, AverageMeter, PropertyChangeProvider, Meter, NamedBean

public class DefaultAverageMeter extends AbstractAnalogIO implements AverageMeter
Abstract base class for average meter objects.
  • Constructor Details

  • Method Details

    • enable

      public void enable()
      Enable this meter
      Specified by:
      enable in interface Meter
    • disable

      public void disable()
      Disable this meter
      Specified by:
      disable in interface Meter
    • sendValueToLayout

      protected void sendValueToLayout(double value) throws JmriException
      Sends the string to the layout. The string [u]must not[/u] be longer than the value of getMaximumLength() unless that value is zero. Some microcomputers have little memory and it's very important that this method is never called with too long strings.

      Override this if the meter can send value to the layout.

      Specified by:
      sendValueToLayout in class AbstractAnalogIO
      Parameters:
      value - the desired string value
      Throws:
      JmriException - general error when setting the value fails
    • cutOutOfBoundsValues

      protected boolean cutOutOfBoundsValues()
      Cut out of bounds values instead of throwing an exception? For example, if the AnalogIO is a display, it could be desired to accept too long strings. On the other hand, if the AnalogIO is used to send a command, a too long string is an error.
      Specified by:
      cutOutOfBoundsValues in class AbstractAnalogIO
      Returns:
      true if long strings should be cut
    • setState

      public void setState(int s) throws JmriException
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.

      Specified by:
      setState in interface NamedBean
      Parameters:
      s - the state
      Throws:
      JmriException - general error when setting the state fails
    • getState

      public int getState()
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.

      Specified by:
      getState in interface NamedBean
      Returns:
      the state
    • getBeanType

      public String getBeanType()
      For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.
      Specified by:
      getBeanType in interface NamedBean
      Overrides:
      getBeanType in class AbstractAnalogIO
      Returns:
      a string of the bean type, eg Turnout, Sensor etc
    • getUnit

      public Meter.Unit getUnit()
      Specified by:
      getUnit in interface Meter
    • getMin

      public double getMin()
      Get the minimum value of this AnalogIO.
      Specified by:
      getMin in interface AnalogIO
      Returns:
      minimum value.
    • getMax

      public double getMax()
      Get the maximum value of this AnalogIO.
      Specified by:
      getMax in interface AnalogIO
      Returns:
      maximum value.
    • getResolution

      public double getResolution()
      Get the resolution of this AnalogIO.
      Specified by:
      getResolution in interface AnalogIO
      Returns:
      analog resolution.
    • getAbsoluteOrRelative

      Is this AnalogIO absolute or relative?
      Specified by:
      getAbsoluteOrRelative in interface AnalogIO
      Returns:
      if absolute or relative.
    • requestUpdateFromLayout

      public void requestUpdateFromLayout()
      Request an update from the layout.
      Specified by:
      requestUpdateFromLayout in interface AnalogIO
    • getTime

      public int getTime()
      Description copied from interface: AverageMeter
      Get the time in milliseconds to average on.
      Specified by:
      getTime in interface AverageMeter
      Returns:
      the time
    • setTime

      public void setTime(int time)
      Description copied from interface: AverageMeter
      Set the time in milliseconds to average on.
      Specified by:
      setTime in interface AverageMeter
      Parameters:
      time - the time
    • getMeter

      public Meter getMeter()
      Description copied from interface: AverageMeter
      Get the meter.
      Specified by:
      getMeter in interface AverageMeter
      Returns:
      the meter
    • setMeter

      public void setMeter(Meter meter)
      Description copied from interface: AverageMeter
      Set the meter.
      Specified by:
      setMeter in interface AverageMeter
      Parameters:
      meter - the meter
    • getKnownAnalogValue

      public double getKnownAnalogValue()
      Query the known analog value. This is a bound parameter, so you can also register a listener to be informed of changes. A result is always returned; if no other feedback method is available, the commanded value will be used.

      The result must be a valid number, not a NaN or infinity number.

      Specified by:
      getKnownAnalogValue in interface AnalogIO
      Overrides:
      getKnownAnalogValue in class AbstractAnalogIO
      Returns:
      the known analog value
    • dispose

      public void dispose()
      Deactivate this object, so that it releases as many resources as possible and no longer effects others.

      For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

      It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

      Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

      Specified by:
      dispose in interface AverageMeter
      Specified by:
      dispose in interface Meter
      Specified by:
      dispose in interface NamedBean
      Overrides:
      dispose in class AbstractNamedBean