jmri.jmrit.withrottle
Class ThrottleController

java.lang.Object
  extended by jmri.jmrit.withrottle.ThrottleController
All Implemented Interfaces:
PropertyChangeListener, EventListener, ThrottleListener
Direct Known Subclasses:
MultiThrottleController

public class ThrottleController
extends Object
implements ThrottleListener, PropertyChangeListener


Field Summary
protected  ArrayList<ControllerInterface> controllerListeners
           
protected  ArrayList<ThrottleControllerListener> listeners
           
 
Constructor Summary
ThrottleController()
           
ThrottleController(char whichThrottleChar, ThrottleControllerListener tcl, ControllerInterface cl)
           
 
Method Summary
 void addControllerListener(ControllerInterface listener)
          Add a listener to handle: listener.sendPacketToDevice(message);
 void addressDispatch()
           
 void addressRelease()
          Receive notification that an address has been released/dispatched
 void 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.
 DccThrottle getFunctionThrottle()
           
 DccThrottle getThrottle()
           
protected  void handleFunction(String inPackage)
           
protected  void handleMomentary(String inPackage)
           
protected  void handleRequest(String inPackage)
           
protected  void handleSpeedStepMode(int newMode)
           
protected  void idle()
           
 void notifyFailedThrottleRequest(DccLocoAddress address, String reason)
          Get notification that an attempt to request a throttle has failed
 void notifyThrottleFound(DccThrottle t)
          Recieve 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 DccThrottle
 void 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected ArrayList<ThrottleControllerListener> listeners

controllerListeners

protected ArrayList<ControllerInterface> controllerListeners
Constructor Detail

ThrottleController

public ThrottleController()

ThrottleController

public ThrottleController(char whichThrottleChar,
                          ThrottleControllerListener tcl,
                          ControllerInterface cl)
Method Detail

setWhichThrottle

public void setWhichThrottle(char c)

addThrottleControllerListener

public void addThrottleControllerListener(ThrottleControllerListener l)

removeThrottleControllerListener

public void removeThrottleControllerListener(ThrottleControllerListener l)

addControllerListener

public void addControllerListener(ControllerInterface listener)
Add a listener to handle: listener.sendPacketToDevice(message);

Parameters:
listener -

removeControllerListener

public void removeControllerListener(ControllerInterface listener)

addressRelease

public void addressRelease()
Receive notification that an address has been released/dispatched


addressDispatch

public void addressDispatch()

notifyThrottleFound

public void notifyThrottleFound(DccThrottle t)
Recieve notification that a DccThrottle has been found and is in use.

Specified by:
notifyThrottleFound in interface ThrottleListener
Parameters:
t - The throttle which has been found

notifyFailedThrottleRequest

public void notifyFailedThrottleRequest(DccLocoAddress address,
                                        String reason)
Description copied from interface: ThrottleListener
Get notification that an attempt to request a throttle has failed

Specified by:
notifyFailedThrottleRequest in interface ThrottleListener
Parameters:
address - DccLocoAddress of the failed loco request.
reason - The reason why the throttle request failed.

propertyChange

public void propertyChange(PropertyChangeEvent event)
Specified by:
propertyChange in interface PropertyChangeListener

findRosterEntry

public RosterEntry findRosterEntry(DccThrottle t)

syncThrottleFunctions

public void syncThrottleFunctions(DccThrottle t,
                                  RosterEntry re)

sendFunctionLabels

public void sendFunctionLabels(RosterEntry re)

sendAllFunctionStates

public void sendAllFunctionStates(DccThrottle t)
send all function states, primarily for initial status Current Format: RPF}|{whichThrottle]\[function}|{state]\[function}|{state...


buildFStatesHeader

protected String buildFStatesHeader()

sendCurrentSpeed

protected void sendCurrentSpeed(DccThrottle t)

sendCurrentDirection

protected void sendCurrentDirection(DccThrottle t)

sendSpeedStepMode

protected void sendSpeedStepMode(DccThrottle t)

sendAllMomentaryStates

protected void sendAllMomentaryStates(DccThrottle t)

sort

public boolean sort(String inPackage)
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

public void setFunctionThrottle(DccThrottle t)

setLocoForConsistFunctions

public void setLocoForConsistFunctions(String inPackage)

setRosterLocoForConsistFunctions

public void setRosterLocoForConsistFunctions(String id)

shutdownThrottle

public void shutdownThrottle()

setSpeed

protected void setSpeed(int rawSpeed)
handle the conversion from rawSpeed to the float value needed in the DccThrottle

Parameters:
rawSpeed - Value sent from mobile device, range 0 - 126

setDirection

protected void setDirection(boolean isForward)

eStop

protected void eStop()

idle

protected void idle()

setAddress

protected void setAddress(int number,
                          boolean isLong)

requestEntryFromID

public void requestEntryFromID(String id)

getThrottle

public DccThrottle getThrottle()

getFunctionThrottle

public DccThrottle getFunctionThrottle()

getCurrentAddress

public DccLocoAddress getCurrentAddress()

getCurrentAddressString

public String getCurrentAddressString()
Get the string representation of this throttles address. Returns 'Not Set' if no address in use.


sendAddress

public void sendAddress()

handleFunction

protected void handleFunction(String inPackage)

forceFunction

protected void forceFunction(String inPackage)

handleSpeedStepMode

protected void handleSpeedStepMode(int newMode)

handleMomentary

protected void handleMomentary(String inPackage)

handleRequest

protected void handleRequest(String inPackage)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads