Class BiDiBThrottle

All Implemented Interfaces:
PropertyChangeFirer, PropertyChangeProvider, DccThrottle, Throttle

public class BiDiBThrottle extends AbstractThrottle
An implementation of DccThrottle with code specific to an BiDiB connection.
  • Field Details

  • Constructor Details

  • Method Details

    • requestState

      public void requestState()
      Request the state of a loco from BiDiB
    • 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
    • sendFunctionGroup1

      protected void sendFunctionGroup1()
      Send the message to set the state of functions F0, F1, F2, F3, F4.
      Overrides:
      sendFunctionGroup1 in class AbstractThrottle
    • sendFunctionGroup2

      protected void sendFunctionGroup2()
      Send the message to set the state of functions F5, F6, F7, F8.
      Overrides:
      sendFunctionGroup2 in class AbstractThrottle
    • sendFunctionGroup3

      protected void sendFunctionGroup3()
      Send the message to set the state of functions F9, F10, F11, F12.
      Overrides:
      sendFunctionGroup3 in class AbstractThrottle
    • sendFunctionGroup4

      protected void sendFunctionGroup4()
      Send the message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20
      Overrides:
      sendFunctionGroup4 in class AbstractThrottle
    • sendFunctionGroup5

      protected void sendFunctionGroup5()
      Send the message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28
      Overrides:
      sendFunctionGroup5 in class AbstractThrottle
    • setSpeedSetting

      public void setSpeedSetting(float speed)
      Set the speed & direction.
      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
    • sendDriveCommand

      protected boolean sendDriveCommand(boolean isSpeedSet)
      Internal send method for this class. Allocates speed and function data and constructs a BiDiB message
      Parameters:
      isSpeedSet - false if not yet
      Returns:
      true if successful
    • receiveFunctions

      protected void receiveFunctions(byte[] functions)
    • receiveSpeedSetting

      protected void receiveSpeedSetting(int speed)
    • receiveIsForward

      protected void receiveIsForward(boolean forward)
    • floatSpeed

      public float floatSpeed(int speed, int steps)
      Convert speed step value to floating value. This is the oppsite of AbstractThrottle.intSpeed(speed, steps)
      Parameters:
      speed - as integer from 1...steps
      steps - number if speed steps
      Returns:
      speed as floating number from 0.0 to 1.0
    • driveReceive

      protected void driveReceive(byte[] address, org.bidib.jbidibc.messages.DriveState driveState)
    • throttleDispose

      protected 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