jmri.managers
Class AbstractTurnoutManager

java.lang.Object
  extended by jmri.managers.AbstractManager
      extended by jmri.managers.AbstractTurnoutManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, Manager, TurnoutManager
Direct Known Subclasses:
AcelaTurnoutManager, CbusTurnoutManager, EasyDccTurnoutManager, EcosTurnoutManager, InternalTurnoutManager, JMRIClientTurnoutManager, LnTurnoutManager, NceTurnoutManager, OlcbTurnoutManager, 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.managers.AbstractManager
_tsys, _tuser
 
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
AbstractTurnoutManager()
           
 
Method Summary
 boolean allowMultipleAdditions(String systemName)
          A temporary method that determines if it is possible to add a range of turnouts in numerical order eg 10 to 30
 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.
 String createSystemName(String curAddress, String prefix)
          Returns a system name for a given hardware address and system prefix.
 Turnout getBySystemName(String name)
          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 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()
          Get a list of the valid TurnoutOPeration subtypes for use with turnouts of this system
 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
 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)
           
 char typeLetter()
           
 
Methods inherited from class jmri.managers.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getBeanBySystemName, getInstanceBySystemName, getInstanceByUserName, 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.TurnoutManager
getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, getBeanBySystemName, getSystemNameArray, getSystemPrefix, makeSystemName, register, removePropertyChangeListener, systemLetter
 

Constructor Detail

AbstractTurnoutManager

public AbstractTurnoutManager()
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

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

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 name)
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 systemName,
                          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

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

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

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

allowMultipleAdditions

public boolean allowMultipleAdditions(String systemName)
A temporary method that determines if it is possible to add a range of turnouts in numerical order eg 10 to 30

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


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