jmri.jmrix.lenz
Class XNetThrottleManager

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.AbstractThrottleManager
      extended by jmri.jmrix.lenz.XNetThrottleManager
All Implemented Interfaces:
EventListener, AbstractMRListener, XNetListener, ThrottleManager
Direct Known Subclasses:
EliteXNetThrottleManager

public class XNetThrottleManager
extends AbstractThrottleManager
implements ThrottleManager, XNetListener

XNet implementation of a ThrottleManager based on the AbstractThrottleManager.


Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractThrottleManager
AbstractThrottleManager.Addresses
 
Field Summary
(package private) static org.slf4j.Logger log
           
protected  XNetTrafficController tc
           
protected  HashMap<LocoAddress,XNetThrottle> throttles
           
 
Fields inherited from class jmri.jmrix.AbstractThrottleManager
adapterMemo, userName
 
Constructor Summary
XNetThrottleManager(XNetSystemConnectionMemo memo)
          Constructor.
 
Method Summary
 boolean addressTypeUnique()
          Are there any ambiguous addresses (short vs long) on this system?
 boolean canBeLongAddress(int address)
          Address 100 and above is a long address
 boolean canBeShortAddress(int address)
          Address 99 and below is a short address
 boolean disposeThrottle(DccThrottle t, ThrottleListener l)
          Not for general use, see releaseThrottle and dispatchThrottle.
 boolean hasDispatchFunction()
          Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary
(package private) static boolean isLongAddress(int num)
           
 void message(XNetMessage l)
          Member function that will be invoked by a XNetInterface implementation to forward a XNet message sent to the layout.
 void message(XNetReply r)
          Member function that will be invoked by a XNetInterface implementation to forward a XNet message from the layout.
 void notifyTimeout(XNetMessage msg)
          Member function invoked by an XNetInterface implementation to notify * a sender that an outgoing message timed out and was dropped from the * queue.
 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)
          Request a new throttle object be creaetd for the address, and let the throttle listeners know about it.
protected  boolean singleUse()
          Does this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?
 int supportedSpeedModes()
          What speed modes are supported by this system?
 
Methods inherited from class jmri.jmrix.AbstractThrottleManager
addressReleased, addressStillRequired, attachListener, attachListener, attachListener, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, dispatchThrottle, failedThrottleRequest, getAddress, getAddress, getAddressProtocolTypes, getAddressTypes, getAddressTypeString, getProtocolFromString, getThrottleInfo, getUserName, notifyThrottleKnown, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottleSetup
 
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, cancelThrottleRequest, dispatchThrottle, getAddress, getAddress, getAddressProtocolTypes, getAddressTypes, getAddressTypeString, getProtocolFromString, getThrottleInfo, getUserName, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle
 

Field Detail

throttles

protected HashMap<LocoAddress,XNetThrottle> throttles

tc

protected XNetTrafficController tc

log

static org.slf4j.Logger log
Constructor Detail

XNetThrottleManager

public XNetThrottleManager(XNetSystemConnectionMemo memo)
Constructor.

Method Detail

requestThrottleSetup

public void requestThrottleSetup(LocoAddress address,
                                 boolean control)
Request a new throttle object be creaetd for the address, and let the throttle listeners know about it.

Specified by:
requestThrottleSetup in class AbstractThrottleManager

hasDispatchFunction

public boolean hasDispatchFunction()
Description copied from class: AbstractThrottleManager
Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary

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

singleUse

protected boolean singleUse()
Description copied from class: AbstractThrottleManager
Does this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?

Overrides:
singleUse in class AbstractThrottleManager

canBeLongAddress

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

Specified by:
canBeLongAddress in interface ThrottleManager

canBeShortAddress

public boolean canBeShortAddress(int address)
Address 99 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

isLongAddress

static boolean isLongAddress(int num)

supportedSpeedModes

public int supportedSpeedModes()
What speed modes are supported by this system? value should be xor of possible modes specifed by the DccThrottle interface XPressNet supports 14,27,28 and 128 speed step modes

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

message

public void message(XNetReply r)
Description copied from interface: XNetListener
Member function that will be invoked by a XNetInterface implementation to forward a XNet message from the layout.

Specified by:
message in interface XNetListener
Parameters:
r - The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.

message

public void message(XNetMessage l)
Description copied from interface: XNetListener
Member function that will be invoked by a XNetInterface implementation to forward a XNet message sent to the layout. Normally, this function will do nothing.

Specified by:
message in interface XNetListener
Parameters:
l - The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.

notifyTimeout

public void notifyTimeout(XNetMessage msg)
Description copied from interface: XNetListener
Member function invoked by an XNetInterface implementation to notify * a sender that an outgoing message timed out and was dropped from the * queue.

Specified by:
notifyTimeout in interface XNetListener

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

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.


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