jmri.jmrit.display.layoutEditor
Class LayoutBlockManager

Show UML class diagram
java.lang.Object
  extended by jmri.managers.AbstractManager
      extended by jmri.jmrit.display.layoutEditor.LayoutBlockManager
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.beans.VetoableChangeListener, java.util.EventListener, InstanceManagerAutoDefault, Manager

public class LayoutBlockManager
extends AbstractManager
implements InstanceManagerAutoDefault

Implementation of a Manager to handle LayoutBlocks Note: that the same LayoutBlocks may appear in multiple LayoutEditor panels.

This manager does not enforce any particular system naming convention.

LayoutBlocks are usually addressed by userName. The systemName is hidden from the user for the most part.


Field Summary
(package private) static LayoutBlockManager _instance
           
(package private)  boolean checking
           
protected  boolean enableAdvancedRouting
           
(package private)  LayoutBlockConnectivityTools lbct
           
(package private) static org.slf4j.Logger log
           
(package private) static java.util.ResourceBundle rb
           
(package private)  boolean stabilised
           
(package private)  java.lang.Thread thr
           
 
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
LayoutBlockManager()
           
 
Method Summary
 void addBadBeanError()
           
 LayoutBlock createNewLayoutBlock()
           
 LayoutBlock createNewLayoutBlock(java.lang.String systemName, java.lang.String userName)
          Method to create a new LayoutBlock if the LayoutBlock does not exist Returns null if a LayoutBlock with the same systemName or userName already exists, or if there is trouble creating a new LayoutBlock.
 void deleteLayoutBlock(LayoutBlock block)
          Remove an existing LayoutBlock.
 void enableAdvancedRouting(boolean boo)
          Enables the advanced layout block routing protocol The block routing protocol enables each layout block to build up a list of all reachable blocks, along with how far away they are, which direction they are in and which of the connected blocks they are reachable from.
 java.lang.String getBeanTypeHandled()
          For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.
 LayoutBlock getBlockWithMemoryAssigned(Memory m)
          Method to find a LayoutBlock with a specified Memory assigned as its value display.
 LayoutBlock getBlockWithSensorAssigned(Sensor s)
          Method to find a LayoutBlock with a specified Sensor assigned as its occupancy sensor.
 LayoutBlock getBySystemName(java.lang.String name)
           
 LayoutBlock getByUserName(java.lang.String key)
           
 NamedBean getFacingBean(Block facingBlock, Block protectedBlock, LayoutEditor panel, java.lang.Class<?> T)
          Method to return a facing bean into a specified Block from a specified protected Block.
 LayoutBlock getFacingBlock(SignalHead signalHead, LayoutEditor panel)
           
 LayoutBlock getFacingBlock(java.lang.String signalName, LayoutEditor panel)
          Method to return the LayoutBlock that a given signal is facing.
 LayoutBlock getFacingBlockByMast(SignalMast signalMast, LayoutEditor panel)
          Method to return the LayoutBlock that a given signal is facing.
 LayoutBlock getFacingBlockByNamedBean(NamedBean nb, LayoutEditor panel)
          Method to return the block facing a given bean object (Sensor, SignalMast or SignalHead).
 LayoutBlock getFacingBlockBySensor(Sensor sensor, LayoutEditor panel)
          Method to return the LayoutBlock that a given sensor is facing.
 LayoutBlock getFacingBlockBySensor(java.lang.String sensorName, LayoutEditor panel)
          Method to return the LayoutBlock that a given sensor is facing.
 NamedBean getFacingNamedBean(Block facingBlock, Block protectedBlock, LayoutEditor panel)
          Method to return the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.
 Sensor getFacingSensor(Block facingBlock, Block protectedBlock, LayoutEditor panel)
          Method to return the Sensor facing into a specified Block from a specified protected Block.
 SignalHead getFacingSignalHead(Block facingBlock, Block protectedBlock)
          Method to return the Signal Head facing into a specified Block from a specified protected Block.
 SignalMast getFacingSignalMast(Block facingBlock, Block protectedBlock)
           
 SignalMast getFacingSignalMast(Block facingBlock, Block protectedBlock, LayoutEditor panel)
          Method to return the Signal Mast facing into a specified Block from a specified protected Block.
 java.lang.Object getFacingSignalObject(Block facingBlock, Block protectedBlock)
          Returns in the first instance a Signal Mast or if none exists a Signal Head for a given facing block and protected block combination.
 long getLastRoutingChange()
          returns the time when the last routing change was made, recorded as System.nanoTime()
 LayoutBlock getLayoutBlock(Block block)
           
 LayoutBlock getLayoutBlock(java.lang.String name)
          Method to get an existing LayoutBlock.
 LayoutBlockConnectivityTools getLayoutBlockConnectivityTools()
           
 NamedBean getNamedBeanAtEndBumper(Block facingBlock, LayoutEditor panel)
          Method to return the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.
 NamedBeanHandle<Sensor> getNamedStabilisedSensor()
          Get the sensor used for the stability indication
 LayoutBlock getProtectedBlock(SignalHead signalHead, LayoutEditor panel)
           
 LayoutBlock getProtectedBlock(java.lang.String signalName, LayoutEditor panel)
          Method to return the LayoutBlock that a given signal is protecting.
 LayoutBlock getProtectedBlockByMast(SignalMast signalMast, LayoutEditor panel)
           
 LayoutBlock getProtectedBlockByNamedBean(NamedBean nb, LayoutEditor panel)
          Method to return the block that a given bean object (Sensor, SignalMast or SignalHead) is protecting
 LayoutBlock getProtectedBlockBySensor(Sensor sensor, LayoutEditor panel)
          Method to return the LayoutBlock that a given sensor is protecting.
 LayoutBlock getProtectedBlockBySensor(java.lang.String sensorName, LayoutEditor panel)
          Method to return the LayoutBlock that a given sensor is protecting.
 java.util.List<LayoutBlock> getProtectingBlocksByNamedBean(NamedBean nb, LayoutEditor panel)
           
 java.util.List<LayoutBlock> getProtectingBlocksBySensor(Sensor sensor, LayoutEditor panel)
           
 java.util.List<LayoutBlock> getProtectingBlocksBySensorOld(Sensor sensor, LayoutEditor panel)
           
 Sensor getSensorAtEndBumper(Block facingBlock, LayoutEditor panel)
          Method to return a Sensor facing into a specific Block.
 SignalMast getSignalMastAtEndBumper(Block facingBlock, LayoutEditor panel)
          Method to return a Signal Mast that is assigned to a block which has an end bumper at one end.
 Sensor getStabilisedSensor()
          Return the sensor used to indicate if the routing protocol has stabilised or not
 java.lang.String getSystemPrefix()
          Provides access to the system prefix string.
 int getXMLOrder()
           
 void initializeLayoutBlockPaths()
          Initializes/checks the Paths of all Blocks associated with LayoutBlocks.
