jmri.jmrit.dispatcher
Class AutoActiveTrain

java.lang.Object
  extended by jmri.jmrit.dispatcher.AutoActiveTrain
All Implemented Interfaces:
EventListener, ThrottleListener

public class AutoActiveTrain
extends Object
implements ThrottleListener

This class holds information and options for an ActiveTrain when it is running in AUTOMATIC mode. It ia an extension to Active Train for automatic running.

This class implements logic that follows a train around a layout. Train follows signals, provided the next Section is allocated to it, and its ActiveTrain's status is RUNNING.

This class is linked via it's parent ActiveTrain object.

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.

The AutoEngineer sub class is based in part on code by Pete Cressman contained in Warrants.java

Author:
Dave Duchamp Copyright (C) 2010-2011

Field Summary
static int BEGINNING_RESET
           
static int END_REVERSAL
           
static int LIMITED_SPEED
           
static int MAXIMUM_SPEED
           
static int MEDIUM_SPEED
           
static int NO_TASK
           
static int NORMAL_SPEED
           
static int RAMP_FAST
           
static int RAMP_MED_SLOW
           
static int RAMP_MEDIUM
           
static int RAMP_NONE
           
static int RAMP_SLOW
           
static int RESTRICTED_SPEED
           
static int SLOW_SPEED
           
static int SPEED_MASK
           
static int STOP_SPEED
           
 
Constructor Summary
AutoActiveTrain(ActiveTrain at)
          Main constructor method
 
Method Summary
protected  void decrementHornExecution()
           
 void dispose()
           
protected  void executeStopTasks(int task)
           
 ActiveTrain getActiveTrain()
           
 jmri.jmrit.dispatcher.AutoActiveTrain.AutoEngineer getAutoEngineer()
           
 AutoTrainAction getAutoTrainAction()
           
protected  AllocatedSection getCurrentAllocatedSection()
           
 boolean getForward()
           
 float getMaxSpeed()
           
 float getMaxTrainLength()
           
 int getRampRate()
           
 boolean getResistanceWheels()
           
 boolean getRunInReverse()
           
 int getSavedStatus()
           
 boolean getSoundDecoder()
           
 float getSpeedFactor()
           
 float getTargetSpeed()
           
protected  void handleBlockStateChange(AllocatedSection as, Block b)
           
protected  void handleSectionOccupancyChange(AllocatedSection as)
           
protected  void handleSectionStateChange(AllocatedSection as)
          Notification methods Handle notification of change in state and occupancy of Sections and Blocks to track the train around the Transit
protected  void incrementHornExecution()
           
 boolean initialize()
          Initialize new Auto Active Train or get a new throttle after WORKING Sets up the DCC address and initiates creation of a throttle to run the train.
protected  void initiateWorking()
          Initiates running in manual mode with external throttle This method is triggered by an action in the Transit The throttle in use for automatic operation is dispatched
 void notifyFailedThrottleRequest(DccLocoAddress address, String reason)
          Get notification that an attempt to request a throttle has failed
 void notifyThrottleFound(DccThrottle t)
          Get notification that a throttle has been found as you requested.
 Thread pauseTrain(int fastMinutes)
          Pauses the auto active train for a specified number of fast clock minutes Pausing operation is performed in a separate thread
protected  void removeAllocatedSection(AllocatedSection as)
           
protected  void restoreSavedSpeed()
           
protected  void resumeAutomaticRunning()
          Resumes automatic running after a working session using an external throttle This method is triggered by the dispatcher hitting the "Resume Auto Running" button A new throttle is acquired to allow automatic running to resume
protected  void saveSpeed()
           
 void setCurrentRampRate(int rate)
           
protected  void setEngineDirection()
          support methods
 void setForward(boolean set)
           
 void setMaxSpeed(float speed)
           
 void setMaxTrainLength(float length)
           
 void setRampRate(int rate)
           
 void setResistanceWheels(boolean set)
           
 void setRunInReverse(boolean set)
           
 void setSavedStatus(int status)
           
 void setSoundDecoder(boolean set)
           
protected  void setSpeedBySignal()
           
 void setSpeedFactor(float factor)
           
 void setTargetSpeed(float speed)
           
 void terminate()
           
protected  void waitUntilStopped()
          Returns when train is stopped Note: Provides for _autoEngineer becoming null during wait Ties up the current autoActiveTrain thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPEED_MASK

public static final int SPEED_MASK
See Also:
Constant Field Values

STOP_SPEED

public static final int STOP_SPEED
See Also:
Constant Field Values

RESTRICTED_SPEED

public static final int RESTRICTED_SPEED
See Also:
Constant Field Values

SLOW_SPEED

public static final int SLOW_SPEED
See Also:
Constant Field Values

MEDIUM_SPEED

public static final int MEDIUM_SPEED
See Also:
Constant Field Values

LIMITED_SPEED

public static final int LIMITED_SPEED
See Also:
Constant Field Values

NORMAL_SPEED

