Class CbusThrottle
- All Implemented Interfaces:
PropertyChangeFirer,PropertyChangeProvider,DccThrottle,Throttle
Speed in the Throttle interfaces and AbstractThrottle is a float, but in CBUS is normally an int with values from 0 to 127.
| setSpeedSetting | CBUS DSPD | Translated | Throttle |
| 0 | 0 | Speed 0 | 0 % |
| -1 | 1 | E Stop | 0 % |
| 0.007937 | 2 | Speed 1 | 1/126 % |
| 0.015873 | 3 | Speed 2 | 2/126 % |
| 0.984127 | 125 | Speed 124 | 124/126 % |
| 0.992063 | 126 | Speed 125 | 125/126 % |
| 1 | 127 | Speed 126 | 100 % |
| CBUS DSPD | Translated | Throttle |
| 0 | Speed 0 Encoding 1 | 0 % |
| 1 | Speed 0 Encoding 2 | 0 % |
| 2 | E Stop Encoding 1 | 0 % |
| 3 | E Stop Encoding 2 | 0 % |
| 4 | Speed 1 | 1/28 % |
| 5 | Speed 2 | 2/28 % |
| 29 | Speed 26 | 26/28 % |
| 30 | Speed 27 | 27/28 % |
| 31 | Speed 28 | 100 % |
| CBUS DSPD | Translated | Throttle |
| 0 | Speed 0 | 0 % |
| 1 | E Stop | 0 % |
| 2 | Speed 1 | 1/14 % |
| 3 | Speed 2 | 2/14 % |
| 13 0x0D | Speed 12 | 12/14 % |
| 14 0x0E | Speed 13 | 13/14 % |
| 15 0x0F | Speed 14 | 100 % |
-
Field Summary
Fields inherited from class jmri.jmrix.AbstractThrottle
active, adapterMemo, FUNCTION_GROUPS, isForward, speedSetting, speedStepMode, startFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupportFields inherited from interface jmri.Throttle
CONNECTED, DISPATCH_ENABLED, 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, RELEASE_ENABLED, SPEEDINCREMENT, SPEEDSETTING, SPEEDSTEPMODE, SPEEDSTEPS -
Constructor Summary
ConstructorsConstructorDescriptionCbusThrottle(CanSystemConnectionMemo memo, LocoAddress address, int handle) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected floatfloatSpeed(int lSpeed) Convert a CBUS speed integer to a float speed valueprotected intReturn the handle for this throttleLocomotive address.protected intGet the number of external steal recovery attemptsprotected voidIncrease a count of external steal recovery attemptsprotected booleanisStolen()Get Throttle Stolen Flagprotected voidRelease session from a command station ie. throttle with clean full dispose called from releaseThrottleprotected voidReset count of recovery attemptsprotected voidsendFunctionGroup(int group) protected voidSend the CBUS message to set the state of functions F0, F1, F2, F3, F4.protected voidSend the CBUS message to set the state of functions F5, F6, F7, F8.protected voidSend the CBUS message to set the state of functions F9, F10, F11, F12.protected voidSend the CBUS message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20protected voidSend the CBUS message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28protected voidSend the CBUS message to set the state of functions F29 - F36protected voidsetDispatchActive(boolean newval) Adds extra check for num of this JMRI throttle users before notifying and makes sure these always get sent as a pair the abstracts only send to ThrottleListeners if value has been changedprotected voidsetHandle(int newHandle) Set the handle for this throttlevoidsetIsForward(boolean forward) Set the direction and reset speed.voidsetSpeedSetting(float speed, boolean allowDuplicates, boolean allowDuplicatesOnStop) Set the speed.voidsetSpeedStepMode(SpeedStepMode stepMode) setSpeedStepMode - set the speed step value.protected voidsetStolen(boolean isStolen) Set Throttle Stolen Flagprotected final voidvoidDispose when finished with this object.protected voidthrottleInit(int speed, int f0f4, int f5f8, int f9f12) Set initial throttle values as taken from PLOC reply from hardwaretoString()protected voidupdateFunctionGroup(int group, int fns) protected voidupdateIsForward(boolean forward) Update the throttles direction without sending to hardware.Used to support CBUS sharing by taking direction received from the hardware in an OPC_DSPD message.protected voidupdateSpeedSetting(int speed) Update the throttles speed setting without sending to hardware.Methods inherited from class jmri.jmrix.AbstractThrottle
addPropertyChangeListener, dispatch, dispose, finishRecord, getFunction, getFunctionMomentary, getFunctionMomentaryNoWarn, getFunctionNoWarn, getFunctions, getFunctionsMomentary, getIsForward, getMemo, getRosterEntry, getSpeedIncrement, getSpeedSetting, getSpeedStepMode, intSpeed, intSpeed, notifyThrottleDisconnect, notifyThrottleDispatchEnabled, notifyThrottleReleaseEnabled, record, release, removePropertyChangeListener, sendFunctionGroup, sendFunctionGroup10, sendFunctionGroup7, sendFunctionGroup8, sendFunctionGroup9, sendMomentaryFunctionGroup1, sendMomentaryFunctionGroup10, sendMomentaryFunctionGroup2, sendMomentaryFunctionGroup3, sendMomentaryFunctionGroup4, sendMomentaryFunctionGroup5, sendMomentaryFunctionGroup6, sendMomentaryFunctionGroup7, sendMomentaryFunctionGroup8, sendMomentaryFunctionGroup9, setFunction, setFunctionMomentary, setRosterEntry, setSpeedSetting, setSpeedSettingAgain, startClock, updateFunction, updateFunctionMomentaryMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListenerMethods inherited from interface jmri.Throttle
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, 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
-
Constructor Details
-
CbusThrottle
Constructor- Parameters:
memo- System Connectionaddress- The address this throttle relates to.handle- the Session ID for the Throttle
-
-
Method Details
-
throttleInit
Set initial throttle values as taken from PLOC reply from hardware- Parameters:
speed- including direction flagf0f4- Functions 0-4f5f8- Functions 5-8f9f12- Functions 9-12
-
setSpeedStepMode
setSpeedStepMode - set the speed step value.Overridden to capture mode changes to be forwarded to the hardware. New throttles default to 128 step mode. CBUS Command stations also default to 128SS so this does not need to be sent if unchanged.
- Specified by:
setSpeedStepModein interfaceDccThrottle- Overrides:
setSpeedStepModein classAbstractThrottle- Parameters:
stepMode- the current speed step mode - default should be 128 speed step mode in most cases
-
floatSpeed
Convert a CBUS speed integer to a float speed value- Parameters:
lSpeed- -1 to 127- Returns:
- float value -1 to 1
-
sendFunctionGroup1
Send the CBUS message to set the state of functions F0, F1, F2, F3, F4.- Overrides:
sendFunctionGroup1in classAbstractThrottle
-
sendFunctionGroup2
Send the CBUS message to set the state of functions F5, F6, F7, F8.- Overrides:
sendFunctionGroup2in classAbstractThrottle
-
sendFunctionGroup3
Send the CBUS message to set the state of functions F9, F10, F11, F12.- Overrides:
sendFunctionGroup3in classAbstractThrottle
-
sendFunctionGroup4
Send the CBUS message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20- Overrides:
sendFunctionGroup4in classAbstractThrottle
-
sendFunctionGroup5
Send the CBUS message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28- Overrides:
sendFunctionGroup5in classAbstractThrottle
-
sendFunctionGroup6
Send the CBUS message to set the state of functions F29 - F36- Overrides:
sendFunctionGroup6in classAbstractThrottle
-
sendFunctionGroup
-
updateFunctionGroup
-
setSpeedSetting
Set the speed.This intentionally skips the emergency stop value of 1.
- Specified by:
setSpeedSettingin interfaceThrottle- Overrides:
setSpeedSettingin classAbstractThrottle- Parameters:
speed- Number from 0 to 1; less than zero is emergency stopallowDuplicates- don't suppress messagesallowDuplicatesOnStop- don't suppress messages if the new speed is 'stop'
-
updateSpeedSetting
Update the throttles speed setting without sending to hardware. Used to support CBUS sharing by taking speed received from the hardware in an OPC_DSPD message.No compensation required for a direction flag
- Parameters:
speed- integer speed value
-
setIsForward
Set the direction and reset speed. Forwards to the layout Implementing functions should override this function, but should either make a call to super.setIsForward() to notify the listeners, or should notify the listeners themselves.- Specified by:
setIsForwardin interfaceThrottle- Overrides:
setIsForwardin classAbstractThrottle- Parameters:
forward- true if forward; false otherwise
-
updateIsForward
Update the throttles direction without sending to hardware.Used to support CBUS sharing by taking direction received from the hardware in an OPC_DSPD message.- Parameters:
forward- True if Forward, else False
-
toString
-
getHandle
Return the handle for this throttle- Returns:
- integer session handle
-
setHandle
Set the handle for this throttleThis is normally done on Throttle Construction but certain operations, eg. recovering from an external steal may need to change this.
- Parameters:
newHandle- session handle
-
setStolen
Set Throttle Stolen FlagThis is false on Throttle Construction but certain operations may need to change this, eg. an external steal.
Sends IsAvailable Property Change Notification
- Parameters:
isStolen- true if Throttle has been stolen, else false
-
isStolen
Get Throttle Stolen FlagThis is false on Throttle Construction but certain operations may need to change this, eg. an external steal.
- Returns:
- true if Throttle has been stolen, else false
-
getNumRecoverAttempts
Get the number of external steal recovery attempts- Returns:
- Number of attempts since last reset
-
increaseNumRecoverAttempts
Increase a count of external steal recovery attempts -
resetNumRecoverAttempts
Reset count of recovery attempts -
releaseFromCommandStation
Release session from a command station ie. throttle with clean full dispose called from releaseThrottle -
throttleDispose
Dispose when finished with this object. After this, further usage of this Throttle object will result in a JmriException.- Specified by:
throttleDisposein classAbstractThrottle
-
startRefresh
-
getLocoAddress
Locomotive address. The exact format is defined by the specific implementation, as subclasses of LocoAddress will contain different information.This is an unbound property.
- Returns:
- The locomotive address
-
setDispatchActive
Adds extra check for num of this JMRI throttle users before notifying and makes sure these always get sent as a pair the abstracts only send to ThrottleListeners if value has been changed- Parameters:
newval- set true if dispatch can be enabled, else false
-