jmri.jmrix.cmri.serial
Class SerialTurnoutManager

Show UML class diagram
java.lang.Object
  extended by jmri.managers.AbstractManager
      extended by jmri.managers.AbstractTurnoutManager
          extended by jmri.jmrix.cmri.serial.SerialTurnoutManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, Manager, TurnoutManager

public class SerialTurnoutManager
extends AbstractTurnoutManager

Implement turnout manager for CMRI serial systems

System names are "CTnnn", where nnn is the turnout number without padding.


Field Summary
(package private) static SerialTurnoutManager _instance
           
(package private)  int bitNum
           
(package private) static org.slf4j.Logger log
           
(package private)  int nAddress
           
 
Fields inherited from class jmri.managers.AbstractManager
_tsys, _tuser
 
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
SerialTurnoutManager()
           
 
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.
 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.
 String getNextValidAddress(String curAddress, String prefix)
          A method that returns the next valid free turnout hardware address
 String getSystemPrefix()
          Provides access to the system prefix string.
static SerialTurnoutManager instance()
           
 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
 void notifySecondBitConflict(String conflict, int bitNum)
          Public method to notify user when the second bit of a proposed two output bit turnout has a conflict with another assigned bit
 void notifyTurnoutCreationError(String conflict, int bitNum)
          Public method to notify user of Turnout creation error.
 int selectNumberOfControlBits()
          Public method to allow user to specify one or two output bits for turnout control Note: This method returns 1 or 2 if the user selected, or 0 if the user cancelled without selecting.
 int selectOutputType()
          Public method to allow user to specify pulsed or steady state for two output bits for turnout control Note: This method returns 1 for steady state or 2 for pulsed if the user selected, or 0 if the user cancelled without selecting.
 
Methods inherited from class jmri.managers.AbstractTurnoutManager
getBySystemName, getByUserName, getClosedText, getDefaultClosedSpeed, getDefaultThrownSpeed, getThrownText, getTurnout, getValidOperationTypes, getXMLOrder, newTurnout, provideTurnout, setDefaultClosedSpeed, setDefaultThrownSpeed, typeLetter
 
Methods inherited from class jmri.managers.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getBeanBySystemName, getBeanByUserName, getInstanceBySystemName, getInstanceByUserName, getNamedBean, getNamedBeanList, 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, getBeanByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, makeSystemName, register, removePropertyChangeListener, systemLetter
 

Field Detail

_instance

static SerialTurnoutManager _instance

bitNum

int bitNum

nAddress

int nAddress

log

static org.slf4j.Logger log
Constructor Detail

SerialTurnoutManager

public SerialTurnoutManager()
Method Detail

getSystemPrefix

public String getSystemPrefix()
Description copied from interface: Manager
Provides access to the system prefix string. This was previously called the "System letter"


createNewTurnout

public Turnout createNewTurnout(String systemName,
                                String userName)
Description copied from class: AbstractTurnoutManager
Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.

Specified by:
createNewTurnout in class AbstractTurnoutManager
Returns:
never null

notifyTurnoutCreationError

public void notifyTurnoutCreationError(String conflict,
                                       int bitNum)
Public method to notify user of Turnout creation error.


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. This function is called whenever a new turnout is defined in the Turnout table. It can also be used to set up other turnout control options, such as pulsed control of turnout machines.

Specified by:
askNumControlBits in interface TurnoutManager
Overrides:
askNumControlBits in class AbstractTurnoutManager

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
Overrides:
askControlType in class AbstractTurnoutManager

selectNumberOfControlBits

public int selectNumberOfControlBits()
Public method to allow user to specify one or two output bits for turnout control Note: This method returns 1 or 2 if the user selected, or 0 if the user cancelled without selecting.


selectOutputType

public int selectOutputType()
Public method to allow user to specify pulsed or steady state for two output bits for turnout control Note: This method returns 1 for steady state or 2 for pulsed if the user selected, or 0 if the user cancelled without selecting.


notifySecondBitConflict

public void notifySecondBitConflict(String conflict,
                                    int bitNum)
Public method to notify user when the second bit of a proposed two output bit turnout has a conflict with another assigned bit


instance

public static SerialTurnoutManager instance()

allowMultipleAdditions

public boolean allowMultipleAdditions(String systemName)
Description copied from class: AbstractTurnoutManager
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
Overrides:
allowMultipleAdditions in class AbstractTurnoutManager

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
Overrides:
isNumControlBitsSupported in class AbstractTurnoutManager

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
Overrides:
isControlTypeSupported in class AbstractTurnoutManager

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
Overrides:
createSystemName in class AbstractTurnoutManager
Throws:
JmriException

getNextValidAddress

public String getNextValidAddress(String curAddress,
                                  String prefix)
                           throws JmriException
A method that returns the next valid free turnout hardware address

Specified by:
getNextValidAddress in interface TurnoutManager
Overrides:
getNextValidAddress in class AbstractTurnoutManager
Parameters:
curAddress - - The hardware address of the turnout we which to check.
prefix - - The System Prefix used to make up the systemName
Throws:
JmriException


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