jmri
Interface TurnoutManager

Show UML class diagram
All Superinterfaces:
Manager
All Known Implementing Classes:
AbstractTurnoutManager, AcelaTurnoutManager, CbusTurnoutManager, EasyDccTurnoutManager, EcosTurnoutManager, EliteXNetTurnoutManager, InternalTurnoutManager, InternalTurnoutManager, JMRIClientTurnoutManager, LnTurnoutManager, MarklinTurnoutManager, NceTurnoutManager, OlcbTurnoutManager, ProxyTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SerialTurnoutManager, SprogTurnoutManager, SRCPTurnoutManager, TamsTurnoutManager, XNetTurnoutManager, XpaTurnoutManager

public interface TurnoutManager
extends Manager

Locate a Turnout object representing some specific turnout on the layout.

Turnout objects are obtained from a TurnoutManager, which in turn is generally located from the InstanceManager. A typical call sequence might be:

 Turnout turnout = InstanceManager.turnoutManagerInstance().provideTurnout("23");

Each turnout has a two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, and provides a unique mapping to the layout control system (e.g. LocoNet, NCE, etc) and address within that system.

Much of the book-keeping is implemented in the AbstractTurnoutManager class, which can form the basis for a system-specific implementation.

A sample use of the TurnoutManager interface can be seen in the jmri.jmrit.simpleturnoutctrl.SimpleTurnoutCtrlFrame class, which provides a simple GUI for controlling a single turnout.

This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See Also:
Turnout, InstanceManager, SimpleTurnoutCtrlFrame

Field Summary
 
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
 
Method Summary
 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.
 List<String> getSystemNameList()
          Get a list of all Turnouts' system names.
 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
 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)
           
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, getBeanBySystemName, getBeanByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, getSystemPrefix, getXMLOrder, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Method Detail

provideTurnout

Turnout provideTurnout(String name)
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.

Parameters:
name - User name, system name, or address which can be promoted to system name
Returns:
Never null
Throws:
IllegalArgumentException - if Turnout doesn't already exist and the manager cannot create the Turnout due to e.g. an illegal name or name that can't be parsed.

getTurnout

Turnout getTurnout(String name)
Locate via user name, then system name if needed. If that fails, return null

Parameters:
name -
Returns:
null if no match found

getBySystemName

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

Returns:
requested Turnout object or null if none exists

getByUserName

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

Returns:
requested Turnout object or null if none exists

newTurnout

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 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.

Returns:
requested Turnout object (never null)
Throws:
IllegalArgumentException - if cannot create the Turnout due to e.g. an illegal name or name that can't be parsed.

getSystemNameList

List<String> getSystemNameList()
Get a list of all Turnouts' system names.

Specified by:
getSystemNameList in interface Manager

getClosedText

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.


getThrownText

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.


getValidOperationTypes

String[] getValidOperationTypes()
Get a list of the valid TurnoutOPeration subtypes for use with turnouts of this system


askNumControlBits

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 one 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.


isNumControlBitsSupported

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


askControlType

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).


isControlTypeSupported

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


allowMultipleAdditions

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. where as if the address format is 1b23 this will return false.


getNextValidAddress

String getNextValidAddress(String curAddress,
                           String prefix)
                           throws JmriException
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.

Parameters:
prefix - - The System Prefix used to make up the systemName
curAddress - - The hardware address of the turnout we which to check.
Throws:
JmriException

createSystemName

String createSystemName(String curAddress,
                        String prefix)
                        throws JmriException
Returns a system name for a given hardware address and system prefix.

Throws:
JmriException

setDefaultClosedSpeed

void setDefaultClosedSpeed(String speed)
                           throws JmriException
Throws:
JmriException

setDefaultThrownSpeed

void setDefaultThrownSpeed(String speed)
                           throws JmriException
Throws:
JmriException

getDefaultThrownSpeed

String getDefaultThrownSpeed()

getDefaultClosedSpeed

String getDefaultClosedSpeed()


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