Class TimeoutReporter

java.lang.Object
jmri.implementation.decorators.AbstractNamedBeanDecorator
jmri.implementation.decorators.TimeoutReporter
All Implemented Interfaces:
PropertyChangeListener, Comparable<NamedBean>, EventListener, PropertyChangeProvider, IdTagListener, NamedBean, Reporter

public class TimeoutReporter
extends AbstractNamedBeanDecorator
implements Reporter, IdTagListener, PropertyChangeListener
Timeout decorator implementation for reporters.

This decorator causes the current report to be reset to nullified after a preset time period. This is to be used for reporter hardware that reports a value, but never reports the value is cleared (e.g. most RFID readers).


This file is part of JMRI.

based on TimeoutRfidReporter originally implemented by Matthew Harris

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Based

Since:
4.19.4
  • Constructor Details

  • Method Details

    • getLastReport

      Description copied from interface: Reporter
      Query the last report. This will return a value even if there's no current report available. If there is a current report, both this and the current report will be equal. If nothing has ever been reported, this will return a null object.
      Specified by:
      getLastReport in interface Reporter
      Returns:
      the last report or null
    • getCurrentReport

      Description copied from interface: Reporter
      Query the current report. If there is no current report available (e.g. the reporting hardware says no information is currently available) this will return a null object.
      Specified by:
      getCurrentReport in interface Reporter
      Returns:
      the current report or null
    • setReport

      public void setReport​(Object r)
      Description copied from interface: Reporter
      Set the report to an arbitrary object.

      A Reporter object will usually just "report"; its contents usually come from the layout, and hence are only set by lower-level implementation classes. But there are occasionally reasons to set it from inside the program, e.g. debugging via entering values in the Reporter Table. Hence provision of this method.

      Specified by:
      setReport in interface Reporter
      Parameters:
      r - the report
    • getState

      public int getState()
      Description copied from interface: Reporter
      Provide an integer form of the last report.
      Specified by:
      getState in interface NamedBean
      Specified by:
      getState in interface Reporter
      Returns:
      the state
    • dispose

      public void dispose()
      Description copied from interface: NamedBean
      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 NamedBean
      Overrides:
      dispose in class AbstractNamedBeanDecorator
    • setState

      public void setState​(int i) throws JmriException
      Description copied from interface: NamedBean
      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:
      i - the state
      Throws:
      JmriException - general error when setting the state fails
    • notify

      public void notify​(IdTag r)
      Specified by:
      notify in interface IdTagListener
    • propertyChange

      public void propertyChange​(PropertyChangeEvent evt)
      Intercepts property change events from the underlying reporter and forwards them to property change listeners for this reporter.
      Specified by:
      propertyChange in interface PropertyChangeListener