jmri.jmrit.logix
Class Warrant

Show UML class diagram
java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.jmrit.logix.Warrant
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, NamedBean, ThrottleListener

public class Warrant
extends AbstractNamedBean
implements ThrottleListener, PropertyChangeListener

An Warrant contains the operating permissions and directives needed for a train to proceed from an Origin to a Destination

Version 1.11 - remove setting of SignalHeads

See Also:
Serialized Form

Field Summary
static int ABORT
           
static int HALT
           
static int MODE_LEARN
           
static int MODE_NONE
           
static int MODE_RUN
           
static int RESUME
           
static int RUNNING
           
static int SPEED_RESTRICTED
           
static int WAIT
           
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
Warrant(String sName, String uName)
          Create an object with no route defined.
 
Method Summary
 void addBlockOrder(BlockOrder order)
          Add permanently saved BlockOrder
 void addThrottleCommand(ThrottleSetting ts)
           
 String allocateRoute()
          Allocate the current saved blocks of this warrant.
 void clearAll()
           
 boolean controlRunTrain(int idx)
          Pause and resume auto-running train
 void deAllocate()
          Deallocates blocks from the current BlockOrder list
 BlockOrder getCurrentBlockOrder()
           
 int getCurrentCommandIndex()
           
 int getCurrentOrderIndex()
           
 DccLocoAddress getDccAddress()
           
 BlockOrder getfirstOrder()
          Return permanently saved Origin
 BlockOrder getLastOrder()
          Return permanently saved Destination
 List<BlockOrder> getOrders()
          Return permanently saved BlockOrders
 boolean getRunBlind()
           
 int getRunMode()
          Methods for running trains
 String getRunningMessage()
           
static SignalSpeedMap getSpeedMap()
           
 int getState()
          Provide generic access to internal state.
 List<ThrottleSetting> getThrottleCommands()
           
 String getTrainId()
           
 BlockOrder getViaOrder()
          Return permanently saved BlockOrder that must be included in the route
 boolean hasRouteSet()
          Turnouts and signals are set for the route
 boolean isAllocated()
          Listeners are installed for the route
 void notifyThrottleFound(DccThrottle t)
          Get notification that a throttle has been found as you requested.
 void propertyChange(PropertyChangeEvent evt)
           
 boolean routeIsFree()
          Test if the permanent saved blocks of this warrant are free (unoccupied and unallocated)
 boolean routeIsOccupied()
          Test if the permanent saved blocks of this warrant are occupied
 String runAutoTrain(boolean run)
          Starts or ends an automated train run.
 void setDccAddress(DccLocoAddress address)
           
 String setRoute(int delay, List<BlockOrder> orders)
          Set the route paths and turnouts for the warrant.
 void setRunBlind(boolean runBlind)
           
 void setState(int state)
          Provide generic access to internal state.
 String setThrottleFactor(String sFactor)
           
 boolean setTrainId(String id)
           
 void setViaOrder(BlockOrder order)
           
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, dispose, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_NONE

public static final int MODE_NONE
See Also:
Constant Field Values

MODE_LEARN

public static final int MODE_LEARN
See Also:
Constant Field Values

MODE_RUN

public static final int MODE_RUN
See Also:
Constant Field Values

HALT

public static final int HALT
See Also:
Constant Field Values

RESUME

public static final int RESUME
See Also:
Constant Field Values

ABORT

public static final int ABORT
See Also:
Constant Field Values

WAIT

public static final int WAIT
See Also:
Constant Field Values

RUNNING

public static final int RUNNING
See Also:
Constant Field Values

SPEED_RESTRICTED

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

Warrant

public Warrant(String sName,
               String uName)
Create an object with no route defined. The list of BlockOrders is the route from an Origin to a Destination

Method Detail

getSpeedMap

public static final SignalSpeedMap getSpeedMap()

getState

public int getState()
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. getCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
getState in interface NamedBean

setState

public void setState(int state)
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. setCommandedState in Turnout) This provided to make Jython script access easier to read.

Specified by:
setState in interface NamedBean

clearAll

public void clearAll()

getOrders

public List<BlockOrder> getOrders()
Return permanently saved BlockOrders


addBlockOrder

public void addBlockOrder(BlockOrder order)
Add permanently saved BlockOrder


getfirstOrder

public BlockOrder getfirstOrder()
Return permanently saved Origin


getLastOrder

public BlockOrder getLastOrder()
Return permanently saved Destination


getViaOrder

public BlockOrder getViaOrder()
Return permanently saved BlockOrder that must be included in the route


setViaOrder

public void setViaOrder(BlockOrder order)

getCurrentBlockOrder

public BlockOrder getCurrentBlockOrder()

getCurrentOrderIndex

public int getCurrentOrderIndex()

getThrottleCommands

public List<ThrottleSetting> getThrottleCommands()

addThrottleCommand

public void addThrottleCommand(ThrottleSetting ts)

getTrainId

public String getTrainId()

setTrainId

public boolean setTrainId(String id)

getDccAddress

public DccLocoAddress getDccAddress()

setDccAddress

public void setDccAddress(DccLocoAddress address)

getRunBlind

public boolean getRunBlind()

setRunBlind

public void setRunBlind(boolean runBlind)

setThrottleFactor

public String setThrottleFactor(String sFactor)

isAllocated

public boolean isAllocated()
Listeners are installed for the route


hasRouteSet

public boolean hasRouteSet()
Turnouts and signals are set for the route


routeIsFree

public boolean routeIsFree()
Test if the permanent saved blocks of this warrant are free (unoccupied and unallocated)


routeIsOccupied

public boolean routeIsOccupied()
Test if the permanent saved blocks of this warrant are occupied


getRunMode

public int getRunMode()
Methods for running trains


runAutoTrain

public String runAutoTrain(boolean run)
Starts or ends an automated train run. setRoute nust be called before calling this method.

Parameters:
run - set Run throttle command or Stop
Returns:
returns an error message (or null on success)

getRunningMessage

public String getRunningMessage()

getCurrentCommandIndex

public int getCurrentCommandIndex()

controlRunTrain

public boolean controlRunTrain(int idx)
Pause and resume auto-running 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.

allocateRoute

public String allocateRoute()
Allocate the current saved blocks of this warrant. Installs listeners for the entire route. Sets this warrant into OBlock's _warrant field. Returns the index of a block allocated to another warrant, (i.e. value field not null).

Returns:
index of block that failed to be allocated to this warrant

deAllocate

public void deAllocate()
Deallocates blocks from the current BlockOrder list


setRoute

public String setRoute(int delay,
                       List<BlockOrder> orders)
Set the route paths and turnouts for the warrant. Returns the name of the first block that failed allocation to this warrant. When running with block detection, only the first block must be allocated and have its path set.

Parameters:
delay - - delay in seconds, between setting signals and throwing turnouts
orders - - BlockOrder list of route. If null, use permanent warrant copy.
Returns:
message of block that failed allocation to this warrant or null

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener


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