static LayoutBlockManager instance()
           
 boolean isAdvancedRoutingEnabled()
          returns true if advanced layout block routing has been enabled.
 boolean routingStablised()
          Returns true if the layout block routing protocol has stabilised
(package private)  void setLastRoutingChange()
           
 void setStabilisedSensor(java.lang.String pName)
          Assign a sensor to the routing protocol, that changes state dependant upon if the routing protocol has stabilised or is under going a change.
 void turnOffWarning()
           
 char typeLetter()
           
 boolean warn()
          Controls switching off incompatible block connectivity messages Warnings are always on when program starts up.
 
Methods inherited from class jmri.managers.AbstractManager
addPropertyChangeListener, addVetoableChangeListener, deleteBean, deregister, dispose, firePropertyChange, fireVetoableChange, getBeanBySystemName, getBeanByUserName, getInstanceBySystemName, getInstanceByUserName, getNamedBean, getNamedBeanList, getSystemNameArray, getSystemNameList, makeSystemName, propertyChange, register, registerSelf, removePropertyChangeListener, removeVetoableChangeListener, systemLetter, vetoableChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

static final java.util.ResourceBundle rb

_instance

static LayoutBlockManager _instance

enableAdvancedRouting

protected boolean enableAdvancedRouting

lbct

LayoutBlockConnectivityTools lbct

