jmri
Class AbstractTurnoutManager

java.lang.Object
  extended by jmri.AbstractManager
      extended by jmri.AbstractTurnoutManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, Manager, TurnoutManager
Direct Known Subclasses:
EasyDccTurnoutManager, InternalTurnoutManager, LnTurnoutManager, NceTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SprogTurnoutManager, SRCPTurnoutManager, XNetTurnoutManager, XpaTurnoutManager

public abstract class AbstractTurnoutManager
extends AbstractManager
implements TurnoutManager

Abstract partial implementation of a TurnoutManager.

Author:
Bob Jacobsen Copyright (C) 2001

Field Summary
 
Fields inherited from class jmri.AbstractManager
_tsys, _tuser
 
Constructor Summary
AbstractTurnoutManager()
           
 
Method Summary
 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.
protected abstract  Turnout createNewTurnout(String systemName, String userName)
          Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.
 Turnout getBySystemName(String key)
          Locate an instance based on a system name.
 Turnout getByUserName(String key)
          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()
          Get a list of the valid TurnoutOPeration subtypes for use with turnouts of this system
 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.
 char typeLetter()
           
 
Methods inherited from class jmri.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getInstanceBySystemName, getInstanceByUserName, getSystemNameList, makeSystemName, propertyChange, register, removePropertyChangeListener
 
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
 

Constructor Detail

AbstractTurnoutManager

public AbstractTurnoutManager()
Method Detail

typeLetter

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

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

getTurnout

public Turnout getTurnout(String name)
Description copied from interface: TurnoutManager
Locate via user name, then system name if needed. If that fails, return null

Specified by:
getTurnout in interface TurnoutManager
Returns:
null if no match found

getBySystemName

public Turnout getBySystemName(String key)
Description copied from interface: TurnoutManager
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 key)
Description copied from interface: TurnoutManager
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)
Description copied from interface: TurnoutManager
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 Turnout 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:
newTurnout in interface TurnoutManager
Returns:
requested Turnout 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.

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.

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

createNewTurnout

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

Returns:
never null

getValidOperationTypes

public String[] getValidOperationTypes()
Description copied from interface: TurnoutManager
Get a list of the valid TurnoutOPeration subtypes for use with turnouts of this system

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