jmri.jmrit.display.layoutEditor
Class LayoutBlock

Show UML class diagram
java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.jmrit.display.layoutEditor.LayoutBlock
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, NamedBean

public class LayoutBlock
extends AbstractNamedBean
implements PropertyChangeListener

A LayoutBlock is a group of track segments and turnouts on a LayoutEditor panel corresponding to a 'block'. LayoutBlock is a LayoutEditor specific extension of the JMRI Block object.

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 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.

See Also:
Serialized Form

Field Summary
(package private)  ArrayList<Integer> actedUponUpdates
           
(package private)  boolean active
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths> activePaths
           
(package private) static int ADDITION
           
(package private)  JComboBox attachedBlocks
           
(package private)  LayoutEditorAuxTools auxTool
           
(package private)  JButton blockEditCancel
           
(package private)  JButton blockEditDone
           
 Color blockExtraColor
           
 String blockName
           
 Color blockOccupiedColor
           
(package private)  JComboBox blockSpeedBox
           
 Color blockTrackColor
           
(package private)  JLabel blockUseLabel
           
(package private)  Component callingPane
           
(package private)  Color[] colorCode
           
(package private)  String[] colorText
          Methods and data to support initialization of color Combo box
(package private)  ConnectivityUtil connection
           
(package private)  boolean defaultMetric
           
(package private)  JmriJFrame editLayoutBlockFrame
           
(package private)  boolean editOpen
           
static int EMPTY
           
 boolean enableAddRouteLogging
           
 boolean enableDeleteRouteLogging
           
 boolean enableSearchRouteLogging
           
 boolean enableUpdateRouteLogging
           
(package private)  JComboBox extraColorBox
           
(package private)  boolean layoutConnectivity
           
 String lbSystemName
           
protected  Vector<PropertyChangeListener> listeners
           
(package private) static org.slf4j.Logger log
           
 String memoryName
           
(package private)  JTextField memoryNameField
           
(package private)  int metric
           
(package private)  JTextField metricField
           
(package private)  ArrayList<JComboBox> neighbourDir
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies> neighbours
           
(package private) static int NONE
           
(package private)  int numColors
           
 String occupancySensorName
           
static int OCCUPIED
           
(package private)  JComboBox occupiedColorBox
           
 int occupiedSense
           
(package private)  PropertyChangeSupport pcs
           
(package private)  JCheckBox permissiveCheck
           
(package private)  ResourceBundle rb
           
(package private) static int REMOVAL
           
static int RESERVED
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> routes
           
(package private) static int RXONLY
           
(package private) static int RXTX
           
(package private)  int senseActiveIndex
           
(package private)  JComboBox senseBox
           
(package private)  int senseInactiveIndex
           
(package private)  JTextField sensorDebounceActiveField
           
(package private)  JCheckBox sensorDebounceGlobalCheck
           
(package private)  JTextField sensorDebounceInactiveField
           
(package private)  JTextField sensorNameField
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths> throughPaths
           
(package private) static long time
           
(package private)  JComboBox trackColorBox
           
(package private) static int TXONLY
           
static int UNKNOWN
           
(package private) static int UPDATE
           
(package private) static ArrayList<Integer> updateReferences
           
(package private)  String[] working
           
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT
 
Constructor Summary
LayoutBlock(String sName, String uName)
           
 
Method Summary
(package private)  void addAdjacency(Path addPath)
           
 void addAllThroughPaths()
           
 void addLayoutEditor(LayoutEditor panel)
          Keeps track of LayoutEditor panels that are using this LayoutBlock
(package private)  void addNeighbour(Block addBlock, int direction, int workingDirection)
           
 void addPropertyChangeListener(PropertyChangeListener l)
           
(package private)  void addRouteFromNeighbour(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)
           
(package private)  void addRouteToNeighbours(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro)
           
(package private)  void addThroughPath(Block srcBlock, Block dstBlock)
           
