jmri.managers
Class ProxyTurnoutManager

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. The first to be added is the "Primary".

Author:
Bob Jacobsen Copyright (C) 2003

Constructor Summary
ProxyTurnoutManager()
           
 
Method Summary
 void addManager(Manager m)
          Revise superclass behavior: Added managers mean that the default internal manager is not the primary.
 int askControlType(String sysName)
          Get from the user, the type of output to be used bits to control a turnout.
 int askNumControlBits(String sysName)
          Get from the user, the number of addressed bits used to control a turnout.
 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 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.
 Turnout newTurnout(String sysName, 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.
 
Methods inherited from class jmri.managers.AbstractProxyManager
addPropertyChangeListener, deregister, dispose, getSystemNameList, makeSystemName, 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, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Constructor Detail

ProxyTurnoutManager

public ProxyTurnoutManager()
Method Detail

addManager

public void addManager(Manager m)
Revise superclass behavior: Added managers mean that the default internal manager is not the primary. Also 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

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
Returns:
Never null under normal circumstances

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 sysName,
                          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 sysName)
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 sysName)
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

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


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