jmri.jmrit.display.layoutEditor
Class ConnectivityUtil

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

public class ConnectivityUtil
extends Object

ConnectivityUtil provides methods supporting use of layout connectivity available in Layout Editor panels. These tools allow outside classes to inquire into connectivity information contained in a specified Layout Editor panel.

Connectivity information is stored in the track diagram of a Layout Editor panel. The "connectivity graph" of the layout consists of nodes (LayoutTurnouts, LevelXings, and PositionablePoints) connected by lines (TrackSegments). These methods extract information from the connection graph and make it available. Each instance of ConnectivityUtil is associated with a specific Layout Editor panel, and is accessed via that LayoutEditor panel's 'getConnectivityUtil' method.

The methods in this module do not modify the Layout in any way, or change the state of items on the layout. They only provide information to allow other modules to do so as appropriate. For example, the "getTurnoutList" method provides information about the turnouts in a block, but does not test the state, or change the state, of any turnout.

The methods in this module are accessed via direct calls from the inquiring method.


Field Summary
static int CONTINUING
           
static int DIVERGING
           
(package private)  LayoutBlock lb
           
(package private) static org.slf4j.Logger log
           
(package private)  LayoutBlock nlb
           
static int OVERALL
           
(package private)  LayoutBlock plb
           
(package private)  ResourceBundle rb
           
 
Constructor Summary
ConnectivityUtil(LayoutEditor thePanel)
           
 
Method Summary
 boolean addSensorToSignalHeadLogic(String name, SignalHead sh, int where)
           
 boolean blockInternalToLevelXing(LevelXing x, Block block)
          Returns 'true' if the specified block is internal to the Level Xing, and if all else is OK.
 ArrayList<LayoutTurnout> getAllTurnoutsThisBlock(LayoutBlock lb)
           
 ArrayList<PositionablePoint> getAnchorBoundariesThisBlock(Block block)
          Returns a list of all anchor point boundaries involving the specified Block
 ArrayList<Block> getConnectedBlocks(Block block)
          Returns a list of all Blocks connected to a specified Block
 int getDirectionFromAnchor(ArrayList<EntryPoint> mForwardEntryPoints, ArrayList<EntryPoint> mReverseEntryPoints, PositionablePoint p)
          Matches the anchor point to an Entry Point, and returns the direction specified in the Entry Point If no match is found, UNKNOWN is returned, indicating that the block boundary is internal to the Section.
 Block getExitBlockForTrackNode(TrackNode node, Block excludedBlock)
          Returns an "exit block" for the specified track node if there is one, else returns null.
 ArrayList<LayoutTurnout> getLayoutTurnoutsThisBlock(Block block)
          Returns a list of all layout turnouts involving the specified Block
 ArrayList<LevelXing> getLevelCrossingsThisBlock(Block block)
          Returns a list of all levelXings involving the specified Block.
 TrackNode getNextNode(TrackNode cNode, int cNodeState)
          Returns the next Node following the specified TrackNode If the specified track node can lead to different paths to the next node, for example, if the specified track node is a turnout entered at its throat, then "cNodeState" must be specified to choose between the possible paths.
 SignalHead getSignalHeadAtAnchor(PositionablePoint p, Block block, boolean facing)
          Returns the Signal Head at the Anchor block boundary If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block
 SignalHead getSignalHeadAtLevelXing(LevelXing x, Block block, boolean facing)
          Returns the Signal Head at the level crossing If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block
 SignalMast getSignalMastAtAnchor(PositionablePoint p, Block block, boolean facing)
          Returns the Signal Mast at the Anchor block boundary If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block
 TrackNode getTrackNode(Object cNode, int cNodeType, TrackSegment cTrack, int cNodeState)
          Returns the next Node following the node specified by "cNode" and "cNodeType", assuming that cNode was reached via the specified TrackSegment.
 ArrayList<LayoutTurnout> getTurnoutList(Block block, Block prevBlock, Block nextBlock)
          Provides a list of LayoutTurnouts in a specified Block (block), in order, beginning at the connection to the specified previous Block (prevBlock) and continuing to the specfied next Block (nextBlock).
 ArrayList<Integer> getTurnoutSettingList()
          Returns a list of turnout settings (as Integer Objects) to accomplish the transition through the Block specified in 'getTurnoutList'.
 boolean isInternalLevelXingAC(LevelXing x, Block block)
          Checks if a Level Crossing's AC track and its two connecting Track Segments are internal to the specified block.
 boolean isInternalLevelXingBD(LevelXing x, Block block)
          Checks if a Level Crossing's BD track and its two connecting Track Segments are internal to the specified block.
 boolean isTurnoutConnectivityComplete()
          This flag can be checked after performing a getTurnoutList() to check if the connectivity of the turnouts has been completed in the block when the getTurnoutList() was called.
 boolean layoutTurnoutHasRequiredSignals(LayoutTurnout t)
          Returns 'true' if specified Layout Turnout has required signal heads.
 boolean layoutTurnoutHasSignalMasts(LayoutTurnout t)
           
 boolean removeSensorsFromSignalHeadLogic(ArrayList<String> names, SignalHead sh)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

