Interface Section
-
- All Superinterfaces:
java.lang.Comparable<NamedBean>
,NamedBean
,PropertyChangeProvider
- All Known Implementing Classes:
DefaultSection
public interface Section extends NamedBean
Sections represent a group of one or more connected Blocks that may be allocated to a train traveling in a given direction.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 Modifier and Type Interface Description static class
Section.SectionType
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description static Section.SectionType
DYNAMICADHOC
static int
FORWARD
The value ofNamedBean.getState()
if section is allocated for travel in the forward direction.static int
FREE
The value ofNamedBean.getState()
if section is available for allocation.static int
OCCUPIED
Value representing an occupied section.static int
REVERSE
The value ofNamedBean.getState()
if section is allocated for travel in the reverse direction.static Section.SectionType
SIGNALMASTLOGIC
static int
UNOCCUPIED
Value representing an unoccupied section.static Section.SectionType
USERDEFINED
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addBlock(Block b)
Add a Block to the Section.void
addToForwardList(EntryPoint ep)
void
addToReverseList(EntryPoint ep)
void
clearNameInUnoccupiedBlocks()
Clear the block values for blocks in this Section.boolean
connectsToBlock(Block b)
boolean
containsBlock(Block b)
void
delayedAddBlock(java.lang.String blockName)
void
delayedSetForwardBlockingSensorName(java.lang.String forwardSensor)
void
delayedSetForwardStoppingSensorName(java.lang.String forwardSensor)
void
delayedSetReverseBlockingSensorName(java.lang.String reverseSensor)
void
delayedSetReverseStoppingSensorName(java.lang.String reverseSensor)
int
getActualLength()
Gets the actual length of the Section without any scalingjava.lang.String
getBeginBlockName()
Block
getBlockBySequenceNumber(int seqNumber)
Get Block by its Sequence number in the Section.java.util.List<Block>
getBlockList()
Get a list of blocks in this sectionint
getBlockSequenceNumber(Block b)
Get the sequence number of a Block.java.lang.String
getEndBlockName()
Block
getEntryBlock()
EntryPoint
getEntryPointFromBlock(Block b, int dir)
Get the EntryPoint for entry from the specified Block for travel in the specified direction.EntryPoint
getEntryPointFromSection(Section s, int dir)
Get the EntryPoint for entry from the specified Section for travel in specified direction.java.util.List<EntryPoint>
getEntryPointList()
Block
getExitBlock()
EntryPoint
getExitPointToBlock(Block b, int dir)
Get the EntryPoint for exit to the specified Block for travel in the specified direction.EntryPoint
getExitPointToSection(Section s, int dir)
Get the EntryPoint for exit to specified Section for travel in the specified direction.Sensor
getForwardBlockingSensor()
java.lang.String
getForwardBlockingSensorName()
java.util.List<EntryPoint>
getForwardEntryPointList()
Sensor
getForwardStoppingSensor()
java.lang.String
getForwardStoppingSensorName()
Block
getLastBlock()
float
getLengthF(boolean meters, Scale scale)
Get the scale length of Section.int
getLengthI(boolean meters, Scale scale)
Block
getNextBlock()
int
getNumBlocks()
Gets the number of Blocks in this Sectionint
getOccupancy()
Get the occupancy of a Section.Sensor
getReverseBlockingSensor()
java.lang.String
getReverseBlockingSensorName()
java.util.List<EntryPoint>
getReverseEntryPointList()
Sensor
getReverseStoppingSensor()
java.lang.String
getReverseStoppingSensorName()
Section.SectionType
getSectionType()
Get Section Type.boolean
isForwardEntryPoint(EntryPoint ep)
boolean
isReverseEntryPoint(EntryPoint ep)
int
placeDirectionSensors()
Place direction sensors in SSL for all Signal Heads in this Section if the Sensors are not already present in the SSL.void
removeAllBlocksFromSection()
Remove all Blocks, Block Listeners, and Entry Pointsvoid
removeEntryPoint(EntryPoint ep)
void
setAlternateColor(boolean set)
Set/reset the display to use alternate color for unoccupied blocks in this section.void
setAlternateColorFromActiveBlock(boolean set)
Set/reset the display to use alternate color for unoccupied blocks in this Section.Sensor
setForwardBlockingSensorName(java.lang.String forwardSensor)
Sensor
setForwardStoppingSensorName(java.lang.String forwardSensor)
void
setNameFromActiveBlock(java.lang.Object value)
void
setNameInBlocks(java.lang.Object value)
Set the block values for blocks in this Section.void
setNameInBlocks(java.lang.String name)
Set the block values for blocks in this Section.Sensor
setReverseBlockingSensorName(java.lang.String reverseSensor)
Sensor
setReverseStoppingSensorName(java.lang.String reverseSensor)
void
setSectionType(Section.SectionType type)
Set Section Type.void
setState(int newState)
Provide generic access to internal state.void
suppressNameUpdate(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.java.lang.String
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, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
FREE
static final int FREE
The value ofNamedBean.getState()
if section is available for allocation.- See Also:
- Constant Field Values
-
FORWARD
static final int FORWARD
The value ofNamedBean.getState()
if section is allocated for travel in the forward direction.- See Also:
- Constant Field Values
-
REVERSE
static final int REVERSE
The value ofNamedBean.getState()
if section is allocated for travel in the reverse direction.- See Also:
- Constant Field Values
-
OCCUPIED
static final int OCCUPIED
Value representing an occupied section.- See Also:
- Constant Field Values
-
UNOCCUPIED
static final int UNOCCUPIED
Value representing an unoccupied section.- See Also:
- Constant Field Values
-
USERDEFINED
static final Section.SectionType USERDEFINED
-
SIGNALMASTLOGIC
static final Section.SectionType SIGNALMASTLOGIC
-
DYNAMICADHOC
static final Section.SectionType DYNAMICADHOC
-
-
Method Detail
-
setState
void setState(int newState)
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
java.lang.String getForwardBlockingSensorName()
-
getForwardBlockingSensor
Sensor getForwardBlockingSensor()
-
setForwardBlockingSensorName
Sensor setForwardBlockingSensorName(java.lang.String forwardSensor)
-
delayedSetForwardBlockingSensorName
void delayedSetForwardBlockingSensorName(java.lang.String forwardSensor)
-
getReverseBlockingSensorName
java.lang.String getReverseBlockingSensorName()
-
setReverseBlockingSensorName
Sensor setReverseBlockingSensorName(java.lang.String reverseSensor)
-
delayedSetReverseBlockingSensorName
void delayedSetReverseBlockingSensorName(java.lang.String reverseSensor)
-
getReverseBlockingSensor
Sensor getReverseBlockingSensor()
-
getLastBlock
Block getLastBlock()
-
getForwardStoppingSensorName
java.lang.String getForwardStoppingSensorName()
-
getForwardStoppingSensor
@CheckForNull Sensor getForwardStoppingSensor()
-
setForwardStoppingSensorName
Sensor setForwardStoppingSensorName(java.lang.String forwardSensor)
-
delayedSetForwardStoppingSensorName
void delayedSetForwardStoppingSensorName(java.lang.String forwardSensor)
-
getReverseStoppingSensorName
java.lang.String getReverseStoppingSensorName()
-
setReverseStoppingSensorName
@CheckForNull Sensor setReverseStoppingSensorName(java.lang.String reverseSensor)
-
delayedSetReverseStoppingSensorName
void delayedSetReverseStoppingSensorName(java.lang.String reverseSensor)
-
getReverseStoppingSensor
@CheckForNull Sensor getReverseStoppingSensor()
-
addBlock
boolean addBlock(Block b)
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
void delayedAddBlock(java.lang.String blockName)
-
getBlockList
@Nonnull java.util.List<Block> 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
float getLengthF(boolean meters, Scale scale)
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
int getLengthI(boolean meters, Scale scale)
-
getActualLength
int getActualLength()
Gets the actual length of the Section without any scaling- Returns:
- the real length in millimeters
-
getBlockBySequenceNumber
@CheckForNull Block getBlockBySequenceNumber(int seqNumber)
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
int getBlockSequenceNumber(Block b)
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
@CheckForNull Block getEntryBlock()
-
getNextBlock
@CheckForNull Block getNextBlock()
-
getExitBlock
@CheckForNull Block getExitBlock()
-
containsBlock
boolean containsBlock(Block b)
-
connectsToBlock
boolean connectsToBlock(Block b)
-
getBeginBlockName
java.lang.String getBeginBlockName()
-
getEndBlockName
java.lang.String getEndBlockName()
-
addToForwardList
void addToForwardList(EntryPoint ep)
-
addToReverseList
void addToReverseList(EntryPoint ep)
-
removeEntryPoint
void removeEntryPoint(EntryPoint ep)
-
getForwardEntryPointList
java.util.List<EntryPoint> getForwardEntryPointList()
-
getReverseEntryPointList
java.util.List<EntryPoint> getReverseEntryPointList()
-
getEntryPointList
java.util.List<EntryPoint> getEntryPointList()
-
isForwardEntryPoint
boolean isForwardEntryPoint(EntryPoint ep)
-
isReverseEntryPoint
boolean isReverseEntryPoint(EntryPoint ep)
-
getEntryPointFromSection
@CheckForNull EntryPoint getEntryPointFromSection(Section s, int dir)
Get the EntryPoint for entry from the specified Section for travel in specified direction.
-
getExitPointToSection
@CheckForNull EntryPoint getExitPointToSection(Section s, int dir)
Get the EntryPoint for exit to specified Section for travel in the specified direction.
-
getEntryPointFromBlock
@CheckForNull EntryPoint getEntryPointFromBlock(Block b, int dir)
Get the EntryPoint for entry from the specified Block for travel in the specified direction.
-
getExitPointToBlock
@CheckForNull EntryPoint getExitPointToBlock(Block b, int dir)
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
java.lang.String 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
void setAlternateColor(boolean set)
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
void setAlternateColorFromActiveBlock(boolean set)
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
void setNameInBlocks(java.lang.String name)
Set the block values for blocks in this Section.- Parameters:
name
- the value to set all blocks to
-
setNameInBlocks
void setNameInBlocks(java.lang.Object value)
Set the block values for blocks in this Section.- Parameters:
value
- the name to set block values to
-
setNameFromActiveBlock
void setNameFromActiveBlock(java.lang.Object value)
-
clearNameInUnoccupiedBlocks
void clearNameInUnoccupiedBlocks()
Clear the block values for blocks in this Section.
-
suppressNameUpdate
void suppressNameUpdate(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.- Parameters:
set
- true to suppress the update; false otherwise
-
setSectionType
void setSectionType(Section.SectionType type)
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
Section.SectionType getSectionType()
Get Section Type. Defaults to USERDEFINED.- Returns:
- constant of section type.
-
-