(package private)  void addThroughPath(Block srcBlock, Block dstBlock, LayoutEditor panel)
          This is used to add a through path on this layout block, going from the source block to the destination block, using a specific panel.
(package private)  void addThroughPath(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies adj)
           
(package private)  void blockEditCancelPressed(ActionEvent a)
           
(package private)  void blockEditDonePressed(ActionEvent a)
           
(package private)  boolean checkIsRouteOnValidThroughPath(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r)
           
static String colorToString(Color color)
          Utility methods for converting between string and color Note: These names are only used internally, so don't need a resource bundle
(package private)  String decodePacketFlow(int value)
           
 void decrementUse()
           
 void deleteLayoutEditor(LayoutEditor panel)
           
(package private)  int determineAdjPacketFlow(int our, int neigh)
           
 void disableDeleteRouteLog()
           
protected  void editLayoutBlock(Component callingPane)
          Edit a Layout Block
 void enableDeleteRouteLog()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 ArrayList<Block> getActiveNextBlocks(Block source)
           
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies getAdjacency(Block blk)
           
(package private)  int getAdjacencyPacketFlow(Block blk)
           
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByHop(Block dest)
           
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByLength(Block dest)
           
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByMetric(Block dest)
           
 Block getBlock()
          Get the jmri.Block corresponding to this LayoutBlock
 Color getBlockColor()
          Returns the color for drawing items in this block.
 Color getBlockExtraColor()
           
 int getBlockHopCount(Block destination, Block nextBlock)
          Returns the number of layout blocks to our desintation block going from the next directly connected block.
 float getBlockLength(Block destination, Block nextBlock)
          Returns the distance to our desintation block going from the next directly connected block.
 int getBlockMetric()
          Returns the layout block metric cost
 int getBlockMetric(Block destination, Block nextBlock)
          Returns the metric to our desintation block going from the next directly connected block.
 Color getBlockOccupiedColor()
           
(package private)  int getBlockStatus()
           
 Color getBlockTrackColor()
           
 int getConnectedBlockRouteIndex(Block destBlock, int direction)
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getDestRoutes(Block dstBlock)
          Returns a list of valid Routes to our destination block
 String getID()
          Accessor methods
 LayoutEditor getMaxConnectedPanel()
          Get the Layout Editor panel with the highest connectivity to this Layout Block
 Memory getMemory()
          Returns Memory
 String getMemoryName()
          Returns Memory name
 Block getNeighbourAtIndex(int i)
          Get the neighbouring block at index i
 int getNeighbourDirection(Block neighbourBlock)
           
 int getNeighbourDirection(int i)
          Get the direction of travel to neighbouring block at index i
 int getNeighbourDirection(LayoutBlock neigh)
          Gets the direction of travel to our neighbouring block.
