Class LayoutBlock
- All Implemented Interfaces:
PropertyChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,NamedBean
LayoutBlocks may have an occupancy Sensor. The getOccupancy method returns the occupancy state of the LayoutBlock - OCCUPIED, EMPTY, or UNKNOWN. If no occupancy sensor is provided, UNKNOWN is returned. The occupancy sensor if there is one, is the same as the occupancy sensor of the corresponding JMRI Block.
The name of each Layout Block is the same as that of the corresponding block as defined in Layout Editor. A corresponding JMRI Block object is created when a LayoutBlock is created. The JMRI Block uses the name of the block defined in Layout Editor as its user name and a unique IBnnn system name. The JMRI Block object and its associated Path objects are useful in tracking a train around the layout. Blocks may be viewed in the Block Table.
A LayoutBlock may have an associated Memory object. This Memory object contains a string representing the current "value" of the corresponding JMRI Block object. If the value contains a train name, for example, displaying Memory objects associated with LayoutBlocks, and displayed near each Layout Block can follow a train around the layout, displaying its name when it is in the LayoutBlock.
LayoutBlocks are "cross-panel", similar to sensors and turnouts. A LayoutBlock may be used by more than one Layout Editor panel simultaneously. As a consequence, LayoutBlocks are saved with the configuration, not with a panel.
LayoutBlocks are used by TrackSegments, LevelXings, and LayoutTurnouts. LevelXings carry two LayoutBlock designations, which may be the same. LayoutTurnouts carry LayoutBlock designations also, one per turnout, except for double crossovers and slips which can have up to four.
LayoutBlocks carry a use count. The use count counts the number of track segments, layout turnouts, and levelcrossings which use the LayoutBlock. Only LayoutBlocks which have a use count greater than zero are saved when the configuration is saved.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) static final intstatic final int(package private) int(package private) static final intstatic final intstatic final StringString property constant for hop.static final StringString property constant for length.static final StringString property constant for metric.static final StringString property constant for neighbour length.static final StringString property constant for neighbour metric.static final StringString property constant for neighbour packet flow.static final StringString property constant for path.static final StringString property constant for redraw.static final StringString property constant for routing.static final StringString property constant for through path added.static final StringString property constant for through path removed.static final StringString property constant for valid.(package private) static final intstatic final int(package private) static final int(package private) static final int(package private) static long(package private) static final int(package private) static final intFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddLayoutEditor(LayoutEditor panel) Keep track of LayoutEditor panels that are using this LayoutBlock.voidAdd aPropertyChangeListenerto the listener list.(package private) voidaddRouteFromNeighbour(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) (package private) voidaddRouteToNeighbours(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro) (package private) booleancheckIsRouteOnValidThroughPath(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r) When a route is created, check to see if the through path that this route relates to is active.(package private) StringdecodePacketFlow(int value) voidvoiddeleteLayoutEditor(LayoutEditor panel) voidDeprecated, for removal: This API element is subject to removal in a future version.voideditLayoutBlock(Component callingPane) voidDeprecated, for removal: This API element is subject to removal in a future version.getActiveNextBlocks(Block source) (package private) jmri.jmrit.display.layoutEditor.LayoutBlock.AdjacenciesgetAdjacency(Block blk) (package private) intFor 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.(package private) jmri.jmrit.display.layoutEditor.LayoutBlock.RoutesgetBestRouteByHop(Block dest) (package private) jmri.jmrit.display.layoutEditor.LayoutBlock.RoutesgetBestRouteByLength(Block dest) (package private) jmri.jmrit.display.layoutEditor.LayoutBlock.RoutesgetBestRouteByMetric(Block dest) getBlock()Get the Block corresponding to this LayoutBlock.Get the color for drawing items in this block.intgetBlockHopCount(Block destination, Block nextBlock) Get the number of layout blocks to our destintation block going from the next directly connected block.floatgetBlockLength(Block destination, Block nextBlock) Get the distance to our desintation block going from the next directly connected block.intGet the layout block metric costintgetBlockMetric(Block destination, Block nextBlock) Get the metric to our desintation block going from the next directly connected block.(package private) int(package private) StringintgetConnectedBlockRouteIndex(Block destBlock, int direction) (package private) List<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes>getDestRoutes(Block dstBlock) Get a list of valid Routes to our destination blockgetId()Get the panel with the highest connectivity to this Layout Block.Get Memory.Returns Memory namegetNeighbourAtIndex(int i) Get the neighboring block at index i.intgetNeighbourDirection(int i) Get the direction of travel to neighbouring block at index i.intgetNeighbourDirection(Block neighbourBlock) intgetNeighbourDirection(LayoutBlock neigh) Get the direction of travel to our neighbouring block.(package private) intgetNeighbourIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies adj) intgetNeighbourMetric(int i) Get the metric/cost to neighbouring block at index i.Get the flow of traffic to and from neighbouring block at index i RXTX - Means Traffic can flow both ways between the blocks RXONLY - Means we can only receive traffic from our neighbour, we can not send traffic to it TXONLY - Means we do not receive traffic from our neighbour, but can send traffic to it.intgetNextBestBlock(Block previousBlock, Block destBlock, List<Integer> excludeBlock, LayoutBlockConnectivityTools.Metric routingMethod) last index - the index of the last block we returned ie we last returned index 10, so we don't want to return it again.getNextBlock(Block destBlock, int direction) getNextBlock(Block previousBlock, Block destBlock) Used if we already know the block prior to our block, and the destination block. direction, is optional and is used where the previousBlock is equal to our block.intgetNextBlockByIndex(Block destBlock, int direction, int offSet) intgetNextBlockByIndex(Block previousBlock, Block destBlock, int offSet) (package private) Integer(package private) List<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes>getNextRoutes(Block nxtBlock) Get a list of valid Routes via our next blockintGet the number of neighbor blocks attached to this block.intGet the number of routes that the block has registered.intGet the number of valid through paths on this block.intTest block occupancy.Get occupancy Sensor.Get occupancy Sensor name.intGet occupied sensor state.(package private) jmri.jmrit.display.layoutEditor.LayoutBlock.RoutesgetRouteByDestBlock(Block blk) (package private) List<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes>getRouteByNeighbour(Block blk) getRouteDestBlockAtIndex(int i) Get the destination block at route iintgetRouteDirectionAtIndex(int i) Get the direction of route i.intgetRouteHopCountAtIndex(int i) Get the hop count of route i.
The Hop count is the number of other blocks that we traverse to get to the destination(package private) intgetRouteIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r) floatgetRouteLengthAtIndex(int i) Get the length of route i.
The length is the combined length of all the blocks that we traverse to get to the destinationintgetRouteMetric(int i) Get the metric/cost at route igetRouteNextBlockAtIndex(int i) Get the next block at route iintgetRouteState(int i) Get the state (Occupied, unoccupied) of the destination layout block at index igetRouteStateAsString(int i) Get the state of the destination layout block at index i as a string.booleangetRouteValid(int i) Is the route to the destination potentially valid from our block.intgetState()Provide generic access to internal state.getThroughPathDestination(int i) Get the destination block at index iintgetThroughPathIndex(Block sourceBlock, Block destinationBlock) getThroughPathSource(int i) Get the source block at index igetUsageReport(NamedBean bean) Get a list of references for the specified bean.intboolean(package private) jmri.jmrit.display.layoutEditor.LayoutBlock.RoutesgetValidRoute(Block nxtBlock, Block dstBlock) Get valid Routes, based upon the next block and destination block(package private) voidHandle tasks when block changesvoidvoidCompletes the creation of a LayoutBlock object by adding a Block to it.voidbooleanisActive()"active" is true if the object is still displayed, and should be stored.booleanisNeighbourMutual(int i) Is our neighbouring block at index i a mutual neighbour, ie both blocks have each other registered as neighbours and are exchanging information.booleanisOnPanel(LayoutEditor panel) booleanisRouteToDestValid(Block protecting, Block destination) Is the route to the destination block, going via our neighbouring block valid. ie Does the block have a route registered via neighbour "protecting" to the destination block.isThroughPathActive(int i) Is the through path at index i active?(package private) booleanisValidNeighbour(Block blk) (package private) voidnotifiedNeighbourNoLongerMutual(LayoutBlock srcBlock) voidProvide an output to the console of all our neighbouring blocks.voidProvide an output to the console of all the remote blocks reachable from our block.voidprintRoutes(String inBlockName) Provide an output to the console of how to reach a specific block from our block.voidProvide an output to the console of all the valid paths through this block.voidvoidRedraw panels using this layout block.voidGo through all the routes and refresh the valid flag.(package private) voidremove()Remove this object from display and persistance.voidsetBlockExtraColor(Color color) (package private) voidSet the block metric based upon the track segment that the block is associated with if the (200 if Side, 50 if Main).voidsetBlockMetric(int m) Set a metric cost against a block, this is used in the calculation of a path between two location on the layout, a lower path cost is always preferred For Layout blocks defined as Mainline the default metric is 50.voidsetBlockOccupiedColor(Color color) voidsetBlockTrackColor(Color color) voidvoidsetMemoryName(String name) Add Memory by name.voidsetOccupancySensorName(String name) Add occupancy sensor by name.voidsetOccupiedSense(int sense) Set occupied sensor state.(package private) voidsetRoutesValid(Block nxtHopActive, boolean state) Set the valid flag for routes that are on a valid through path.voidsetState(int i) Does nothing, do not use.Dummy for completion of NamedBean interfacevoidsetSuppressNameUpdate(boolean set) Set/reset update of memory name when block goes from occupied to unoccupied or vice versa.voidsetUseExtraColor(boolean b) (package private) voidprotected voidupdateNeighbourPacketFlow(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies neighbour, int flow) (package private) booleanupdatePacketActedUpon(Integer packetID) voidCheck/Update Path objects for the attached BlockvoidCheck/Update Path objects for the attached Block using the connectivity in the specified Layout Editor panel.(package private) voidupdateRoutesToNeighbours(List<Block> messageRecipients, jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) (package private) voidupdateRoutingInfo(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes route) (package private) voidupdateRoutingInfo(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) booleanvoiduseDefaultMetric(boolean boo) validateMemory(String memName, Component openFrame) Validate that the memory name corresponds to an existing memory.validateSensor(String sensorName, Component openFrame) Validate that the supplied occupancy sensor name corresponds to an existing sensor and is unique among all blocks.booleanvalidThroughPath(Block sourceBlock, Block destinationBlock) voidMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
compareTo, getRecommendedToolTip
-
Field Details
-
OCCUPIED
- See Also:
-
EMPTY
- See Also:
-
PROPERTY_REDRAW
String property constant for redraw.- See Also:
-
PROPERTY_ROUTING
String property constant for routing.- See Also:
-
PROPERTY_PATH
String property constant for path.- See Also:
-
PROPERTY_THROUGH_PATH_ADDED
String property constant for through path added.- See Also:
-
PROPERTY_THROUGH_PATH_REMOVED
String property constant for through path removed.- See Also:
-
PROPERTY_NEIGHBOUR_PACKET_FLOW
String property constant for neighbour packet flow.- See Also:
-
PROPERTY_NEIGHBOUR_METRIC
String property constant for neighbour metric.- See Also:
-
PROPERTY_NEIGHBOUR_LENGTH
String property constant for neighbour length.- See Also:
-
PROPERTY_VALID
String property constant for valid.- See Also:
-
PROPERTY_LENGTH
String property constant for length.- See Also:
-
PROPERTY_HOP
String property constant for hop.- See Also:
-
PROPERTY_METRIC
String property constant for metric.- See Also:
-
neighbourDir
-
active
boolean active -
time
-
RESERVED
- See Also:
-
ADDITION
- See Also:
-
UPDATE
- See Also:
-
REMOVAL
- See Also:
-
RXTX
- See Also:
-
RXONLY
- See Also:
-
TXONLY
- See Also:
-
NONE
- See Also:
-
metric
int metric
-
-
Constructor Details
-
LayoutBlock
Creates a LayoutBlock object. Note: initializeLayoutBlock() must be called to complete the process. They are split so that loading of panel files will be independent of whether LayoutBlocks or Blocks are loaded first.- Parameters:
sName- System name of this LayoutBlockuName- User name of this LayoutBlock but also the user name of the associated Block
-
-
Method Details
-
enableDeleteRouteLog
Deprecated, for removal: This API element is subject to removal in a future version. -
disableDeleteRouteLog
Deprecated, for removal: This API element is subject to removal in a future version. -
initializeLayoutBlock
Completes the creation of a LayoutBlock object by adding a Block to it. The block create process takes into account that the _bean register process considers IB1 and IB01 to be the same name which results in a silent failure. -
initializeLayoutBlockRouting
-
getId
-
getBlockTrackColor
-
setBlockTrackColor
-
getBlockOccupiedColor
-
setBlockOccupiedColor
-
getBlockExtraColor
-
setBlockExtraColor
-
getUseExtraColor
-
setUseExtraColor
-
incrementUse
-
decrementUse
-
getUseCount
-
addLayoutEditor
Keep track of LayoutEditor panels that are using this LayoutBlock.- Parameters:
panel- to keep track of
-
deleteLayoutEditor
-
isOnPanel
-
redrawLayoutBlockPanels
Redraw panels using this layout block. -
validateSensor
Validate that the supplied occupancy sensor name corresponds to an existing sensor and is unique among all blocks. If valid, returns the sensor and sets the block sensor name in the block. Else returns null, and does nothing to the block.- Parameters:
sensorName- to checkopenFrame- determines theFramein which the dialog is displayed; ifnull, or if theparentComponenthas noFrame, a defaultFrameis used- Returns:
- the validated sensor
-
validateMemory
Validate that the memory name corresponds to an existing memory. If valid, returns the memory. Else returns null, and notifies the user.- Parameters:
memName- the memory nameopenFrame- the frame to display any error dialog in- Returns:
- the memory
-
getBlockColor
Get the color for drawing items in this block. Returns color based on block occupancy.- Returns:
- color for block
-
getBlock
Get the Block corresponding to this LayoutBlock.- Returns:
- block
-
getMemoryName
Returns Memory name- Returns:
- name of memory
-
getMemory
Get Memory.- Returns:
- memory bean
-
setMemoryName
Add Memory by name.- Parameters:
name- for memory
-
setMemory
-
getOccupancySensorName
Get occupancy Sensor name.- Returns:
- name of occupancy sensor
-
getOccupancySensor
Get occupancy Sensor.If a sensor has not been assigned, try getting the sensor from the related block.
When setting the layout block sensor from the block itself using the OccupancySensorChange event, the automatic assignment has to be disabled for the sensor checking performed by
LayoutBlockManager.getBlockWithSensorAssigned(jmri.Sensor)- Returns:
- occupancy sensor or null
-
setOccupancySensorName
Add occupancy sensor by name.- Parameters:
name- for senor to add
-
getOccupiedSense
Get occupied sensor state.- Returns:
- occupied sensor state, defaults to Sensor.ACTIVE
-
setOccupiedSense
Set occupied sensor state.- Parameters:
sense- eg. Sensor.INACTIVE
-
getOccupancy
Test block occupancy.- Returns:
- occupancy state
-
getState
Description copied from interface:NamedBeanProvide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.
-
setState
Does nothing, do not use.Dummy for completion of NamedBean interface -
getMaxConnectedPanel
Get the panel with the highest connectivity to this Layout Block.- Returns:
- panel with most connections to this block
-
updatePaths
Check/Update Path objects for the attached BlockIf multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects).
-
updatePathsUsingPanel
Check/Update Path objects for the attached Block using the connectivity in the specified Layout Editor panel.- Parameters:
panel- to extract paths
-
handleBlockChange
Handle tasks when block changes- Parameters:
e- propChgEvent
-
setSuppressNameUpdate
Set/reset update of memory name when block goes from occupied to unoccupied or vice versa. If set is true, name update is suppressed. If set is false, name update works normally.- Parameters:
set- true, update suppress. false, update normal
-
editLayoutBlock
-
remove
void remove()Remove this object from display and persistance. -
isActive
"active" is true if the object is still displayed, and should be stored.- Returns:
- active
-
setBlockMetric
void setBlockMetric()Set the block metric based upon the track segment that the block is associated with if the (200 if Side, 50 if Main). If the block is assigned against multiple track segments all with different types then the highest type will be used. In theory no reason why it couldn't be a compromise. -
useDefaultMetric
-
useDefaultMetric
-
setBlockMetric
Set a metric cost against a block, this is used in the calculation of a path between two location on the layout, a lower path cost is always preferred For Layout blocks defined as Mainline the default metric is 50. For Layout blocks defined as a Siding the default metric is 200.- Parameters:
m- metric value
-
getBlockMetric
Get the layout block metric cost- Returns:
- metric cost of block
-
addAllThroughPaths
-
updateNeighbourPacketFlow
protected void updateNeighbourPacketFlow(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies neighbour, int flow) -
notifiedNeighbourNoLongerMutual
-
stateUpdate
void stateUpdate() -
getBlockStatus
int getBlockStatus() -
getBlockStatusString
-
getNextPacketID
-
updatePacketActedUpon
-
getActiveNextBlocks
-
getThroughPathSourcePathAtIndex
-
getThroughPathDestinationPathAtIndex
-
validThroughPath
-
getThroughPathIndex
-
decodePacketFlow
-
printValidThroughPaths
Provide an output to the console of all the valid paths through this block. -
printAdjacencies
Provide an output to the console of all our neighbouring blocks. -
printRoutes
Provide an output to the console of all the remote blocks reachable from our block. -
printRoutes
Provide an output to the console of how to reach a specific block from our block.- Parameters:
inBlockName- to find in route
-
getNextBlock
- Parameters:
destBlock- is the destination of the block we are followingdirection- is the direction of travel from the previous block- Returns:
- next block
-
getNextBlock
Used if we already know the block prior to our block, and the destination block. direction, is optional and is used where the previousBlock is equal to our block.- Parameters:
previousBlock- start blockdestBlock- finish block- Returns:
- next block
-
getConnectedBlockRouteIndex
-
getNextBlockByIndex
-
getNextBlockByIndex
-
getNextBestBlock
public int getNextBestBlock(Block previousBlock, Block destBlock, List<Integer> excludeBlock, LayoutBlockConnectivityTools.Metric routingMethod) last index - the index of the last block we returned ie we last returned index 10, so we don't want to return it again. The block returned will have a hopcount or metric equal to or greater than the one of the last block returned. if the exclude block list is empty this is the first time, it has been used. The parameters for the best last block are based upon the last entry in the excludedBlock list.- Parameters:
previousBlock- starting blockdestBlock- finish blockexcludeBlock- blocks to skiproutingMethod- value to match metric- Returns:
- next block
-
getRouteByDestBlock
-
getRouteByNeighbour
-
getAdjacencyPacketFlow
-
isValidNeighbour
-
addPropertyChangeListener
Description copied from class:AbstractNamedBeanAdd aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Overrides:
addPropertyChangeListenerin classAbstractNamedBean- Parameters:
listener- The PropertyChangeListener to be added
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
getValidRoute
@CheckForNull jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getValidRoute(Block nxtBlock, Block dstBlock) Get valid Routes, based upon the next block and destination block- Parameters:
nxtBlock- next blockdstBlock- final block- Returns:
- routes that fit, or null
-
isRouteToDestValid
Is the route to the destination block, going via our neighbouring block valid. ie Does the block have a route registered via neighbour "protecting" to the destination block.- Parameters:
protecting- neighbour block that might protectdestination- block- Returns:
- true if we have valid path to block
-
getDestRoutes
Get a list of valid Routes to our destination block- Parameters:
dstBlock- target to find- Returns:
- routes between this and dstBlock
-
getNextRoutes
Get a list of valid Routes via our next block- Parameters:
nxtBlock- target block- Returns:
- list of routes to target block
-
updateRoutingInfo
-
updateRoutingInfo
void updateRoutingInfo(@Nonnull LayoutBlock src, @Nonnull jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) -
updateRoutesToNeighbours
void updateRoutesToNeighbours(List<Block> messageRecipients, jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) -
getBestRouteByMetric
-
getBestRouteByHop
-
getBestRouteByLength
-
addRouteToNeighbours
-
addRouteFromNeighbour
void addRouteFromNeighbour(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update) -
getNeighbourDirection
Get the direction of travel to our neighbouring block.- Parameters:
neigh- neighbor block- Returns:
- direction to get to neighbor block
-
getNeighbourDirection
-
getAdjacency
-
getNumberOfNeighbours
Get the number of neighbor blocks attached to this block.- Returns:
- count of neighbor
-
getNeighbourAtIndex
Get the neighboring block at index i.- Parameters:
i- index to neighbor- Returns:
- neighbor block
-
getNeighbourDirection
Get the direction of travel to neighbouring block at index i.- Parameters:
i- index in neighbors- Returns:
- neighbor block
-
getNeighbourMetric
Get the metric/cost to neighbouring block at index i.- Parameters:
i- index in neighbors- Returns:
- metric of neighbor
-
getNeighbourPacketFlowAsString
Get the flow of traffic to and from neighbouring block at index i RXTX - Means Traffic can flow both ways between the blocks RXONLY - Means we can only receive traffic from our neighbour, we can not send traffic to it TXONLY - Means we do not receive traffic from our neighbour, but can send traffic to it.- Parameters:
i- index in neighbors- Returns:
- direction of traffic
-
isNeighbourMutual
Is our neighbouring block at index i a mutual neighbour, ie both blocks have each other registered as neighbours and are exchanging information.- Parameters:
i- index of neighbor- Returns:
- true if both are mutual neighbors
-
getNeighbourIndex
-
getNumberOfRoutes
Get the number of routes that the block has registered.- Returns:
- count of routes
-
getRouteDirectionAtIndex
Get the direction of route i.- Parameters:
i- index in routes- Returns:
- direction
-
getRouteDestBlockAtIndex
Get the destination block at route i- Parameters:
i- index in routes- Returns:
- dest block from route
-
getRouteNextBlockAtIndex
Get the next block at route i- Parameters:
i- index in routes- Returns:
- next block from route
-
getRouteHopCountAtIndex
Get the hop count of route i.
The Hop count is the number of other blocks that we traverse to get to the destination- Parameters:
i- index in routes- Returns:
- hop count
-
getRouteLengthAtIndex
Get the length of route i.
The length is the combined length of all the blocks that we traverse to get to the destination- Parameters:
i- index in routes- Returns:
- length of block in route
-
getRouteMetric
Get the metric/cost at route i- Parameters:
i- index in routes- Returns:
- metric
-
getRouteState
Get the state (Occupied, unoccupied) of the destination layout block at index i- Parameters:
i- index in routes- Returns:
- state of block
-
getRouteValid
Is the route to the destination potentially valid from our block.- Parameters:
i- index in route- Returns:
- true if route is valid
-
getRouteStateAsString
Get the state of the destination layout block at index i as a string.- Parameters:
i- index in routes- Returns:
- dest status
-
getRouteIndex
-
getBlockHopCount
Get the number of layout blocks to our destintation block going from the next directly connected block. If the destination block and nextblock are the same and the block is also registered as a neighbour then 1 is returned. If no valid route to the destination block can be found via the next block then -1 is returned. If more than one route exists to the destination then the route with the lowest count is returned.- Parameters:
destination- final blocknextBlock- adjcent block- Returns:
- hop count to final, -1 if not available
-
getBlockMetric
Get the metric to our desintation block going from the next directly connected block. If the destination block and nextblock are the same and the block is also registered as a neighbour then 1 is returned. If no valid route to the destination block can be found via the next block then -1 is returned. If more than one route exists to the destination then the route with the lowest count is returned.- Parameters:
destination- final blocknextBlock- adjcent block- Returns:
- metric to final block, -1 if not available
-
getBlockLength
Get the distance to our desintation block going from the next directly connected block. If the destination block and nextblock are the same and the block is also registered as a neighbour then 1 is returned. If no valid route to the destination block can be found via the next block then -1 is returned. If more than one route exists to the destination then the route with the lowest count is returned.- Parameters:
destination- final blocknextBlock- adjcent block- Returns:
- length to final, -1 if not viable
-
getNumberOfThroughPaths
Get the number of valid through paths on this block.- Returns:
- count of paths through this block
-
getThroughPathSource
Get the source block at index i- Parameters:
i- index in throughPaths- Returns:
- source block
-
getThroughPathDestination
Get the destination block at index i- Parameters:
i- index in throughPaths- Returns:
- final block
-
isThroughPathActive
Is the through path at index i active?- Parameters:
i- index in path- Returns:
- active or not
-
getThroughPathSourceByDestination
-
getThroughPathDestinationBySource
-
checkIsRouteOnValidThroughPath
When a route is created, check to see if the through path that this route relates to is active.- Parameters:
r- The route to check- Returns:
- true if that route is active
-
refreshValidRoutes
Go through all the routes and refresh the valid flag. -
setRoutesValid
Set the valid flag for routes that are on a valid through path.- Parameters:
nxtHopActive- the start of the routestate- the state to set into the valid flag
-
vetoableChange
Description copied from class:AbstractNamedBean- Specified by:
vetoableChangein interfaceNamedBean- Overrides:
vetoableChangein classAbstractNamedBean- Throws:
PropertyVetoException
-
getUsageReport
Description copied from interface:NamedBeanGet a list of references for the specified bean.- Specified by:
getUsageReportin interfaceNamedBean- Parameters:
bean- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
getBeanType
Description copied from interface:NamedBeanFor 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:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-