Package jmri.jmrit.display.layoutEditor
Class LayoutBlockConnectivityTools
- java.lang.Object
-
- jmri.jmrit.display.layoutEditor.LayoutBlockConnectivityTools
-
public final class LayoutBlockConnectivityTools extends java.lang.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
Nested Classes Modifier and Type Class Description (package private) static class
LayoutBlockConnectivityTools.BlocksTested
(package private) static class
LayoutBlockConnectivityTools.FacingProtecting
static class
LayoutBlockConnectivityTools.Metric
static class
LayoutBlockConnectivityTools.Routing
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
lastErrorMessage
-
Constructor Summary
Constructors Constructor Description LayoutBlockConnectivityTools()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkValidDest(LayoutBlock currentBlock, LayoutBlock nextBlock, LayoutBlock destBlock, java.util.List<LayoutBlock> destBlockn1, LayoutBlockConnectivityTools.Routing 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, LayoutBlock destProBlock, LayoutBlockConnectivityTools.Routing 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(NamedBean sourceBean, NamedBean destBean, LayoutBlockConnectivityTools.Routing pathMethod)
Determines if a pair of NamedBeans (Signalhead, Signalmast or Sensor) assigned to a block boundary are reachable.
Called bySignallingPanel
using MASTTOMAST.(package private) java.util.List<NamedBean>
discoverPairDest(NamedBean source, LayoutBlock lProtecting, LayoutBlock lFacing, java.util.List<LayoutBlockConnectivityTools.FacingProtecting> blockList, LayoutBlockConnectivityTools.Routing pathMethod)
java.util.List<NamedBean>
discoverPairDest(NamedBean source, LayoutEditor editor, java.lang.Class<?> T, LayoutBlockConnectivityTools.Routing pathMethod)
Returns a list of valid destination beans reachable from a given source bean.java.util.HashMap<NamedBean,java.util.List<NamedBean>>
discoverValidBeanPairs(LayoutEditor editor, java.lang.Class<?> T, LayoutBlockConnectivityTools.Routing 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, java.util.List<java.lang.Integer> offSet, boolean validateOnly, LayoutBlockConnectivityTools.Routing pathMethod)
(package private) java.util.List<LayoutBlockConnectivityTools.FacingProtecting>
generateBlocksWithBeans(LayoutEditor editor, java.lang.Class<?> T)
java.util.List<NamedBean>
getBeansInPath(java.util.List<LayoutBlock> blocklist, LayoutEditor panel, java.lang.Class<?> T)
Returns a list of NamedBeans (Signalhead, Signalmast or Sensor) that are assigned to block boundaries in a given list.java.util.List<LayoutBlock>
getLayoutBlocks(LayoutBlock sourceLayoutBlock, LayoutBlock destinationLayoutBlock, LayoutBlock protectingLayoutBlock, boolean validateOnly, LayoutBlockConnectivityTools.Routing pathMethod)
This 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.java.util.List<LayoutBlock>
getLayoutBlocks(NamedBean sourceBean, NamedBean destBean, boolean validateOnly, LayoutBlockConnectivityTools.Routing 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.
-
-
-
Field Detail
-
lastErrorMessage
java.lang.String lastErrorMessage
-
-
Constructor Detail
-
LayoutBlockConnectivityTools
public LayoutBlockConnectivityTools()
-
-
Method Detail
-
checkValidDest
public boolean checkValidDest(NamedBean sourceBean, NamedBean destBean, LayoutBlockConnectivityTools.Routing pathMethod) throws JmriException
Determines if a pair of NamedBeans (Signalhead, Signalmast or Sensor) assigned to a block boundary are reachable.
Called bySignallingPanel
using MASTTOMAST.Search all of the layout editor panels to find the facing and protecting layout blocks for each bean. Call the 3 block+list version of checkValidDest() to finish the checks.
- Parameters:
sourceBean
- The source bean.destBean
- The destination bean.pathMethod
- Indicates the type of path: Signal head, signal mast or sensor.- Returns:
- true if source and destination beans are reachable.
- Throws:
JmriException
- if no blocks can be found that related to the named beans.
-
getLayoutBlocks
public java.util.List<LayoutBlock> getLayoutBlocks(NamedBean sourceBean, NamedBean destBean, boolean validateOnly, LayoutBlockConnectivityTools.Routing 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 determined, 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 List 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 java.util.List<NamedBean> getBeansInPath(java.util.List<LayoutBlock> blocklist, LayoutEditor panel, java.lang.Class<?> T)
Returns a list of NamedBeans (Signalhead, Signalmast or Sensor) that are assigned 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 againstT
- (Optional) the class that we want to check against, either Sensor, SignalMast or SignalHead, set null will return any.- Returns:
- the list of NamedBeans
-
checkValidDest
public boolean checkValidDest(LayoutBlock currentBlock, LayoutBlock nextBlock, LayoutBlock destBlock, LayoutBlock destProBlock, LayoutBlockConnectivityTools.Routing 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.- Called by
DefaultSignalMastLogic
using MASTTOMAST. - Called by
DestinationPoints
using SENSORTOSENSOR. - Called by
EntryExitPairs
using SENSORTOSENSOR.
- Parameters:
currentBlock
- The facing layout block for the source signal or sensor.nextBlock
- The protected layout block for the source signal or sensor.destBlock
- The facing layout block for the destination signal mast or sensor.destProBlock
- The protected destination block.pathMethod
- Indicates the type of path: Signal head, signal mast or sensor.- Returns:
- true if a path to the destination is valid.
- Throws:
JmriException
- if any Block is null;
- Called by
-
checkValidDest
public boolean checkValidDest(LayoutBlock currentBlock, LayoutBlock nextBlock, LayoutBlock destBlock, java.util.List<LayoutBlock> destBlockn1, LayoutBlockConnectivityTools.Routing 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.
Note: This version is internally called by other versions that pre-process external calls.
- Parameters:
currentBlock
- The facing layout block for the source signal or sensor.nextBlock
- The protected layout block for the source signal or sensor.destBlock
- The facing layout block for the destination signal mast or sensor.destBlockn1
- A list of protected destination blocks. Can be empty if the destination is at an end bumper.pathMethod
- Indicates the type of path: Signal head, signal mast or sensor.- Returns:
- true if a path to the destination is valid.
- Throws:
JmriException
- if any layout block is null or advanced routing is not enabled.
-
getLayoutBlocks
public java.util.List<LayoutBlock> getLayoutBlocks(LayoutBlock sourceLayoutBlock, LayoutBlock destinationLayoutBlock, LayoutBlock protectingLayoutBlock, boolean validateOnly, LayoutBlockConnectivityTools.Routing pathMethod) throws JmriException
This 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 determined, 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 toprotectingLayoutBlock
- The next layout block connected to the source block, this can also be considered as the block being protected by a signalvalidateOnly
- 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 true, 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 List 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, java.util.List<java.lang.Integer> offSet, boolean validateOnly, LayoutBlockConnectivityTools.Routing pathMethod)
-
discoverValidBeanPairs
public java.util.HashMap<NamedBean,java.util.List<NamedBean>> discoverValidBeanPairs(LayoutEditor editor, java.lang.Class<?> T, LayoutBlockConnectivityTools.Routing 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:
editor
- the layout editor panelT
- the typepathMethod
- Determine whether or not we should reject pairs if there are other beans in the way. Constant values of NONE, ANY, MASTTOMAST, HEADTOHEAD- Returns:
- the valid pairs
-
discoverPairDest
public java.util.List<NamedBean> discoverPairDest(NamedBean source, LayoutEditor editor, java.lang.Class<?> T, LayoutBlockConnectivityTools.Routing pathMethod) throws JmriException
Returns a list of valid destination beans reachable from a given source bean.- Parameters:
source
- Either a SignalMast or Sensoreditor
- The layout editor that the source is located on, if null, then all editors are consideredT
- The class of the remote destination, if null, then both SignalMasts and Sensors are consideredpathMethod
- 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
- occurring during nested readAll operation
-
discoverPairDest
java.util.List<NamedBean> discoverPairDest(NamedBean source, LayoutBlock lProtecting, LayoutBlock lFacing, java.util.List<LayoutBlockConnectivityTools.FacingProtecting> blockList, LayoutBlockConnectivityTools.Routing pathMethod) throws JmriException
- Throws:
JmriException
-
generateBlocksWithBeans
java.util.List<LayoutBlockConnectivityTools.FacingProtecting> generateBlocksWithBeans(LayoutEditor editor, java.lang.Class<?> T)
-
-