Package jmri.jmrit.logix
Class Engineer
- java.lang.Object
-
- java.lang.Thread
-
- jmri.jmrit.logix.Engineer
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Runnable
,java.util.EventListener
class Engineer extends java.lang.Thread implements java.beans.PropertyChangeListener
Execute a throttle command script for a warrant.This generally operates on its own thread, but calls the warrant thread via Warrant.fireRunStatus to show status. fireRunStatus uses ThreadingUtil.runOnGUIEventually to display on the layout thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
Engineer.ThrottleRamp
-
Field Summary
Fields Modifier and Type Field Description protected DccThrottle
_throttle
-
Constructor Summary
Constructors Constructor Description Engineer(Warrant warrant, DccThrottle throttle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
cancelRamp(boolean die)
protected void
clearWaitForSync(OBlock block)
Called by the warrant when a the block ahead of a moving train goes occupied.(package private) java.lang.String
debugInfo()
protected int
getCurrentCommandIndex()
protected boolean
getRunOnET()
protected int
getRunState()
protected float
getScriptSpeed()
protected float
getSpeedSetting()
protected Warrant.SpeedState
getSpeedState()
protected java.lang.String
getSpeedType(boolean absolute)
Get the Speed type name.protected OBlock
getSynchBlock()
protected Sensor
getWaitSensor()
protected boolean
isRamping()
void
propertyChange(java.beans.PropertyChangeEvent evt)
protected void
rampSpeedTo(java.lang.String endSpeedType, int endBlockIdx)
Occupancy of blocks, user halts and aspects of Portal signals will modify normal scripted train speeds.void
run()
protected void
setHalt(boolean halt)
Command to stop (or resume speed) of train from Warrant.controlRunTrain() of user's override of throttle script.protected void
setRunOnET(boolean set)
Cannot set _runOnET to true until current NOOP command completes so there is the intermediate flag _setRunOnETprotected void
setSpeed(float speed)
do throttle settingprotected void
setSpeedToType(java.lang.String speedType)
protected void
setWaitforClear(boolean wait)
Command to stop or smoothly resume speed.void
stopRun(boolean abort, boolean turnOffFunctions)
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
_throttle
protected DccThrottle _throttle
-
-
Constructor Detail
-
Engineer
Engineer(Warrant warrant, DccThrottle throttle)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
getCurrentCommandIndex
protected int getCurrentCommandIndex()
-
setRunOnET
protected void setRunOnET(boolean set)
Cannot set _runOnET to true until current NOOP command completes so there is the intermediate flag _setRunOnET- Parameters:
set
- true to run on elapsed time calculations only, false to consider other inputs
-
getRunOnET
protected boolean getRunOnET()
-
getSynchBlock
protected OBlock getSynchBlock()
-
clearWaitForSync
protected void clearWaitForSync(OBlock block)
Called by the warrant when a the block ahead of a moving train goes occupied. typically when this thread is on a timed wait. The call will free the wait.- Parameters:
block
- going active.
-
rampSpeedTo
protected void rampSpeedTo(@Nonnull java.lang.String endSpeedType, int endBlockIdx)
Occupancy of blocks, user halts and aspects of Portal signals will modify normal scripted train speeds. Ramp speed change for smooth prototypical look.- Parameters:
endSpeedType
- signal aspect speed nameendBlockIdx
- BlockOrder index of the block where ramp is to end. -1 if an end block is not specified.
-
isRamping
protected boolean isRamping()
-
getSpeedType
protected java.lang.String getSpeedType(boolean absolute)
Get the Speed type name. _speedType is the type when moving. Used to restore speeds aspects of signals when halts or other conditions have stopped the train. If 'absolute' is true return the absolute speed of the train, i.e. 'Stop' if train is not moving.- Parameters:
absolute
- which speed type, absolute or allowed movement- Returns:
- speed type
-
cancelRamp
protected boolean cancelRamp(boolean die)
-
setSpeed
protected void setSpeed(float speed)
do throttle setting- Parameters:
speed
- throttle setting about to be set. Modified to sType if from script. UnModified if from ThrottleRamp or stop speeds.
-
getSpeedSetting
protected float getSpeedSetting()
-
getScriptSpeed
protected float getScriptSpeed()
-
setSpeedToType
protected void setSpeedToType(java.lang.String speedType)
-
setHalt
protected void setHalt(boolean halt)
Command to stop (or resume speed) of train from Warrant.controlRunTrain() of user's override of throttle script. Also from error conditions such as losing detection of train's location.- Parameters:
halt
- true if train should halt
-
setWaitforClear
protected void setWaitforClear(boolean wait)
Command to stop or smoothly resume speed. Stop due to signal or occupation stopping condition ahead. Caller follows with call for type of stop to make. Track condition override of throttle script.- Parameters:
wait
- true if train should stop
-
debugInfo
java.lang.String debugInfo()
-
getSpeedState
protected Warrant.SpeedState getSpeedState()
-
getRunState
protected int getRunState()
-
stopRun
public void stopRun(boolean abort, boolean turnOffFunctions)
-
getWaitSensor
protected Sensor getWaitSensor()
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
-