checking

boolean checking

stabilised

boolean stabilised

thr

java.lang.Thread thr

log

static org.slf4j.Logger log
Constructor Detail

LayoutBlockManager

public LayoutBlockManager()
Method Detail

getXMLOrder

public int getXMLOrder()
Specified by:
getXMLOrder in interface Manager
Specified by:
getXMLOrder in class AbstractManager

getSystemPrefix

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

Specified by:
getSystemPrefix in interface Manager

typeLetter

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

createNewLayoutBlock

public LayoutBlock createNewLayoutBlock(java.lang.String systemName,
                                        java.lang.String userName)
Method to create a new LayoutBlock if the LayoutBlock does not exist Returns null if a LayoutBlock with the same systemName or userName already exists, or if there is trouble creating a new LayoutBlock. Note that since the userName is used to address LayoutBlocks, the user name must be present. If the user name is not present, the new LayoutBlock is not created, and null is returned.


createNewLayoutBlock

public LayoutBlock createNewLayoutBlock()

deleteLayoutBlock

public void deleteLayoutBlock(LayoutBlock block)
Remove an existing LayoutBlock.


getLayoutBlock

public LayoutBlock getLayoutBlock(java.lang.String name)
Method to get an existing LayoutBlock. First looks up assuming that name is a User Name. If this fails looks up assuming that name is a System Name. If both fail, returns null.


getLayoutBlock

public LayoutBlock getLayoutBlock(Block block)

getBySystemName

public LayoutBlock getBySystemName(java.lang.String name)

getByUserName

public LayoutBlock getByUserName(java.lang.String key)

instance

public static LayoutBlockManager instance()

getBlockWithSensorAssigned

public LayoutBlock getBlockWithSensorAssigned(Sensor s)
Method to find a LayoutBlock with a specified Sensor assigned as its occupancy sensor. Returns the block or null if no existing LayoutBlock has the Sensor assigned.


getBlockWithMemoryAssigned

public LayoutBlock getBlockWithMemoryAssigned(Memory m)
Method to find a LayoutBlock with a specified Memory assigned as its value display. Returns the block or null if no existing LayoutBlock has the memory assigned.


initializeLayoutBlockPaths

public void initializeLayoutBlockPaths()
Initializes/checks the Paths of all Blocks associated with LayoutBlocks.

This routine should be called when loading panels, after all Layout Editor panels have been loaded.


addBadBeanError

public void addBadBeanError()

getFacingSignalHead

public SignalHead getFacingSignalHead(Block facingBlock,
                                      Block protectedBlock)
Method to return the Signal Head facing into a specified Block from a specified protected Block.

This method is primarily designed for use with scripts to get information initially residing in a Layout Editor panel. If either of the input Blocks is null, or if the two blocks do not join at a block boundary, or if either of the input Blocks are not Layout Editor panel blocks, an error message is logged, and "null" is returned. If the signal at the block boundary has two heads--is located at the facing point of a turnout-- the Signal Head that applies for the current setting of turnout (THROWN or CLOSED) is returned. If the turnout state is UNKNOWN or INCONSISTENT, an error message is logged, and "null" is returned. If the signal at the block boundary has three heads--the facing point of a 3-way turnout--the Signal Head that applies for the current settings of the two turnouts of the 3-way turnout is returned. If the turnout state of either turnout is UNKNOWN or INCONSISTENT, an error is logged and "null" is returned. "null" is returned if the block boundary is between the two turnouts of a THROAT_TO_THROAT turnout or a 3-way turnout. "null" is returned for block boundaries exiting a THROAT_TO_THROAT turnout block, since there are no signals that apply there.


