Class SerialThrottle

All Implemented Interfaces:
PropertyChangeFirer, PropertyChangeProvider, DccThrottle, Throttle

public class SerialThrottle extends AbstractThrottle
An implementation of DccThrottle.

Addresses of 99 and below are considered short addresses, and over 100 are considered long addresses.

  • Field Details

    • checksumAccumulator

    • previousValue

    • newValue

    • REPEAT_TIME

      static final int REPEAT_TIME
      This code block is necessary to support the send repeats of the repeatFunctionSendWhileOn(value, func); code above. This code block "Sends Again" if FkKey is still pressed/on, and repeats per the interval set in static final int REPEAT_TIME.
      See Also:
  • Constructor Details

  • Method Details

    • getLocoAddress

      Locomotive address. The exact format is defined by the specific implementation, as subclasses of LocoAddress will contain different information.

      This is an unbound property.

      Returns:
      The locomotive address
    • setFunction

      public void setFunction(int func, boolean value)
      Set Loco Function and send to Layout.
      Specified by:
      setFunction in interface Throttle
      Overrides:
      setFunction in class AbstractThrottle
      Parameters:
      func - Function Number, 0-28
      value - New Function State. True on, false off.
    • setSpeedSetting

      public void setSpeedSetting(float speed)
      Set the speed.
      Specified by:
      setSpeedSetting in interface Throttle
      Overrides:
      setSpeedSetting in class AbstractThrottle
      Parameters:
      speed - Number from 0 to 1; less than zero is emergency stop
    • setIsForward

      public void setIsForward(boolean forward)
      Implementing functions should override this function, but should either make a call to super.setIsForward() to notify the listeners, or should notify the listeners themselves.
      Specified by:
      setIsForward in interface Throttle
      Overrides:
      setIsForward in class AbstractThrottle
      Parameters:
      forward - true if forward; false otherwise
    • sendFnToLayout

      protected void sendFnToLayout(int value, int func)
      Send these messages to the layout and repeat while button is pressed/on.
      Parameters:
      value - Content of message to be sent in three bytes
      func - The number of the function being addressed
    • repeatFunctionSendWhileOn

      protected void repeatFunctionSendWhileOn(int value, int func)
    • setSpeedStepMode

      public void setSpeedStepMode(SpeedStepMode mode)
      Description copied from class: AbstractThrottle
      Set the speed step value. Default should be 128 speed step mode in most cases.

      Specific implementations should override this function.

      Specified by:
      setSpeedStepMode in interface DccThrottle
      Overrides:
      setSpeedStepMode in class AbstractThrottle
      Parameters:
      mode - the current speed step mode
    • throttleDispose

      public void throttleDispose()
      Dispose when finished with this Throttle. May be used in tests for cleanup. Throttles normally call AbstractThrottle.finishRecord() here.
      Specified by:
      throttleDispose in class AbstractThrottle