jmri.managers
Class ProxyTurnoutManager

Show UML class diagram
java.lang.Object
  extended by jmri.managers.AbstractProxyManager
      extended by jmri.managers.ProxyTurnoutManager
All Implemented Interfaces:
Manager, TurnoutManager

public class ProxyTurnoutManager
extends AbstractProxyManager
implements TurnoutManager

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


Field Summary
(package private) static org.slf4j.Logger log
           
 
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
ProxyTurnoutManager()
           
 
Method Summary
 void addManager(Manager m)
          Revise superclass behavior: support TurnoutOperations
 boolean allowMultipleAdditions(String systemName)
          A method that determines if it is possible to add a range of turnouts in numerical order eg 10 to 30 will return true.
 int askControlType(String systemName)
          Get from the user, the type of output to be used bits to control a turnout.
 int askNumControlBits(String systemName)
          Get from the user, the number of addressed bits used to control a turnout.
 String createSystemName(String curAddress, String prefix)
          Returns a system name for a given hardware address and system prefix.
 Turnout getBySystemName(String systemName)
          Locate an instance based on a system name.
 Turnout getByUserName(String userName)
          Locate an instance based on a user name.
 String getClosedText()
          Get text to be used for the Turnout.CLOSED state in user communication.
 String getDefaultClosedSpeed()
           
 String getDefaultThrownSpeed()
           
 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.
 String getThrownText()
          Get text to be used for the Turnout.THROWN state in user communication.
 Turnout getTurnout(String name)
          Locate via user name, then system name if needed.
 String[] getValidOperationTypes()
          TurnoutOperation support.
 int getXMLOrder()
           
 boolean isControlTypeSupported(String systemName)
          Determines if the manager supports the handling of pulsed and steady state control as the askControlType will always return a value even if it is not supported
 boolean isNumControlBitsSupported(String systemName)
          Determines if the manager supports multiple control bits, as the askNumControlBits will always return a value even if it is not supported
protected  NamedBean makeBean(int i, String systemName, String userName)
          Defer creation of the proper type to the subclass
protected  AbstractManager makeInternalManager()
           
 Turnout newTurnout(String systemName, String userName)
          Return an instance with the specified system and user names.
 Turnout provideTurnout(String name)
          Locate via user name, then system name if needed.
 void setDefaultClosedSpeed(String speed)
           
 void setDefaultThrownSpeed(String speed)
           
 
Methods inherited from class jmri.managers.AbstractProxyManager
addPropertyChangeListener, deregister, dispose, getBeanBySystemName, getBeanByUserName, getManagerList, getMgr, getNamedBean, getNamedBeanList, 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.TurnoutManager
getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, getBeanBySystemName, getBeanByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, getSystemPrefix, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Field Detail

log

static org.slf4j.Logger log
Constructor Detail

ProxyTurnoutManager

public ProxyTurnoutManager()
Method Detail

makeInternalManager

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

addManager

public void addManager(Manager m)
Revise superclass behavior: support TurnoutOperations

Overrides:
addManager in class AbstractProxyManager

getTurnout

public Turnout getTurnout(String name)
Locate via user name, then system name if needed.

Specified by:
getTurnout in interface TurnoutManager
Parameters:
name -
Returns:
Null if nothing by that name exists

makeBean

protected NamedBean 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

provideTurnout

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

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

getBySystemName

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

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

getByUserName

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

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

newTurnout

public Turnout newTurnout(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:
newTurnout in interface TurnoutManager
Returns:
requested Sensor object (never null)

getClosedText

public String getClosedText()
Get text to be used for the Turnout.CLOSED state in user communication. Allows text other than "CLOSED" to be use with certain hardware system to represent the Turnout.CLOSED state. Defaults to the primary manager. This means that the primary manager sets the terminology used. Note: the primary manager need not override the method in AbstractTurnoutManager if "CLOSED" is the desired terminology.

Specified by:
getClosedText in interface TurnoutManager

getThrownText

public String getThrownText()
Get text to be used for the Turnout.THROWN state in user communication. Allows text other than "THROWN" to be use with certain hardware system to represent the Turnout.THROWN state. Defaults to the primary manager. This means that the primary manager sets the terminology used. Note: the primary manager need not override the method in AbstractTurnoutManager if "THROWN" is the desired terminology.

Specified by:
getThrownText in interface TurnoutManager

askNumControlBits

public int askNumControlBits(String systemName)
Get from the user, the number of addressed bits used to control a turnout. Normally this is 1, and the default routine returns 1 automatically. Turnout Managers for systems that can handle multiple control bits should override this method with one which asks the user to specify the number of control bits. If the user specifies more than one control bit, this method should check if the additional bits are available (not assigned to another object). If the bits are not available, this method should return 0 for number of control bits, after informing the user of the problem.

Specified by:
askNumControlBits in interface TurnoutManager

askControlType

public int askControlType(String systemName)
Get from the user, the type of output to be used bits to control a turnout. Normally this is 0 for 'steady state' control, and the default routine returns 0 automatically. Turnout Managers for systems that can handle pulsed control as well as steady state control should override this method with one which asks the user to specify the type of control to be used. The routine should return 0 for 'steady state' control, or n for 'pulsed' control, where n specifies the duration of the pulse (normally in seconds).

Specified by:
askControlType in interface TurnoutManager

isControlTypeSupported

public boolean isControlTypeSupported(String systemName)
Description copied from interface: TurnoutManager
Determines if the manager supports the handling of pulsed and steady state control as the askControlType will always return a value even if it is not supported

Specified by:
isControlTypeSupported in interface TurnoutManager

isNumControlBitsSupported

public boolean isNumControlBitsSupported(String systemName)
Description copied from interface: TurnoutManager
Determines if the manager supports multiple control bits, as the askNumControlBits will always return a value even if it is not supported

Specified by:
isNumControlBitsSupported in interface TurnoutManager

getValidOperationTypes

public String[] getValidOperationTypes()
TurnoutOperation support. Return a list which is just the concatenation of all the valid operation types

Specified by:
getValidOperationTypes in interface TurnoutManager

allowMultipleAdditions

public boolean allowMultipleAdditions(String systemName)
Description copied from interface: TurnoutManager
A method that determines if it is possible to add a range of turnouts 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 TurnoutManager

createSystemName

public String createSystemName(String curAddress,
                               String prefix)
                        throws JmriException
Description copied from interface: TurnoutManager
Returns a system name for a given hardware address and system prefix.

Specified by:
createSystemName in interface TurnoutManager
Throws:
JmriException

getNextValidAddress

public String getNextValidAddress(String curAddress,
                                  String prefix)
                           throws JmriException
Description copied from interface: TurnoutManager
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 TurnoutManager
Parameters:
curAddress - - The hardware address of the turnout we which to check.
prefix - - The System Prefix used to make up the systemName
Throws:
JmriException

setDefaultClosedSpeed

public void setDefaultClosedSpeed(String speed)
                           throws JmriException
Specified by:
setDefaultClosedSpeed in interface TurnoutManager
Throws:
JmriException

setDefaultThrownSpeed

public void setDefaultThrownSpeed(String speed)
                           throws JmriException
Specified by:
setDefaultThrownSpeed in interface TurnoutManager
Throws:
JmriException

getDefaultThrownSpeed

public String getDefaultThrownSpeed()
Specified by:
getDefaultThrownSpeed in interface TurnoutManager

getDefaultClosedSpeed

public String getDefaultClosedSpeed()
Specified by:
getDefaultClosedSpeed in interface TurnoutManager

getXMLOrder

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


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