jmri.jmrit.display.layoutEditor
Class LayoutBlockConnectivityTools

Show UML class diagram
java.lang.Object
  extended by jmri.jmrit.display.layoutEditor.LayoutBlockConnectivityTools

public class LayoutBlockConnectivityTools
extends Object

These are a series of layout block connectivity tools that can be used when the advanced layout block routing has been enabled. These tools can determine if a path from a source to destination bean is valid. If a route between two layout blocks is usable and free.


Nested Class Summary
(package private) static class LayoutBlockConnectivityTools.BlocksTested
           
(package private) static class LayoutBlockConnectivityTools.FacingProtecting
           
 
Field Summary
static int ANY
          Constant used in the getLayoutBlocks to represent a path from either a Signal Mast or Head to another Signal Mast or Head and that no mast of head should be in the path.
static int DISTANCE
           
static int HEADTOHEAD
          Constant used in the getLayoutBlocks to represent a path from one Signal Head to another and that no head should be in the path.
static int HOPCOUNT
           
(package private)  String lastErrorMessage
           
(package private) static org.slf4j.Logger log
           
static int MASTTOMAST
          Constant used in the getLayoutBlocks to represent a path from one Signal Mast to another and that no mast should be in the path.
static int METRIC
           
static int NONE
          Constant used in the getLayoutBlocks to indicate that the the system should not check for signal masts or heads on the path.
static int SENSORTOSENSOR
          Constant used in the getLayoutBlocks to represent a path from one Sensor to another and that no sensor should be in the path.
 
Constructor Summary
LayoutBlockConnectivityTools()
           
 
Method Summary
 boolean checkValidDest(LayoutBlock facing, LayoutBlock protecting, LayoutBlockConnectivityTools.FacingProtecting dest, int pathMethod)
          This uses the layout editor to check if the destination location is reachable from the source location
 boolean checkValidDest(LayoutBlock currentBlock, LayoutBlock nextBlock, LayoutBlock destBlock, LayoutBlock destBlockn1, int pathMethod)
          Determines if one set of blocks is reachable from another set of blocks based upon the directions of the set of blocks.
 boolean checkValidDest(LayoutBlock currentBlock, LayoutBlock nextBlock, LayoutBlock destBlock, List<LayoutBlock> destBlockn1, int pathMethod)
           
 boolean checkValidDest(NamedBean sourceBean, NamedBean destBean, int pathMethod)
          Determines if a pair of NamedBeans (Signalhead, Signalmast or Sensor) assigned to a block boundary are reachable.
(package private)  ArrayList<NamedBean> discoverPairDest(NamedBean source, LayoutBlock lProtecting, LayoutBlock lFacing, ArrayList<LayoutBlockConnectivityTools.FacingProtecting> blockList, int pathMethod)
           
 List<NamedBean> discoverPairDest(NamedBean source, LayoutEditor editor, Class<?> T, int pathMethod)
          Returns a list of valid destination beans reachable from a given source bean.
 Hashtable<NamedBean,ArrayList<NamedBean>> discoverValidBeanPairs(LayoutEditor editor, Class<?> T, int pathMethod)
          Discovers valid pairs of beans type T assigned to a layout editor.
(package private)  int findBestHop(Block preBlock, Block currentBlock, Block destBlock, int direction, List<Integer> offSet, boolean validateOnly, int pathMethod)
           
(package private)  ArrayList<LayoutBlockConnectivityTools.FacingProtecting> generateBlocksWithBeans(LayoutEditor editor, Class<?> T)
           
 List<NamedBean> getBeansInPath(List<LayoutBlock> blocklist, LayoutEditor panel, Class<?> T)
          Returns a list of NamedBeans (Signalhead, Signalmast or Sensor) that are assinged to block boundaries in a given list
 ArrayList<LayoutBlock> getLayoutBlocks(LayoutBlock sourceLayoutBlock, LayoutBlock destinationLayoutBlock, LayoutBlock protectingLayoutBlock, boolean validateOnly, int pathMethod)
          The is used in conjunction with the layout block routing protocol, to discover a clear path from a source layout block through to a destination layout block.
 ArrayList<LayoutBlock> getLayoutBlocks(NamedBean sourceBean, NamedBean destBean, boolean validateOnly, int pathMethod)
          The is used in conjunction with the layout block routing protocol, to discover a clear path from a source layout block through to a destination layout block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASTTOMAST

