Class TimeoutReporter
- java.lang.Object
-
- jmri.implementation.decorators.AbstractNamedBeanDecorator
-
- jmri.implementation.decorators.TimeoutReporter
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,IdTagListener
,NamedBean
,Reporter
public class TimeoutReporter extends AbstractNamedBeanDecorator implements Reporter, IdTagListener, java.beans.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
-
Fields inherited from class jmri.implementation.decorators.AbstractNamedBeanDecorator
listenerRefs, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description TimeoutReporter(Reporter reporter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Deactivate this object, so that it releases as many resources as possible and no longer effects others.java.lang.Object
getCurrentReport()
Query the current report.java.lang.Object
getLastReport()
Query the last report.int
getState()
Provide an integer form of the last report.void
notify(IdTag r)
void
propertyChange(java.beans.PropertyChangeEvent evt)
Intercepts property change events from the underlying reporter and forwards them to property change listeners for this reporter.void
setReport(java.lang.Object r)
Set the report to an arbitrary object.void
setState(int i)
Provide generic access to internal state.-
Methods inherited from class jmri.implementation.decorators.AbstractNamedBeanDecorator
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, equals, firePropertyChange, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
TimeoutReporter
public TimeoutReporter(Reporter reporter)
-
-
Method Detail
-
getLastReport
public java.lang.Object 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 interfaceReporter
- Returns:
- the last report or null
-
getCurrentReport
public java.lang.Object 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 interfaceReporter
- Returns:
- the current report or null
-
setReport
public void setReport(java.lang.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.
-
getState
public int getState()
Description copied from interface:Reporter
Provide an integer form of the last report.
-
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 interfaceNamedBean
- Overrides:
dispose
in classAbstractNamedBeanDecorator
-
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 interfaceNamedBean
- Parameters:
i
- the state- Throws:
JmriException
- general error when setting the state fails
-
notify
public void notify(IdTag r)
- Specified by:
notify
in interfaceIdTagListener
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
Intercepts property change events from the underlying reporter and forwards them to property change listeners for this reporter.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
-