jmri.jmrit.dispatcher
Class ActiveTrain

java.lang.Object
  extended by jmri.jmrit.dispatcher.ActiveTrain

public class ActiveTrain
extends Object

This class holds information and options for an ActiveTrain, that is a train that has been linked to a Transit and activated for transit around the layout.

An ActiveTrain may be assigned one of the following modes, which specify how the active train will be run through its transit: AUTOMATIC - indicates the ActiveTrain will be run under automatic control of the computer. (Automatic Running) MANUAL - indicates an ActiveTrain running in AUTOMATIC mode has reached a Special Action in its Transit that requires MANUAL operation. When this happens, the status changes to WORKING, and the mode changes to MANUAL. The ActiveTrain will be run by an operator using a throttle. AUTOMATIC running is resumed when the work has been completed. DISPATCHED - indicates the ActiveTrain will be run by an operator using a throttle. A dispatcher will allocate Sections to the ActiveTrain as needed, control optional signals using a CTC panel or computer logic, and arbitrate any conflicts between ActiveTrains. (Human Dispatcher).

An ActiveTrain will have one of the following statuses: RUNNING - Actively running on the layout, according to its mode of operation. PAUSED - Paused waiting for a user-specified number of fast clock minutes. The Active Train is expected to move to either RUNNING or WAITING once the specified number of minutes has elapsed. This is intended for automatic station stops. (automatic trains only) WAITING - Stopped waiting for a Section allocation. This is the state the Active Train is in when it is created in Dispatcher. WORKING - Peforming work under control of a human engineer. This is the state an Active Train assumes when an engineer is picking up or setting out cars at industries. (automatic trains only) READY - Train has completed WORKING, and is awaiting a restart - dispatcher clearance to resume running. (automatic trains only) STOPPED - Train was stopped by the dispatcher. Dispatcher must resume. (automatic trains only) DONE - Train has completed its transit of the layout and is ready to be terminated by the dispatcher. Status is a bound property.

The ActiveTrain status should maintained (setStatus) by the running class, or if running in DISPATCHED mode, by Dispatcher. When an ActiveTrain is WAITING, and the dispatcher allocates a section to it, the status of the ActiveTrain is automatically set to RUNNING. So an autoRun class can listen to the status of the ActiveTrain to trigger start up if the train has been waiting for the dispatcher. Npte: There is still more to be programmed here.

Train information supplied when the ActiveTrain is created can come from any of the following: ROSTER - The train was selected from the JMRI roster menu OPERATIONS - The train was selected from trains available from JMRI operations USER - Neither menu was used--the user entered a name and DCC address. Train source information is recorded when an ActiveTrain is created, and may be referenced by getTrainSource if it is needed by other objects. The train source should be specified in the Dispatcher Options window prior to creating an ActiveTrain.

ActiveTrains are referenced via a list in DispatcherFrame, which serves as a manager for ActiveTrain objects.

ActiveTrains are transient, and are not saved to disk. Active Train information can be saved to disk, making set up with the same options, etc very easy.

An ActiveTrain runs through its Transit in the FORWARD direction, until a Transit Action reverses the direction of travel in the Transit. When running with its Transit reversed, the Active Train returns to its starting Section. Upon reaching and stopping in its starting Section, the Transit is automatically set back to the forward direction. If AutoRestart is set, the run is repeated. The direction of travel in the Transit is maintained here.

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-2011

Field Summary
static int AUTOMATIC
          Constants representing the mode of running of the Active Train The mode is set when the Active Train is created.
static int DISPATCHED
           
static int DONE
           
static int EXPRESS_FREIGHT
           
static int EXPRESS_PASSENGER
           
static int LOCAL_FREIGHT
           
static int LOCAL_PASSENGER
           
static int MANUAL
           
static int MOW
           
static int NONE
          Constants representing Type of ActiveTrains.
static int OPERATIONS
           
static int PAUSED
           
static int READY
           
static int ROSTER
          Constants representing the source of the train information
static int RUNNING
          Constants representing the Status of this ActiveTrain When created, the Status of an Active Train is always WAITING,
static int STOPPED
           
static int THROUGH_FREIGHT
           
static int THROUGH_PASSENGER
           
static int USER
           
static int WAITING
           
static int WORKING
           
 
Constructor Summary
ActiveTrain(Transit t, String name, int trainSource)
          Main constructor method
 