ResourceBundle rb

lb

LayoutBlock lb

nlb

LayoutBlock nlb

plb

LayoutBlock plb

OVERALL

public static final int OVERALL
See Also:
Constant Field Values

CONTINUING

public static final int CONTINUING
See Also:
Constant Field Values

DIVERGING

public static final int DIVERGING
See Also:
Constant Field Values

log

static org.slf4j.Logger log
Constructor Detail

ConnectivityUtil

public ConnectivityUtil(LayoutEditor thePanel)
Method Detail

getTurnoutList

public ArrayList<LayoutTurnout> getTurnoutList(Block block,
                                               Block prevBlock,
                                               Block nextBlock)
Provides a list of LayoutTurnouts in a specified Block (block), in order, beginning at the connection to the specified previous Block (prevBlock) and continuing to the specfied next Block (nextBlock). Also compiles a companion list of how the turnout should be set for the specified connectivity. The companion list can be accessed by "getTurnoutSettingList" immediately after this method returns. If both the previous Block or the next Block are specified, follows the connectivity and returns only those turnouts needed for the transit of this block. If either are not present (null), returns all turnouts in this block, with settings to enter/exit to whatever block is specified, and other settings set to CLOSED. Returns an empty list if a connectivity anamoly is discovered--specified blocks are not connected.


getTurnoutSettingList

public ArrayList<Integer> getTurnoutSettingList()
Returns a list of turnout settings (as Integer Objects) to accomplish the transition through the Block specified in 'getTurnoutList'. Settings and Turnouts are in sync by position in the returned list.


getConnectedBlocks

public ArrayList<Block> getConnectedBlocks(Block block)
Returns a list of all Blocks connected to a specified Block


getAnchorBoundariesThisBlock

public ArrayList<PositionablePoint> getAnchorBoundariesThisBlock(Block block)
Returns a list of all anchor point boundaries involving the specified Block


getLevelCrossingsThisBlock

public ArrayList<LevelXing> getLevelCrossingsThisBlock(Block block)
Returns a list of all levelXings involving the specified Block. To be returned, a levelXing must have all its four connections and all blocks must be assigned. If any connection is missing, or if a block assignmnet is missing, an error message is printed and the level crossing is not added to the list.


getLayoutTurnoutsThisBlock

public ArrayList<LayoutTurnout> getLayoutTurnoutsThisBlock(Block block)
Returns a list of all layout turnouts involving the specified Block


layoutTurnoutHasRequiredSignals

public boolean layoutTurnoutHasRequiredSignals(LayoutTurnout t)
Returns 'true' if specified Layout Turnout has required signal heads. Returns 'false' if one or more of the required signals are missing.


getSignalHeadAtAnchor

public SignalHead getSignalHeadAtAnchor(PositionablePoint p,
                                        Block block,
                                        boolean facing)
Returns the Signal Head at the Anchor block boundary If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block


getSignalMastAtAnchor

public SignalMast getSignalMastAtAnchor(PositionablePoint p,
                                        Block block,
                                        boolean facing)
Returns the Signal Mast at the Anchor block boundary If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block


layoutTurnoutHasSignalMasts

public boolean layoutTurnoutHasSignalMasts(LayoutTurnout t)

getSignalHeadAtLevelXing

public SignalHead getSignalHeadAtLevelXing(LevelXing x,
                                           Block block,
                                           boolean facing)
Returns the Signal Head at the level crossing If 'facing' is 'true', returns the head that faces toward the specified Block If 'facing' is 'false', returns the head that faces away from the specified Block


blockInternalToLevelXing

public boolean blockInternalToLevelXing(LevelXing x,
                                        Block block)
Returns 'true' if the specified block is internal to the Level Xing, and if all else is OK. Returns 'false' if one of the connecting Track Segments is in the Block, or if there is a problem with looking for a signal head.


getDirectionFromAnchor

public int getDirectionFromAnchor(ArrayList<EntryPoint> mForwardEntryPoints,
                                  ArrayList<EntryPoint> mReverseEntryPoints,
                                  PositionablePoint p)
Matches the anchor point to an Entry Point, and returns the direction specified in the Entry Point If no match is found, UNKNOWN is returned, indicating that the block boundary is internal to the Section.


isInternalLevelXingAC

public boolean isInternalLevelXingAC(LevelXing x,
                                     Block block)
Checks if a Level Crossing's AC track and its two connecting Track Segments are internal to the specified block. If the A and C connecting Track Segments are in the Block, and the LevelXing's AC track is in the block, returns 'true". Otherwise returns 'false', even if one of the tracks of the LevelXing is in the block. Note; if two connecting track segments are in the block, but the internal connecting track is not, that is an error in the Layout Editor panel. If found, an error message is generated and 'false' is returned.


isInternalLevelXingBD

public boolean isInternalLevelXingBD(LevelXing x,
                                     Block block)
Checks if a Level Crossing's BD track and its two connecting Track Segments are internal to the specified block. If the B and D connecting Track Segments are in the Block, and the LevelXing's BD track is in the block, returns 'true". Otherwise returns 'false', even if one of the tracks of the LevelXing is in the block. Note; if two connecting track segments are in the block, but the internal connecting track is not, that is an error in the Layout Editor panel. If found, an error message is generated and 'false' is returned.


addSensorToSignalHeadLogic

public boolean addSensorToSignalHeadLogic(String name,
                                          SignalHead sh,
                                          int where)

removeSensorsFromSignalHeadLogic

public boolean removeSensorsFromSignalHeadLogic(ArrayList<String> names,
                                                SignalHead sh)

getNextNode

public TrackNode getNextNode(TrackNode cNode,
                             int cNodeState)
Returns the next Node following the specified TrackNode

If the specified track node can lead to different paths to the next node, for example, if the specified track node is a turnout entered at its throat, then "cNodeState" must be specified to choose between the possible paths. Returns a TrackNode if one is reached. Returns null if trouble following the track. .


getTrackNode

public TrackNode getTrackNode(Object cNode,
                              int cNodeType,
                              TrackSegment cTrack,
                              int cNodeState)
Returns the next Node following the node specified by "cNode" and "cNodeType", assuming that cNode was reached via the specified TrackSegment.

If the specified track node can lead to different paths to the next node, for example, if the specified track node is a turnout entered at its throat, then "cNodeState" must be specified to choose between the possible paths. If cNodeState = 0, the search will follow the 'continuing' track; if cNodeState = 1, the search will follow the 'diverging' track; if cNodeState = 2 (3-way turnouts only), the search will follow the second 'diverging' track.

In determining which track is the 'continuing' track for RH, LH, and WYE turnouts, this search routine uses the layout turnout's 'continuingState'.

When following track, this method skips over anchor points that are not block boundaries.

When following track, this method treats a modelled 3-way turnout as a single turnout. It also treats two THROAT_TO_THROAT turnouts as a single turnout, but with each turnout having a continuing sense.

Returns a TrackNode if a node or end_of-track is reached. Returns null if trouble following the track.


getExitBlockForTrackNode

public Block getExitBlockForTrackNode(TrackNode node,
                                      Block excludedBlock)
Returns an "exit block" for the specified track node if there is one, else returns null. An "exit block" must be different from the block of the track segment in the node. If the node is a PositionablePoint, it is assumed to be a block boundary anchor point. If an "excludedBlock" is entered, that block will not be returned as the exit block of a Node of type TURNOUT_x.


isTurnoutConnectivityComplete

public boolean isTurnoutConnectivityComplete()
This flag can be checked after performing a getTurnoutList() to check if the connectivity of the turnouts has been completed in the block when the getTurnoutList() was called. Returns 'false' if a turnout conectivity is not complete. Returns 'true' if the turnout conectivity is complete.


getAllTurnoutsThisBlock

public ArrayList<LayoutTurnout> getAllTurnoutsThisBlock(LayoutBlock lb)


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