Class ActiveTrain
- All Implemented Interfaces:
PropertyChangeProvider
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
- Performing 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, or Restart pressed to repeat the automated run.
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. Note: 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.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow much of the train can be detectedstatic enumScale Length type -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe value ofgetAllocateMethod()if allocating as many sections as are clear.static final intThe value ofgetAllocateMethod()if allocating up until the next safe sectionstatic final intConstants representing the mode of running of the Active Train The mode is set when the Active Train is created.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int(package private) intstatic final intstatic final intConstants representing Type of ActiveTrains.static final intstatic final intstatic final StringString property constant for mode.static final StringString property constant for section allocated.static final StringString property constant for section de-allocated.static final StringString property constant for signal.static final StringString property constant for status.static final int(package private) int(package private) int(package private) booleanstatic final intConstants representing the source of the train informationstatic final intConstants representing the Status of this ActiveTrain When created, the Status of an Active Train is always WAITING,static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleanaddEndSection(Section s, int seq) voidAdd aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.voidThis resets the state of the ActiveTrain so that it can be reallocated.voidvoiddispose()protected voidfirePropertyChange(String p, Object old, Object n) voidintReturns the AllocateM Method to be used by autoAllocateintgetAllocationDirectionFromSectionAndSeq(Section s, int seqNo) booleanReturns list of all Blocks occupied by or allocated to this train.intintintintintintintintgetMode()intintGet allPropertyChangeListeners currently attached to this object.getPropertyChangeListeners(String propertyName) Get allPropertyChangeListeners currently listening to changes to the specified property.booleanbooleanbooleanbooleanintintintbooleanintintgetRunningDirectionFromSectionAndSeq(Section s, int seqNo) protected SectionintintbooleanintGets the train detection typeintintprotected booleanprotected voidholdAllocation(boolean boo) voidvoidinitializeRestartAllocationSensor(NamedBeanHandle<Sensor> restartAllocationSensor) voidinitializeRestartSensor(Sensor restartSensor, boolean resetSensor) booleanprotected booleanprotected booleanbooleanprotected booleanvoidprotected voidvoidRemove the specified listener from this object.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Remove the specified listener of the specified property from this object.protected voidprotected voidrestart()protected AllocatedSectionvoidsetAllocateMethod(int i) Sets the Allocation Method to be used bu autoAllocatevoidsetAllocationReversed(boolean set) voidvoidsetAutoRun(boolean autoRun) voidsetControlingSignal(Object oldSignal, Object newSignal) voidsetDccAddress(String dccAddress) voidsetDelayedRestart(int delay) voidsetDelayedStart(int delay) voidvoidsetDepartureTimeHr(int hr) voidsetDepartureTimeMin(int min) voidvoidsetEndBlock(Block eBlock) voidsetEndBlockSection(Section eSection) voidsetEndBlockSectionSequenceNumber(int eBlockSeqNum) voidsetMode(int mode) voidsetNextTrain(String nextTrain) voidsetPriority(int priority) voidsetResetRestartSensor(boolean b) voidsetResetStartSensor(boolean b) voidsetResetWhenDone(boolean s) protected voidsetRestart(int delayType, int restartDelay, Sensor delaySensor, boolean resetSensorAfter) voidsetRestartDelay(int min) voidvoidsetReverseAtEnd(boolean s) voidsetReverseDelayRestart(int delay) voidvoidsetReverseResetRestartSensor(boolean b) voidsetReverseRestartDelay(int min) voidvoidsetStartBlock(Block sBlock) voidsetStartBlockSectionSequenceNumber(int sBlockSeqNum) voidvoidsetStatus(int status) voidsetTerminateWhenDone(boolean boo) voidsets the train detection typevoidsetTrainType(int type) voidsetTrainType(String sType) set train type using localized string name as storedvoidsetTransitReversed(boolean set) void
-
Field Details
-
RUNNING
Constants representing the Status of this ActiveTrain When created, the Status of an Active Train is always WAITING,- See Also:
-
PAUSED
- See Also:
-
WAITING
- See Also:
-
WORKING
- See Also:
-
READY
- See Also:
-
STOPPED
- See Also:
-
DONE
- See Also:
-
NONE
Constants representing Type of ActiveTrains.- See Also:
-
LOCAL_PASSENGER
- See Also:
-
LOCAL_FREIGHT
- See Also:
-
THROUGH_PASSENGER
- See Also:
-
THROUGH_FREIGHT
- See Also:
-
EXPRESS_PASSENGER
- See Also:
-
EXPRESS_FREIGHT
- See Also:
-
MOW
- See Also:
-
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:
-
MANUAL
- See Also:
-
DISPATCHED
- See Also:
-
TERMINATED
- See Also:
-
ROSTER
Constants representing the source of the train information- See Also:
-
OPERATIONS
- See Also:
-
USER
- See Also:
-
ALLOCATE_AS_FAR_AS_IT_CAN
The value ofgetAllocateMethod()if allocating as many sections as are clear.- See Also:
-
ALLOCATE_BY_SAFE_SECTIONS
The value ofgetAllocateMethod()if allocating up until the next safe section- See Also:
-
PROPERTY_STATUS
String property constant for status.- See Also:
-
PROPERTY_MODE
String property constant for mode.- See Also:
-
PROPERTY_SIGNAL
String property constant for signal.- See Also:
-
PROPERTY_SECTION_ALLOCATED
String property constant for section allocated.- See Also:
-
PROPERTY_SECTION_DEALLOCATED
String property constant for section de-allocated.- See Also:
-
NODELAY
- See Also:
-
TIMEDDELAY
- See Also:
-
SENSORDELAY
- See Also:
-
mReverseRestartDelay
-
restartHr
int restartHr -
restartMin
int restartMin -
restartPoint
boolean restartPoint
-
-
Constructor Details
-
ActiveTrain
Create an ActiveTrain.- Parameters:
t- the transit linked to this ActiveTrainname- the train nametrainSource- the source for this ActiveTrain
-
-
Method Details
-
getStarted
-
setDispatcher
-
setStarted
-
getTransit
-
getTransitName
-
getActiveTrainName
-
getTrainName
-
getTrainSource
-
setRosterEntry
-
getRosterEntry
-
getStatus
-
setStatus
-
setControlingSignal
-
getStatusText
-
setTrainDetection
sets the train detection type- Parameters:
value-ActiveTrain.TrainDetection
-
getTrainDetection
Gets the train detection type- Returns:
ActiveTrain.TrainDetection
-
isTransitReversed
-
setTransitReversed
-
isAllocationReversed
-
setAllocationReversed
-
getDelayedStart
-
setNextTrain
-
getNextTrain
-
setDelayedStart
-
getDelayedRestart
-
setDelayedRestart
-
getDelayReverseRestart
-
setReverseDelayRestart
-
getDepartureTimeHr
-
setDepartureTimeHr
-
getDepartureTimeMin
-
setDepartureTimeMin
-
setRestartDelay
-
getRestartDelay
-
getReverseRestartDelay
-
setReverseRestartDelay
-
getRestartDepartHr
-
getRestartDepartMin
-
setTerminateWhenDone
-
getDelaySensor
-
getDelaySensorName
-
setDelaySensor
-
setResetStartSensor
-
getResetStartSensor
-
getReverseRestartSensor
-
getReverseRestartSensorName
-
setReverseDelaySensor
-
setReverseResetRestartSensor
-
getResetReverseRestartSensor
-
getRestartSensor
-
getRestartSensorName
-
setRestartSensor
-
setResetRestartSensor
-
getResetRestartSensor
-
getSignalType
-
initializeDelaySensor
-
initializeRestartSensor
-
initializeRestartAllocationSensor
-
setTrainType
-
setTrainType
set train type using localized string name as stored- Parameters:
sType- name, such as "LOCAL_PASSENGER"
-
getTrainType
-
getTrainTypeText
-
getMode
-
forcePassNextSafeSection
-
setMode
-
getModeText
-
setAutoActiveTrain
-
getAutoActiveTrain
-
getRunningDirectionFromSectionAndSeq
-
getAllocationDirectionFromSectionAndSeq
-
addAllocatedSection
-
removeAllocatedSection
-
allocateAFresh
This resets the state of the ActiveTrain so that it can be reallocated. -
clearAllocations
-
getAllocatedSectionList
-
getBlockList
Returns list of all Blocks occupied by or allocated to this train. They are in order from the tail of the train to the head of the train then on to the forward-most allocated block. Note that unoccupied blocks can exist before and after the occupied blocks. TODO: doesn't handle reversing of adjacent multi-block sections well- Returns:
- the list of blocks order of occupation
-
getLastAllocatedSection
-
getLastAllocOverrideSafe
-
getLastAllocatedSectionSeqNumber
-
getLastAllocatedSectionName
-
getNextSectionToAllocate
-
getNextSectionSeqNumber
-
getNextSectionToAllocateName
-
getStartBlock
-
setStartBlock
-
getStartBlockSectionSequenceNumber
-
setStartBlockSectionSequenceNumber
-
getEndBlock
-
setEndBlock
-
getEndBlockSection
-
setEndBlockSection
-
getEndBlockSectionSequenceNumber
-
setEndBlockSectionSequenceNumber
-
getPriority
-
setPriority
-
getAutoRun
-
setAutoRun
-
getDccAddress
-
setDccAddress
-
getResetWhenDone
-
setResetWhenDone
-
getReverseAtEnd
-
setReverseAtEnd
-
getSecondAllocatedSection
-
getAllocateMethod
Returns the AllocateM Method to be used by autoAllocate- Returns:
- The number of Blocks ahead to be allocated or 0 = Allocate By Safe sections or -1 - Allocate All The Way.
-
setAllocateMethod
Sets the Allocation Method to be used bu autoAllocate- Parameters:
i- The number of Blocks ahead to be allocated or 0 = Allocate By Safe sections or -1 - Allocate All The Way.
-
initializeFirstAllocation
-
addEndSection
-
removeLastAllocatedSection
-
reverseAllAllocatedSections
-
resetAllAllocatedSections
-
setRestart
protected void setRestart(int delayType, int restartDelay, Sensor delaySensor, boolean resetSensorAfter) -
isInAllocatedList
-
isInAllocatedList
-
holdAllocation
-
holdAllocation
-
reachedRestartPoint
-
restart
-
terminate
-
dispose
-
firePropertyChange
-
addPropertyChangeListener
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- The PropertyChangeListener to be added
-
addPropertyChangeListener
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
getPropertyChangeListeners
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently attached to this object.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently listening to changes to the specified property.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Parameters:
propertyName- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
removePropertyChangeListener
Description copied from interface:PropertyChangeProviderRemove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- ThePropertyChangeListenerto remove.
-
removePropertyChangeListener
Description copied from interface:PropertyChangeProviderRemove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-