public static final int MASTTOMAST
Constant used in the getLayoutBlocks to represent a path from one Signal Mast to another and that no mast should be in the path.

See Also:
Constant Field Values

HEADTOHEAD

public static final int HEADTOHEAD
Constant used in the getLayoutBlocks to represent a path from one Signal Head to another and that no head should be in the path.

See Also:
Constant Field Values

SENSORTOSENSOR

public static final int SENSORTOSENSOR
Constant used in the getLayoutBlocks to represent a path from one Sensor to another and that no sensor should be in the path.

See Also:
Constant Field Values

ANY

public static final int ANY
Constant used in the getLayoutBlocks to represent a path from either a Signal Mast or Head to another Signal Mast or Head and that no mast of head should be in the path.

See Also:
Constant Field Values

NONE

public static final int NONE
Constant used in the getLayoutBlocks to indicate that the the system should not check for signal masts or heads on the path.

See Also:
Constant Field Values

HOPCOUNT

public static final int HOPCOUNT
See Also:
Constant Field Values

METRIC

public static final int METRIC
See Also:
Constant Field Values

DISTANCE

public static final int DISTANCE
See Also:
Constant Field Values

lastErrorMessage

String lastErrorMessage

log

static org.slf4j.Logger log
Constructor Detail

LayoutBlockConnectivityTools

public LayoutBlockConnectivityTools()
Method Detail

checkValidDest

public boolean checkValidDest(NamedBean sourceBean,
                              NamedBean destBean,
                              int pathMethod)
                       throws JmriException
Determines if a pair of NamedBeans (Signalhead, Signalmast or Sensor) assigned to a block boundary are reachable.

Returns:
true if source and destination beans are reachable, or false if they are not
Throws:
Jmri.Exception - if no blocks can be found that related to the named beans.
JmriException

getLayoutBlocks

public ArrayList<LayoutBlock> getLayoutBlocks(NamedBean sourceBean,
                                              NamedBean destBean,
                                              boolean validateOnly,
                                              int pathMethod)
                                       throws JmriException
The is used in conjunction with the layout block routing protocol, to discover a clear path from a source layout block through to a destination layout block. By specifying the sourceLayoutBlock and protectingLayoutBlock or sourceLayoutBlock+1, a direction of travel can then be termined, eg east to west, south to north etc.

Parameters:
sourceBean - - The source bean (SignalHead, SignalMast or Sensor) assigned to a block boundary that we are starting from.
destBean - - The destination bean.
validateOnly - - When set false, the system will not use layout blocks that are set as either reserved(useExtraColor set) or occupied, if it finds any then it will try to find an alternative path When set false, no block state checking is performed.
pathMethod - - Performs a check to see if any signal heads/masts are in the path, if there are then the system will try to find an alternative path. If set to NONE, then no checking is performed.
Returns:
an ArrayList of all the layoutblocks in the path.
Throws:
JmriException - if it can not find a valid path or the routing has not been enabled.

getBeansInPath

public List<NamedBean> getBeansInPath(List<LayoutBlock> blocklist,
                                      LayoutEditor panel,
                                      Class<?> T)
Returns a list of NamedBeans (Signalhead, Signalmast or Sensor) that are assinged to block boundaries in a given list

Parameters:
blocklist - The list of block in order that need to be checked.
panel - (Optional) panel that the blocks need to be checked against
T - (Optional) the class that we want to check against, either Sensor, SignalMast or SignalHead, set null will return any.

checkValidDest

public boolean checkValidDest(LayoutBlock currentBlock,
                              LayoutBlock nextBlock,
                              LayoutBlock destBlock,
                              LayoutBlock destBlockn1,
                              int pathMethod)
                       throws JmriException
Determines if one set of blocks is reachable from another set of blocks based upon the directions of the set of blocks.

This is used to help with identifying items such as signalmasts located at positionable points or turnouts are facing in the same direction as other given signalmasts.

Given the current block and the next block we can work out the direction of travel. Given the destBlock and the next block on, we can determine the whether the destBlock comes before the destBlock+1.

