jmri.jmrix.loconet
Class Pr2Throttle

java.lang.Object
  extended by jmri.jmrix.AbstractThrottle
      extended by jmri.jmrix.loconet.Pr2Throttle
All Implemented Interfaces:
DccThrottle, Throttle

public class Pr2Throttle
extends AbstractThrottle

An implementation of DccThrottle via AbstractThrottle with code specific to a PR2 connection.

Speed in the Throttle interfaces and AbstractThrottle is a float, but in LocoNet is an int with values from 0 to 127.

Author:
Bob Jacobsen Copyright (C) 2006

Field Summary
 
Fields inherited from class jmri.jmrix.AbstractThrottle
active, f0, f0Momentary, f1, f10, f10Momentary, f11, f11Momentary, f12, f12Momentary, f13, f13Momentary, f14, f14Momentary, f15, f15Momentary, f16, f16Momentary, f17, f17Momentary, f18, f18Momentary, f19, f19Momentary, f1Momentary, f2, f20, f20Momentary, f21, f21Momentary, f22, f22Momentary, f23, f23Momentary, f24, f24Momentary, f25, f25Momentary, f26, f26Momentary, f27, f27Momentary, f28, f28Momentary, f2Momentary, f3, f3Momentary, f4, f4Momentary, f5, f5Momentary, f6, f6Momentary, f7, f7Momentary, f8, f8Momentary, f9, f9Momentary, isForward, speedIncrement, speedSetting, speedStepMode
 
Fields inherited from interface jmri.DccThrottle
SpeedStepMode128, SpeedStepMode14, SpeedStepMode27, SpeedStepMode28
 
Constructor Summary
Pr2Throttle(DccLocoAddress address)
          Constructor
 
Method Summary
 void dispatch()
          Dispatch the loco from this throttle, then clean up the object.
 void dispose()
          Dispose when finished with this object.
protected  float floatSpeed(int lSpeed)
          Convert a LocoNet speed integer to a float speed value
 LocoAddress getLocoAddress()
          Locomotive address.
protected  int intSpeed(float fSpeed)
          Convert a float speed value to a LocoNet speed integer
 void release()
          Release the loco from this throttle, then clean up the object.
protected  void sendFunctionGroup1()
          Send the LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4.
protected  void sendFunctionGroup2()
          Send the LocoNet message to set the state of functions F5, F6, F7, F8.
protected  void sendFunctionGroup3()
          Send the message to set the state of functions F9, F10, F11, F12 This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
 void setIsForward(boolean forward)
          LocoNet actually puts forward and backward in the same message as the first function group.
 void setSpeedSetting(float speed)
          Set the speed.
 String toString()
           
 void writeData()
           
 
Methods inherited from class jmri.jmrix.AbstractThrottle
addPropertyChangeListener, getF0, getF0Momentary, getF1, getF10, getF10Momentary, getF11, getF11Momentary, getF12, getF12Momentary, getF13, getF13Momentary, getF14, getF14Momentary, getF15, getF15Momentary, getF16, getF16Momentary, getF17, getF17Momentary, getF18, getF18Momentary, getF19, getF19Momentary, getF1Momentary, getF2, getF20, getF20Momentary, getF21, getF21Momentary, getF22, getF22Momentary, getF23, getF23Momentary, getF24, getF24Momentary, getF25, getF25Momentary, getF26, getF26Momentary, getF27, getF27Momentary, getF28, getF28Momentary, getF2Momentary, getF3, getF3Momentary, getF4, getF4Momentary, getF5, getF5Momentary, getF6, getF6Momentary, getF7, getF7Momentary, getF8, getF8Momentary, getF9, getF9Momentary, getIsForward, getSpeedIncrement, getSpeedSetting, getSpeedStepMode, notifyPropertyChangeListener, removePropertyChangeListener, sendFunctionGroup4, sendFunctionGroup5, sendMomentaryFunctionGroup1, sendMomentaryFunctionGroup2, sendMomentaryFunctionGroup3, sendMomentaryFunctionGroup4, sendMomentaryFunctionGroup5, setF0, setF0Momentary, setF1, setF10, setF10Momentary, setF11, setF11Momentary, setF12, setF12Momentary, setF13, setF13Momentary, setF14, setF14Momentary, setF15, setF15Momentary, setF16, setF16Momentary, setF17, setF17Momentary, setF18, setF18Momentary, setF19, setF19Momentary, setF1Momentary, setF2, setF20, setF20Momentary, setF21, setF21Momentary, setF22, setF22Momentary, setF23, setF23Momentary, setF24, setF24Momentary, setF25, setF25Momentary, setF26, setF26Momentary, setF27, setF27Momentary, setF28, setF28Momentary, setF2Momentary, setF3, setF3Momentary, setF4, setF4Momentary, setF5, setF5Momentary, setF6, setF6Momentary, setF7, setF7Momentary, setF8, setF8Momentary, setF9, setF9Momentary, setSpeedStepMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pr2Throttle

public Pr2Throttle(DccLocoAddress address)
Constructor

Method Detail

floatSpeed

protected float floatSpeed(int lSpeed)
Convert a LocoNet speed integer to a float speed value


intSpeed

protected int intSpeed(float fSpeed)
Convert a float speed value to a LocoNet speed integer


writeData

public void writeData()

sendFunctionGroup1

protected void sendFunctionGroup1()
Send the LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4. Invoked by AbstractThrottle when needed.

Overrides:
sendFunctionGroup1 in class AbstractThrottle

sendFunctionGroup2

protected void sendFunctionGroup2()
Send the LocoNet message to set the state of functions F5, F6, F7, F8. Invoked by AbstractThrottle when needed.

Overrides:
sendFunctionGroup2 in class AbstractThrottle

sendFunctionGroup3

protected void sendFunctionGroup3()
Description copied from class: AbstractThrottle
Send the message to set the state of functions F9, F10, F11, F12

This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.

Overrides:
sendFunctionGroup3 in class AbstractThrottle

setSpeedSetting

public void setSpeedSetting(float speed)
Set the speed.

This intentionally skips the emergency stop value of 1.

Parameters:
speed - Number from 0 to 1; less than zero is emergency stop

setIsForward

public void setIsForward(boolean forward)
LocoNet actually puts forward and backward in the same message as the first function group.


release

public void release()
Release the loco from this throttle, then clean up the object.

Specified by:
release in interface Throttle
Overrides:
release in class AbstractThrottle

dispatch

public void dispatch()
Dispatch the loco from this throttle, then clean up the object.

Specified by:
dispatch in interface Throttle
Overrides:
dispatch in class AbstractThrottle

toString

public String toString()
Overrides:
toString in class Object

dispose

public void dispose()
Dispose when finished with this object. After this, further usage of this Throttle object will result in a JmriException.

Specified by:
dispose in interface Throttle
Overrides:
dispose in class AbstractThrottle

getLocoAddress

public LocoAddress getLocoAddress()
Description copied from interface: Throttle
Locomotive address. The exact format is defined by the specific implementation, as subclasses of LocoAddress will contain different information. This is an unbound parameter.



Copyright © 1997 - 2009 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