(package private)  int getNeighbourIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies adj)
           
 int getNeighbourMetric(int i)
          Get the metric/cost to neighbouring block at index i
 String getNeighbourPacketFlowAsString(int 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 recieve traffic from our neighbour, we can not send traffic to it TXONLY - Means we do not recieve traffic from our neighbour, but can send traffic to it.
 int getNextBestBlock(Block previousBlock, Block destBlock, List<Integer> excludeBlock, int 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.
 Block getNextBlock(Block previousBlock, Block destBlock)
          Used if we already know the block prior to our block, and the destination block.
 Block getNextBlock(Block destBlock, int direction)
           
 int getNextBlockByIndex(Block previousBlock, Block destBlock, int offSet)
           
 int getNextBlockByIndex(Block destBlock, int direction, int offSet)
           
(package private)  Integer getNextPacketID()
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getNextRoutes(Block nxtBlock)
          Returns a list of valid Routes via our next block
 int getNumberOfNeighbours()
          Get the number of neighbour blocks attached to this block
 int getNumberOfRoutes()
          Get the number of routes that the block has registered.
 int getNumberOfThroughPaths()
          Returns the number of valid through paths on this block.
 int getOccupancy()
          Test block occupancy
 Sensor getOccupancySensor()
          Returns occupancy Sensor
 String getOccupancySensorName()
          Returns occupancy Sensor name
 int getOccupiedSense()
          Get/Set occupied sense
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getRouteByDestBlock(Block blk)
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getRouteByNeighbour(Block blk)
           
 Block getRouteDestBlockAtIndex(int i)
          Get the destination block at route i
 int getRouteDirectionAtIndex(int i)
          Get the direction of route i.
 int getRouteHopCountAtIndex(int i)
          Get the hop count of route i.
(package private)  int getRouteIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r)
           
 float getRouteLengthAtIndex(int i)
          Get the length of route i.
 int getRouteMetric(int i)
          Get the metric/cost at route i
 Block getRouteNextBlockAtIndex(int i)
          Get the next block at route i
 int getRouteState(int i)
          Gets the state (Occupied, unoccupied) of the destination layout block at index i
 String getRouteStateAsString(int i)
          Gets the state of the destination layout block at index i as a string
 boolean getRouteValid(int i)
          Is the route to the destination potentially valid from our block.
 int getState()
          Provide generic access to internal state.
 Block getThroughPathDestination(int i)
          Returns the destination block at index i
(package private)  ArrayList<Block> getThroughPathDestinationBySource(Block source)
           
 Path getThroughPathDestinationPathAtIndex(int i)
           
 int getThroughPathIndex(Block sourceBlock, Block destinationBlock)
           
 Block getThroughPathSource(int i)
          Returns the source block at index i
(package private)  ArrayList<Block> getThroughPathSourceByDestination(Block dest)
           
 Path getThroughPathSourcePathAtIndex(int i)
           
 int getUseCount()
           
 boolean getUseExtraColor()
           
(package private)  jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getValidRoute(Block nxtBlock, Block dstBlock)
          Returns a valid Routes, based upon the next block and destination block
(package private)  void handleBlockChange(PropertyChangeEvent e)
          Handle tasks when block changes
 void incrementUse()
           
(package private)  boolean informNeighbourOfAttachment(LayoutBlock lBlock, Block block, int workingDirection)
           
(package private)  void informNeighbourOfValidRoutes(Block newblock)
           
protected  void initializeLayoutBlock()
           
protected  void initializeLayoutBlockRouting()
           
 boolean isActive()
          "active" means that the object is still displayed, and should be stored.
 boolean isNeighbourMutual(int i)
          Is our neighbouring block at index i a mutual neighbour, ie both blocks have each other registered as neighbours and are exchaning information.
 boolean isOnPanel(LayoutEditor panel)
           
 boolean isRouteToDestValid(Block protecting, Block destination)
          Is the route to the destination block, going via our neighbouring block valid.
 Boolean isThroughPathActive(int i)
          Is the through path at index i active
(package private)  boolean isValidNeighbour(Block blk)
           
(package private)  void notifiedNeighbourNoLongerMutual(LayoutBlock srcBlock)
           
(package private)  void notifyNeighboursOfRemoval(ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> routesToRemove, Block notifyingblk)
           
 void printAdjacencies()
          Provides an output to the console of all our neighbouring blocks
 void printRoutes()
          Provides an output to the console of all the remote blocks reachable from our block
 void printRoutes(String blockName)
          Provides an output to the console of how to reach a specific block from our block
 void printValidThroughPaths()
          Provides an output to the console of all the valid paths through this block
 void propertyChange(PropertyChangeEvent e)
           
 void redrawLayoutBlockPanels()
          Redraws panels using this layout block
 void refreshValidRoutes()
           
(package private)  void remove()
          Removes this object from display and persistance
(package private)  void removeAdjacency(LayoutBlock layoutBlock)
           
(package private)  void removeAdjacency(Path removedPath)
           
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a request for a call-back when a bound property changes.
(package private)  void removeRouteFromNeighbour(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)
           
(package private)  ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> removeRouteRecievedFromNeighbour(Block removedBlock)
           
 void setBlockExtraColor(Color color)
           
(package private)  void setBlockMetric()
          Used to set the block metric based upon the track segment that the block is associated with if the (200 if Side, 50 if Main).
 void setBlockMetric(int m)
          Sets 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.
 void setBlockOccupiedColor(Color color)
           
 void setBlockTrackColor(Color color)
           
 void setMemoryName(String name)
          Add Memory by name
 void setOccupancySensorName(String name)
          Add occupancy sensor by name
 void setOccupiedSense(int sense)
           
(package private)  void setRoutesValid(Block nxtHopActive, boolean state)
           
 void setState(int i)
          Provide generic access to internal state.
 void setSuppressNameUpdate(boolean set)
          Sets/resets update of memory name when block goes from occupied to unoccupied or vice versa.
 void setUseExtraColor(boolean b)
           
(package private)  void stateUpdate()
           
static Color stringToColor(String string)
           
(package private)  void updateActiveThroughPaths(jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths tp, boolean active)
           
(package private)  void updateNeighbourPacketFlow(Block neighbour, int flow)
           
protected  void updateNeighbourPacketFlow(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies neighbour, int flow)
           
(package private)  boolean updatePacketActedUpon(Integer packetID)
           
 void updatePaths()
          Check/Update Path objects for the attached jmri.Block If multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects);
 void updatePathsUsingPanel(LayoutEditor panel)
          Check/Update Path objects for the attached jmri.Block using the connectivity in the specified Layout Editor panel.
(package private)  void updateRoutesToNeighbours(ArrayList<Block> messageRecipients, jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)
           
(package private)  void updateRoutingInfo(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes route)
           
(package private)  void updateRoutingInfo(LayoutBlock src, jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)
           
 boolean useDefaultMetric()
           
 void useDefaultMetric(boolean boo)
           
 Memory validateMemory(String memName, Component openFrame)
          Validates that the memory name corresponds to an existing memory.
 Sensor validateSensor(String sensorName, Component openFrame)
          Validates that the supplied occupancy sensor name corresponds to an existing sensor and is unique among all blocks.
 boolean validThroughPath(Block sourceBlock, Block destinationBlock)
           
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, dispose, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, updateListenerRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enableAddRouteLogging

public boolean enableAddRouteLogging

enableUpdateRouteLogging

public boolean enableUpdateRouteLogging

enableDeleteRouteLogging

public boolean enableDeleteRouteLogging

enableSearchRouteLogging

public boolean enableSearchRouteLogging

updateReferences

static ArrayList<Integer> updateReferences

actedUponUpdates

ArrayList<Integer> actedUponUpdates

rb

ResourceBundle rb

OCCUPIED

public static final int OCCUPIED
See Also:
Constant Field Values

EMPTY

public static final int EMPTY
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

blockName

public String blockName

lbSystemName

public String lbSystemName

occupancySensorName

public String occupancySensorName

memoryName

public String memoryName

occupiedSense

public int occupiedSense

blockTrackColor

public Color blockTrackColor

blockOccupiedColor

public Color blockOccupiedColor

blockExtraColor

public Color blockExtraColor

editLayoutBlockFrame

JmriJFrame editLayoutBlockFrame

callingPane

Component callingPane

sensorNameField

JTextField sensorNameField

sensorDebounceInactiveField

JTextField sensorDebounceInactiveField

sensorDebounceActiveField

JTextField sensorDebounceActiveField

sensorDebounceGlobalCheck

JCheckBox sensorDebounceGlobalCheck

memoryNameField

JTextField memoryNameField

metricField

JTextField metricField

senseBox

JComboBox senseBox

permissiveCheck

JCheckBox permissiveCheck

senseActiveIndex

int senseActiveIndex

senseInactiveIndex

int senseInactiveIndex

trackColorBox

JComboBox trackColorBox

occupiedColorBox

JComboBox occupiedColorBox

extraColorBox

JComboBox extraColorBox

blockSpeedBox

JComboBox blockSpeedBox

blockUseLabel

JLabel blockUseLabel

blockEditDone

JButton blockEditDone

blockEditCancel

JButton blockEditCancel

editOpen

boolean editOpen

attachedBlocks

JComboBox attachedBlocks

working

String[] working

neighbourDir

ArrayList<JComboBox> neighbourDir

colorText

String[] colorText
Methods and data to support initialization of color Combo box


colorCode

Color[] colorCode

numColors

int numColors

active

boolean active

defaultMetric

boolean defaultMetric

time

static long time

auxTool

LayoutEditorAuxTools auxTool

connection

ConnectivityUtil connection

layoutConnectivity

boolean layoutConnectivity

RESERVED

public static final int RESERVED
See Also:
Constant Field Values

neighbours

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies> neighbours

throughPaths

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths> throughPaths

routes

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> routes

listeners

protected Vector<PropertyChangeListener> listeners

pcs

PropertyChangeSupport pcs

ADDITION

static final int ADDITION
See Also:
Constant Field Values

UPDATE

static final int UPDATE
See Also:
Constant Field Values

REMOVAL

static final int REMOVAL
See Also:
Constant Field Values

RXTX

static final int RXTX
See Also:
Constant Field Values

RXONLY

static final int RXONLY
See Also:
Constant Field Values

TXONLY

static final int TXONLY
See Also:
Constant Field Values

NONE

static final int NONE
See Also:
Constant Field Values

metric

int metric

activePaths

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths> activePaths

log

static org.slf4j.Logger log
Constructor Detail

LayoutBlock

public LayoutBlock(String sName,
                   String uName)
Method Detail

enableDeleteRouteLog

public void enableDeleteRouteLog()

disableDeleteRouteLog

public void disableDeleteRouteLog()

initializeLayoutBlock

protected void initializeLayoutBlock()

initializeLayoutBlockRouting

protected void initializeLayoutBlockRouting()

getID

public String getID()
Accessor methods


getBlockTrackColor

public Color getBlockTrackColor()

setBlockTrackColor

public void setBlockTrackColor(Color color)

getBlockOccupiedColor

public Color getBlockOccupiedColor()

setBlockOccupiedColor

public void setBlockOccupiedColor(Color color)

getBlockExtraColor

public Color getBlockExtraColor()

setBlockExtraColor

public void setBlockExtraColor(Color color)

getUseExtraColor

public boolean getUseExtraColor()

setUseExtraColor

public void setUseExtraColor(boolean b)

incrementUse

public void incrementUse()

decrementUse

public void decrementUse()

getUseCount

public int getUseCount()

addLayoutEditor

public void addLayoutEditor(LayoutEditor panel)
Keeps track of LayoutEditor panels that are using this LayoutBlock


deleteLayoutEditor

public void deleteLayoutEditor(LayoutEditor panel)

isOnPanel

public boolean isOnPanel(LayoutEditor panel)

redrawLayoutBlockPanels

public void redrawLayoutBlockPanels()
Redraws panels using this layout block


validateSensor

public Sensor validateSensor(String sensorName,
                             Component openFrame)
Validates 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. This method also converts the sensor name to upper case if it is a system name.


validateMemory

public Memory validateMemory(String memName,
                             Component openFrame)
Validates that the memory name corresponds to an existing memory. If valid, returns the memory. Else returns null, and notifies the user. This method also converts the memory name to upper case if it is a system name.


getBlockColor

public Color getBlockColor()
Returns the color for drawing items in this block. Returns color based on block occupancy.


getBlock

public Block getBlock()
Get the jmri.Block corresponding to this LayoutBlock


getMemoryName

public String getMemoryName()
Returns Memory name


getMemory

public Memory getMemory()
Returns Memory


setMemoryName

public void setMemoryName(String name)
Add Memory by name


getOccupancySensorName

public String getOccupancySensorName()
Returns occupancy Sensor name


getOccupancySensor

public Sensor getOccupancySensor()
Returns occupancy Sensor


setOccupancySensorName

public void setOccupancySensorName(String name)
Add occupancy sensor by name


getOccupiedSense

public int getOccupiedSense()
Get/Set occupied sense


setOccupiedSense

public void setOccupiedSense(int sense)

getOccupancy

public int getOccupancy()
Test block occupancy


getState

public int getState()
Description copied from interface: NamedBean
Provide 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 provided to make Jython script access easier to read.

Specified by:
getState in interface NamedBean

setState

public void setState(int i)
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. setCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
setState in interface NamedBean

getMaxConnectedPanel

public LayoutEditor getMaxConnectedPanel()
Get the Layout Editor panel with the highest connectivity to this Layout Block


updatePaths

public void updatePaths()
Check/Update Path objects for the attached jmri.Block

If multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects);


updatePathsUsingPanel

public void updatePathsUsingPanel(LayoutEditor panel)
Check/Update Path objects for the attached jmri.Block using the connectivity in the specified Layout Editor panel.


handleBlockChange

void handleBlockChange(PropertyChangeEvent e)
Handle tasks when block changes


setSuppressNameUpdate

public void setSuppressNameUpdate(boolean set)
Sets/resets 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.


editLayoutBlock

protected void editLayoutBlock(Component callingPane)
Edit a Layout Block


blockEditDonePressed

void blockEditDonePressed(ActionEvent a)

blockEditCancelPressed

void blockEditCancelPressed(ActionEvent a)

colorToString

public static String colorToString(Color color)
Utility methods for converting between string and color Note: These names are only used internally, so don't need a resource bundle


stringToColor

public static Color stringToColor(String string)

remove

void remove()
Removes this object from display and persistance


isActive

public boolean isActive()
"active" means that the object is still displayed, and should be stored.


setBlockMetric

void setBlockMetric()
Used to 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

public boolean useDefaultMetric()

useDefaultMetric

public void useDefaultMetric(boolean boo)

setBlockMetric

public void setBlockMetric(int m)
Sets 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.


getBlockMetric

public int getBlockMetric()
Returns the layout block metric cost


addAllThroughPaths

public void addAllThroughPaths()

addNeighbour

void addNeighbour(Block addBlock,
                  int direction,
                  int workingDirection)

informNeighbourOfAttachment

boolean informNeighbourOfAttachment(LayoutBlock lBlock,
                                    Block block,
                                    int workingDirection)

determineAdjPacketFlow

int determineAdjPacketFlow(int our,
                           int neigh)

informNeighbourOfValidRoutes

void informNeighbourOfValidRoutes(Block newblock)

addAdjacency

void addAdjacency(Path addPath)

removeAdjacency

void removeAdjacency(Path removedPath)

removeAdjacency

void removeAdjacency(LayoutBlock layoutBlock)

removeRouteFromNeighbour

void removeRouteFromNeighbour(LayoutBlock src,
                              jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)

removeRouteRecievedFromNeighbour

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> removeRouteRecievedFromNeighbour(Block removedBlock)

updateNeighbourPacketFlow

void updateNeighbourPacketFlow(Block neighbour,
                               int flow)

updateNeighbourPacketFlow

protected void updateNeighbourPacketFlow(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies neighbour,
                                         int flow)

notifyNeighboursOfRemoval

void notifyNeighboursOfRemoval(ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> routesToRemove,
                               Block notifyingblk)

addThroughPath

void addThroughPath(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies adj)

addThroughPath

void addThroughPath(Block srcBlock,
                    Block dstBlock)

addThroughPath

void addThroughPath(Block srcBlock,
                    Block dstBlock,
                    LayoutEditor panel)
This is used to add a through path on this layout block, going from the source block to the destination block, using a specific panel. Note: That if the reverse path is required, then this need to be added seperately.


notifiedNeighbourNoLongerMutual

void notifiedNeighbourNoLongerMutual(LayoutBlock srcBlock)

stateUpdate

void stateUpdate()

getBlockStatus

int getBlockStatus()

getNextPacketID

Integer getNextPacketID()

updatePacketActedUpon

boolean updatePacketActedUpon(Integer packetID)

getActiveNextBlocks

public ArrayList<Block> getActiveNextBlocks(Block source)

getThroughPathSourcePathAtIndex

public Path getThroughPathSourcePathAtIndex(int i)

getThroughPathDestinationPathAtIndex

public Path getThroughPathDestinationPathAtIndex(int i)

validThroughPath

public boolean validThroughPath(Block sourceBlock,
                                Block destinationBlock)

getThroughPathIndex

public int getThroughPathIndex(Block sourceBlock,
                               Block destinationBlock)

decodePacketFlow

String decodePacketFlow(int value)

printValidThroughPaths

public void printValidThroughPaths()
Provides an output to the console of all the valid paths through this block


printAdjacencies

public void printAdjacencies()
Provides an output to the console of all our neighbouring blocks


printRoutes

public void printRoutes()
Provides an output to the console of all the remote blocks reachable from our block


printRoutes

public void printRoutes(String blockName)
Provides an output to the console of how to reach a specific block from our block


getNextBlock

public Block getNextBlock(Block destBlock,
                          int direction)
Parameters:
destBlock - - is the destination of the block we are following
direction - - is the direction of travel from the previous block

getNextBlock

public Block 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.


getConnectedBlockRouteIndex

public int getConnectedBlockRouteIndex(Block destBlock,
                                       int direction)

getNextBlockByIndex

public int getNextBlockByIndex(Block destBlock,
                               int direction,
                               int offSet)

getNextBlockByIndex

public int getNextBlockByIndex(Block previousBlock,
                               Block destBlock,
                               int offSet)

getNextBestBlock

public int getNextBestBlock(Block previousBlock,
                            Block destBlock,
                            List<Integer> excludeBlock,
                            int 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


getRouteByDestBlock

jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getRouteByDestBlock(Block blk)

getRouteByNeighbour

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getRouteByNeighbour(Block blk)

getAdjacencyPacketFlow

int getAdjacencyPacketFlow(Block blk)

isValidNeighbour

boolean isValidNeighbour(Block blk)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface NamedBean
Overrides:
addPropertyChangeListener in class AbstractNamedBean

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Description copied from interface: NamedBean
Remove a request for a call-back when a bound property changes.

Specified by:
removePropertyChangeListener in interface NamedBean
Overrides:
removePropertyChangeListener in class AbstractNamedBean

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)
Overrides:
firePropertyChange in class AbstractNamedBean

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

getValidRoute

jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getValidRoute(Block nxtBlock,
                                                                 Block dstBlock)
Returns a valid Routes, based upon the next block and destination block


isRouteToDestValid

