jmri.jmrix.loconet
Class LnThrottleManager

java.lang.Object
  extended by jmri.jmrix.AbstractThrottleManager
      extended by jmri.jmrix.loconet.LnThrottleManager
All Implemented Interfaces:
EventListener, SlotListener, ThrottleManager

public class LnThrottleManager
extends AbstractThrottleManager
implements ThrottleManager, SlotListener

LocoNet implementation of a ThrottleManager.

Works in cooperation with the SlotManager, which actually handles the communications.

Author:
Bob Jacobsen Copyright (C) 2001
See Also:
SlotManager

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractThrottleManager
AbstractThrottleManager.Addresses
 
Constructor Summary
LnThrottleManager(SlotManager slotManager)
          Constructor.
 
Method Summary
 boolean addressTypeUnique()
          Are there any ambiguous addresses (short vs long) on this system?
 boolean canBeLongAddress(int address)
          Address 128 and above is a long address
 boolean canBeShortAddress(int address)
          Address 127 and below is a short address
 void dispatchThrottle(DccThrottle t, ThrottleListener l)
          The throttle listener has finished with the specific Throttle and is is available for reuse/reallocation by somebody else.
 boolean disposeThrottle(DccThrottle t, ThrottleListener l)
          Not for general use, see releaseThrottle and dispatchThrottle.
 boolean hasDispatchFunction()
          LocoNet does have a Dispatch function
 void notifyChangedSlot(LocoNetSlot s)
          SlotListener contract.
 void releaseThrottle(DccThrottle t, ThrottleListener l)
          The specified Throttle Listener has finished using a given throttle and no longer requires access to it.
 void requestThrottleSetup(LocoAddress address, boolean control)
          Start creating a Throttle object.
protected  boolean singleUse()
          LocoNet allows multiple throttles for the same device
 
Methods inherited from class jmri.jmrix.AbstractThrottleManager
addressReleased, addressStillRequired, attachListener, cancelThrottleRequest, cancelThrottleRequest, failedThrottleRequest, getThrottleInfo, notifyThrottleKnown, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottleSetup, supportedSpeedModes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.ThrottleManager
addressStillRequired, attachListener, cancelThrottleRequest, cancelThrottleRequest, getThrottleInfo, removeListener, requestThrottle, requestThrottle, requestThrottle, supportedSpeedModes
 

Constructor Detail

LnThrottleManager

public LnThrottleManager(SlotManager slotManager)
Constructor. Gets a reference to the LocoNet SlotManager.

Method Detail

singleUse

protected boolean singleUse()
LocoNet allows multiple throttles for the same device

Overrides:
singleUse in class AbstractThrottleManager

requestThrottleSetup

public void requestThrottleSetup(LocoAddress address,
                                 boolean control)
Start creating a Throttle object. This returns directly, having arranged for the Throttle object to be delivered via callback

Specified by:
requestThrottleSetup in class AbstractThrottleManager

hasDispatchFunction

public boolean hasDispatchFunction()
LocoNet does have a Dispatch function

Specified by:
hasDispatchFunction in interface ThrottleManager
Overrides:
hasDispatchFunction in class AbstractThrottleManager

notifyChangedSlot

public void notifyChangedSlot(LocoNetSlot s)
SlotListener contract. Get notification that an address has changed slot. This method creates a throttle for all ThrottleListeners of that address and notifies them via the ThrottleListener.notifyThrottleFound method.

Specified by:
notifyChangedSlot in interface SlotListener

canBeLongAddress

public boolean canBeLongAddress(int address)
Address 128 and above is a long address

Specified by:
canBeLongAddress in interface ThrottleManager

canBeShortAddress

public boolean canBeShortAddress(int address)
Address 127 and below is a short address

Specified by:
canBeShortAddress in interface ThrottleManager

addressTypeUnique

public boolean addressTypeUnique()
Are there any ambiguous addresses (short vs long) on this system?

Specified by:
addressTypeUnique in interface ThrottleManager

disposeThrottle

public boolean disposeThrottle(DccThrottle t,
                               ThrottleListener l)
Description copied from interface: ThrottleManager
Not for general use, see releaseThrottle and dispatchThrottle.

Dispose of object when finished it. This will free up hardware resource

Used for handling certain internal error conditions, where the object still exists but hardware is not associated with it.

After this, further usage of this Throttle object will result in a JmriException.

Specified by:
disposeThrottle in interface ThrottleManager
Overrides:
disposeThrottle in class AbstractThrottleManager
Parameters:
t - Throttle being released
l - Throttle Listener releasing the throttle
Returns:
true if the throttle has been disposed of.

dispatchThrottle

public void dispatchThrottle(DccThrottle t,
                             ThrottleListener l)
Description copied from interface: ThrottleManager
The throttle listener has finished with the specific Throttle and is is available for reuse/reallocation by somebody else. If possible, tell the layout that this locomotive has been dispatched to another user. Not all layouts will implement this, in which case it is synomous with release();

Normally, dispatch ends with a call to dispose.

Specified by:
dispatchThrottle in interface ThrottleManager
Overrides:
dispatchThrottle in class AbstractThrottleManager
Parameters:
t - Throttle being released
l - Throttle Listener releasing the throttle

releaseThrottle

public void releaseThrottle(DccThrottle t,
                            ThrottleListener l)
Description copied from interface: ThrottleManager
The specified Throttle Listener has finished using a given throttle and no longer requires access to it.

After releasing the throttle, the manager will perform further checks to see if it is in use by any other listeners or if there are any propertychangelisteners attached. If there are no other uses of the throttle then it is disposed of.

Normally, release ends with a call to dispose.

Specified by:
releaseThrottle in interface ThrottleManager
Overrides:
releaseThrottle in class AbstractThrottleManager
Parameters:
t - Throttle being released
l - Throttle Listener releasing the throttle


Copyright © 1997 - 2011 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