Interface Section
- All Superinterfaces:
Comparable<NamedBean>,NamedBean,PropertyChangeProvider
- All Known Implementing Classes:
DefaultSection
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 ClassesNested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Section.SectionTypestatic final intThe value ofNamedBean.getState()if section is allocated for travel in the forward direction.static final intThe value ofNamedBean.getState()if section is available for allocation.static final intValue representing an occupied section.static final StringString constant for the property occupancy.static final intThe value ofNamedBean.getState()if section is allocated for travel in the reverse direction.static final Section.SectionTypestatic final intValue representing an unoccupied section.static final Section.SectionTypeFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
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 scalinggetBlockBySequenceNumber(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.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 newState) Provide generic access to internal state.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.Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getState, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
FREE
The value ofNamedBean.getState()if section is available for allocation.- See Also:
-
FORWARD
The value ofNamedBean.getState()if section is allocated for travel in the forward direction.- See Also:
-
REVERSE
The value ofNamedBean.getState()if section is allocated for travel in the reverse direction.- See Also:
-
OCCUPIED
Value representing an occupied section.- See Also:
-
UNOCCUPIED
Value representing an unoccupied section.- See Also:
-
PROPERTY_OCCUPANCY
String constant for the property occupancy.- See Also:
-
USERDEFINED
-
SIGNALMASTLOGIC
-
DYNAMICADHOC
-
-
Method Details
-
setState
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 is provided to make scripts access easier to read.
This isn't an exact override because it doesn't throw JmriException
-
getOccupancy
int getOccupancy()Get the occupancy of a Section.- Returns:
OCCUPIED,UNOCCUPIED, or the state of the first block that is neither occupied or unoccupied
-
getForwardBlockingSensorName
-
getForwardBlockingSensor
-
setForwardBlockingSensorName
-
delayedSetForwardBlockingSensorName
-
getReverseBlockingSensorName
-
setReverseBlockingSensorName
-
delayedSetReverseBlockingSensorName
-
getReverseBlockingSensor
-
getLastBlock
-
getForwardStoppingSensorName
-
getForwardStoppingSensor
-
setForwardStoppingSensorName
-
delayedSetForwardStoppingSensorName
-
getReverseStoppingSensorName
-
setReverseStoppingSensorName
-
delayedSetReverseStoppingSensorName
-
getReverseStoppingSensor
-
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.- Parameters:
b- the block to add- Returns:
- true if Block was added or false if Block does not connect to the current Block, or the Block is not unique.
-
delayedAddBlock
-
getBlockList
Get a list of blocks in this section- Returns:
- a list of blocks
-
getNumBlocks
int getNumBlocks()Gets the number of Blocks in this Section- 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.- Parameters:
meters- true to return length in meters, false to use feetscale- the scale; one ofScale- Returns:
- the scale length
-
getLengthI
-
getActualLength
int getActualLength()Gets the actual length of the Section without any scaling- Returns:
- the real length in millimeters
-
getBlockBySequenceNumber
Get Block by its Sequence number in the Section.- Parameters:
seqNumber- the sequence number- Returns:
- the block or null if the sequence number is invalid
-
getBlockSequenceNumber
Get the sequence number of a Block.- 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
void removeAllBlocksFromSection()Remove all Blocks, Block Listeners, and Entry Points -
getEntryBlock
-
getNextBlock
-
getExitBlock
-
containsBlock
-
connectsToBlock
-
getBeginBlockName
-
getEndBlockName
-
addToForwardList
-
addToReverseList
-
removeEntryPoint
-
getForwardEntryPointList
-
getReverseEntryPointList
-
getEntryPointList
-
isForwardEntryPoint
-
isReverseEntryPoint
-
getEntryPointFromSection
Get the EntryPoint for entry from the specified Section for travel in specified direction. -
getExitPointToSection
Get the EntryPoint for exit to specified Section for travel in the specified direction. -
getEntryPointFromBlock
Get the EntryPoint for entry from the specified Block for travel in the specified direction. -
getExitPointToBlock
Get the EntryPoint for exit to the specified Block for travel in the specified direction. -
placeDirectionSensors
int 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.
- 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.- Returns:
- an error description or empty string if there are no errors
-
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.- 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.- Parameters:
set- true to use alternate unoccupied color; false otherwise
-
setNameInBlocks
Set the block values for blocks in this Section.- Parameters:
name- the value to set all blocks to
-
setNameInBlocks
Set the block values for blocks in this Section.- Parameters:
value- the name to set block values to
-
setNameFromActiveBlock
-
clearNameInUnoccupiedBlocks
void clearNameInUnoccupiedBlocks()Clear the block values for blocks in this Section. -
suppressNameUpdate
Suppress the update of a memory variable when a block goes to unoccupied, so the text set above doesn't get wiped out.- 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.
- Parameters:
type- constant of section type.
-
getSectionType
Get Section Type. Defaults to USERDEFINED.- Returns:
- constant of section type.
-