public boolean isRouteToDestValid(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.


getDestRoutes

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getDestRoutes(Block dstBlock)
Returns a list of valid Routes to our destination block


getNextRoutes

ArrayList<jmri.jmrit.display.layoutEditor.LayoutBlock.Routes> getNextRoutes(Block nxtBlock)
Returns a list of valid Routes via our next block


updateRoutingInfo

void updateRoutingInfo(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes route)

updateRoutingInfo

void updateRoutingInfo(LayoutBlock src,
                       jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)

updateRoutesToNeighbours

void updateRoutesToNeighbours(ArrayList<Block> messageRecipients,
                              jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro,
                              jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)

getBestRouteByMetric

jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByMetric(Block dest)

getBestRouteByHop

jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByHop(Block dest)

getBestRouteByLength

jmri.jmrit.display.layoutEditor.LayoutBlock.Routes getBestRouteByLength(Block dest)

addRouteToNeighbours

void addRouteToNeighbours(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes ro)

addRouteFromNeighbour

void addRouteFromNeighbour(LayoutBlock src,
                           jmri.jmrit.display.layoutEditor.LayoutBlock.RoutingPacket update)

getNeighbourDirection

public int getNeighbourDirection(LayoutBlock neigh)
Gets the direction of travel to our neighbouring block.


getNeighbourDirection

public int getNeighbourDirection(Block neighbourBlock)

getAdjacency

jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies getAdjacency(Block blk)

getNumberOfNeighbours

public int getNumberOfNeighbours()
Get the number of neighbour blocks attached to this block


getNeighbourAtIndex

public Block getNeighbourAtIndex(int i)
Get the neighbouring block at index i


getNeighbourDirection

public int getNeighbourDirection(int i)
Get the direction of travel to neighbouring block at index i


getNeighbourMetric

public int getNeighbourMetric(int i)
Get the metric/cost to neighbouring block at index i


getNeighbourPacketFlowAsString

public String getNeighbourPacketFlowAsString(int 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 recieve traffic from our neighbour, we can not send traffic to it TXONLY - Means we do not recieve traffic from our neighbour, but can send traffic to it.


isNeighbourMutual

public boolean isNeighbourMutual(int i)
Is our neighbouring block at index i a mutual neighbour, ie both blocks have each other registered as neighbours and are exchaning information.


getNeighbourIndex

int getNeighbourIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Adjacencies adj)

getNumberOfRoutes

public int getNumberOfRoutes()
Get the number of routes that the block has registered.


getRouteDirectionAtIndex

public int getRouteDirectionAtIndex(int i)
Get the direction of route i.


getRouteDestBlockAtIndex

public Block getRouteDestBlockAtIndex(int i)
Get the destination block at route i


getRouteNextBlockAtIndex

public Block getRouteNextBlockAtIndex(int i)
Get the next block at route i


getRouteHopCountAtIndex

public int getRouteHopCountAtIndex(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


getRouteLengthAtIndex

public float getRouteLengthAtIndex(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 destination


getRouteMetric

public int getRouteMetric(int i)
Get the metric/cost at route i


getRouteState

public int getRouteState(int i)
Gets the state (Occupied, unoccupied) of the destination layout block at index i


getRouteValid

public boolean getRouteValid(int i)
Is the route to the destination potentially valid from our block.


getRouteStateAsString

public String getRouteStateAsString(int i)
Gets the state of the destination layout block at index i as a string


getRouteIndex

int getRouteIndex(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r)

getBlockHopCount

public int getBlockHopCount(Block destination,
                            Block nextBlock)
Returns the number of layout blocks 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.


getBlockMetric

public int getBlockMetric(Block destination,
                          Block nextBlock)
Returns 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.


getBlockLength

public float getBlockLength(Block destination,
                            Block nextBlock)
Returns 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.


getNumberOfThroughPaths

public int getNumberOfThroughPaths()
Returns the number of valid through paths on this block.


getThroughPathSource

public Block getThroughPathSource(int i)
Returns the source block at index i


getThroughPathDestination

public Block getThroughPathDestination(int i)
Returns the destination block at index i


isThroughPathActive

public Boolean isThroughPathActive(int i)
Is the through path at index i active


getThroughPathSourceByDestination

ArrayList<Block> getThroughPathSourceByDestination(Block dest)

getThroughPathDestinationBySource

ArrayList<Block> getThroughPathDestinationBySource(Block source)

checkIsRouteOnValidThroughPath

boolean checkIsRouteOnValidThroughPath(jmri.jmrit.display.layoutEditor.LayoutBlock.Routes r)

refreshValidRoutes

public void refreshValidRoutes()

updateActiveThroughPaths

void updateActiveThroughPaths(jmri.jmrit.display.layoutEditor.LayoutBlock.ThroughPaths tp,
                              boolean active)

setRoutesValid

void setRoutesValid(Block nxtHopActive,
                    boolean state)


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