Package jmri.jmrix.dccpp
Class DCCppThrottleManager
- java.lang.Object
-
- jmri.jmrix.AbstractThrottleManager
-
- jmri.jmrix.dccpp.DCCppThrottleManager
-
- All Implemented Interfaces:
java.util.EventListener,AbstractMRListener,DCCppListener,ThrottleManager
public class DCCppThrottleManager extends AbstractThrottleManager implements DCCppListener
DCC++ 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 DCCppTrafficControllertcprotected java.util.HashMap<LocoAddress,DCCppThrottle>throttles-
Fields inherited from class jmri.jmrix.AbstractThrottleManager
adapterMemo, userName
-
-
Constructor Summary
Constructors Constructor Description DCCppThrottleManager(DCCppSystemConnectionMemo memo)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddressTypeUnique()There are no ambiguous addresses on this system.booleancanBeLongAddress(int address)Address 128 and above is a long addressbooleancanBeShortAddress(int address)Address between 1 and 127 is a short addressvoiddispose()Allow to cleanly release the traffic controller in ThrottleManager Tests remove listeners, if any stop timers, is anybooleandisposeThrottle(DccThrottle t, ThrottleListener l)Not for general use, seereleaseThrottleanddispatchThrottle.booleanhasDispatchFunction()DCC++ based systems DO NOT use the Dispatch Function (do they?)protected static booleanisLongAddress(int num)Local method for deciding short/long address.voidmessage(DCCppMessage l)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout.voidmessage(DCCppReply r)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.voidnotifyTimeout(DCCppMessage msg)Member function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.voidrequestThrottleSetup(LocoAddress address, boolean control)Request a new throttle object be created for the address, and let the throttle listeners know about it.protected booleansingleUse()DCC++ based systems can have multiple throttles for the same devicejava.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, 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 java.util.HashMap<LocoAddress,DCCppThrottle> throttles
-
tc
protected DCCppTrafficController tc
-
-
Constructor Detail
-
DCCppThrottleManager
public DCCppThrottleManager(DCCppSystemConnectionMemo memo)
Constructor.- Parameters:
memo- the memo for the connection this tm will use
-
-
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:
requestThrottleSetupin classAbstractThrottleManager- Parameters:
address- addresscontrol- false - read only.
-
hasDispatchFunction
public boolean hasDispatchFunction()
DCC++ based systems DO NOT use the Dispatch Function (do they?) Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary- Specified by:
hasDispatchFunctionin interfaceThrottleManager- Overrides:
hasDispatchFunctionin classAbstractThrottleManager- Returns:
- true if dispatch is possible; false otherwise
-
singleUse
protected boolean singleUse()
DCC++ based systems can have multiple throttles for the same deviceDoes this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?
- Overrides:
singleUsein classAbstractThrottleManager- Returns:
- true or false
-
canBeLongAddress
public boolean canBeLongAddress(int address)
Address 128 and above is a long address- Specified by:
canBeLongAddressin interfaceThrottleManager- Parameters:
address- address number to test- Returns:
- true if address can be long; false otherwise
-
canBeShortAddress
public boolean canBeShortAddress(int address)
Address between 1 and 127 is a short address- Specified by:
canBeShortAddressin interfaceThrottleManager- Parameters:
address- address number to test- Returns:
- true if address can be short; false otherwise
-
addressTypeUnique
public boolean addressTypeUnique()
There are no ambiguous addresses on this system.- Specified by:
addressTypeUniquein 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. (is it?)- Parameters:
num- the address number to check.- Returns:
- true if number greater than or equals 128.
-
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 DCC++ supports 14,27,28 and 128 speed step modes- Specified by:
supportedSpeedModesin interfaceThrottleManager- Overrides:
supportedSpeedModesin classAbstractThrottleManager- Returns:
- an XOR of the possible modes specified in the throttle interface
-
message
public void message(DCCppReply r)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.- Specified by:
messagein interfaceDCCppListener- Parameters:
r- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
public void message(DCCppMessage l)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout. Normally, this function will do nothing.- Specified by:
messagein interfaceDCCppListener- Parameters:
l- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
public void notifyTimeout(DCCppMessage msg)
Description copied from interface:DCCppListenerMember function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeoutin interfaceDCCppListener- Parameters:
msg- the message that timed out.
-
disposeThrottle
public boolean disposeThrottle(DccThrottle t, ThrottleListener l)
Description copied from class:AbstractThrottleManagerNot for general use, seereleaseThrottleanddispatchThrottle.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:
disposeThrottlein interfaceThrottleManager- Overrides:
disposeThrottlein classAbstractThrottleManager- Parameters:
t- Throttle being releasedl- Throttle Listener releasing the throttle- Returns:
- true if the throttle has been disposed of.
-
dispose
public void dispose()
Allow to cleanly release the traffic controller in ThrottleManager Tests- remove listeners, if any
- stop timers, is any
- Specified by:
disposein interfaceThrottleManager- Overrides:
disposein classAbstractThrottleManager
-
-