Class CbusThrottleManager
- All Implemented Interfaces:
EventListener,Disposable,AbstractMRListener,CanListener,ThrottleManager
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractThrottleManager
AbstractThrottleManager.Addresses -
Field Summary
FieldsFields inherited from class jmri.jmrix.AbstractThrottleManager
adapterMemo, userName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanShort and long address spaces overlap and are not unique.booleancanBeLongAddress(int address) Any address is potentially a long address.booleancanBeShortAddress(int address) Address 127 and below is a short address.voidcancelThrottleRequest(LocoAddress address, ThrottleListener l) Cancel a request for a throttle.voiddispose()Allow to cleanly release the traffic controller in ThrottleManager Tests remove listeners, if any stop timers, is anybooleanNot for general use, seereleaseThrottleanddispatchThrottle.booleanHardware has a sharing implementation.booleanHardware has a stealing implementation.protected voidThrottle can no longer be relied upon, potentially from an external forced steal or hardware error.booleanCBUS has a dynamic Dispatch function, defaulting to false Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary(package private) static booleanisLongAddress(int num) Local method for deciding short/long address.protected voidmakeHardwareDecision(LocoAddress address, ThrottleListener.DecisionType question) CBUS Hardware will make its own decision on preferred option.voidCalled when an outgoing message is sent to the CAN Network.voidCalled when an incoming CanFrame is received from the CAN Network.voidrequestThrottleSetup(LocoAddress address, boolean control) Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system.voidresponseThrottleDecision(LocoAddress address, ThrottleListener l, ThrottleListener.DecisionType decision) Send a request to steal or share a requested throttle.protected booleanCBUS allows Throttle sharing, both internally within JMRI and externally by command stationsMERG CBUS Throttle sessions default to 128 SS.protected voidupdateNumUsers(LocoAddress la, int numUsers) The number of users of this throttle has been updatedMethods inherited from class jmri.jmrix.AbstractThrottleManager
addressReleased, addressStillRequired, addressStillRequired, addressStillRequired, addressStillRequired, attachListener, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, dispatchThrottle, failedThrottleRequest, getAddress, getAddress, getAddressProtocolTypes, getAddressTypes, getAddressTypeString, getProtocolFromString, getThrottleInfo, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getUserName, hideStealNotifications, notifyDecisionRequest, notifyThrottleKnown, releaseThrottle, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottleSetup, responseThrottleDecision, responseThrottleDecision, showSessionCancelDialogueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrix.can.CanListener
addTc, addTc, removeTc, removeTc
-
Field Details
-
THROTTLE_TIMEOUT
-
-
Constructor Details
-
CbusThrottleManager
-
-
Method Details
-
dispose
Allow to cleanly release the traffic controller in ThrottleManager Tests- remove listeners, if any
- stop timers, is any
- Specified by:
disposein interfaceDisposable- Specified by:
disposein interfaceThrottleManager- Overrides:
disposein classAbstractThrottleManager
-
singleUse
CBUS allows Throttle sharing, both internally within JMRI and externally by command stationsDoes 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
-
requestThrottleSetup
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.
-
message
Called when an outgoing message is sent to the CAN Network.- Specified by:
messagein interfaceCanListener- Parameters:
m- the CanMessage being sent.
-
reply
Called when an incoming CanFrame is received from the CAN Network.- Specified by:
replyin interfaceCanListener- Parameters:
m- the CanReply being received.
-
hasDispatchFunction
CBUS has a dynamic Dispatch function, defaulting to false 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
-
canBeLongAddress
Any address is potentially a long address. Test if a specific number is a valid long address on this system.- Specified by:
canBeLongAddressin interfaceThrottleManager- Parameters:
address- address number to test- Returns:
- true if address can be long; false otherwise
-
canBeShortAddress
Address 127 and below is a short address. Test if a specific number is a valid short address on this system.- Specified by:
canBeShortAddressin interfaceThrottleManager- Parameters:
address- address number to test- Returns:
- true if address can be short; false otherwise
-
addressTypeUnique
Short and long address spaces overlap and are not unique.- Specified by:
addressTypeUniquein interfaceThrottleManager- Returns:
- always false. true if ambiguous addresses are not allowed; false otherwise
-
isLongAddress
Local method for deciding short/long address.- Parameters:
num- the address number- Returns:
- true if address equal to or greater than 128.
-
enablePrefSilentStealOption
Hardware has a stealing implementation. Hardware that uses the Silent Steal preference will need to override Test if the Silent Steal Throttles preference option should be enabled.- Specified by:
enablePrefSilentStealOptionin interfaceThrottleManager- Overrides:
enablePrefSilentStealOptionin classAbstractThrottleManager- Returns:
- true if steal is possible; false otherwise
-
makeHardwareDecision
CBUS Hardware will make its own decision on preferred option.This is the default for scripts that do NOT have a GUI for asking what to do when a steal / share decision is required. For when a steal / share decision is needed and the ThrottleListener has delegated this decision to the ThrottleManager.
Responds to the question by requesting a Throttle "Steal" by default.
Can be overridden by hardware types which do not wish the default behaviour to Steal.
This applies only to those systems where "stealing" or "sharing" applies, such as LocoNet.
- Overrides:
makeHardwareDecisionin classAbstractThrottleManager- Parameters:
address- The LocoAddress the steal / share question relates toquestion- The Question to be put to the ThrottleListener
-
responseThrottleDecision
public void responseThrottleDecision(LocoAddress address, ThrottleListener l, ThrottleListener.DecisionType decision) Send a request to steal or share a requested throttle.Steal or Share a requested throttle.
- Specified by:
responseThrottleDecisionin interfaceThrottleManager- Overrides:
responseThrottleDecisionin classAbstractThrottleManager- Parameters:
address- desired LocoAddressl- The ThrottleListener which has made the decisiondecision- from the ThrottleListener, STEAL or SHARE.
-
supportedSpeedModes
MERG CBUS Throttle sessions default to 128 SS. This can be changed by a subsequent message from Throttle to CS, or by message from Command Station to CbusThrottle. Supported modes are 128, 28 and 14. What speed modes are supported by this system? value should be xor of possible modes specifed by the DccThrottle interface- Specified by:
supportedSpeedModesin interfaceThrottleManager- Overrides:
supportedSpeedModesin classAbstractThrottleManager- Returns:
- an XOR of the possible modes specified in the throttle interface
-
disposeThrottle
Not 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.
-
forceDisposeThrottle
Throttle can no longer be relied upon, potentially from an external forced steal or hardware error.Normally, #releaseThrottle should be used to close throttles.
Removes locoaddress from list to force new throttle requests to request new sessions where the Command station model implements a dynamic stack, not a static stack.
Managers still need to advise listeners that the session has been cancelled and actually dispose of the throttle
- Overrides:
forceDisposeThrottlein classAbstractThrottleManager- Parameters:
la- address release
-
updateNumUsers
The number of users of this throttle has been updatedTypically used to update dispatch / release availablility specific implementations can override this function to get updates
- Overrides:
updateNumUsersin classAbstractThrottleManager- Parameters:
la- the Loco Address which has been updatednumUsers- current number of users
-
cancelThrottleRequest
Cancel a request for a throttle.- Specified by:
cancelThrottleRequestin interfaceThrottleManager- Overrides:
cancelThrottleRequestin classAbstractThrottleManager- Parameters:
address- unwanted Loco addressl- ThrottleListener canceling request for a throttle
-