Package jmri

Interface Reporter

All Superinterfaces:
Comparable<NamedBean>, NamedBean, PropertyChangeProvider
All Known Subinterfaces:
CollectingReporter
All Known Implementing Classes:
AbstractIdTagReporter, AbstractRailComReporter, AbstractReporter, CbusReporter, Dcc4PcReporter, EcosReporter, JMRIClientReporter, LnReporter, RfidReporter, RpsReporter, TimeoutReporter, TimeoutRfidReporter, TrackReporter, Z21CanReporter, Z21Reporter

public interface Reporter
extends NamedBean
Represent a device that can report identification information.

Reporting devices might include:

  • A DCC device that reports a locomotive number when it's in a particular location
  • A device that reports something about the layout environment, e.g. the current drawn or light intensity
  • A device that reacts to some happening on the layout with a complicated report

In contrast to Sensors, a Reporter provides more detailed information. A Sensor provides a status of ACTIVE or INACTIVE, while a Reporter returns an Object. The real type of that object can be whatever a particular Reporter finds useful to report. Typical values might be a String or Int, both of which can be displayed, printed, equated, etc.

A Reporter might also not be able to report all the time. The previous value remains available, but it's also possible to distinguish this case by using the getCurrentReport member function.


This file is part of JMRI.

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.

See Also:
Sensor, ReporterManager, InstanceManager
  • Method Details

    • getLastReport

      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.
      Returns:
      the last report or null
    • getCurrentReport

      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.
      Returns:
      the current report or null
    • setReport

      void setReport​(Object r)
      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.

      Parameters:
      r - the report
    • getState

      int getState()
      Provide an integer form of the last report.
      Specified by:
      getState in interface NamedBean
      Returns:
      the state