getNamedBeanAtEndBumper

public NamedBean getNamedBeanAtEndBumper(Block facingBlock,
                                         LayoutEditor panel)
Method to return the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.

Parameters:
facingBlock -
panel -
Returns:
The assigned sensor or signal mast as a named bean

getSignalMastAtEndBumper

public SignalMast getSignalMastAtEndBumper(Block facingBlock,
                                           LayoutEditor panel)
Method to return a Signal Mast that is assigned to a block which has an end bumper at one end.


getSensorAtEndBumper

public Sensor getSensorAtEndBumper(Block facingBlock,
                                   LayoutEditor panel)
Method to return a Sensor facing into a specific Block. This is used for blocks that have an end bumper at one end


getFacingNamedBean

public NamedBean getFacingNamedBean(Block facingBlock,
                                    Block protectedBlock,
                                    LayoutEditor panel)
Method to return the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.

Parameters:
facingBlock -
protectedBlock -
Returns:
The assigned sensor or signal mast as a named bean

getFacingSignalMast

public SignalMast getFacingSignalMast(Block facingBlock,
                                      Block protectedBlock)

getFacingSignalMast

public SignalMast getFacingSignalMast(Block facingBlock,
                                      Block protectedBlock,
                                      LayoutEditor panel)
Method to return the Signal Mast facing into a specified Block from a specified protected Block.

Parameters:
facingBlock -
protectedBlock -
Returns:
The assigned signalMast.

getFacingSensor

public Sensor getFacingSensor(Block facingBlock,
                              Block protectedBlock,
                              LayoutEditor panel)
Method to return the Sensor facing into a specified Block from a specified protected Block.

Parameters:
facingBlock -
protectedBlock -
Returns:
The assigned sensor.

getFacingBean

public NamedBean getFacingBean(Block facingBlock,
                               Block protectedBlock,
                               LayoutEditor panel,
                               java.lang.Class<?> T)
Method to return a facing bean into a specified Block from a specified protected Block.

Parameters:
facingBlock -
protectedBlock -
panel - the layout editor panel the block is assigned, if null then the maximum connected panel of the facing block is used
T - The class of the item that we are looking for, either SignalMast or Sensor
Returns:
The assigned sensor.

getFacingSignalObject

public java.lang.Object getFacingSignalObject(Block facingBlock,
                                              Block protectedBlock)
Returns in the first instance a Signal Mast or if none exists a Signal Head for a given facing block and protected block combination. see getFacingSignalMast and getFacingSignalHead as to how they deal with what they each return.

Parameters:
facingBlock -
protectedBlock -
Returns:
either a signalMast or signalHead

getProtectedBlockByNamedBean

public LayoutBlock getProtectedBlockByNamedBean(NamedBean nb,
                                                LayoutEditor panel)
Method to return the block that a given bean object (Sensor, SignalMast or SignalHead) is protecting

Parameters:
nb - NamedBean
panel - - panel that this bean is on
Returns:
The block that the bean object is facing

getProtectingBlocksByNamedBean

public java.util.List<LayoutBlock> getProtectingBlocksByNamedBean(NamedBean nb,
                                                                  LayoutEditor panel)

getProtectedBlockByMast

public LayoutBlock getProtectedBlockByMast(SignalMast signalMast,
                                           LayoutEditor panel)

getProtectedBlockBySensor

public LayoutBlock getProtectedBlockBySensor(java.lang.String sensorName,
                                             LayoutEditor panel)
Method to return the LayoutBlock that a given sensor is protecting.


getProtectingBlocksBySensor

public java.util.List<LayoutBlock> getProtectingBlocksBySensor(Sensor sensor,
                                                               LayoutEditor panel)