Method Summary
 void addAllocatedSection(AllocatedSection as)
           
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void dispose()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 String getActiveTrainName()
           
 ArrayList<AllocatedSection> getAllocatedSectionList()
           
 int getAllocationDirectionFromSectionAndSeq(Section s, int seqNo)
           
 AutoActiveTrain getAutoActiveTrain()
           
 boolean getAutoRun()
           
 String getDccAddress()
           
 boolean getDelayedStart()
           
 int getDepartureTimeHr()
           
 int getDepartureTimeMin()
           
 Block getEndBlock()
           
 Section getEndBlockSection()
           
 int getEndBlockSectionSequenceNumber()
           
 Section getLastAllocatedSection()
           
 String getLastAllocatedSectionName()
           
 int getMode()
           
 String getModeText()
           
 int getNextSectionSeqNumber()
           
 Section getNextSectionToAllocate()
           
 String getNextSectionToAllocateName()
           
 int getPriority()
           
 boolean getResetWhenDone()
           
 boolean getReverseAtEnd()
           
 int getRunningDirectionFromSectionAndSeq(Section s, int seqNo)
           
protected  Section getSecondAllocatedSection()
           
 Block getStartBlock()
           
 int getStartBlockSectionSequenceNumber()
           
 boolean getStarted()
          Access methods
 int getStatus()
           
 String getStatusText()
           
 String getTrainName()
           
 int getTrainSource()
           
 int getTrainType()
           
 String getTrainTypeText()
           
 Transit getTransit()
           
 String getTransitName()
           
 AllocationRequest initializeFirstAllocation()
          Operating methods
 boolean isAllocationReversed()
           
 boolean isTransitReversed()
           
 void removeAllocatedSection(AllocatedSection as)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
protected  void resetAllAllocatedSections()
           
protected  void reverseAllAllocatedSections()
           
 void setAllocationReversed(boolean set)
           
 void setAutoActiveTrain(AutoActiveTrain aat)
           
 void setAutoRun(boolean autoRun)
           
 void setDccAddress(String dccAddress)
           
 void setDelayedStart(boolean set)
           
 void setDepartureTimeHr(int hr)
           
 void setDepartureTimeMin(int min)
           
 void setEndBlock(Block eBlock)
           
 void setEndBlockSection(Section eSection)
           
 void setEndBlockSectionSequenceNumber(int eBlockSeqNum)
           
 void setMode(int mode)
           
 void setPriority(int priority)
           
 void setResetWhenDone(boolean s)
           
 void setReverseAtEnd(boolean s)
           
 void setStartBlock(Block sBlock)
           
 void setStartBlockSectionSequenceNumber(int sBlockSeqNum)
           
 void setStarted()
           
 void setStatus(int status)
           
 void setTrainType(int type)
           
 void setTransitReversed(boolean set)
           
 void terminate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RUNNING

public static final int RUNNING
Constants representing the Status of this ActiveTrain When created, the Status of an Active Train is always WAITING,

See Also:
Constant Field Values

PAUSED

public static final int PAUSED
See Also:
Constant Field Values

WAITING

public static final int WAITING
See Also:
Constant Field Values

WORKING

public static final int WORKING
See Also:
Constant Field Values

READY

public static final int READY
See Also:
Constant Field Values

STOPPED

public static final int STOPPED
See Also:
Constant Field Values

DONE

public static final int DONE
See Also:
Constant Field Values

NONE

public static final int NONE
Constants representing Type of ActiveTrains.

See Also:
Constant Field Values

LOCAL_PASSENGER

public static final int LOCAL_PASSENGER
See Also:
Constant Field Values

LOCAL_FREIGHT

public static final int LOCAL_FREIGHT
See Also:
Constant Field Values

THROUGH_PASSENGER

public static final int THROUGH_PASSENGER
See Also:
Constant Field Values

THROUGH_FREIGHT

public static final int THROUGH_FREIGHT
See Also:
Constant Field Values

EXPRESS_PASSENGER

public static final int EXPRESS_PASSENGER
See Also:
Constant Field Values

EXPRESS_FREIGHT

public static final int EXPRESS_FREIGHT
See Also:
Constant Field Values

MOW

public static final int MOW
See Also:
Constant Field Values

AUTOMATIC

public static final int AUTOMATIC
Constants representing the mode of running of the Active Train The mode is set when the Active Train is created. The mode may be switched during a run.

See Also:
Constant Field Values

MANUAL

public static final int MANUAL
See Also:
Constant Field Values

DISPATCHED

public static final int DISPATCHED
See Also:
Constant Field Values

ROSTER

public static final int ROSTER
Constants representing the source of the train information

See Also:
Constant Field Values

OPERATIONS

public static final int OPERATIONS
See Also:
Constant Field Values

USER

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

ActiveTrain

public ActiveTrain(Transit t,
                   String name,
                   int trainSource)
Main constructor method

Method Detail

getStarted

public boolean getStarted()
Access methods


setStarted

public void setStarted()

getTransit

public Transit getTransit()

getTransitName

public String getTransitName()

getActiveTrainName

public String getActiveTrainName()

getTrainName

public String getTrainName()

getTrainSource

public int getTrainSource()

getStatus

public int getStatus()

setStatus

public void setStatus(int status)

getStatusText

public String getStatusText()

isTransitReversed

public boolean isTransitReversed()

setTransitReversed

public void setTransitReversed(boolean set)

isAllocationReversed

public boolean isAllocationReversed()

setAllocationReversed

public void setAllocationReversed(boolean set)

getDelayedStart

public boolean getDelayedStart()

setDelayedStart

public void setDelayedStart(boolean set)

getDepartureTimeHr

public int getDepartureTimeHr()

setDepartureTimeHr

public void setDepartureTimeHr(int hr)

getDepartureTimeMin

public int getDepartureTimeMin()

setDepartureTimeMin

public void setDepartureTimeMin(int min)

setTrainType

public void setTrainType(int type)

getTrainType

public int getTrainType()

getTrainTypeText

public String getTrainTypeText()

getMode

public int getMode()

setMode

public void setMode(int mode)

getModeText

public String getModeText()

setAutoActiveTrain

public void setAutoActiveTrain(AutoActiveTrain aat)

getAutoActiveTrain

public AutoActiveTrain getAutoActiveTrain()

getRunningDirectionFromSectionAndSeq

public int getRunningDirectionFromSectionAndSeq(Section s,
                                                int seqNo)

getAllocationDirectionFromSectionAndSeq

public int getAllocationDirectionFromSectionAndSeq(Section s,
                                                   int seqNo)

addAllocatedSection

public void addAllocatedSection(AllocatedSection as)

removeAllocatedSection

public void removeAllocatedSection(AllocatedSection as)

getAllocatedSectionList

public ArrayList<AllocatedSection> getAllocatedSectionList()

getLastAllocatedSection

public Section getLastAllocatedSection()

getLastAllocatedSectionName

public String getLastAllocatedSectionName()

getNextSectionToAllocate

public Section getNextSectionToAllocate()

getNextSectionSeqNumber

public int getNextSectionSeqNumber()

getNextSectionToAllocateName

public String getNextSectionToAllocateName()

getStartBlock

public Block getStartBlock()

setStartBlock

public void setStartBlock(Block sBlock)

getStartBlockSectionSequenceNumber

public int getStartBlockSectionSequenceNumber()

setStartBlockSectionSequenceNumber

public void setStartBlockSectionSequenceNumber(int sBlockSeqNum)

getEndBlock

public Block getEndBlock()

setEndBlock

public void setEndBlock(Block eBlock)

getEndBlockSection

public Section getEndBlockSection()

setEndBlockSection

public void setEndBlockSection(Section eSection)

getEndBlockSectionSequenceNumber

public int getEndBlockSectionSequenceNumber()

setEndBlockSectionSequenceNumber

public void setEndBlockSectionSequenceNumber(int eBlockSeqNum)

getPriority

public int getPriority()

setPriority

public void setPriority(int priority)

getAutoRun

public boolean getAutoRun()

setAutoRun

public void setAutoRun(boolean autoRun)

getDccAddress

public String getDccAddress()

setDccAddress

public void setDccAddress(String dccAddress)

getResetWhenDone

public boolean getResetWhenDone()

setResetWhenDone

public void setResetWhenDone(boolean s)

getReverseAtEnd

public boolean getReverseAtEnd()

setReverseAtEnd

public void setReverseAtEnd(boolean s)

getSecondAllocatedSection

protected Section getSecondAllocatedSection()

initializeFirstAllocation

public AllocationRequest initializeFirstAllocation()
Operating methods


reverseAllAllocatedSections

protected void reverseAllAllocatedSections()

resetAllAllocatedSections

protected void resetAllAllocatedSections()

terminate

public void terminate()

dispose

public void dispose()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)


Copyright © 1997 - 2011 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