jmri.implementation
Class AbstractSensor

Show UML class diagram
java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.AbstractSensor
All Implemented Interfaces:
Serializable, NamedBean, Sensor
Direct Known Subclasses:
AcelaSensor, CbusSensor, Dcc4PcSensor, EcosSensor, JMRIClientSensor, LnSensor, MarklinSensor, NceSensor, OlcbSensor, RfidSensor, RpsSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, SRCPSensor, XNetSensor

public abstract class AbstractSensor
extends AbstractNamedBean
implements Sensor, Serializable

Abstract class providing the basic logic of the Sensor interface

Sensor system names are always upper case.

See Also:
Serialized Form

Field Summary
protected  boolean _inverted
           
protected  int _knownState
           
protected  int _rawState
           
protected  Runnable r
           
(package private)  Reporter reporter
           
(package private)  int restartcount
           
protected  long sensorDebounceGoingActive
           
protected  long sensorDebounceGoingInActive
           
protected  Thread thr
           
protected  boolean useDefaultTimerSettings
           
 
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, log, mSystemName, mUserName, parameters, pcs, register
 
Fields inherited from interface jmri.Sensor
ACTIVE, INACTIVE
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
AbstractSensor(String systemName)
           
AbstractSensor(String systemName, String userName)
           
 
Method Summary
 boolean getInverted()
          Get the inverted state.
 int getKnownState()
          Known state on layout is a bound parameter
 int getRawState()
          Used to return the Raw state of a sensor prior to the known state of a sensor being set.
 Reporter getReporter()
          Retrieve the reporter assocated with this sensor if there is one.
 long getSensorDebounceGoingActiveTimer()
          Get the Active debounce delay in milliSeconds.
 long getSensorDebounceGoingInActiveTimer()
          Get the InActive debounce delay in milliSeconds.
 int getState()
          Implement a shorter name for getKnownState.
protected  void sensorDebounce()
           
 void setInverted(boolean inverted)
          Control whether the actual sensor input is considered to be inverted, e.g. the normal electrical signal that results in an ACTIVE state now results in an INACTIVE state.
 void setKnownState(int s)
          Potentially allow the user to set the known state on the layout.
 void setOwnState(int s)
          Set our internal state information, and notify bean listeners.
 void setReporter(Reporter er)
          Some sensor boards also serve the function of being able to report back train identities via such methods as RailCom.
 void setSensorDebounceGoingActiveTimer(long time)
          Set the Active debounce delay in milliSeconds.
 void setSensorDebounceGoingInActiveTimer(long time)
          Set the InActive debounce delay in milliSeconds.
 void setState(int s)
          Implement a shorter name for setKnownState.
 boolean useDefaultTimerSettings()
          Does this sensor use the default timers for
 void useDefaultTimerSettings(boolean boo)
          Use the timers specified in the Sensor manager, for the debounce delay
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removeProperty, 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, dispose, removePropertyChangeListener, requestUpdateFromLayout
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, updateListenerRef
 

Field Detail

sensorDebounceGoingActive

protected long sensorDebounceGoingActive

sensorDebounceGoingInActive

protected long sensorDebounceGoingInActive

useDefaultTimerSettings

protected boolean useDefaultTimerSettings

thr

protected Thread thr

r

protected Runnable r

restartcount

int restartcount

_inverted

protected boolean _inverted

_knownState

protected int _knownState

_rawState

protected int _rawState

reporter

Reporter reporter
Constructor Detail

AbstractSensor

public AbstractSensor(String systemName)

AbstractSensor

public AbstractSensor(String systemName,
                      String userName)
Method Detail

getKnownState

public int getKnownState()
Description copied from interface: Sensor
Known state on layout is a bound parameter

Specified by:
getKnownState in interface Sensor
Returns:
known state value

setSensorDebounceGoingActiveTimer

public void setSensorDebounceGoingActiveTimer(long time)
Description copied from interface: Sensor
Set the Active debounce delay in milliSeconds. If a zero value is entered then debounce delay is de-activated.

Specified by:
setSensorDebounceGoingActiveTimer in interface Sensor

getSensorDebounceGoingActiveTimer

public long getSensorDebounceGoingActiveTimer()
Description copied from interface: Sensor
Get the Active debounce delay in milliSeconds.

Specified by:
getSensorDebounceGoingActiveTimer in interface Sensor

setSensorDebounceGoingInActiveTimer

public void setSensorDebounceGoingInActiveTimer(long time)
Description copied from interface: Sensor
Set the InActive debounce delay in milliSeconds. If a zero value is entered then debounce delay is de-activated.

Specified by:
setSensorDebounceGoingInActiveTimer in interface Sensor

getSensorDebounceGoingInActiveTimer

public long getSensorDebounceGoingInActiveTimer()
Description copied from interface: Sensor
Get the InActive debounce delay in milliSeconds.

Specified by:
getSensorDebounceGoingInActiveTimer in interface Sensor

useDefaultTimerSettings

public void useDefaultTimerSettings(boolean boo)
Description copied from interface: Sensor
Use the timers specified in the Sensor manager, for the debounce delay

Specified by:
useDefaultTimerSettings in interface Sensor

useDefaultTimerSettings

public boolean useDefaultTimerSettings()
Description copied from interface: Sensor
Does this sensor use the default timers for

Specified by:
useDefaultTimerSettings in interface Sensor

sensorDebounce

protected void sensorDebounce()

setKnownState

public void setKnownState(int s)
                   throws JmriException
Description copied from interface: Sensor
Potentially allow the user to set the known state on the layout. This might not always be available, depending on the limits of the underlying system and implementation.

Specified by:
setKnownState in interface Sensor
Throws:
JmriException

setOwnState

public void setOwnState(int s)
Set our internal state information, and notify bean listeners.


getRawState

public int getRawState()
Description copied from interface: Sensor
Used to return the Raw state of a sensor prior to the known state of a sensor being set. The raw state value can be different when the sensor debounce option is used.

Specified by:
getRawState in interface Sensor
Returns:
raw state value

setState

public void setState(int s)
              throws JmriException
Implement a shorter name for setKnownState.

This generally shouldn't be used by Java code; use setKnownState instead. The is provided to make Jython script access easier to read.

Specified by:
setState in interface NamedBean
Throws:
JmriException - general error when cant do the needed operation

getState

public int getState()
Implement a shorter name for getKnownState.

This generally shouldn't be used by Java code; use getKnownState instead. The is provided to make Jython script access easier to read.

Specified by:
getState in interface NamedBean

setInverted

public void setInverted(boolean inverted)
Control whether the actual sensor input is considered to be inverted, e.g. the normal electrical signal that results in an ACTIVE state now results in an INACTIVE state.

Specified by:
setInverted in interface Sensor

getInverted

public final boolean getInverted()
Get the inverted state. If true, the electrical signal that results in an ACTIVE state now results in an INACTIVE state.

Used in polling loops in system-specific code, so made final to allow optimization.

Specified by:
getInverted in interface Sensor

setReporter

public void setReporter(Reporter er)
Some sensor boards also serve the function of being able to report back train identities via such methods as RailCom. The setting and creation of the reporter against the sensor should be done when the sensor is created. This information is not saved.

returns null if there is no direct reporter.

Specified by:
setReporter in interface Sensor

getReporter

public Reporter getReporter()
Description copied from interface: Sensor
Retrieve the reporter assocated with this sensor if there is one.

returns null if there is no direct reporter.

Specified by:
getReporter in interface Sensor


Copyright © 1997-2013 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