Class 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  
      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected DccThrottle _throttle  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • 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 _setRunOnET
      protected void setSpeed​(float speed)
      do throttle setting
      protected 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • 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
      • 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 name
        endBlockIdx - BlockOrder index of the block where ramp is to end. -1 if an end block is not specified.
      • 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.
      • 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
      • stopRun

        public void stopRun​(boolean abort,
                            boolean turnOffFunctions)
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener