jmri.jmrix.loconet
Class LnSensor

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.AbstractSensor
          extended by jmri.jmrix.loconet.LnSensor
All Implemented Interfaces:
Serializable, EventListener, LocoNetListener, NamedBean, Sensor

public class LnSensor
extends AbstractSensor
implements LocoNetListener

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.

Author:
Bob Jacobsen Copyright (C) 2001
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmri.implementation.AbstractSensor
_inverted, _knownState, _rawState, r, sensorDebounceGoingActive, sensorDebounceGoingInActive, thr, useDefaultTimerSettings
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.Sensor
ACTIVE, INACTIVE
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
LnSensor(String systemName, LnTrafficController tc, String prefix)
           
LnSensor(String systemName, String userName, LnTrafficController tc, String prefix)
           
 
Method Summary
 void dispose()
          Deactivate this object, so that it releases as many resources as possible and no longer effects others.
 void message(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 broadcast that to all listeners by putting it out on LocoNet.
 
Methods inherited from class jmri.implementation.AbstractSensor
getInverted, getKnownState, getRawState, getSensorDebounceGoingActiveTimer, getSensorDebounceGoingInActiveTimer, getState, sensorDebounce, setInverted, setOwnState, setSensorDebounceGoingActiveTimer, setSensorDebounceGoingInActiveTimer, setState, useDefaultTimerSettings, useDefaultTimerSettings
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName, updateListenerRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.Sensor
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, setComment, setProperty, setUserName, updateListenerRef
 

Constructor Detail

LnSensor

public LnSensor(String systemName,
                String userName,
                LnTrafficController tc,
                String prefix)

LnSensor

public LnSensor(String systemName,
                LnTrafficController tc,
                String prefix)
Method Detail

requestUpdateFromLayout

public void requestUpdateFromLayout()
request an update on status by sending a loconet message

Specified by:
requestUpdateFromLayout in interface Sensor

setKnownState

public void setKnownState(int s)
                   throws JmriException
User request to set the state, which means that we broadcast that to all listeners by putting it out on LocoNet. In turn, the code in this class should use setOwnState to handle internal sets and bean notifies.

Specified by:
setKnownState in interface Sensor
Overrides:
setKnownState in class AbstractSensor
Parameters:
s -
Throws:
JmriException

message

public void message(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)

Specified by:
message in interface LocoNetListener
Parameters:
l -

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 interface NamedBean
Specified by:
dispose in interface Sensor
Overrides:
dispose in class AbstractNamedBean


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads