Class LayoutBlockManager
- All Implemented Interfaces:
PropertyChangeListener,VetoableChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,InstanceManagerAutoDefault,Manager<LayoutBlock>
This manager does not enforce any particular system naming convention.
LayoutBlocks are usually addressed by userName. The systemName is hidden from the user for the most part.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final StringString constant for advanced routing enabled.static final StringString constant for the topology property.(package private) booleanFields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, memo, silenceableProperties, silencedPropertiesFields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupportFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupportFields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateNewLayoutBlock(String systemName, String userName) Create a new LayoutBlock if the LayoutBlock does not exist.voiddeleteLayoutBlock(LayoutBlock block) Remove an existing LayoutBlock.voiddispose()Free resources when no longer used.voidenableAdvancedRouting(boolean boo) getBeanTypeHandled(boolean plural) Get the user-readable name of the type of NamedBean handled by this manager.Find a LayoutBlock with a specified Memory assigned as its value display.Find a LayoutBlock with a specified Sensor assigned as its occupancy sensor.getFacingBean(Block facingBlock, Block protectedBlock, LayoutEditor panel, Class<?> T) Get a facing bean into a specified Block from a specified protected Block.getFacingBlock(String signalName, LayoutEditor panel) Get the LayoutBlock that a given signal is facing.getFacingBlock(SignalHead signalHead, LayoutEditor panel) getFacingBlockByMast(SignalMast signalMast, LayoutEditor panel) Get the LayoutBlock that a given signal is facing.getFacingBlockByNamedBean(NamedBean nb, LayoutEditor panel) Get the block facing a given bean object (Sensor, SignalMast or SignalHead).getFacingBlockBySensor(String sensorName, LayoutEditor panel) Get the LayoutBlock that a given sensor is facing.getFacingBlockBySensor(Sensor sensor, LayoutEditor panel) Get the LayoutBlock that a given sensor is facing.getFacingNamedBean(Block facingBlock, Block protectedBlock, LayoutEditor panel) Get the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.getFacingSensor(Block facingBlock, Block protectedBlock, LayoutEditor panel) Get the Sensor facing into a specified Block from a specified protected Block.getFacingSignalHead(Block facingBlock, Block protectedBlock) Get the Signal Head facing into a specified Block from a specified protected Block.getFacingSignalMast(Block facingBlock, Block protectedBlock) getFacingSignalMast(Block facingBlock, Block protectedBlock, LayoutEditor panel) Get the Signal Mast facing into a specified Block from a specified protected Block.getFacingSignalObject(Block facingBlock, Block protectedBlock) In the first instance get a Signal Mast or if none exists a Signal Head for a given facing block and protected block combination.longgetLayoutBlock(String name) Get an existing LayoutBlock.getLayoutBlock(Block block) Get a list of layout blocks which this roster entry appears to be occupying.getNamedBeanAtEndBumper(Block facingBlock, LayoutEditor panel) Get the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.Get the class of NamedBean supported by this Manager.Get the sensor used for the stability indication.getProtectedBlock(String signalName, LayoutEditor panel) Get the LayoutBlock that a given signal is protecting.getProtectedBlock(SignalHead signalHead, LayoutEditor panel) getProtectedBlockByMast(SignalMast signalMast, LayoutEditor panel) getProtectedBlockByNamedBean(NamedBean nb, LayoutEditor panel) Get the block that a given bean object (Sensor, SignalMast or SignalHead) is protecting.getProtectedBlockBySensor(String sensorName, LayoutEditor panel) Get the LayoutBlock that a given sensor is protecting.getProtectedBlockBySensor(Sensor sensor, LayoutEditor panel) Get the LayoutBlock that a given sensor is protecting.getProtectingBlocksByNamedBean(NamedBean nb, LayoutEditor panel) getProtectingBlocksBySensor(Sensor sensor, LayoutEditor panel) getProtectingBlocksBySensorOld(Sensor sensor, LayoutEditor panel) getSensorAtEndBumper(Block facingBlock, LayoutEditor panel) Get a Sensor facing into a specific Block.getSignalMastAtEndBumper(Block facingBlock, LayoutEditor panel) Get a Signal Mast that is assigned to a block which has an end bumper at one end.Get the sensor used to indicate if the routing protocol has stabilised or not.intDetermine the order that types should be written when storing panel files.voidInitialize/check the Paths of all Blocks associated with LayoutBlocks.booleanboolean(package private) voidvoidsetStabilisedSensor(String pName) Assign a sensor to the routing protocol, that changes state dependant upon if the routing protocol has stabilised or is under going a change.voidcharbooleanwarn()Controls switching off incompatible block connectivity messages.Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deleteBean, deregister, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getBySystemName, getByUserName, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getOuterBean, getSystemPrefix, handleUserNameUniqueness, makeSystemName, propertyChange, register, registerSelf, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, updateAutoNumber, validSystemNameFormat, vetoableChangeMethods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListenerMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.Manager
getBeanTypeHandled, getEntryToolTip, getSubSystemNamePrefix, getSystemNamePrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormatMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Field Details
-
PROPERTY_ADVANCED_ROUTING_ENABLED
String constant for advanced routing enabled.- See Also:
-
PROPERTY_TOPOLOGY
String constant for the topology property.- See Also:
-
enableAdvancedRouting
-
stabilised
boolean stabilised
-
-
Constructor Details
-
LayoutBlockManager
public LayoutBlockManager()
-
-
Method Details
-
getXMLOrder
Description copied from interface:ManagerDetermine the order that types should be written when storing panel files. Uses one of the constants defined in this class.Yes, that's an overly-centralized methodology, but it works for now.
- Specified by:
getXMLOrderin interfaceManager<LayoutBlock>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
- Specified by:
typeLetterin interfaceManager<LayoutBlock>- Returns:
- The type letter for a specific implementation
-
createNewLayoutBlock
@CheckReturnValue @CheckForNull public LayoutBlock createNewLayoutBlock(@CheckForNull String systemName, String userName) Create a new LayoutBlock if the LayoutBlock does not exist.Note that since the userName is used to address LayoutBlocks, the user name must be present. If the user name is not present, the new LayoutBlock is not created, and null is returned.
- Parameters:
systemName- block system name.userName- block username, must be non-empty.- Returns:
- null if a LayoutBlock with the same systemName or userName already exists, or if there is trouble creating a new LayoutBlock
-
createNewLayoutBlock
-
deleteLayoutBlock
Remove an existing LayoutBlock.- Parameters:
block- the block to remove.
-
getLayoutBlock
Get an existing LayoutBlock. First looks up assuming that name is a User Name. If this fails, looks up assuming that name is a System Name.- Parameters:
name- ideally block username, can be system name.- Returns:
- LayoutBlock, or null if not found by either user name or system name
-
getLayoutBlock
-
getBlockWithSensorAssigned
@CheckReturnValue @CheckForNull public LayoutBlock getBlockWithSensorAssigned(@CheckForNull Sensor s) Find a LayoutBlock with a specified Sensor assigned as its occupancy sensor.- Parameters:
s- the sensor to search for.- Returns:
- the block or null if no existing LayoutBlock has the Sensor assigned
-
getBlockWithMemoryAssigned
Find a LayoutBlock with a specified Memory assigned as its value display.- Parameters:
m- the memory to search for.- Returns:
- the block or null if no existing LayoutBlock has the memory assigned.
-
initializeLayoutBlockPaths
Initialize/check the Paths of all Blocks associated with LayoutBlocks.This routine should be called when loading panels, after all Layout Editor panels have been loaded.
-
addBadBeanError
-
getFacingSignalHead
@CheckReturnValue @CheckForNull public SignalHead getFacingSignalHead(@CheckForNull Block facingBlock, @CheckForNull Block protectedBlock) Get the Signal Head facing into a specified Block from a specified protected Block.This method is primarily designed for use with scripts to get information initially residing in a Layout Editor panel. If either of the input Blocks is null, or if the two blocks do not join at a block boundary, or if either of the input Blocks are not Layout Editor panel blocks, an error message is logged, and "null" is returned. If the signal at the block boundary has two heads--is located at the facing point of a turnout-- the Signal Head that applies for the current setting of turnout (THROWN or CLOSED) is returned. If the turnout state is UNKNOWN or INCONSISTENT, an error message is logged, and "null" is returned. If the signal at the block boundary has three heads--the facing point of a 3-way turnout--the Signal Head that applies for the current settings of the two turnouts of the 3-way turnout is returned. If the turnout state of either turnout is UNKNOWN or INCONSISTENT, an error is logged and "null" is returned. "null" is returned if the block boundary is between the two turnouts of a THROAT_TO_THROAT turnout or a 3-way turnout. "null" is returned for block boundaries exiting a THROAT_TO_THROAT turnout block, since there are no signals that apply there.
- Parameters:
facingBlock- the facing block.protectedBlock- the protected block.- Returns:
- the signal head, may be null.
-
getNamedBeanAtEndBumper
@CheckReturnValue @CheckForNull public NamedBean getNamedBeanAtEndBumper(@CheckForNull Block facingBlock, @CheckForNull LayoutEditor panel) Get the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.- Parameters:
facingBlock- the facing block.panel- the main layout editor.- Returns:
- The assigned sensor or signal mast as a named bean
-
getSignalMastAtEndBumper
@CheckReturnValue @CheckForNull public SignalMast getSignalMastAtEndBumper(@CheckForNull Block facingBlock, @CheckForNull LayoutEditor panel) Get a Signal Mast that is assigned to a block which has an end bumper at one end.- Parameters:
facingBlock- the facing block.panel- the main layout editor.- Returns:
- the signal mast.
-
getSensorAtEndBumper
@CheckReturnValue @CheckForNull public Sensor getSensorAtEndBumper(@CheckForNull Block facingBlock, @CheckForNull LayoutEditor panel) Get a Sensor facing into a specific Block. This is used for Blocks that have an end bumper at one end.- Parameters:
facingBlock- the facing block.panel- the main layout editor.- Returns:
- the facing sensor.
-
getFacingNamedBean
@CheckReturnValue @CheckForNull public NamedBean getFacingNamedBean(@CheckForNull Block facingBlock, @CheckForNull Block protectedBlock, @CheckForNull LayoutEditor panel) Get the named bean of either a Sensor or signalmast facing into a specified Block from a specified protected Block.- Parameters:
facingBlock- the facing block.protectedBlock- the protected block.panel- the main layout editor.- Returns:
- The assigned sensor or signal mast as a named bean
-
getFacingSignalMast
@CheckReturnValue @CheckForNull public SignalMast getFacingSignalMast(@Nonnull Block facingBlock, @CheckForNull Block protectedBlock) -
getFacingSignalMast
@CheckReturnValue @CheckForNull public SignalMast getFacingSignalMast(@Nonnull Block facingBlock, @CheckForNull Block protectedBlock, @CheckForNull LayoutEditor panel) Get the Signal Mast facing into a specified Block from a specified protected Block.- Parameters:
facingBlock- the facing block.protectedBlock- the protected block.panel- the main layout editor.- Returns:
- The assigned signalMast.
-
getFacingSensor
@CheckReturnValue @CheckForNull public Sensor getFacingSensor(@CheckForNull Block facingBlock, @CheckForNull Block protectedBlock, @CheckForNull LayoutEditor panel) Get the Sensor facing into a specified Block from a specified protected Block.- Parameters:
facingBlock- the facing block.protectedBlock- the protected block.panel- the main layout editor.- Returns:
- The assigned sensor
-
getFacingBean
@CheckReturnValue @CheckForNull public NamedBean getFacingBean(@CheckForNull Block facingBlock, @CheckForNull Block protectedBlock, @CheckForNull LayoutEditor panel, Class<?> T) Get a facing bean into a specified Block from a specified protected Block.- Parameters:
facingBlock- the facing block.protectedBlock- the protected block.panel- the layout editor panel the block is assigned, if null then the maximum connected panel of the facing block is usedT- The class of the item that we are looking for, either SignalMast or Sensor- Returns:
- The assigned sensor.
-
getFacingSignalObject
@CheckReturnValue @CheckForNull public Object getFacingSignalObject(@Nonnull Block facingBlock, @CheckForNull Block protectedBlock) In the first instance get a Signal Mast or if none exists a Signal Head for a given facing block and protected block combination. See #getFacingSignalMast() and #getFacingSignalHead() as to how they deal with what each returns.- Parameters:
facingBlock- the facing block to search for.protectedBlock- the protected block to search for.- Returns:
- either a signalMast or signalHead
-
getProtectedBlockByNamedBean
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlockByNamedBean(@CheckForNull NamedBean nb, @CheckForNull LayoutEditor panel) Get the block that a given bean object (Sensor, SignalMast or SignalHead) is protecting.- Parameters:
nb- NamedBeanpanel- panel that this bean is on- Returns:
- The block that the bean object is facing
-
getProtectingBlocksByNamedBean
-
getProtectedBlockByMast
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlockByMast(@CheckForNull SignalMast signalMast, @CheckForNull LayoutEditor panel) -
getProtectedBlockBySensor
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlockBySensor(@Nonnull String sensorName, @CheckForNull LayoutEditor panel) Get the LayoutBlock that a given sensor is protecting.- Parameters:
sensorName- the sensor name to search for.panel- the layout editor panel.- Returns:
- the layout block, may be null.
-
getProtectingBlocksBySensor
@Nonnull public List<LayoutBlock> getProtectingBlocksBySensor(@CheckForNull Sensor sensor, @CheckForNull LayoutEditor panel) -
getProtectingBlocksBySensorOld
@Nonnull public List<LayoutBlock> getProtectingBlocksBySensorOld(@CheckForNull Sensor sensor, @Nonnull LayoutEditor panel) -
getProtectedBlockBySensor
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlockBySensor(@CheckForNull Sensor sensor, @CheckForNull LayoutEditor panel) Get the LayoutBlock that a given sensor is protecting.- Parameters:
sensor- sensor to search for.panel- layout editor panel to search.- Returns:
- the layout block, may be null.
-
getFacingBlockByNamedBean
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlockByNamedBean(@Nonnull NamedBean nb, @CheckForNull LayoutEditor panel) Get the block facing a given bean object (Sensor, SignalMast or SignalHead).- Parameters:
nb- NamedBeanpanel- panel that this bean is on- Returns:
- The block that the bean object is facing
-
getFacingBlockBySensor
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlockBySensor(@Nonnull String sensorName, @CheckForNull LayoutEditor panel) Get the LayoutBlock that a given sensor is facing.- Parameters:
sensorName- the sensor name.panel- the layout editor panel.- Returns:
- the facing layout block, may be null.
-
getFacingBlockByMast
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlockByMast(@Nonnull SignalMast signalMast, @Nonnull LayoutEditor panel) Get the LayoutBlock that a given signal is facing.- Parameters:
signalMast- the signal mast to search for.panel- the layout editor panel.- Returns:
- the layout block, may be null.
-
getFacingBlockBySensor
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlockBySensor(@Nonnull Sensor sensor, @Nonnull LayoutEditor panel) Get the LayoutBlock that a given sensor is facing.- Parameters:
sensor- the sensor to search for.panel- the layout editor panel to search.- Returns:
- the layout block, may be null.
-
getProtectedBlock
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlock(@Nonnull SignalHead signalHead, @CheckForNull LayoutEditor panel) -
getProtectedBlock
@CheckReturnValue @CheckForNull public LayoutBlock getProtectedBlock(@Nonnull String signalName, @Nonnull LayoutEditor panel) Get the LayoutBlock that a given signal is protecting.- Parameters:
signalName- the signal name to search for.panel- the main layout editor panel.- Returns:
- the layout block, may be null.
-
getFacingBlock
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlock(@Nonnull SignalHead signalHead, @CheckForNull LayoutEditor panel) -
getFacingBlock
@CheckReturnValue @CheckForNull public LayoutBlock getFacingBlock(@Nonnull String signalName, @Nonnull LayoutEditor panel) Get the LayoutBlock that a given signal is facing.- Parameters:
signalName- signal name.panel- layout editor panel.- Returns:
- the facing layout block.
-
warn
Controls switching off incompatible block connectivity messages.Warnings are always on when program starts up. Once stopped by the user, these messages may not be switched on again until program restarts.
- Returns:
- true if connectivity warning flag set, else false.
-
turnOffWarning
-
isAdvancedRoutingEnabled
- Returns:
- true if advanced layout block routing has been enabled
-
enableAdvancedRouting
-
getLayoutBlockConnectivityTools
-
setLastRoutingChange
void setLastRoutingChange() -
setStabilisedSensor
Assign a sensor to the routing protocol, that changes state dependant upon if the routing protocol has stabilised or is under going a change.- Parameters:
pName- sensor name, will be provided if not existing.- Throws:
JmriException- if no sensor manager.
-
getStabilisedSensor
Get the sensor used to indicate if the routing protocol has stabilised or not.- Returns:
- routing stability sensor, may be null.
-
getNamedStabilisedSensor
Get the sensor used for the stability indication.- Returns:
- stability sensor, may be null.
-
routingStablised
- Returns:
- true if the layout block routing protocol has stabilised
-
getLastRoutingChange
- Returns:
- the time when the last routing change was made, recorded as System.nanoTime()
-
getBeanTypeHandled
Description copied from interface:ManagerGet the user-readable name of the type of NamedBean handled by this manager.For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.
- Specified by:
getBeanTypeHandledin interfaceManager<LayoutBlock>- Parameters:
plural- true to return plural form of the type; false to return singular form- Returns:
- a string of the bean type that the manager handles, eg Turnout, Sensor etc
-
getNamedBeanClass
Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.- Specified by:
getNamedBeanClassin interfaceManager<LayoutBlock>- Returns:
- the class supported by this Manager.
-
getLayoutBlocksOccupiedByRosterEntry
Get a list of layout blocks which this roster entry appears to be occupying. A layout block is assumed to contain this roster entry if the value of the underlying block is the RosterEntry itself, or a string with the entry's id or dcc address.- Parameters:
re- the roster entry- Returns:
- list of layout block user names
-
dispose
Description copied from class:AbstractManagerFree resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected.- Specified by:
disposein interfaceManager<LayoutBlock>- Overrides:
disposein classAbstractManager<LayoutBlock>
-