Package jmri.jmrix.lenz
Class XNetThrottleManager
- java.lang.Object
-
- jmri.jmrix.AbstractThrottleManager
-
- jmri.jmrix.lenz.XNetThrottleManager
-
- All Implemented Interfaces:
java.util.EventListener
,AbstractMRListener
,XNetListener
,ThrottleManager
- Direct Known Subclasses:
EliteXNetThrottleManager
,RocoXNetThrottleManager
public class XNetThrottleManager extends AbstractThrottleManager implements 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
Fields Modifier and Type Field Description protected XNetTrafficController
tc
protected java.util.HashMap<LocoAddress,XNetThrottle>
throttles
-
Fields inherited from class jmri.jmrix.AbstractThrottleManager
adapterMemo, userName
-
-
Constructor Summary
Constructors Constructor Description XNetThrottleManager(XNetSystemConnectionMemo memo)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, seereleaseThrottle
anddispatchThrottle
.boolean
hasDispatchFunction()
XpressNet based systems DO NOT use the Dispatch Function.protected static boolean
isLongAddress(int num)
Local method for deciding short/long addressvoid
message(XNetMessage l)
Listen for the messages to the LI100/LI101.void
message(XNetReply r)
Handle incoming messages for throttles.void
notifyTimeout(XNetMessage msg)
Handle a timeout notification.void
requestThrottleSetup(LocoAddress address, boolean control)
Request a new throttle object be created for the address, and let the throttle listeners know about it.protected boolean
singleUse()
XpressNet based systems can have multiple throttles for the same device.java.util.EnumSet<SpeedStepMode>
supportedSpeedModes()
What speed modes are supported by this system?-
Methods inherited from class jmri.jmrix.AbstractThrottleManager
addressReleased, addressStillRequired, addressStillRequired, addressStillRequired, addressStillRequired, attachListener, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, dispatchThrottle, dispose, enablePrefSilentShareOption, enablePrefSilentStealOption, failedThrottleRequest, forceDisposeThrottle, getAddress, getAddress, getAddressProtocolTypes, getAddressTypes, getAddressTypeString, getProtocolFromString, getThrottleInfo, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getUserName, hideStealNotifications, makeHardwareDecision, notifyDecisionRequest, notifyThrottleKnown, releaseThrottle, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottleSetup, responseThrottleDecision, responseThrottleDecision, responseThrottleDecision, showSessionCancelDialogue, updateNumUsers
-
-
-
-
Field Detail
-
throttles
protected final java.util.HashMap<LocoAddress,XNetThrottle> throttles
-
tc
protected XNetTrafficController tc
-
-
Constructor Detail
-
XNetThrottleManager
public XNetThrottleManager(XNetSystemConnectionMemo memo)
Constructor.- Parameters:
memo
- system connection.
-
-
Method Detail
-
requestThrottleSetup
public void requestThrottleSetup(LocoAddress address, boolean control)
Request a new throttle object be created for the address, and let the throttle listeners know about it. Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system.- Specified by:
requestThrottleSetup
in classAbstractThrottleManager
- Parameters:
address
- addresscontrol
- false - read only.
-
hasDispatchFunction
public boolean hasDispatchFunction()
XpressNet based systems DO NOT use the Dispatch Function.- Specified by:
hasDispatchFunction
in interfaceThrottleManager
- Overrides:
hasDispatchFunction
in classAbstractThrottleManager
- Returns:
- false always.
-
singleUse
protected boolean singleUse()
XpressNet based systems can have multiple throttles for the same device.Does this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?
- Overrides:
singleUse
in classAbstractThrottleManager
- Returns:
- true or false
-
canBeLongAddress
public boolean canBeLongAddress(int address)
Address 100 and above is a long address.- Specified by:
canBeLongAddress
in interfaceThrottleManager
- Parameters:
address
- address number to test- Returns:
- true if address can be long; false otherwise
-
canBeShortAddress
public boolean canBeShortAddress(int address)
Address 99 and below is a short address.- Specified by:
canBeShortAddress
in interfaceThrottleManager
- Parameters:
address
- address number to test- Returns:
- true if address can be short; false otherwise
-
addressTypeUnique
public boolean addressTypeUnique()
Are there any ambiguous addresses (short vs long) on this system?- Specified by:
addressTypeUnique
in interfaceThrottleManager
- Returns:
- true if ambiguous addresses are not allowed; false otherwise
-
isLongAddress
protected static boolean isLongAddress(int num)
Local method for deciding short/long address- Parameters:
num
- address to examine- Returns:
- true if can be long address
-
supportedSpeedModes
public java.util.EnumSet<SpeedStepMode> 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 interfaceThrottleManager
- Overrides:
supportedSpeedModes
in classAbstractThrottleManager
- Returns:
- an XOR of the possible modes specified in the throttle interface
-
message
public void message(XNetReply r)
Handle incoming messages for throttles.- Specified by:
message
in interfaceXNetListener
- 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)
Listen for the messages to the LI100/LI101.- Specified by:
message
in interfaceXNetListener
- 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)
Handle a timeout notification.- Specified by:
notifyTimeout
in interfaceXNetListener
- Parameters:
msg
- message which has timed out.
-
disposeThrottle
public boolean disposeThrottle(DccThrottle t, ThrottleListener l)
Description copied from class:AbstractThrottleManager
Not for general use, seereleaseThrottle
anddispatchThrottle
.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 interfaceThrottleManager
- Overrides:
disposeThrottle
in classAbstractThrottleManager
- Parameters:
t
- Throttle being releasedl
- Throttle Listener releasing the throttle- Returns:
- true if the throttle has been disposed of.
-
-