jmri
Class AbstractSensor

java.lang.Object
  extended by jmri.AbstractNamedBean
      extended by jmri.AbstractSensor
All Implemented Interfaces:
Serializable, NamedBean, Sensor
Direct Known Subclasses:
AcelaSensor, CbusSensor, LnSensor, NceSensor, RpsSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, SerialSensor, XNetSensor

public abstract class AbstractSensor
extends AbstractNamedBean
implements Sensor, Serializable

Abstract class providing the basic logic of the Sensor interface

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

Field Summary
protected  boolean _inverted
           
protected  int _knownState
           
 
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 getState()
          Implement a shorter name for getKnownState.
 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 out internal state information, and notify bean listeners.
 void setState(int s)
          Implement a shorter name for setKnownState.
 
Methods inherited from class jmri.AbstractNamedBean
addPropertyChangeListener, dispose, firePropertyChange, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName
 
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
getComment, getNumPropertyChangeListeners, getSystemName, getUserName, setComment, setUserName
 

Field Detail

_inverted

protected boolean _inverted

_knownState

protected int _knownState
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

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 out internal state information, and notify bean listeners.


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


Copyright © 1997 - 2008 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: SourceForge_Logo