Package jmri.jmrit.withrottle
Class ThrottleController
java.lang.Object
jmri.jmrit.withrottle.ThrottleController
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,ThrottleListener
- Direct Known Subclasses:
MultiThrottleController
public class ThrottleController extends Object implements ThrottleListener, PropertyChangeListener
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<ControllerInterface>
controllerListeners
(package private) DccThrottle
functionThrottle
(package private) boolean
isAddressSet
(package private) boolean
isMomF2
protected Queue<Float>
lastSentSpeed
(package private) DccLocoAddress
leadAddress
(package private) ConsistFunctionController
leadLocoF
protected ArrayList<ThrottleControllerListener>
listeners
(package private) String
locoKey
protected float
newSpeed
(package private) RosterEntry
rosterLoco
(package private) float
speedMultiplier
(package private) DccThrottle
throttle
(package private) boolean
useLeadLocoF
(package private) char
whichThrottle
-
Constructor Summary
Constructors Constructor Description ThrottleController()
ThrottleController(char whichThrottleChar, ThrottleControllerListener tcl, ControllerInterface cl)
-
Method Summary
Modifier and Type Method Description void
addControllerListener(ControllerInterface listener)
Add a listener to handle: listener.sendPacketToDevice(message);void
addressDispatch()
void
addressRelease()
Receive notification that an address has been released/dispatchedvoid
addThrottleControllerListener(ThrottleControllerListener l)
protected String
buildFStatesHeader()
protected void
eStop()
RosterEntry
findRosterEntry(DccThrottle t)
protected void
forceFunction(String inPackage)
DccLocoAddress
getCurrentAddress()
String
getCurrentAddressString()
Get the string representation of this throttles address.String
getCurrentRosterIdString()
Get the string representation of this Roster ID.DccThrottle
getFunctionThrottle()
DccThrottle
getThrottle()
protected void
handleFunction(String inPackage)
protected void
handleMomentary(String inPackage)
protected void
handleRequest(String inPackage)
protected void
handleSpeedStepMode(SpeedStepMode newMode)
protected void
idle()
void
notifyDecisionRequired(LocoAddress address, ThrottleListener.DecisionType question)
calls notifyFailedThrottleRequest, Steal Requiredvoid
notifyFailedThrottleRequest(LocoAddress address, String reason)
Get notification that an attempt to request a throttle has failed.void
notifyThrottleFound(DccThrottle t)
Receive notification that a DccThrottle has been found and is in use.void
propertyChange(PropertyChangeEvent event)
void
removeControllerListener(ControllerInterface listener)
void
removeThrottleControllerListener(ThrottleControllerListener l)
void
requestEntryFromID(String id)
void
sendAddress()
void
sendAllFunctionStates(DccThrottle t)
send all function states, primarily for initial status Current Format: RPF}|{whichThrottle]\[function}|{state]\[function}|{state...protected void
sendAllMomentaryStates(DccThrottle t)
protected void
sendCurrentDirection(DccThrottle t)
protected void
sendCurrentSpeed(DccThrottle t)
void
sendFunctionLabels(RosterEntry re)
protected void
sendSpeedStepMode(DccThrottle t)
protected void
setAddress(int number, boolean isLong)
protected void
setDirection(boolean isForward)
void
setFunctionThrottle(DccThrottle t)
void
setLocoForConsistFunctions(String inPackage)
void
setRosterLocoForConsistFunctions(String id)
protected void
setSpeed(int rawSpeed)
handle the conversion from rawSpeed to the float value needed in the DccThrottlevoid
setWhichThrottle(char c)
void
shutdownThrottle()
boolean
sort(String inPackage)
Figure out what the received command means, where it has to go, and translate to a jmri method.void
syncThrottleFunctions(DccThrottle t, RosterEntry re)
-
Field Details
-
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:
notifyThrottleFound
in interfaceThrottleListener
- Parameters:
t
- The throttle which has been found
-
notifyFailedThrottleRequest
Description copied from interface:ThrottleListener
Get notification that an attempt to request a throttle has failed.- Specified by:
notifyFailedThrottleRequest
in 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:
notifyDecisionRequired
in interfaceThrottleListener
- Parameters:
address
- The LocoAddress that needs the decision.question
- The question being asked, steal / cancel, share / cancel, steal / share / cancel
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
findRosterEntry
-
syncThrottleFunctions
-
sendFunctionLabels
-
sendAllFunctionStates
send all function states, primarily for initial status Current Format: RPF}|{whichThrottle]\[function}|{state]\[function}|{state...- 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
-