Package jmri.jmrix.loconet
Class LnSensor
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractSensor
-
- jmri.jmrix.loconet.LnSensor
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,DigitalIO
,NamedBean
,Sensor
public class LnSensor extends AbstractSensor
Extend jmri.AbstractSensor for LocoNet layouts.Some of the message formats used in this class are Copyright Digitrax, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Digitrax Inc for separate permission.
-
-
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.Sensor
Sensor.PullResistance
-
-
Field Summary
Fields Modifier and Type Field Description (package private) LnTrafficController
tc
-
Fields inherited from class jmri.implementation.AbstractSensor
_inverted, _knownState, _rawState, r, sensorDebounceGoingActive, sensorDebounceGoingInActive, thr, useDefaultTimerSettings
-
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
-
Fields inherited from interface jmri.Sensor
ACTIVE, INACTIVE, MAX_DEBOUNCE
-
-
Constructor Summary
Constructors Constructor Description LnSensor(java.lang.String systemName, java.lang.String userName, LnTrafficController tc, java.lang.String prefix)
LnSensor(java.lang.String systemName, LnTrafficController tc, java.lang.String prefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
messageFromManager(LocoNetMessage l)
implementing classes will typically have a function/listener to get updates from the layout, which will then call public void firePropertyChange(String propertyName, Object oldValue, Object newValue) _once_ if anything has changed state (or set the commanded state directly)void
requestUpdateFromLayout()
Request an update on status by sending a LocoNet message.void
setKnownState(int s)
User request to set the state, which means that we need to broadcast the new state over the loconet so that other attached devices.-
Methods inherited from class jmri.implementation.AbstractSensor
canInvert, describeState, dispose, getBeanType, getInverted, getKnownState, getPullResistance, getRawState, getReporter, getSensorDebounceGoingActiveTimer, getSensorDebounceGoingInActiveTimer, getState, getUseDefaultTimerSettings, sensorDebounce, setInverted, setOwnState, setPullResistance, setReporter, setSensorDebounceGoingActiveTimer, setSensorDebounceGoingInActiveTimer, setState, setUseDefaultTimerSettings, stateChangeCheck
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, 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, 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
-
Methods inherited from interface jmri.Sensor
getCommandedState, isConsistentState, setCommandedState
-
-
-
-
Constructor Detail
-
LnSensor
public LnSensor(java.lang.String systemName, java.lang.String userName, LnTrafficController tc, java.lang.String prefix)
-
LnSensor
public LnSensor(java.lang.String systemName, LnTrafficController tc, java.lang.String prefix)
-
-
Method Detail
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Request an update on status by sending a LocoNet message. The only known way to do this from LocoNet is to request the status of _all_ devices, which is here considered too heavyweight. See LnSensorManager.updateAll()
-
setKnownState
public void setKnownState(int s) throws JmriException
User request to set the state, which means that we need to broadcast the new state over the loconet so that other attached devices. The incoming message will in turn, be processed by the SensorManager.- Specified by:
setKnownState
in interfaceSensor
- Overrides:
setKnownState
in classAbstractSensor
- Parameters:
s
- the state to set- Throws:
JmriException
- if unable to set the state
-
messageFromManager
public void messageFromManager(LocoNetMessage l)
implementing classes will typically have a function/listener to get updates from the layout, which will then call public void firePropertyChange(String propertyName, Object oldValue, Object newValue) _once_ if anything has changed state (or set the commanded state directly)- Parameters:
l
- LocoNet message from manager.
-
-