Interface Transit
- All Superinterfaces:
Comparable<NamedBean>,NamedBean,PropertyChangeProvider
- All Known Implementing Classes:
DefaultTransit
A Transit may have the following states:
- IDLE
- available for assignment to a train
- ASSIGNED
- linked to a train in an
ActiveTrain
When assigned to a Transit, options may be set for the assigned Section. The
Section and its options are kept in a TransitSection object.
To accommodate passing sidings and other track features, there may be multiple Sections connecting two other Sections in a Transit. If so, one Section is assigned as primary, and the other connecting Sections are assigned as alternates.
A Section may be in a Transit more than once, for example if a train is to make two or more loops around a layout before going elsewhere.
A Transit is normally traversed in the forward direction, that is, the direction of increasing Section Numbers. When a Transit traversal is started up, it is always started in the forward direction. However, to accommodate point-to-point (back and forth) route designs, the direction of travel in a Transit may be "reversed". While the Transit direction is "reversed", the direction of travel is the direction of decreasing Section numbers. Whether a Transit is in the "reversed" direction is kept in the ActiveTrain using the Transit.
-
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 intThe assigned to an ActiveTrain state.static final intThe idle, or available for assignment to an ActiveTrain state.Fields 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 TypeMethodDescriptionvoidAdd a Section to this Transit.booleanCheck if this Transit is capable of continuous running.booleancontainsBlock(Block block) Check if a Block is in this Transit.booleanCheck if a Section is in this Transit.intgetBlockCount(Block block) Get the number of times a Block is in this Transit.Get a list of sequence numbers in this Transit.Get a list of destination Block sequence numbers in this Transit.getDestinationBlocksList(Block startBlock, boolean startInTransit) Get a list of all destination blocks that can be reached from a specified starting block.intgetDirectionFromSectionAndSeq(Section s, int seq) Get the direction of a Section in the transit from its sequence number.Get a list of all entry Blocks to this Transit.Get a list of all blocks internal to this Transit.intGet the maximum sequence number used in this Transit.getSectionFromBlockAndSeq(Block b, int seq) Get a Section from one of its Blocks and its sequence number.getSectionFromConnectedBlockAndSeq(Block b, int seq) Get Section from one of its EntryPoint Blocks and its sequence number.getSectionListBySeq(int seq) Get a List of Sections with a given sequence number.Get a List of sequence numbers for a given Section.getTransitSectionFromSectionAndSeq(Section s, int seq) Get a TransitSection in the transit from its Section and sequence number.Get the list of TransitSections.getTransitSectionListBySeq(int seq) Get a List of TransitSections with a given sequence number.Get Transit Type.intInitialize blocking sensors for Sections in this Transit.voidRemove all TransitSections in this Transit.booleanvoidvoidsetState(int state) Set the state of this Transit.voidSet transit Type.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
-
IDLE
The idle, or available for assignment to an ActiveTrain state.- See Also:
-
ASSIGNED
The assigned to an ActiveTrain state.- See Also:
-
-
Method Details
-
setState
Set the state of this Transit. -
addTransitSection
Add a Section to this Transit.- Parameters:
s- the Section object to add
-
getTransitSectionList
Get the list of TransitSections.- Returns:
- a copy of the internal list of TransitSections or an empty list
-
getMaxSequence
int getMaxSequence()Get the maximum sequence number used in this Transit.- Returns:
- the maximum sequence
-
removeAllSections
void removeAllSections()Remove all TransitSections in this Transit. -
containsSection
Check if a Section is in this Transit.- Parameters:
s- the section to check for- Returns:
- true if the section is present; false otherwise
-
getSectionListBySeq
Get a List of Sections with a given sequence number.- Parameters:
seq- the sequence number- Returns:
- the list of of matching sections or an empty list if none
-
getTransitSectionListBySeq
Get a List of TransitSections with a given sequence number.- Parameters:
seq- the sequence number- Returns:
- the list of of matching sections or an empty list if none
-
getSeqListBySection
Get a List of sequence numbers for a given Section.- Parameters:
s- the section to match- Returns:
- the list of matching sequence numbers or an empty list if none
-
containsBlock
Check if a Block is in this Transit.- Parameters:
block- the block to check for- Returns:
- true if block is present; false otherwise
-
getBlockCount
Get the number of times a Block is in this Transit.- Parameters:
block- the block to check for- Returns:
- the number of times block is present; 0 if block is not present
-
getSectionFromBlockAndSeq
Get a Section from one of its Blocks and its sequence number.- Parameters:
b- the block within the Sectionseq- the sequence number of the Section- Returns:
- the Section or null if no matching Section is present
-
getSectionFromConnectedBlockAndSeq
Get Section from one of its EntryPoint Blocks and its sequence number.- Parameters:
b- the connecting block to the Sectionseq- the sequence number of the Section- Returns:
- the Section or null if no matching Section is present
-
getDirectionFromSectionAndSeq
Get the direction of a Section in the transit from its sequence number.- Parameters:
s- the Section to checkseq- the sequence number of the Section- Returns:
- the direction of the Section (one of
Section.FORWARDorSection.REVERSEor zero if s and seq are not in a TransitSection together
-
getTransitSectionFromSectionAndSeq
Get a TransitSection in the transit from its Section and sequence number.- Parameters:
s- the Section to checkseq- the sequence number of the Section- Returns:
- the transit section or null if not found
-
getInternalBlocksList
Get a list of all blocks internal to this Transit. Since Sections may be present more than once, blocks may be listed more than once. The sequence numbers of the Section the Block was found in are accumulated in a parallel list, which can be accessed by immediately callinggetBlockSeqList().- Returns:
- the list of all Blocks or an empty list if none are present
-
getBlockSeqList
Get a list of sequence numbers in this Transit. This list is generated by callinggetInternalBlocksList()orgetEntryBlocksList().- Returns:
- the list of all sequence numbers or an empty list if no Blocks are present
-
getEntryBlocksList
Get a list of all entry Blocks to this Transit. These are Blocks that a Train might enter from and be going in the direction of this Transit. The sequence numbers of the Section the Block will enter are accumulated in a parallel list, which can be accessed by immediately callinggetBlockSeqList().- Returns:
- the list of all blocks or an empty list if none are present
-
getDestinationBlocksList
Get a list of all destination blocks that can be reached from a specified starting block. The sequence numbers of the Sections destination blocks were found in are accumulated in a parallel list, which can be accessed by immediately callinggetDestBlocksSeqList().Note: A Train may not terminate in the same Section in which it starts.
Note: A Train must terminate in a Block within the Transit.
- Parameters:
startBlock- the starting Block to find destinations forstartInTransit- true if startBlock is within this Transit; false otherwise- Returns:
- a list of destination Blocks or an empty list if none exist
-
getDestBlocksSeqList
Get a list of destination Block sequence numbers in this Transit. This list is generated by callinggetDestinationBlocksList(jmri.Block, boolean).- Returns:
- the list of all destination Block sequence numbers or an empty list if no destination Blocks are present
-
canBeResetWhenDone
boolean canBeResetWhenDone()Check if this Transit is capable of continuous running.A Transit is capable of continuous running if, after an Active Train completes the Transit, it can automatically be restarted. To be restartable, the first Section and the last Section must be the same Section, and the first and last Sections must be defined to run in the same direction. If the last Section is an alternate Section, the previous Section is tested. However, if the Active Train does not complete its Transit in the same Section it started in, the restart will not take place.
- Returns:
- true if continuous running is possible; otherwise false
-
initializeBlockingSensors
Initialize blocking sensors for Sections in this Transit. This should be done before any Sections are allocated for this Transit. Only Sections that areSection.FREEare initialized, so as not to interfere with running active trains. If any Section does not have blocking sensors, warning messages are logged.- Returns:
- 0 if no errors, number of errors otherwise.
-
removeTemporarySections
void removeTemporarySections() -
removeLastTemporarySection
-
setTransitType
Set transit Type.- USERDEFINED - Default Save all the information.
- DYNAMICADHOC - Created on an as required basis, not to be saved.
- Parameters:
type- constant of transit type.
-
getTransitType
Get Transit Type. Defaults to USERDEFINED.- Returns:
- constant of section type.
-