Package jmri.jmrit.withrottle
Class ThrottleController
java.lang.Object
jmri.jmrit.withrottle.ThrottleController
- All Implemented Interfaces:
PropertyChangeListener,EventListener,ThrottleListener
- Direct Known Subclasses:
MultiThrottleController
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList<ControllerInterface>(package private) DccThrottle(package private) boolean(package private) final boolean(package private) DccLocoAddress(package private) ConsistFunctionControllerprotected ArrayList<ThrottleControllerListener>(package private) Stringprotected float(package private) RosterEntry(package private) float(package private) DccThrottle(package private) boolean(package private) char -
Constructor Summary
ConstructorsConstructorDescriptionThrottleController(char whichThrottleChar, ThrottleControllerListener tcl, ControllerInterface cl) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddControllerListener(ControllerInterface listener) Add a listener to handle: listener.sendPacketToDevice(message);voidvoidReceive notification that an address has been released/dispatchedvoidprotected Stringprotected voideStop()protected voidforceFunction(String inPackage) Get the string representation of this throttles address.Get the string representation of this Roster ID.protected voidhandleFunction(String inPackage) protected voidhandleMomentary(String inPackage) protected voidhandleRequest(String inPackage) protected voidhandleSpeedStepMode(SpeedStepMode newMode) protected voididle()voidnotifyDecisionRequired(LocoAddress address, ThrottleListener.DecisionType question) calls notifyFailedThrottleRequest, Steal RequiredvoidnotifyFailedThrottleRequest(LocoAddress address, String reason) Get notification that an attempt to request a throttle has failed.voidReceive notification that a DccThrottle has been found and is in use.voidvoidremoveControllerListener(ControllerInterface listener) voidvoidvoidvoidsend all function states, primarily for initial status Current Format: RPF}|{whichThrottle]\[function}|{state]\[function}|{state...protected voidprotected voidprotected voidvoidSend function labels for a roster entry, using old format.protected voidprotected voidsetAddress(int number, boolean isLong) protected voidsetDirection(boolean isForward) voidvoidsetLocoForConsistFunctions(String inPackage) voidprotected voidsetSpeed(int rawSpeed) handle the conversion from rawSpeed to the float value needed in the DccThrottlevoidsetWhichThrottle(char c) voidbooleanFigure out what the received command means, where it has to go, and translate to a jmri method.void
-
Field Details
-
throttle
-
functionThrottle
-
rosterLoco
-
leadAddress
-
whichThrottle
char whichThrottle -
speedMultiplier
float speedMultiplier -
lastSentSpeed
-
newSpeed
-
isAddressSet
boolean isAddressSet -
listeners
-
controllerListeners
-
useLeadLocoF
boolean useLeadLocoF -
leadLocoF
-
locoKey
-
isMomF2
-
-
Constructor Details
-
ThrottleController
public ThrottleController() -
ThrottleController
public ThrottleController(char whichThrottleChar, ThrottleControllerListener tcl, ControllerInterface cl)
-
-
Method Details
-
setWhichThrottle
-
addThrottleControllerListener
-
removeThrottleControllerListener
-
addControllerListener
Add a listener to handle: listener.sendPacketToDevice(message);- Parameters:
listener- handle of listener to add
-
removeControllerListener
-
addressRelease
Receive notification that an address has been released/dispatched -
addressDispatch
-
notifyThrottleFound
Receive notification that a DccThrottle has been found and is in use.- Specified by:
notifyThrottleFoundin interfaceThrottleListener- Parameters:
t- The throttle which has been found
-
notifyFailedThrottleRequest
Description copied from interface:ThrottleListenerGet notification that an attempt to request a throttle has failed.- Specified by:
notifyFailedThrottleRequestin interfaceThrottleListener- Parameters:
address- address of the failed requestreason- failure cause
-
notifyDecisionRequired
calls notifyFailedThrottleRequest, Steal RequiredGet notification that a throttle request is in use by another device, and a "steal", "share", or "steal/share" decision may be required.
- Specified by:
notifyDecisionRequiredin interfaceThrottleListener- Parameters:
address- The LocoAddress that needs the decision.question- The question being asked, steal / cancel, share / cancel, steal / share / cancel
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
findRosterEntry
-
syncThrottleFunctions
-
sendFunctionLabels
Send function labels for a roster entry, using old format. This implementation is legacy and should not change from the limit of 29 functions.- Parameters:
re- The roster entry to get the labels from.
-
sendAllFunctionStates
send all function states, primarily for initial status Current Format: RPF}|{whichThrottle]\[function}|{state]\[function}|{state... This implementation is legacy and should not change from the limit of 29 functions.- Parameters:
t- throttle to send functions to
-
buildFStatesHeader
-
sendCurrentSpeed
-
sendCurrentDirection
-
sendSpeedStepMode
-
sendAllMomentaryStates
-
sort
Figure out what the received command means, where it has to go, and translate to a jmri method.- Parameters:
inPackage- The package minus its prefix which steered it here.- Returns:
- true to keep reading in run loop.
-
setFunctionThrottle
-
setLocoForConsistFunctions
-
setRosterLocoForConsistFunctions
-
shutdownThrottle
-
setSpeed
handle the conversion from rawSpeed to the float value needed in the DccThrottle- Parameters:
rawSpeed- Value sent from mobile device, range 0 - 126
-
setDirection
-
eStop
-
idle
-
setAddress
-
requestEntryFromID
-
getThrottle
-
getFunctionThrottle
-
getCurrentAddress
-
getCurrentAddressString
Get the string representation of this throttles address. Returns 'Not Set' if no address in use.- Returns:
- string value of throttle address
-
getCurrentRosterIdString
Get the string representation of this Roster ID. Returns empty string if no address in use. since 4.15.4- Returns:
- string value of throttle Roster ID
-
sendAddress
-
handleFunction
-
forceFunction
-
handleSpeedStepMode
-
handleMomentary
-
handleRequest
-