Class DefaultSection
- All Implemented Interfaces:
Comparable<NamedBean>,PropertyChangeProvider,NamedBean,Section
A Block may be in multiple Sections. All Blocks contained in a given section must be unique. Blocks are kept in order--the first block is connected to the second, the second is connected to the third, etc.
A Block in a Section must be connected to the Block before it (if there is one) and to the Block after it (if there is one), but may not be connected to any other Block in the Section. This restriction is enforced when a Section is created, and checked when a Section is loaded from disk.
A Section has a "direction" defined by the sequence in which Blocks are added to the Section. A train may run through a Section in either the forward direction (from first block to last block) or reverse direction (from last block to first block).
A Section has one or more EntryPoints. Each EntryPoint is a Path of one of the Blocks in the Section that defines a connection to a Block outside of the Section. EntryPoints are grouped into two lists: "forwardEntryPoints" - entry through which will result in a train traveling in the "forward" direction "reverseEntryPoints" - entry through which will result in a train traveling in the "reverse" direction Note that "forwardEntryPoints" are also reverse exit points, and vice versa.
A Section has one of the following states" FREE - available for allocation by a dispatcher FORWARD - allocated for travel in the forward direction REVERSE - allocated for travel in the reverse direction
A Section has an occupancy. A Section is OCCUPIED if any of its Blocks is OCCUPIED. A Section is UNOCCUPIED if all of its Blocks are UNOCCUPIED
A Section of may be allocated to only one train at a time, even if the trains are travelling in the same direction. If a Section has sufficient space for multiple trains travelling in the same direction it should be broken up into multiple Sections so the trains can follow each other through the original Section.
A Section may not contain any reverse loops. The track that is reversed in a reverse loop must be in a separate Section.
Each Section optionally carries two direction sensors, one for the forward direction and one for the reverse direction. These sensors force signals for travel in their respective directions to "RED" when they are active. When the Section is free, both the sensors are Active. These internal sensors follow the state of the Section, permitting signals to function normally in the direction of allocation.
Each Section optionally carries two stopping sensors, one for the forward direction and one for the reverse direction. These sensors change to active when a train traversing the Section triggers its sensing device. Stopping sensors are physical layout sensors, and may be either point sensors or occupancy sensors for short blocks at the end of the Section. A stopping sensor is used during automatic running to stop a train that has reached the end of its allocated Section. This is needed, for example, to allow a train to enter a passing siding and clear the track behind it. When not running automatically, these sensors may be used to light panel lights to notify the dispatcher that the train has reached the end of the Section.
This Section implementation provides for delayed initialization of blocks and direction sensors to be independent of order of items in panel files.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameExceptionNested classes/interfaces inherited from interface jmri.Section
Section.SectionType -
Field Summary
FieldsFields 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, UNKNOWNFields inherited from interface jmri.Section
DYNAMICADHOC, FORWARD, FREE, OCCUPIED, PROPERTY_OCCUPANCY, REVERSE, SIGNALMASTLOGIC, UNOCCUPIED, USERDEFINED -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSection(String systemName) DefaultSection(String systemName, String userName) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a Block to the Section.voidvoidvoidClear the block values for blocks in this Section.booleanbooleanvoiddelayedAddBlock(String blockName) voiddelayedSetForwardBlockingSensorName(String forwardSensor) voiddelayedSetForwardStoppingSensorName(String forwardSensor) voiddelayedSetReverseBlockingSensorName(String reverseSensor) voiddelayedSetReverseStoppingSensorName(String reverseSensor) intGets the actual length of the Section without any scalingFor 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.getBlockBySequenceNumber(int seqNumber) Get Block by its Sequence number in the Section.Get a list of blocks in this sectionintGet the sequence number of a Block.getEntryPointFromBlock(Block b, int dir) Get the EntryPoint for entry from the specified Block for travel in the specified direction.getEntryPointFromSection(Section s, int dir) Get the EntryPoint for entry from the specified Section for travel in specified direction.getExitPointToBlock(Block b, int dir) Get the EntryPoint for exit to the specified Block for travel in the specified direction.getExitPointToSection(Section s, int dir) Get the EntryPoint for exit to specified Section for travel in the specified direction.floatgetLengthF(boolean meters, Scale scale) Get the scale length of Section.intgetLengthI(boolean meters, Scale scale) intGets the number of Blocks in this SectionintGet the occupancy of a Section.Get Section Type.intgetState()Get the state of the Section.getUsageReport(NamedBean bean) Get a list of references for the specified bean.booleanbooleanintPlace direction sensors in SSL for all Signal Heads in this Section if the Sensors are not already present in the SSL.voidRemove all Blocks, Block Listeners, and Entry PointsvoidvoidsetAlternateColor(boolean set) Set/reset the display to use alternate color for unoccupied blocks in this section.voidsetAlternateColorFromActiveBlock(boolean set) Set/reset the display to use alternate color for unoccupied blocks in this Section.setForwardBlockingSensorName(String forwardSensor) setForwardStoppingSensorName(String forwardSensor) voidsetNameFromActiveBlock(Object value) voidsetNameInBlocks(Object value) Set the block values for blocks in this Section.voidsetNameInBlocks(String name) Set the block values for blocks in this Section.setReverseBlockingSensorName(String reverseSensor) setReverseStoppingSensorName(String reverseSensor) voidSet Section Type.voidsetState(int state) Set the state of the Section.voidsuppressNameUpdate(boolean set) Suppress the update of a memory variable when a block goes to unoccupied, so the text set above doesn't get wiped out.validate()Validate the Section.voidMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, 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
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRefMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
nbhm
-
-
Constructor Details
-
DefaultSection
-
DefaultSection
-
-
Method Details
-
getState
Get the state of the Section. UNKNOWN, FORWARD, REVERSE, FREE -
setState
Set the state of the Section. FREE, FORWARD or REVERSE.
UNKNOWN state not accepted here. -
getOccupancy
Get the occupancy of a Section.- Specified by:
getOccupancyin interfaceSection- Returns:
Section.OCCUPIED,Section.UNOCCUPIED, or the state of the first block that is neither occupied or unoccupied
-
getForwardBlockingSensorName
- Specified by:
getForwardBlockingSensorNamein interfaceSection
-
getForwardBlockingSensor
- Specified by:
getForwardBlockingSensorin interfaceSection
-
setForwardBlockingSensorName
- Specified by:
setForwardBlockingSensorNamein interfaceSection
-
delayedSetForwardBlockingSensorName
- Specified by:
delayedSetForwardBlockingSensorNamein interfaceSection
-
getReverseBlockingSensorName
- Specified by:
getReverseBlockingSensorNamein interfaceSection
-
setReverseBlockingSensorName
- Specified by:
setReverseBlockingSensorNamein interfaceSection
-
delayedSetReverseBlockingSensorName
- Specified by:
delayedSetReverseBlockingSensorNamein interfaceSection
-
getReverseBlockingSensor
- Specified by:
getReverseBlockingSensorin interfaceSection
-
getLastBlock
- Specified by:
getLastBlockin interfaceSection
-
getForwardStoppingSensorName
- Specified by:
getForwardStoppingSensorNamein interfaceSection
-
getForwardStoppingSensor
- Specified by:
getForwardStoppingSensorin interfaceSection
-
setForwardStoppingSensorName
- Specified by:
setForwardStoppingSensorNamein interfaceSection
-
delayedSetForwardStoppingSensorName
- Specified by:
delayedSetForwardStoppingSensorNamein interfaceSection
-
getReverseStoppingSensorName
- Specified by:
getReverseStoppingSensorNamein interfaceSection
-
setReverseStoppingSensorName
- Specified by:
setReverseStoppingSensorNamein interfaceSection
-
delayedSetReverseStoppingSensorName
- Specified by:
delayedSetReverseStoppingSensorNamein interfaceSection
-
getReverseStoppingSensor
- Specified by:
getReverseStoppingSensorin interfaceSection
-
addBlock
Add a Block to the Section. Block and sequence number must be unique within the Section. Block sequence numbers are set automatically as blocks are added. -
delayedAddBlock
- Specified by:
delayedAddBlockin interfaceSection
-
getBlockList
Get a list of blocks in this section- Specified by:
getBlockListin interfaceSection- Returns:
- a list of blocks
-
getNumBlocks
Gets the number of Blocks in this Section- Specified by:
getNumBlocksin interfaceSection- Returns:
- the number of blocks
-
getLengthF
Get the scale length of Section. Length of the Section is calculated by summing the lengths of all Blocks in the section. If all Block lengths have not been entered, length will not be correct.- Specified by:
getLengthFin interfaceSection- Parameters:
meters- true to return length in meters, false to use feetscale- the scale; one ofScale- Returns:
- the scale length
-
getLengthI
- Specified by:
getLengthIin interfaceSection
-
getActualLength
Gets the actual length of the Section without any scaling- Specified by:
getActualLengthin interfaceSection- Returns:
- the real length in millimeters
-
getBlockBySequenceNumber
Get Block by its Sequence number in the Section.- Specified by:
getBlockBySequenceNumberin interfaceSection- Parameters:
seqNumber- the sequence number- Returns:
- the block or null if the sequence number is invalid
-
getBlockSequenceNumber
Get the sequence number of a Block.- Specified by:
getBlockSequenceNumberin interfaceSection- Parameters:
b- the block to get the sequence of- Returns:
- the sequence number of b or -1 if b is not in the Section
-
removeAllBlocksFromSection
Remove all Blocks, Block Listeners, and Entry Points- Specified by:
removeAllBlocksFromSectionin interfaceSection
-
getEntryBlock
- Specified by:
getEntryBlockin interfaceSection
-
getNextBlock
- Specified by:
getNextBlockin interfaceSection
-
getExitBlock
- Specified by:
getExitBlockin interfaceSection
-
containsBlock
- Specified by:
containsBlockin interfaceSection
-
connectsToBlock
- Specified by:
connectsToBlockin interfaceSection
-
getBeginBlockName
- Specified by:
getBeginBlockNamein interfaceSection
-
getEndBlockName
- Specified by:
getEndBlockNamein interfaceSection
-
addToForwardList
- Specified by:
addToForwardListin interfaceSection
-
addToReverseList
- Specified by:
addToReverseListin interfaceSection
-
removeEntryPoint
- Specified by:
removeEntryPointin interfaceSection
-
getForwardEntryPointList
- Specified by:
getForwardEntryPointListin interfaceSection
-
getReverseEntryPointList
- Specified by:
getReverseEntryPointListin interfaceSection
-
getEntryPointList
- Specified by:
getEntryPointListin interfaceSection
-
isForwardEntryPoint
- Specified by:
isForwardEntryPointin interfaceSection
-
isReverseEntryPoint
- Specified by:
isReverseEntryPointin interfaceSection
-
getEntryPointFromSection
Get the EntryPoint for entry from the specified Section for travel in specified direction.- Specified by:
getEntryPointFromSectionin interfaceSection- Parameters:
s- the sectiondir- the direction of travel; one ofSection.FORWARDorSection.REVERSE- Returns:
- the entry point or null if not found
-
getExitPointToSection
Get the EntryPoint for exit to specified Section for travel in the specified direction.- Specified by:
getExitPointToSectionin interfaceSection- Parameters:
s- the sectiondir- the direction of travel; one ofSection.FORWARDorSection.REVERSE- Returns:
- the entry point or null if not found
-
getEntryPointFromBlock
Get the EntryPoint for entry from the specified Block for travel in the specified direction.- Specified by:
getEntryPointFromBlockin interfaceSection- Parameters:
b- the blockdir- the direction of travel; one ofSection.FORWARDorSection.REVERSE- Returns:
- the entry point or null if not found
-
getExitPointToBlock
Get the EntryPoint for exit to the specified Block for travel in the specified direction.- Specified by:
getExitPointToBlockin interfaceSection- Parameters:
b- the blockdir- the direction of travel; one ofSection.FORWARDorSection.REVERSE- Returns:
- the entry point or null if not found
-
placeDirectionSensors
Place direction sensors in SSL for all Signal Heads in this Section if the Sensors are not already present in the SSL.Only anchor point block boundaries that have assigned signals are considered. Only turnouts that have assigned signals are considered. Only level crossings that have assigned signals are considered. Turnouts and anchor points without signals are counted, and reported in warning messages during this procedure, if there are any missing signals.
If this method has trouble, an error message is placed in the log describing the trouble.
- Specified by:
placeDirectionSensorsin interfaceSection- Returns:
- the number or errors placing sensors; 1 is returned if no direction sensor is defined for this section
-
validate
Validate the Section. This checks block connectivity, warns of redundant EntryPoints, and otherwise checks internal consistency of the Section. An appropriate error message is logged if a problem is found. This method assumes that Block Paths are correctly initialized. -
setAlternateColor
Set/reset the display to use alternate color for unoccupied blocks in this section. If Layout Editor panel is not present, Layout Blocks will not be present, and nothing will be set.- Specified by:
setAlternateColorin interfaceSection- Parameters:
set- true to use alternate unoccupied color; false otherwise
-
setAlternateColorFromActiveBlock
Set/reset the display to use alternate color for unoccupied blocks in this Section. If the Section already contains an active block, then the alternative color will be set from the active block, if no active block is found or we are clearing the alternative color then all the blocks in the Section will be set. If Layout Editor panel is not present, Layout Blocks will not be present, and nothing will be set.- Specified by:
setAlternateColorFromActiveBlockin interfaceSection- Parameters:
set- true to use alternate unoccupied color; false otherwise
-
setNameInBlocks
Set the block values for blocks in this Section.- Specified by:
setNameInBlocksin interfaceSection- Parameters:
name- the value to set all blocks to
-
setNameInBlocks
Set the block values for blocks in this Section.- Specified by:
setNameInBlocksin interfaceSection- Parameters:
value- the name to set block values to
-
setNameFromActiveBlock
- Specified by:
setNameFromActiveBlockin interfaceSection
-
clearNameInUnoccupiedBlocks
Clear the block values for blocks in this Section.- Specified by:
clearNameInUnoccupiedBlocksin interfaceSection
-
suppressNameUpdate
Suppress the update of a memory variable when a block goes to unoccupied, so the text set above doesn't get wiped out.- Specified by:
suppressNameUpdatein interfaceSection- Parameters:
set- true to suppress the update; false otherwise
-
setSectionType
Set Section Type.- USERDEFINED - Default Save all the information.
- SIGNALMASTLOGIC - Save only the name, blocks will be added by the SignalMast logic.
- DYNAMICADHOC - Created on an as required basis, not to be saved.
- Specified by:
setSectionTypein interfaceSection- Parameters:
type- constant of section type.
-
getSectionType
Get Section Type. Defaults to USERDEFINED.- Specified by:
getSectionTypein interfaceSection- Returns:
- constant of section type.
-
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
-
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.
-