jmri.jmrix
Class AbstractThrottleManager

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.AbstractThrottleManager
All Implemented Interfaces:
ThrottleManager
Direct Known Subclasses:
CbusThrottleManager, DebugThrottleManager, EasyDccThrottleManager, EcosDccThrottleManager, LnPr2ThrottleManager, LnThrottleManager, NceThrottleManager, SerialThrottleManager, SprogCSThrottleManager, SprogThrottleManager, SRCPThrottleManager, ThrottleManager, XNetThrottleManager, XpaThrottleManager

public abstract class AbstractThrottleManager
extends Object
implements ThrottleManager

Abstract implementation of a ThrottleManager.

Based on Glen Oberhauser's original LnThrottleManager implementation.


Constructor Summary
AbstractThrottleManager()
           
 
Method Summary
 void cancelThrottleRequest(int address, boolean isLong, ThrottleListener l)
          Cancel a request for a throttle
 void cancelThrottleRequest(int address, ThrottleListener l)
          Cancel a request for a throttle.
 void failedThrottleRequest(DccLocoAddress address)
          If the system-specific ThrottleManager has been unable to create the DCC throttle then it needs to be removed from the throttleListeners, otherwise any subsequent request for that address results in the address being reported as already in use, if singleUse is set.
 boolean hasDispatchFunction()
          Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary
 void notifyThrottleKnown(DccThrottle throttle, LocoAddress addr)
          Handle throttle information when it's finally available, e.g. when a new Throttle object has been created.
 boolean requestThrottle(int address, boolean isLongAddress, ThrottleListener l)
          Request a throttle, given a decoder address.
 boolean requestThrottle(int address, ThrottleListener l)
          Request a throttle, given a decoder address.
abstract  void requestThrottleSetup(LocoAddress a)
          Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system
 int supportedSpeedModes()
          What speed modes are supported by this system?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.ThrottleManager
addressTypeUnique, canBeLongAddress, canBeShortAddress
 

Constructor Detail

AbstractThrottleManager

public AbstractThrottleManager()
Method Detail

requestThrottle

public boolean requestThrottle(int address,
                               boolean isLongAddress,
                               ThrottleListener l)
Request a throttle, given a decoder address. When the decoder address is located, the ThrottleListener gets a callback via the ThrottleListener.notifyThrottleFound method.

Specified by:
requestThrottle in interface ThrottleManager
Parameters:
address - The decoder address desired.
isLongAddress - True if this is a request for a DCC long (extended) address.
l - The ThrottleListener awaiting notification of a found throttle.
Returns:
True if the request will continue, false if the request will not be made. False may be returned if a the throttle is already in use.

requestThrottle

public boolean requestThrottle(int address,
                               ThrottleListener l)
Request a throttle, given a decoder address. When the decoder address is located, the ThrottleListener gets a callback via the ThrottleListener.notifyThrottleFound method.

This is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.

Specified by:
requestThrottle in interface ThrottleManager
Parameters:
address - The decoder address desired.
l - The ThrottleListener awaiting notification of a found throttle.
Returns:
True if the request will continue, false if the request will not be made. False may be returned if a the throttle is already in use.

requestThrottleSetup

public abstract void requestThrottleSetup(LocoAddress a)
Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system


cancelThrottleRequest

public void cancelThrottleRequest(int address,
                                  boolean isLong,
                                  ThrottleListener l)
Cancel a request for a throttle

Specified by:
cancelThrottleRequest in interface ThrottleManager
Parameters:
address - The decoder address desired.
isLong - True if this is a request for a DCC long (extended) address.
l - The ThrottleListener cancelling request for a throttle.

cancelThrottleRequest

public void cancelThrottleRequest(int address,
                                  ThrottleListener l)
Cancel a request for a throttle.

This is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.

Specified by:
cancelThrottleRequest in interface ThrottleManager
Parameters:
address - The decoder address desired.
l - The ThrottleListener cancelling request for a throttle.

failedThrottleRequest

public void failedThrottleRequest(DccLocoAddress address)
If the system-specific ThrottleManager has been unable to create the DCC throttle then it needs to be removed from the throttleListeners, otherwise any subsequent request for that address results in the address being reported as already in use, if singleUse is set.

Parameters:
address - The DCC Loco Address that the request failed on.

notifyThrottleKnown

public void notifyThrottleKnown(DccThrottle throttle,
                                LocoAddress addr)
Handle throttle information when it's finally available, e.g. when a new Throttle object has been created.

This method creates a throttle for all ThrottleListeners of that address and notifies them via the ThrottleListener.notifyThrottleFound method.


hasDispatchFunction

public boolean hasDispatchFunction()
Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary

Specified by:
hasDispatchFunction in interface ThrottleManager

supportedSpeedModes

public int supportedSpeedModes()
What speed modes are supported by this system? value should be xor of possible modes specifed by the DccThrottle interface

Specified by:
supportedSpeedModes in interface ThrottleManager


Copyright © 1997 - 2010 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads