Class LnReporter
- All Implemented Interfaces:
Comparable<NamedBean>
,PropertyChangeProvider
,CollectingReporter
,IdTagListener
,NamedBean
,PhysicalLocationReporter
,Reporter
public class LnReporter extends AbstractIdTagReporter implements CollectingReporter
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.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, String prefix)
-
Method Summary
Modifier and Type Method Description Collection
getCollection()
PhysicalLocationReporter.Direction
getDirection(String rep)
Gets the direction (ENTER/EXIT) of the report.LocoAddress
getLocoAddress(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(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.AbstractReporter
getBeanType, getCurrentReport, getLastReport, setReport
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, 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, getFullyFormattedDisplayName, getFullyFormattedDisplayName, 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
-
Field Details
-
Constructor Details
-
Method Details
-
getNumber
- Returns:
- the LocoNet address number for this reporter.
-
messageFromManager
Process loconet message handed to us from the LnReporterManager- Parameters:
l
- - a loconetmessage.
-
isTranspondingLocationReport
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
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
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
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
Handle LISSY message- Parameters:
l
- Message from which to extract LISSY content
-
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
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
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
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
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
Get the PhysicalLocation of the Reporter.- Specified by:
getPhysicalLocation
in interfacePhysicalLocationReporter
- Overrides:
getPhysicalLocation
in classAbstractIdTagReporter
- Parameters:
s
- unused.
-
getCollection
- Specified by:
getCollection
in interfaceCollectingReporter
- Returns:
- the collection of elements associated with this reporter.
-