Package jmri.jmrix.loconet
Class LocoNetThrottle
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrix.AbstractThrottle
jmri.jmrix.loconet.LocoNetThrottle
- All Implemented Interfaces:
EventListener,PropertyChangeFirer,PropertyChangeProvider,DccThrottle,SlotListener,Throttle
- Direct Known Subclasses:
Ib1Throttle,Ib2Throttle
An implementation of DccThrottle via AbstractThrottle with code specific to a
LocoNet connection.
Speed in the Throttle interfaces and AbstractThrottle is a float, but in LocoNet is an int with values from 0 to 127.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanprotected intprotected intprotected intprotected int(package private) Timerprotected LocoNetInterfaceprotected booleanprotected longprotected intprotected longprotected LocoNetSlotprotected intprotected LnThrottleManagerFields 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
ConstructorsConstructorDescriptionLocoNetThrottle(LocoNetSystemConnectionMemo memo, LocoNetSlot slot) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid"Dispatch" a LocoNet throttle by setting the slot as "common" then performing a slot move to slot 0.protected floatfloatSpeed(int lSpeed) Convert a LocoNet speed integer to a float speed valueGet the address controlled by this throttle.Get the LocoNetSlot which is used for controlling the loco assoicated with this throttle.protected intintSpeed(float fSpeed) Computes the integer speed value from a float.voidnotifyChangedSlot(LocoNetSlot pSlot) Get notified when underlying slot information changesvoidnotifyRefused(int addr, String s) Get notified when underlying slot acquisition process fails.protected voidSend the Expanded LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4, F5, F6protected voidSend the Expanded LocoNet message to set the state of functions F7, F8, F8, F9, F10, F11, F12, F13protected voidSends expanded loconet message F14 thru F20 Message.protected voidSends Expanded loconet message F21 thru F28 Message.protected voidsendExpSpeedAndDirection(boolean isFwd) Send the expanded slot command for speed and direction on change of direction Note we send our stored speed if slot has not yet been updated by the echoprotected voidsendExpSpeedAndDirection(int speed) Send the expanded slot command for speed and direction on change of speed Note we send our stored values as slot is updated via an echo and may not have been updated yet when sending rapid commandsprotected voidsendFunctionGroup(int functionNum, boolean momentary) Send whole (DCC) Function Group for a particular function number.protected voidSend the LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4 Unfortunately this is used by all throttles to send direction changes, but the expanded slots dont use this for direction changes, they use speed...protected voidSends Function Group 10 values - F61 thru F68, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSend the LocoNet message to set the state of functions F5, F6, F7, F8protected voidSends Function Group 3 values - F9 thru F12, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 4 values - F13 thru F20, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 5 values - F21 thru F28, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 6 values - F29 thru F36, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 7 values - F37 thru F44, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 8 values - F45 thru F52, using an "OPC_IMM_PACKET" LocoNet Message.protected voidSends Function Group 9 values - F53 thru F60, using an "OPC_IMM_PACKET" LocoNet Message.voidsetIsForward(boolean forward) Send a LocoNet message containing the specified direction of travel.voidsetSpeedSetting(float speed) Send a LocoNet message to set the loco speed speed.voidsetSpeedSetting(float speed, boolean allowDuplicates, boolean allowDuplicatesOnStop) Set the speed.voidsetSpeedSettingAgain(float speed) Set the Speed, ensuring that a LocoNet message is sent to update the slot even if the new speed is effectively the same as the current speed.voidSet the speed step value and the related speedIncrement value.protected voidStart the "refresh" timer.voidDispose the LocoNetThrottle when finished with this object.protected voidtimeout()Internal routine to resend the speed on a timeouttoString()protected voidupdate the F0-F29 functions.Methods inherited from class jmri.jmrix.AbstractThrottle
addPropertyChangeListener, dispatch, dispose, finishRecord, getFunction, getFunctionMomentary, getFunctionMomentaryNoWarn, getFunctionNoWarn, getFunctions, getFunctionsMomentary, getIsForward, getMemo, getRosterEntry, getSpeedIncrement, getSpeedSetting, getSpeedStepMode, intSpeed, notifyThrottleDisconnect, notifyThrottleDispatchEnabled, notifyThrottleReleaseEnabled, record, release, removePropertyChangeListener, sendMomentaryFunctionGroup1, sendMomentaryFunctionGroup10, sendMomentaryFunctionGroup2, sendMomentaryFunctionGroup3, sendMomentaryFunctionGroup4, sendMomentaryFunctionGroup5, sendMomentaryFunctionGroup6, sendMomentaryFunctionGroup7, sendMomentaryFunctionGroup8, sendMomentaryFunctionGroup9, setFunction, setFunctionMomentary, setRosterEntry, 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
-
Field Details
-
slot
-
network
-
throttleManager
-
address
-
layout_spd
-
layout_dirf
-
layout_snd
-
layout_stat1
-
new_spd
-
new_spd_lastupdated
-
new_isFwd
-
new_isFwd_lastupdated
-
slotStatus
-
isDisposing
-
mRefreshTimer
-
-
Constructor Details
-
LocoNetThrottle
Constructor- Parameters:
memo- connection detailsslot- The LocoNetSlot this throttle will talk on.
-
-
Method Details
-
floatSpeed
Convert a LocoNet speed integer to a float speed value- Parameters:
lSpeed- LocoNet style speed value- Returns:
- speed as float 0->1.0, or -1.0 to indicate E-Stop
-
intSpeed
Computes the integer speed value from a float.Values of less than 0 indicate Emergency Stop.
Value of 0.0 indicates stop.
Values between 0.0+ and 1.0 imply speed step values between 2 and the maximum value allowed for the loco's speed step mode.
- Overrides:
intSpeedin classAbstractThrottle- Parameters:
fSpeed- is the floating-point speed value to be converted- Returns:
- an integer which represents the speed step value
-
sendFunctionGroup
Send whole (DCC) Function Group for a particular function number.- Overrides:
sendFunctionGroupin classAbstractThrottle- Parameters:
functionNum- Function Numbermomentary- False to send normal function status, true to send momentary.
-
sendFunctionGroup1
Send the LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4 Unfortunately this is used by all throttles to send direction changes, but the expanded slots dont use this for direction changes, they use speed... And we don't know if the caller wants to send functions or direction.- Overrides:
sendFunctionGroup1in classAbstractThrottle
-
sendFunctionGroup2
Send the LocoNet message to set the state of functions F5, F6, F7, F8- Overrides:
sendFunctionGroup2in classAbstractThrottle
-
sendFunctionGroup3
Sends Function Group 3 values - F9 thru F12, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup3in classAbstractThrottle
-
sendFunctionGroup4
Sends Function Group 4 values - F13 thru F20, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup4in classAbstractThrottle
-
sendFunctionGroup5
Sends Function Group 5 values - F21 thru F28, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup5in classAbstractThrottle
-
sendFunctionGroup6
Sends Function Group 6 values - F29 thru F36, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup6in classAbstractThrottle
-
sendFunctionGroup7
Sends Function Group 7 values - F37 thru F44, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup7in classAbstractThrottle
-
sendFunctionGroup8
Sends Function Group 8 values - F45 thru F52, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup8in classAbstractThrottle
-
sendFunctionGroup9
Sends Function Group 9 values - F53 thru F60, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup9in classAbstractThrottle
-
sendFunctionGroup10
Sends Function Group 10 values - F61 thru F68, using an "OPC_IMM_PACKET" LocoNet Message.- Overrides:
sendFunctionGroup10in classAbstractThrottle
-
sendExpFunctionGroup1
Send the Expanded LocoNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4, F5, F6 -
sendExpFunctionGroup2
Send the Expanded LocoNet message to set the state of functions F7, F8, F8, F9, F10, F11, F12, F13 -
sendExpFunctionGroup3
Sends expanded loconet message F14 thru F20 Message. -
sendExpFunctionGroup4
Sends Expanded loconet message F21 thru F28 Message. -
sendExpSpeedAndDirection
Send the expanded slot command for speed and direction on change of speed Note we send our stored values as slot is updated via an echo and may not have been updated yet when sending rapid commands- Parameters:
speed- the speed to set
-
sendExpSpeedAndDirection
Send the expanded slot command for speed and direction on change of direction Note we send our stored speed if slot has not yet been updated by the echo- Parameters:
isFwd- new direction
-
setSpeedSetting
Send a LocoNet message to set the loco speed speed.- Specified by:
setSpeedSettingin interfaceThrottle- Overrides:
setSpeedSettingin classAbstractThrottle- Parameters:
speed- Number from 0 to 1; less than zero is "emergency stop"
-
setSpeedSettingAgain
Set the Speed, ensuring that a LocoNet message is sent to update the slot even if the new speed is effectively the same as the current speed. Note: this can cause an increase in LocoNet traffic.- Specified by:
setSpeedSettingAgainin interfaceThrottle- Overrides:
setSpeedSettingAgainin classAbstractThrottle- Parameters:
speed- Number from 0 to 1; less than zero is emergency stop
-
setSpeedSetting
Set the speed. No LocoNet message is sent if the new speed would result in a 'duplicate' - ie. a speed setting no different to the one the slot currently has - unless the boolean paramters indicate it should be.- Specified by:
setSpeedSettingin interfaceThrottle- Overrides:
setSpeedSettingin classAbstractThrottle- Parameters:
speed- Number from 0 to 1; less than zero is emergency stopallowDuplicates- boolean - if true, send a LocoNet message no matter whatallowDuplicatesOnStop- boolean - if true, send a LocoNet message if the new speed is 'idle' or 'emergency stop', even if that matches the existing speed.
-
setIsForward
Send a LocoNet message containing the specified direction of travel. LocoNet actually puts forward and backward in the same message as the first function group.- Specified by:
setIsForwardin interfaceThrottle- Overrides:
setIsForwardin classAbstractThrottle- Parameters:
forward- is true for forward movement, else false
-
getLocoNetSlot
Get the LocoNetSlot which is used for controlling the loco assoicated with this throttle.- Returns:
- the LocoNetSlot
-
toString
-
throttleDispose
Dispose the LocoNetThrottle when finished with this object. After this is executed, further use of this Throttle object will result in a JmriException.- Specified by:
throttleDisposein classAbstractThrottle
-
startRefresh
Start the "refresh" timer. The "refresh" timer determines when to send a new LocoNet message to "refresh" the slot's speed setting, so that the slot does not get "purged". -
timeout
Internal routine to resend the speed on a timeout -
notifyRefused
Get notified when underlying slot acquisition process fails. Slot acquisition failure is handled by @link LnThrottleManager, so no code is required here.- Parameters:
addr- Locomotive addresss- reason the acquisition failed
-
notifyChangedSlot
Get notified when underlying slot information changes- Specified by:
notifyChangedSlotin interfaceSlotListener- Parameters:
pSlot- the slot which was changed
-
updateFunctions
update the F0-F29 functions. Invoked by notifyChangedSlot(), this nominally updates from the slot. -
setSpeedStepMode
Set the speed step value and the related speedIncrement value.- Specified by:
setSpeedStepModein interfaceDccThrottle- Overrides:
setSpeedStepModein classAbstractThrottle- Parameters:
Mode- the current speed step mode - default should be 128 speed step mode in most cases
-
getLocoAddress
Get the address controlled by this throttle. If the throttle is controlling.- Specified by:
getLocoAddressin interfaceThrottle- Returns:
- a LocoAddress for the address controlled by this throttle
-
dispatchThrottle
"Dispatch" a LocoNet throttle by setting the slot as "common" then performing a slot move to slot 0.The throttle being dispatched no longer has control of the loco, but other throttles may continue to control the loco.
- Parameters:
t- throttle being dispatchedl- throttle listener to remove
-