jmri.managers
Class AbstractSensorManager

Show UML class diagram
java.lang.Object
  extended by jmri.managers.AbstractManager
      extended by jmri.managers.AbstractSensorManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, Manager, SensorManager
Direct Known Subclasses:
AcelaSensorManager, CbusSensorManager, Dcc4PcSensorManager, EcosSensorManager, InternalSensorManager, JMRIClientSensorManager, LnSensorManager, MarklinSensorManager, NceSensorManager, OlcbSensorManager, RfidSensorManager, RpsSensorManager, SerialSensorManager, SerialSensorManager, SerialSensorManager, SerialSensorManager, SerialSensorManager, SerialSensorManager, SRCPSensorManager, XNetSensorManager

public abstract class AbstractSensorManager
extends AbstractManager
implements SensorManager

Abstract base implementation of the SensorManager interface.


Field Summary
(package private) static org.slf4j.Logger log
           
(package private) static Matcher numberMatcher
           
protected  long sensorDebounceGoingActive
           
protected  long sensorDebounceGoingInActive
           
 
Fields inherited from class jmri.managers.AbstractManager
_tsys, _tuser, pcs
 
Fields inherited from interface jmri.Manager
AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXS, MEMORIES, OBLOCKS, PANELFILES, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
 
Constructor Summary
AbstractSensorManager()
           
 
Method Summary
 boolean allowMultipleAdditions(String systemName)
          A method that determines if it is possible to add a range of sensors in numerical order eg 10 to 30, primarily used to enable/disable the add range box in the add sensor panel
protected abstract  Sensor createNewSensor(String systemName, String userName)
          Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.
 String createSystemName(String curAddress, String prefix)
           
 Sensor getBySystemName(String key)
           
 Sensor getByUserName(String key)
           
 long getDefaultSensorDebounceGoingActive()
           
 long getDefaultSensorDebounceGoingInActive()
           
protected  Object getInstanceBySystemName(String systemName)
          Locate an instance based on a system name.
 String getNextValidAddress(String curAddress, String prefix)
          Determine if the address supplied is valid and free, if not then it shall return the next free valid address up to a maximum of 10 address away from the initial address.
 Sensor getSensor(String name)
          Locate via user name, then system name if needed.
 int getXMLOrder()
           
(package private)  boolean isNumber(String s)
           
 Sensor newSensor(String sysName, String userName)
          Return an instance with the specified system and user names.
protected  String normalizeSystemName(String sysName)
           
 Sensor provideSensor(String name)
          Locate via user name, then system name if needed.
 void setDefaultSensorDebounceGoingActive(long timer)
           
 void setDefaultSensorDebounceGoingInActive(long timer)
           
 char typeLetter()
           
 void updateAll()
          Requests status of all layout sensors under this Sensor Manager.
 
Methods inherited from class jmri.managers.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getBeanBySystemName, getBeanByUserName, getInstanceByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, getSystemNameList, makeSystemName, propertyChange, register, registerSelf, removePropertyChangeListener, systemLetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.SensorManager
dispose, getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, getBeanBySystemName, getBeanByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, getSystemPrefix, makeSystemName, register, removePropertyChangeListener, systemLetter
 

Field Detail

numberMatcher

static final Matcher numberMatcher

sensorDebounceGoingActive

protected long sensorDebounceGoingActive

sensorDebounceGoingInActive

protected long sensorDebounceGoingInActive

log

static org.slf4j.Logger log
Constructor Detail

AbstractSensorManager

public AbstractSensorManager()
Method Detail

getXMLOrder

public int getXMLOrder()
Specified by:
getXMLOrder in interface Manager
Specified by:
getXMLOrder in class AbstractManager

typeLetter

public char typeLetter()
Specified by:
typeLetter in interface Manager
Returns:
The type letter for a specific implementation

provideSensor

public Sensor provideSensor(String name)
Description copied from interface: SensorManager
Locate via user name, then system name if needed. If that fails, create a new sensor: If the name is a valid system name, it will be used for the new sensor. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.

Specified by:
provideSensor in interface SensorManager
Parameters:
name - User name, system name, or address which can be promoted to system name
Returns:
Never null

getSensor

public Sensor getSensor(String name)
Description copied from interface: SensorManager
Locate via user name, then system name if needed. Does not create a new one if nothing found

Specified by:
getSensor in interface SensorManager
Returns:
null if no match found

isNumber

boolean isNumber(String s)

getBySystemName

public Sensor getBySystemName(String key)
Specified by:
getBySystemName in interface SensorManager

getInstanceBySystemName

protected Object getInstanceBySystemName(String systemName)
Description copied from class: AbstractManager
Locate an instance based on a system name. Returns null if no instance already exists. This is intended to be used by concrete classes to implement their getBySystemName method. We can't call it that here because Java doesn't have polymorphic return types.

Overrides:
getInstanceBySystemName in class AbstractManager
Returns:
requested Turnout object or null if none exists

getByUserName

public Sensor getByUserName(String key)
Specified by:
getByUserName in interface SensorManager

normalizeSystemName

protected String normalizeSystemName(String sysName)

newSensor

public Sensor newSensor(String sysName,
                        String userName)
Description copied from interface: SensorManager
Return an instance with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Sensor object representing a given physical turnout and therefore only one with a specific system or user name.

This will always return a valid object reference; a new object will be created if necessary. In that case:

Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating Turnouts when you should be looking them up.

Specified by:
newSensor in interface SensorManager
Returns:
requested Sensor object (never null)

createNewSensor

protected abstract Sensor createNewSensor(String systemName,
                                          String userName)
Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.

Returns:
new null

updateAll

public void updateAll()
Requests status of all layout sensors under this Sensor Manager. This method may be invoked whenever the status of sensors needs to be updated from the layout, for example, when an XML configuration file is read in. Note that this null implementation only needs be implemented in system-specific Sensor Managers where readout of sensor status from the layout is possible.

Specified by:
updateAll in interface SensorManager

allowMultipleAdditions

public boolean allowMultipleAdditions(String systemName)
A method that determines if it is possible to add a range of sensors in numerical order eg 10 to 30, primarily used to enable/disable the add range box in the add sensor panel

Specified by:
allowMultipleAdditions in interface SensorManager

createSystemName

public String createSystemName(String curAddress,
                               String prefix)
                        throws JmriException
Specified by:
createSystemName in interface SensorManager
Throws:
JmriException

getNextValidAddress

public String getNextValidAddress(String curAddress,
                                  String prefix)
Description copied from interface: SensorManager
Determine if the address supplied is valid and free, if not then it shall return the next free valid address up to a maximum of 10 address away from the initial address.

Specified by:
getNextValidAddress in interface SensorManager
Parameters:
curAddress - - The hardware address of the turnout we which to check.
prefix - - The System Prefix used to make up the systemName

getDefaultSensorDebounceGoingActive

public long getDefaultSensorDebounceGoingActive()
Specified by:
getDefaultSensorDebounceGoingActive in interface SensorManager

getDefaultSensorDebounceGoingInActive

public long getDefaultSensorDebounceGoingInActive()
Specified by:
getDefaultSensorDebounceGoingInActive in interface SensorManager

setDefaultSensorDebounceGoingActive

public void setDefaultSensorDebounceGoingActive(long timer)
Specified by:
setDefaultSensorDebounceGoingActive in interface SensorManager

setDefaultSensorDebounceGoingInActive

public void setDefaultSensorDebounceGoingInActive(long timer)
Specified by:
setDefaultSensorDebounceGoingInActive in interface SensorManager


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