public static final int NORMAL_SPEED
See Also:
Constant Field Values

MAXIMUM_SPEED

public static final int MAXIMUM_SPEED
See Also:
Constant Field Values

RAMP_NONE

public static final int RAMP_NONE
See Also:
Constant Field Values

RAMP_FAST

public static final int RAMP_FAST
See Also:
Constant Field Values

RAMP_MEDIUM

public static final int RAMP_MEDIUM
See Also:
Constant Field Values

RAMP_MED_SLOW

public static final int RAMP_MED_SLOW
See Also:
Constant Field Values

RAMP_SLOW

public static final int RAMP_SLOW
See Also:
Constant Field Values

NO_TASK

public static final int NO_TASK
See Also:
Constant Field Values

END_REVERSAL

public static final int END_REVERSAL
See Also:
Constant Field Values

BEGINNING_RESET

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

AutoActiveTrain

public AutoActiveTrain(ActiveTrain at)
Main constructor method

Method Detail

getActiveTrain

public ActiveTrain getActiveTrain()

getAutoEngineer

public jmri.jmrit.dispatcher.AutoActiveTrain.AutoEngineer getAutoEngineer()

getAutoTrainAction

public AutoTrainAction getAutoTrainAction()

getForward

public boolean getForward()

setForward

public void setForward(boolean set)

getTargetSpeed

public float getTargetSpeed()

setTargetSpeed

public void setTargetSpeed(float speed)

getSavedStatus

public int getSavedStatus()

setSavedStatus

public void setSavedStatus(int status)

setCurrentRampRate

public void setCurrentRampRate(int rate)

getRampRate

public int getRampRate()

setRampRate

public void setRampRate(int rate)

getSpeedFactor

public float getSpeedFactor()

setSpeedFactor

public void setSpeedFactor(float factor)

getMaxSpeed

public float getMaxSpeed()

setMaxSpeed

public void setMaxSpeed(float speed)

getResistanceWheels

public boolean getResistanceWheels()

setResistanceWheels

public void setResistanceWheels(boolean set)

getRunInReverse

public boolean getRunInReverse()

setRunInReverse

public void setRunInReverse(boolean set)

getSoundDecoder

public boolean getSoundDecoder()

setSoundDecoder

public void setSoundDecoder(boolean set)

getMaxTrainLength

public float getMaxTrainLength()

setMaxTrainLength

public void setMaxTrainLength(float length)

initialize

public boolean initialize()
Initialize new Auto Active Train or get a new throttle after WORKING Sets up the DCC address and initiates creation of a throttle to run the train.


notifyThrottleFound

public void notifyThrottleFound(DccThrottle t)
Description copied from interface: ThrottleListener
Get notification that a throttle has been found as you requested.

Specified by:
notifyThrottleFound in interface ThrottleListener
Parameters:
t - An instantiation of the DccThrottle with the address requested.

notifyFailedThrottleRequest

public void notifyFailedThrottleRequest(DccLocoAddress address,
                                        String reason)
Description copied from interface: ThrottleListener
Get notification that an attempt to request a throttle has failed

Specified by:
notifyFailedThrottleRequest in interface ThrottleListener
Parameters:
address - DccLocoAddress of the failed loco request.
reason - The reason why the throttle request failed.

saveSpeed

protected void saveSpeed()

restoreSavedSpeed

protected void restoreSavedSpeed()

decrementHornExecution

protected void decrementHornExecution()

incrementHornExecution

protected void incrementHornExecution()

handleSectionStateChange

protected void handleSectionStateChange(AllocatedSection as)
Notification methods Handle notification of change in state and occupancy of Sections and Blocks to track the train around the Transit


handleSectionOccupancyChange

protected void handleSectionOccupancyChange(AllocatedSection as)

handleBlockStateChange

protected void handleBlockStateChange(AllocatedSection as,
                                      Block b)

setEngineDirection

protected void setEngineDirection()
support methods


getCurrentAllocatedSection

protected AllocatedSection getCurrentAllocatedSection()

removeAllocatedSection

protected void removeAllocatedSection(AllocatedSection as)

setSpeedBySignal

protected void setSpeedBySignal()

executeStopTasks

protected void executeStopTasks(int task)

initiateWorking

protected void initiateWorking()
Initiates running in manual mode with external throttle This method is triggered by an action in the Transit The throttle in use for automatic operation is dispatched


waitUntilStopped

protected void waitUntilStopped()
Returns when train is stopped Note: Provides for _autoEngineer becoming null during wait Ties up the current autoActiveTrain thread


resumeAutomaticRunning

protected void resumeAutomaticRunning()
Resumes automatic running after a working session using an external throttle This method is triggered by the dispatcher hitting the "Resume Auto Running" button A new throttle is acquired to allow automatic running to resume


pauseTrain

public Thread pauseTrain(int fastMinutes)
Pauses the auto active train for a specified number of fast clock minutes Pausing operation is performed in a separate thread


terminate

public void terminate()

dispose

public void dispose()


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