jmri.managers
Class ProxySensorManager

java.lang.Object
  extended by jmri.managers.AbstractProxyManager
      extended by jmri.managers.ProxySensorManager
All Implemented Interfaces:
Manager, SensorManager

public class ProxySensorManager
extends AbstractProxyManager
implements SensorManager

Implementation of a SensorManager that can serves as a proxy for multiple system-specific implementations.

Author:
Bob Jacobsen Copyright (C) 2003, 2010

Field Summary
 
Fields inherited from interface jmri.Manager
AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXS, MEMORIES, OBLOCKS, PANELFILES, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
 
Constructor Summary
ProxySensorManager()
           
 
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 will return true.
 String createSystemName(String curAddress, String prefix)
           
 Sensor getBySystemName(String sName)
          Locate an instance based on a system name.
 Sensor getByUserName(String userName)
          Locate an instance based on a user name.
 long getDefaultSensorDebounceGoingActive()
           
 long getDefaultSensorDebounceGoingInActive()
           
 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()
           
protected  Sensor makeBean(int i, String systemName, String userName)
          Defer creation of the proper type to the subclass
protected  AbstractManager makeInternalManager()
           
 Sensor newSensor(String systemName, String userName)
          Return an instance with the specified system and user names.
 Sensor provideSensor(String sName)
          Locate via user name, then system name if needed.
 void setDefaultSensorDebounceGoingActive(long timer)
           
 void setDefaultSensorDebounceGoingInActive(long timer)
           
 void updateAll()
          Requests status of all layout sensors under this Sensor Manager.
 
Methods inherited from class jmri.managers.AbstractProxyManager
addManager, addPropertyChangeListener, deregister, dispose, getBeanBySystemName, getBeanByUserName, getManagerList, getMgr, getNamedBean, getSystemNameArray, getSystemNameList, getSystemPrefix, makeSystemName, match, matchTentative, newNamedBean, nMgrs, provideNamedBean, register, removePropertyChangeListener, systemLetter, typeLetter
 
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, getSystemNameArray, getSystemPrefix, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Constructor Detail

ProxySensorManager

public ProxySensorManager()
Method Detail

makeInternalManager

protected AbstractManager makeInternalManager()
Specified by:
makeInternalManager in class AbstractProxyManager

getSensor

public Sensor getSensor(String name)
Locate via user name, then system name if needed.

Specified by:
getSensor in interface SensorManager
Parameters:
name -
Returns:
Null if nothing by that name exists

makeBean

protected Sensor makeBean(int i,
                          String systemName,
                          String userName)
Description copied from class: AbstractProxyManager
Defer creation of the proper type to the subclass

Specified by:
makeBean in class AbstractProxyManager
Parameters:
i - Which manager to invoke

provideSensor

public Sensor provideSensor(String sName)
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:
sName - User name, system name, or address which can be promoted to system name
Returns:
Never null

getBySystemName

public Sensor getBySystemName(String sName)
Locate an instance based on a system name. Returns null if no instance already exists.

Specified by:
getBySystemName in interface SensorManager
Returns:
requested Turnout object or null if none exists

getByUserName

public Sensor getByUserName(String userName)
Locate an instance based on a user name. Returns null if no instance already exists.

Specified by:
getByUserName in interface SensorManager
Returns:
requested Turnout object or null if none exists

newSensor

public Sensor newSensor(String systemName,
                        String userName)
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 for a valid request; 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 Sensors when you should be looking them up.

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

updateAll

public void updateAll()
Description copied from interface: SensorManager
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 there is a null implementation of this method in AbstractSensorManager. This method 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)
Description copied from interface: SensorManager
A method that determines if it is possible to add a range of sensors in numerical order eg 10 to 30 will return true. where as if the address format is 1b23 this will return false.

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)
                           throws JmriException
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
Throws:
JmriException

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

getXMLOrder

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


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