Package jmri.jmrit.withrottle
Class MultiThrottle
- java.lang.Object
-
- jmri.jmrit.withrottle.MultiThrottle
-
public class MultiThrottle extends java.lang.Object
Keeps track of what locos are being controlled by a throttle, and passes the control messages on to them. Creates a new MultiThrottleController for each loco requested on this throttle. Each loco will then be able to be controlled individually. '*' is a wildcard loco key. Forwards to all locos on this MultiThrottle.Sample messages:
- MT+L757<;>L757 On T throttle, add loco L757.
- MT+L1234<;>L1234 On T throttle, add loco L1234.
- MTSL1234<;>L1234 On T throttle, steal loco L1234.
- MTAL757<;>R1 On T throttle, loco L757, set direction to forward.
- MTAL1234<;>R0 On T throttle, loco L1234, set direction to reverse.
- MTAL757<;>V42 On T throttle, loco L757, set speed to 42.
- MTAL1234<;>V42 On T throttle, loco L1234, set speed to 42.
- MTA*<;>V16 On T throttle, all locos, set speed to 16.
- MT-L757<;>L757 On T throttle, remove loco L757. (Still has L1234)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.ConcurrentHashMap<java.lang.String,MultiThrottleController>
throttles
(package private) char
whichThrottle
-
Constructor Summary
Constructors Constructor Description MultiThrottle(char id, ThrottleControllerListener tcl, ControllerInterface ci)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addThrottleController(java.lang.String key, java.lang.String action)
void
canceledThrottleRequest(java.lang.String key)
A request for a this address has been cancelled, clean up the waiting MultiThrottleController.void
dispose()
void
eStop()
void
handleMessage(java.lang.String message)
Handle a message sent from the device.protected void
passActionsToControllers(java.lang.String key, java.lang.String action)
protected boolean
removeThrottleController(java.lang.String key, java.lang.String action)
protected void
stealThrottleController(java.lang.String key, java.lang.String action)
-
-
-
Field Detail
-
whichThrottle
char whichThrottle
-
throttles
java.util.concurrent.ConcurrentHashMap<java.lang.String,MultiThrottleController> throttles
-
-
Constructor Detail
-
MultiThrottle
public MultiThrottle(char id, ThrottleControllerListener tcl, ControllerInterface ci)
-
-
Method Detail
-
handleMessage
public void handleMessage(java.lang.String message)
Handle a message sent from the device. A key is used to send an action to the correct loco. '*' is a wildcard key, sends action to all locos in this MultiThrottle.- Parameters:
message
- Consists of a control character, the loco's key, a separator "<;>", and the action to forward to the MultiThrottleController.
-
addThrottleController
protected void addThrottleController(java.lang.String key, java.lang.String action)
-
stealThrottleController
protected void stealThrottleController(java.lang.String key, java.lang.String action)
-
removeThrottleController
protected boolean removeThrottleController(java.lang.String key, java.lang.String action)
-
passActionsToControllers
protected void passActionsToControllers(java.lang.String key, java.lang.String action)
-
dispose
public void dispose()
-
eStop
public void eStop()
-
canceledThrottleRequest
public void canceledThrottleRequest(java.lang.String key)
A request for a this address has been cancelled, clean up the waiting MultiThrottleController. If the MTC is marked as a steal, this cancel needs to not happen.- Parameters:
key
- The string to use as a key to remove the proper MultiThrottleController
-
-