jmri.jmrix.loconet
Class LnPr2ThrottleManager

java.lang.Object
  extended by jmri.jmrix.AbstractThrottleManager
      extended by jmri.jmrix.loconet.LnPr2ThrottleManager
All Implemented Interfaces:
ThrottleManager

public class LnPr2ThrottleManager
extends AbstractThrottleManager

LocoNet implementation of a ThrottleManager for the PR2

Does direct "push" writes to the extended slot in the PR2.

The PR2 only allows a single locomotive address to be active, because it implements a single-slot command station.

Author:
Bob Jacobsen Copyright (C) 2001, 2006
See Also:
AbstractThrottleManager

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractThrottleManager
AbstractThrottleManager.Addresses
 
Constructor Summary
LnPr2ThrottleManager()
          Constructor, works via superclass.
 
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.
 DccLocoAddress getActiveAddress()
          Make the active address available to the power manager, which needs it to turn on and off "neutral mode" in the locomotive
 boolean hasDispatchFunction()
          PR2 does not have a Dispatch function
 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)
          Get a new Throttle object.
protected  boolean singleUse()
          PR2 allows only one throttle
 
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
 

Constructor Detail

LnPr2ThrottleManager

public LnPr2ThrottleManager()
Constructor, works via superclass.

Method Detail

singleUse

protected boolean singleUse()
PR2 allows only one throttle

Overrides:
singleUse in class AbstractThrottleManager

requestThrottleSetup

public void requestThrottleSetup(LocoAddress address,
                                 boolean control)
Get a new Throttle object. This immediately invokes the callback with the a new throttle object.

Specified by:
requestThrottleSetup in class AbstractThrottleManager

hasDispatchFunction

public boolean hasDispatchFunction()
PR2 does not have a Dispatch function

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

canBeLongAddress

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


canBeShortAddress

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


addressTypeUnique

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


getActiveAddress

public DccLocoAddress getActiveAddress()
Make the active address available to the power manager, which needs it to turn on and off "neutral mode" in the locomotive


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