getProtectingBlocksBySensorOld

public java.util.List<LayoutBlock> getProtectingBlocksBySensorOld(Sensor sensor,
                                                                  LayoutEditor panel)

getProtectedBlockBySensor

public LayoutBlock getProtectedBlockBySensor(Sensor sensor,
                                             LayoutEditor panel)
Method to return the LayoutBlock that a given sensor is protecting.


getFacingBlockByNamedBean

public LayoutBlock getFacingBlockByNamedBean(NamedBean nb,
                                             LayoutEditor panel)
Method to return the block facing a given bean object (Sensor, SignalMast or SignalHead).

Parameters:
nb - NamedBean
panel - - panel that this bean is on
Returns:
The block that the bean object is facing

getFacingBlockBySensor

public LayoutBlock getFacingBlockBySensor(java.lang.String sensorName,
                                          LayoutEditor panel)
Method to return the LayoutBlock that a given sensor is facing.


getFacingBlockByMast

public LayoutBlock getFacingBlockByMast(SignalMast signalMast,
                                        LayoutEditor panel)
Method to return the LayoutBlock that a given signal is facing.


getFacingBlockBySensor

public LayoutBlock getFacingBlockBySensor(Sensor sensor,
                                          LayoutEditor panel)
Method to return the LayoutBlock that a given sensor is facing.


getProtectedBlock

public LayoutBlock getProtectedBlock(SignalHead signalHead,
                                     LayoutEditor panel)

getProtectedBlock

public LayoutBlock getProtectedBlock(java.lang.String signalName,
                                     LayoutEditor panel)
Method to return the LayoutBlock that a given signal is protecting.


getFacingBlock

public LayoutBlock getFacingBlock(SignalHead signalHead,
                                  LayoutEditor panel)

getFacingBlock

public LayoutBlock getFacingBlock(java.lang.String signalName,
                                  LayoutEditor panel)
Method to return the LayoutBlock that a given signal is facing.


warn

public boolean warn()
Controls switching off incompatible block connectivity messages

Warnings are always on when program starts up. Once stopped by the user, these messages may not be switched on again until program restarts.


turnOffWarning

public void turnOffWarning()

isAdvancedRoutingEnabled

public boolean isAdvancedRoutingEnabled()
returns true if advanced layout block routing has been enabled.


enableAdvancedRouting

public void enableAdvancedRouting(boolean boo)
Enables the advanced layout block routing protocol

The block routing protocol enables each layout block to build up a list of all reachable blocks, along with how far away they are, which direction they are in and which of the connected blocks they are reachable from.


getLayoutBlockConnectivityTools

public LayoutBlockConnectivityTools getLayoutBlockConnectivityTools()

setLastRoutingChange

void setLastRoutingChange()

setStabilisedSensor

public void setStabilisedSensor(java.lang.String pName)
                         throws JmriException
Assign a sensor to the routing protocol, that changes state dependant upon if the routing protocol has stabilised or is under going a change.

Throws:
JmriException

getStabilisedSensor

public Sensor getStabilisedSensor()
Return the sensor used to indicate if the routing protocol has stabilised or not


getNamedStabilisedSensor

public NamedBeanHandle<Sensor> getNamedStabilisedSensor()
Get the sensor used for the stability indication


routingStablised

public boolean routingStablised()
Returns true if the layout block routing protocol has stabilised


getLastRoutingChange

public long getLastRoutingChange()
returns the time when the last routing change was made, recorded as System.nanoTime()


getBeanTypeHandled

public java.lang.String getBeanTypeHandled()
Description copied from interface: Manager
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.

Specified by:
getBeanTypeHandled in interface Manager
Specified by:
getBeanTypeHandled in class AbstractManager
Returns:
a string of the bean type that the manager handles, eg Turnout, Sensor etc


Copyright © 1997-2014 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