Package jmri.jmrit.logix
Class Engineer
java.lang.Object
java.lang.Thread
jmri.jmrit.logix.Engineer
- All Implemented Interfaces:
PropertyChangeListener,Runnable,EventListener
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 ClassesNested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DccThrottlestatic final StringProperty change constant for Memory Set Command.static final StringProperty change constant for Ramp Done.static final StringProperty change constant for Speed Set Command.static final StringProperty change constant for Sensor Wait Command.static final StringProperty change constant for Speed Change.static final StringProperty change constant for Wait For Sync.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionEngineer(Warrant warrant, DccThrottle throttle) Create a new Engineer for a given Warrant and Throttle. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancancelRamp(boolean die) warrant.cancelDelayRamp() called for immediate Stop commands When die==true for ending the warrant run.protected voidclearWaitForSync(OBlock block) Called by the warrant when a the block ahead of a moving train goes occupied.(package private) StringGenerate Debug Info for Warrant progression state.protected intprotected booleanprotected intGet the Warrant run state.protected floatGet the current commanded speed as set in the Warrant script.protected floatGet the current Throttle speed.protected Warrant.SpeedStateGet the Warrant SpeedState ENUM.protected StringgetSpeedType(boolean absolute) Get the Speed type name.protected OBlockprotected Sensorprotected booleanGet if Engineer is ramping up or down the speed.voidprotected voidrampSpeedTo(String endSpeedType, int endBlockIdx) Occupancy of blocks, user halts and aspects of Portal signals will modify normal scripted train speeds.voidrun()Run the Warrant commands on this Engineer thread.protected voidsetHalt(boolean halt) Command to stop (or resume speed) of train from Warrant.controlRunTrain() of user's override of throttle script.protected voidsetRunOnET(boolean set) Cannot set _runOnET to true until current NOOP command completes so there is the intermediate flag _setRunOnETprotected voidsetSpeed(float speed) do throttle settingprotected voidsetSpeedToType(String speedType) Do immediate speed change.protected voidsetWaitforClear(boolean wait) Command to stop or smoothly resume speed.voidstopRun(boolean abort, boolean turnOffFunctions) Stop the Engineer run.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 Details
-
_throttle
-
PROPERTY_WAIT_FOR_SYNC
Property change constant for Wait For Sync.- See Also:
-
PROPERTY_SPEED_CHANGE
Property change constant for Speed Change.- See Also:
-
PROPERTY_MEMORY_SET_COMMAND
Property change constant for Memory Set Command.- See Also:
-
PROPERTY_SENSOR_SET_COMMAND
Property change constant for Speed Set Command.- See Also:
-
PROPERTY_SENSOR_WAIT_COMMAND
Property change constant for Sensor Wait Command.- See Also:
-
PROPERTY_RAMP_DONE
Property change constant for Ramp Done.- See Also:
-
-
Constructor Details
-
Engineer
Engineer(Warrant warrant, DccThrottle throttle) Create a new Engineer for a given Warrant and Throttle.- Parameters:
warrant- The Warrant to execute.throttle- The Engine throttle to command.
-
-
Method Details
-
run
Run the Warrant commands on this Engineer thread. -
getCurrentCommandIndex
-
setRunOnET
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
-
getSynchBlock
-
clearWaitForSync
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
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
Get if Engineer is ramping up or down the speed.- Returns:
- true if is ramping.
-
getSpeedType
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
warrant.cancelDelayRamp() called for immediate Stop commands When die==true for ending the warrant run.- Parameters:
die- true for ending the warrant run- Returns:
- true if _ramp not null and die is false and _isRamping
-
setSpeed
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
Get the current Throttle speed. If Speed is negative ( i.e. E-Stop ), sets Throttle speed to 0.- Returns:
- speed setting reported by Throttle.
-
getScriptSpeed
Get the current commanded speed as set in the Warrant script.- Returns:
- the most recent commanded speed.
-
setSpeedToType
Do immediate speed change.- Parameters:
speedType- speed type
-
setHalt
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
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
Generate Debug Info for Warrant progression state.- Returns:
- String for use in debug output.
-
getSpeedState
Get the Warrant SpeedState ENUM.- Returns:
- e.g. Warrant.SpeedState.RAMPING_DOWN or SpeedState.STEADY_SPEED.
-
getRunState
Get the Warrant run state.- Returns:
- e.g. Warrant.WAIT_FOR_SENSOR or Warrant.RUNNING.
-
stopRun
Stop the Engineer run.- Parameters:
abort- true to abort, else false.turnOffFunctions- true to set Functions 0, 1, 2 and 3 to off ( if speed is > 0 ).
-
getWaitSensor
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-