Class Z21XNetThrottle

All Implemented Interfaces:
EventListener, PropertyChangeFirer, PropertyChangeProvider, DccThrottle, AbstractMRListener, XNetListener, Throttle

public class Z21XNetThrottle extends RocoXNetThrottle
An implementation of DccThrottle with code specific to a z21 XpressNet connection.
  • Constructor Details

  • Method Details

    • setSpeedSetting

      public void setSpeedSetting(float speed)
      Notify listeners and send the new speed to the command station.
      Specified by:
      setSpeedSetting in interface Throttle
      Overrides:
      setSpeedSetting in class XNetThrottle
      Parameters:
      speed - the speed as a 0.0 -> 1.0. fraction of maximum possible speed or -1 for emergency stop.
    • setSpeedSetting

      public void setSpeedSetting(float speed, boolean allowDuplicates, boolean allowDuplicatesOnStop)
      setSpeedSetting - Implementations should override this method only if they normally suppress messages to the system if, as far as JMRI can tell, the new message would make no difference to the system state (eg. the speed is the same, or effectivly the same, as the existing speed). Then, the boolean options can affect this behaviour.
      Specified by:
      setSpeedSetting in interface Throttle
      Overrides:
      setSpeedSetting in class AbstractThrottle
      Parameters:
      speed - the new speed
      allowDuplicates - don't suppress messages
      allowDuplicatesOnStop - don't suppress messages if the new speed is 'stop'
    • sendStatusInformationRequest

      protected void sendStatusInformationRequest()
      Send a request to get the speed, direction and function status from the command station.
      Overrides:
      sendStatusInformationRequest in class XNetThrottle
    • sendFunctionGroup1

      protected void sendFunctionGroup1()
      Send the XpressNet messages to set the state of locomotive direction and functions F0, F1, F2, F3, F4.
      Overrides:
      sendFunctionGroup1 in class XNetThrottle
    • sendFunctionGroup2

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

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

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

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

      protected void sendEmergencyStop()
      Description copied from class: XNetThrottle
      Since XpressNet has a seperate Opcode for emergency stop, we're setting this up as a seperate protected function.
      Overrides:
      sendEmergencyStop in class RocoXNetThrottle
    • message

      public void message(XNetReply l)
      Description copied from interface: XNetListener
      Member function that will be invoked by an XNetInterface implementation to forward an XNet message from the layout.
      Specified by:
      message in interface XNetListener
      Overrides:
      message in class XNetThrottle
      Parameters:
      l - The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
    • throttleDispose

      public void throttleDispose()
      Dispose when finished with this object. After this, further usage of this Throttle object will result in a JmriException.

      This is quite problematic, because a using object doesn't know when it's the last user.

      Overrides:
      throttleDispose in class RocoXNetThrottle