Class LnReporter
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractReporter
-
- jmri.implementation.AbstractIdTagReporter
-
- jmri.jmrix.loconet.LnReporter
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,CollectingReporter
,IdTagListener
,NamedBean
,PhysicalLocationReporter
,Reporter
public class LnReporter extends AbstractIdTagReporter implements CollectingReporter
Extend jmri.AbstractIdTagReporter for LocoNet layouts.This implementation reports Transponding messages from LocoNet-based "Reporters". For LocoNet connections, a "Reporter" represents either a Digitrax "transponding zone" or a Lissy "measurement zone". The messages from these Reporters are handled by this code. The LnReporterManager is responsible for decode of appropriate LocoNet messages and passing only those messages to the Reporter which match its Reporter address.
Each transponding message creates a new current report. The last report is always available, and is the same as the contents of the last transponding message received.
Reports are Strings, formatted as
- NNNN enter - locomotive address NNNN entered the transponding zone. Short vs long address is indicated by the NNNN value
- NNNN exits - locomotive address NNNN left the transponding zone.
- NNNN seen northbound - LISSY measurement
- NNNN seen southbound - LISSY measurement
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
Nested classes/interfaces inherited from interface jmri.PhysicalLocationReporter
PhysicalLocationReporter.Direction
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
lastLoco
-
Fields inherited from class jmri.implementation.AbstractReporter
_currentReport, _lastReport
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description LnReporter(int number, LnTrafficController tc, java.lang.String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.lang.Object>
getCollection()
PhysicalLocationReporter.Direction
getDirection(java.lang.String rep)
Gets the direction (ENTER/EXIT) of the report.LocoAddress
getLocoAddress(java.lang.String rep)
Get the locomotive address we're reporting about from the current report.int
getLocoAddrFromTranspondingMsg(LocoNetMessage l)
extract long or short address from transponding message Assumes that the LocoNet message is a valid transponding message.int
getNumber()
PhysicalLocation
getPhysicalLocation()
Get the PhysicalLocation of the Reporter Reports its own location, for now.PhysicalLocation
getPhysicalLocation(java.lang.String s)
Get the PhysicalLocation of the Reporter.int
getState()
Provide an int value for use in scripts, etc.boolean
isTranspondingFindReport(LocoNetMessage l)
Check if message is a Transponding Find Report message A Transponding Location Report message is sent by transponding hardware in response to a Transponding Find Request message when the addressed decoder is within a transponding zone and the decoder is transponding-enabled.boolean
isTranspondingLocationReport(LocoNetMessage l)
Check if message is a Transponding Location Report message A Transponding Location Report message is sent by transponding hardware when a transponding mobile decoder enters or leaves a transponding zone.(package private) void
lissyReport(LocoNetMessage l)
Handle LISSY messagevoid
messageFromManager(LocoNetMessage l)
Process loconet message handed to us from the LnReporterManagervoid
setState(int s)
Provide generic access to internal state.(package private) void
transpondingReport(LocoNetMessage l)
Handle transponding message passed to us by the LnReporting Manager Assumes that the LocoNet message is a valid transponding message.-
Methods inherited from class jmri.implementation.AbstractIdTagReporter
describeState, notify
-
Methods inherited from class jmri.implementation.AbstractReporter
getBeanType, getCurrentReport, getLastReport, setReport
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, 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, dispose, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.Reporter
getCurrentReport, getLastReport, setReport
-
-
-
-
Field Detail
-
lastLoco
int lastLoco
-
-
Constructor Detail
-
LnReporter
public LnReporter(int number, LnTrafficController tc, java.lang.String prefix)
-
-
Method Detail
-
getNumber
public int getNumber()
- Returns:
- the LocoNet address number for this reporter.
-
messageFromManager
public void messageFromManager(LocoNetMessage l)
Process loconet message handed to us from the LnReporterManager- Parameters:
l
- - a loconetmessage.
-
isTranspondingLocationReport
public final boolean isTranspondingLocationReport(LocoNetMessage l)
Check if message is a Transponding Location Report message A Transponding Location Report message is sent by transponding hardware when a transponding mobile decoder enters or leaves a transponding zone.- Parameters:
l
- LocoNet message to check- Returns:
- true if message is a Transponding Location Report, else false.
-
isTranspondingFindReport
public final boolean isTranspondingFindReport(LocoNetMessage l)
Check if message is a Transponding Find Report message A Transponding Location Report message is sent by transponding hardware in response to a Transponding Find Request message when the addressed decoder is within a transponding zone and the decoder is transponding-enabled.- Parameters:
l
- LocoNet message to check- Returns:
- true if message is a Transponding Find Report, else false.
-
transpondingReport
void transpondingReport(LocoNetMessage l)
Handle transponding message passed to us by the LnReporting Manager Assumes that the LocoNet message is a valid transponding message.- Parameters:
l
- - incoming loconetmessage
-
getLocoAddrFromTranspondingMsg
public int getLocoAddrFromTranspondingMsg(LocoNetMessage l)
extract long or short address from transponding message Assumes that the LocoNet message is a valid transponding message.- Parameters:
l
- LocoNet message- Returns:
- loco address
-
lissyReport
void lissyReport(LocoNetMessage l)
Handle LISSY message- Parameters:
l
- Message from which to extract LISSY content
-
getState
public int getState()
Provide an int value for use in scripts, etc. This will be the numeric locomotive address last seen, unless the last message said the loco was exiting. Note that there may still some other locomotive in the transponding zone!
-
setState
public void setState(int s)
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
- Overrides:
setState
in classAbstractIdTagReporter
- Parameters:
s
- the state
-
getLocoAddress
public LocoAddress getLocoAddress(java.lang.String rep)
Get the locomotive address we're reporting about from the current report.- Specified by:
getLocoAddress
in interfacePhysicalLocationReporter
- Overrides:
getLocoAddress
in classAbstractIdTagReporter
- Parameters:
rep
- ignored, IdTag Reporters don't send String type reports.
-
getDirection
public PhysicalLocationReporter.Direction getDirection(java.lang.String rep)
Gets the direction (ENTER/EXIT) of the report.Because of the way IdTag Reporters work, all reports are ENTER type.
- Specified by:
getDirection
in interfacePhysicalLocationReporter
- Overrides:
getDirection
in classAbstractIdTagReporter
-
getPhysicalLocation
public PhysicalLocation getPhysicalLocation()
Get the PhysicalLocation of the Reporter Reports its own location, for now. Not sure if that's the right thing or not. NOT DONE YET- Specified by:
getPhysicalLocation
in interfacePhysicalLocationReporter
- Overrides:
getPhysicalLocation
in classAbstractIdTagReporter
-
getPhysicalLocation
public PhysicalLocation getPhysicalLocation(java.lang.String s)
Get the PhysicalLocation of the Reporter.- Specified by:
getPhysicalLocation
in interfacePhysicalLocationReporter
- Overrides:
getPhysicalLocation
in classAbstractIdTagReporter
- Parameters:
s
- unused.
-
getCollection
public java.util.Collection<java.lang.Object> getCollection()
- Specified by:
getCollection
in interfaceCollectingReporter
- Returns:
- the collection of elements associated with this reporter.
-
-