Returns:
true if destBlock comes before destBlock+1 or false if destBlock comes after destBlock+1
Throws:
Jmri.Exception - if any Block is null;
JmriException

checkValidDest

public boolean checkValidDest(LayoutBlock currentBlock,
                              LayoutBlock nextBlock,
                              LayoutBlock destBlock,
                              List<LayoutBlock> destBlockn1,
                              int pathMethod)
                       throws JmriException
Throws:
JmriException

checkValidDest

public boolean checkValidDest(LayoutBlock facing,
                              LayoutBlock protecting,
                              LayoutBlockConnectivityTools.FacingProtecting dest,
                              int pathMethod)
                       throws JmriException
This uses the layout editor to check if the destination location is reachable from the source location

Parameters:
facing - Layout Block that is considered our first block
protecting - Layout Block that is considered first block +1
dest - Layout Block that we want to get to
Returns:
true if valid, false if not valid.
Throws:
JmriException

getLayoutBlocks

public ArrayList<LayoutBlock> getLayoutBlocks(LayoutBlock sourceLayoutBlock,
                                              LayoutBlock destinationLayoutBlock,
                                              LayoutBlock protectingLayoutBlock,
                                              boolean validateOnly,
                                              int pathMethod)
                                       throws JmriException
The is used in conjunction with the layout block routing protocol, to discover a clear path from a source layout block through to a destination layout block. By specifying the sourceLayoutBlock and protectingLayoutBlock or sourceLayoutBlock+1, a direction of travel can then be termined, eg east to west, south to north etc.

Parameters:
sourceLayoutBlock - - The layout block that we are starting from, can also be considered as the block facing a signal.
destinationLayoutBlock - - The layout block that we want to get to
protectingLayoutBlock - - The next layout block connected to the source block, this can also be considered as the block being protected by a signal
validateOnly - - When set false, the system will not use layout blocks that are set as either reserved(useExtraColor set) or occupied, if it finds any then it will try to find an alternative path When set false, no block state checking is performed.
pathMethod - - Performs a check to see if any signal heads/masts are in the path, if there are then the system will try to find an alternative path. If set to NONE, then no checking is performed.
Returns:
an ArrayList of all the layoutblocks in the path.
Throws:
JmriException - if it can not find a valid path or the routing has not been enabled.

findBestHop

int findBestHop(Block preBlock,
                Block currentBlock,
                Block destBlock,
                int direction,
                List<Integer> offSet,
                boolean validateOnly,
                int pathMethod)

discoverValidBeanPairs

public Hashtable<NamedBean,ArrayList<NamedBean>> discoverValidBeanPairs(LayoutEditor editor,
                                                                        Class<?> T,
                                                                        int pathMethod)
Discovers valid pairs of beans type T assigned to a layout editor. If no bean type is provided, then either SignalMasts or Sensors are discovered If no editor is provided, then all editors are considered

Parameters:
pathMethod - Determine whether or not we should reject pairs if there are other beans in the way. Constant values of NONE, ANY, MASTTOMAST, HEADTOHEAD

discoverPairDest

public List<NamedBean> discoverPairDest(NamedBean source,
                                        LayoutEditor editor,
                                        Class<?> T,
                                        int pathMethod)
                                 throws JmriException
Returns a list of valid destination beans reachable from a given source bean.

Parameters:
source - Either a SignalMast or Sensor
editor - The layout editor that the source is located on, if null, then all editors are considered
T - The class of the remote destination, if null, then both SignalMasts and Sensors are considered
pathMethod - Determine whether or not we should reject pairs if there are other beans in the way. Constant values of NONE, ANY, MASTTOMAST, HEADTOHEAD
Returns:
A list of all reachable NamedBeans
Throws:
JmriException

discoverPairDest

ArrayList<NamedBean> discoverPairDest(NamedBean source,
                                      LayoutBlock lProtecting,
                                      LayoutBlock lFacing,
                                      ArrayList<LayoutBlockConnectivityTools.FacingProtecting> blockList,
                                      int pathMethod)
                                throws JmriException
Throws:
JmriException

generateBlocksWithBeans

ArrayList<LayoutBlockConnectivityTools.FacingProtecting> generateBlocksWithBeans(LayoutEditor editor,
                                                                                 Class<?> T)


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