jmri
Class Transit

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.Transit
All Implemented Interfaces:
Serializable, NamedBean

public class Transit
extends AbstractNamedBean
implements Serializable

Class providing the basic implementation of a Transit.

Transits represent a group of Sections representing a specified path through a layout.

A Transit may have the following states. IDLE - indicating that it is available for "assignment" ASSIGNED - linked to a train to form 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 accomodate passing sidings and other track features, there may be alternate Sections connecting two Sections in a Transit. If so, one Section is assigned as primary, and other 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 before going elsewhere.

This file is part of JMRI.

JMRI is open source software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author:
Dave Duchamp Copyright (C) 2008
See Also:
Serialized Form

Field Summary
static int ASSIGNED
           
static int IDLE
          Constants representing the state of the Transit.
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
Transit(String systemName)
           
Transit(String systemName, String userName)
           
 
Method Summary
 void addTransitSection(TransitSection s)
          Add a TransitSection to the Transit Section sequence numnbers are set automatically as Sections are added.
 boolean canBeResetWhenDone()
          Determines whether this Transit is capable of continuous running.
 boolean checkSignals(JmriJFrame frame, LayoutEditor panel)
          Checks that exit Signal Heads are in place for all Sections in this Transit and for block boundaries at turnouts or level crossings within Sections of the Transit for the direction defined in this Transit.
 boolean containsBlock(Block b)
          Test if a Block is in the Transit
 boolean containsSection(Section s)
          Test if a Section is in the Transit
 int getBlockCount(Block b)
          Count the number of times a Block is in this Transit
 ArrayList<Integer> getBlockSeqList()
           
 ArrayList<Integer> getDestBlocksSeqList()
           
 ArrayList<Block> getDestinationBlocksList(Block startBlock, boolean startInTransit)
          Get a list of all destination blocks that can be reached from a specified starting block, "startBlock".
 int getDirectionFromSectionAndSeq(Section s, int seq)
          Gets the direction of a Section in the transit from its sequence number Returns 0 if direction was not found.
 ArrayList<Block> getEntryBlocksList()
          Get a list of all entry blocks to this Transit.
 ArrayList<Block> 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.
 int getMaxSequence()
          Get the maximum sequence number used in this Transit
 Section getSectionFromBlockAndSeq(Block b, int seq)
          Returns a Section from one of its Blocks and its sequence number
 Section getSectionFromConnectedBlockAndSeq(Block b, int seq)
          Returns a Section from one of its EntryPoint Blocks and its sequence number
 ArrayList<Section> getSectionListBySeq(int seq)
          Get a List of Sections with a given sequence number
 ArrayList<Integer> getSeqListBySection(Section s)
          Get a List of sequence numbers for a given Section
 int getState()
          Query the state of the Transit
 ArrayList<TransitSection> getTransitSectionList()
          Get a copy of this Transit's TransitSection list
 void removeAllSections()
          Remove all TransitSections
 void setState(int state)
          Set the state of the Transit
 boolean validateConnectivity(JmriJFrame frame, LayoutEditor panel)
          Validates connectivity through the Transit.
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDLE

public static final int IDLE
Constants representing the state of the Transit. A Transit can be either: IDLE - available for assignment to an ActiveTrain, or ASSIGNED - assigned to an ActiveTrain

See Also:
Constant Field Values

ASSIGNED

public static final int ASSIGNED
See Also:
Constant Field Values
Constructor Detail

Transit

public Transit(String systemName,
               String userName)

Transit

public Transit(String systemName)
Method Detail

getState

public int getState()
Query the state of the Transit

Specified by:
getState in interface NamedBean

setState

public void setState(int state)
Set the state of the Transit

Specified by:
setState in interface NamedBean

addTransitSection

public void addTransitSection(TransitSection s)
Add a TransitSection to the Transit Section sequence numnbers are set automatically as Sections are added. Returns "true" if Section was added. Returns "false" if Section does not connect to the current Section.


getTransitSectionList

public ArrayList<TransitSection> getTransitSectionList()
Get a copy of this Transit's TransitSection list


getMaxSequence

public int getMaxSequence()
Get the maximum sequence number used in this Transit


removeAllSections

public void removeAllSections()
Remove all TransitSections


containsSection

public boolean containsSection(Section s)
Test if a Section is in the Transit


getSectionListBySeq

public ArrayList<Section> getSectionListBySeq(int seq)
Get a List of Sections with a given sequence number


getSeqListBySection

public ArrayList<Integer> getSeqListBySection(Section s)
Get a List of sequence numbers for a given Section


containsBlock

public boolean containsBlock(Block b)
Test if a Block is in the Transit


getBlockCount

public int getBlockCount(Block b)
Count the number of times a Block is in this Transit


getSectionFromBlockAndSeq

public Section getSectionFromBlockAndSeq(Block b,
                                         int seq)
Returns a Section from one of its Blocks and its sequence number


getSectionFromConnectedBlockAndSeq

public Section getSectionFromConnectedBlockAndSeq(Block b,
                                                  int seq)
Returns a Section from one of its EntryPoint Blocks and its sequence number


getDirectionFromSectionAndSeq

public int getDirectionFromSectionAndSeq(Section s,
                                         int seq)
Gets the direction of a Section in the transit from its sequence number Returns 0 if direction was not found.


getInternalBlocksList

public ArrayList<Block> 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 calling getBlockSeqList().


getBlockSeqList

public ArrayList<Integer> getBlockSeqList()

getEntryBlocksList

public ArrayList<Block> 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 Transit's direction. The sequence numbers of the Section the Block will enter are accumulated in a parallel list, which can be accessed by immediately calling getBlockSeqList().


getDestinationBlocksList

public ArrayList<Block> getDestinationBlocksList(Block startBlock,
                                                 boolean startInTransit)
Get a list of all destination blocks that can be reached from a specified starting block, "startBlock". "startInTransit" should be set "true" if "startBlock" is in the Transit, and "false" otherwise. The sequence numbers of the Section the Block was found in are accumulated in a parallel list, which can be accessed by immediately calling getDestBlocksSeqList(). 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!


getDestBlocksSeqList

public ArrayList<Integer> getDestBlocksSeqList()

canBeResetWhenDone

public boolean canBeResetWhenDone()
Determines whether this Transit is capable of continuous running. That is, after an Active Train completes the Transit, can it automatically be set up to start again? To be resetable, 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. Returns 'true' if continuous running is possible, returns 'false' otherwise.


checkSignals

public boolean checkSignals(JmriJFrame frame,
                            LayoutEditor panel)
Checks that exit Signal Heads are in place for all Sections in this Transit and for block boundaries at turnouts or level crossings within Sections of the Transit for the direction defined in this Transit. Signal Heads are not required at anchor point block boundaries where both blocks are within the same Section, and for turnouts with two or more connections in the same Section. Returns "true" if everything is OK. Sends message to the user if a signal head is missing, and returns 'false'. Quits looking after finding the first missing signal head.


validateConnectivity

public boolean validateConnectivity(JmriJFrame frame,
                                    LayoutEditor panel)
Validates connectivity through the Transit. Returns "true" if everything is OK. Sends message to the user if break in connectivity is detected, ,and returns 'false'. Quits looking after finding the first problem.



Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads