Class AbstractThrottle
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrix.AbstractThrottle
-
- All Implemented Interfaces:
PropertyChangeFirer
,PropertyChangeProvider
,DccThrottle
,Throttle
- Direct Known Subclasses:
BiDiBThrottle
,CbusThrottle
,DCCppThrottle
,DebugThrottle
,EasyDccThrottle
,EcosDccThrottle
,LocoNetThrottle
,MarklinThrottle
,MqttThrottle
,MrcThrottle
,Mx1Throttle
,NceThrottle
,OlcbThrottle
,Pr2Throttle
,SerialThrottle
,SprogCSThrottle
,SprogThrottle
,SRCPThrottle
,TamsThrottle
,Throttle
,XNetThrottle
,XpaThrottle
public abstract class AbstractThrottle extends PropertyChangeSupport implements DccThrottle
An abstract implementation of DccThrottle. Based on Glen Oberhauser's original LnThrottleManager implementation.Note that this implements DccThrottle, not Throttle directly, so it has some DCC-specific content.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
Is this object still usable?protected SystemConnectionMemo
adapterMemo
System Connection this throttle is on(package private) long
durationRunning
protected static int[]
FUNCTION_GROUPS
Constants to represent Function Groups.protected boolean
isForward
(package private) BasicRosterEntry
re
protected float
speedSetting
protected SpeedStepMode
speedStepMode
Question: should we set a default speed step mode so it's never zero?protected long
start
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields inherited from interface jmri.Throttle
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, SPEEDSTEPS
-
-
Constructor Summary
Constructors Constructor Description AbstractThrottle(SystemConnectionMemo memo)
Create a new AbstractThrottle with Functions 0-28..AbstractThrottle(SystemConnectionMemo memo, int totalFunctions)
Create a new AbstractThrottle with custom number of functions.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Temporary behaviour only allowing unique PCLs.void
dispatch(ThrottleListener l)
Finished with this Throttle, tell the layout that the locomotive is available for reuse/reallocation by somebody else.void
dispose(ThrottleListener l)
Call from a ThrottleListener to dispose of the throttle instanceprotected void
finishRecord()
boolean
getFunction(int fN)
Get Loco Function status.boolean
getFunctionMomentary(int fN)
Get the Momentary Function Value.protected boolean
getFunctionMomentaryNoWarn(int fN)
Get Momentary Function Number without warning if Throttle does not support.protected boolean
getFunctionNoWarn(int fN)
Get Function Number without warning if Throttle does not support.boolean[]
getFunctions()
Get copy of function array.boolean[]
getFunctionsMomentary()
Get copy of function momentary status array.boolean
getIsForward()
direction This is an bound parameter.BasicRosterEntry
getRosterEntry()
float
getSpeedIncrement()
Handle quantized speed.float
getSpeedSetting()
speed - expressed as a value 0.0 -> 1.0. Negative means emergency stop.SpeedStepMode
getSpeedStepMode()
Get the current speed step value.protected int
intSpeed(float speed)
Get an integer speed for the given raw speed value.protected static int
intSpeed(float speed, int steps)
Get an integer speed for the given raw speed value.protected void
notifyThrottleDisconnect()
Notify listeners that a Throttle has disconnected and is no longer available for use.void
notifyThrottleDispatchEnabled(boolean newVal)
Notify listeners that a Throttle has Dispatch enabled or disabled.void
notifyThrottleReleaseEnabled(boolean newVal)
Notify listeners that a Throttle has Release enabled or disabled.protected void
record(float speed)
Processes updated speed from subclasses.void
release(ThrottleListener l)
Finished with this Throttle, tell the layout that the locomotive is available for reuse/reallocation by somebody else.void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove the specified listener from this object.protected void
sendFunctionGroup(int functionNum, boolean momentary)
Send whole (DCC) Function Group for a particular function number.protected void
sendFunctionGroup1()
Send the message to set the state of functions F0, F1, F2, F3, F4.protected void
sendFunctionGroup10()
Send the message to set the state of functions F61 - F68.protected void
sendFunctionGroup2()
Send the 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.protected void
sendFunctionGroup4()
Send the message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20.protected void
sendFunctionGroup5()
Send the message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28.protected void
sendFunctionGroup6()
Send the message to set the state of functions F29 - F36.protected void
sendFunctionGroup7()
Send the message to set the state of functions F37 - F44.protected void
sendFunctionGroup8()
Send the message to set the state of functions F45 - F52.protected void
sendFunctionGroup9()
Send the message to set the state of functions F53 - F60.protected void
sendMomentaryFunctionGroup1()
Send the message to set the momentary state of functions F0, F1, F2, F3, F4.protected void
sendMomentaryFunctionGroup10()
Send the message to set the Momentary state of functions F61 - F68protected void
sendMomentaryFunctionGroup2()
Send the message to set the momentary state of functions F5, F6, F7, F8.protected void
sendMomentaryFunctionGroup3()
Send the message to set the Momentary state of functions F9, F10, F11, F12protected void
sendMomentaryFunctionGroup4()
Send the message to set the Momentary state of functions F13, F14, F15, F16, F17, F18, F19, F20protected void
sendMomentaryFunctionGroup5()
Send the message to set the Momentary state of functions F21, F22, F23, F24, F25, F26, F27, F28protected void
sendMomentaryFunctionGroup6()
Send the message to set the Momentary state of functions F29 - F36protected void
sendMomentaryFunctionGroup7()
Send the message to set the Momentary state of functions F37 - F44protected void
sendMomentaryFunctionGroup8()
Send the message to set the Momentary state of functions F45 - 52protected void
sendMomentaryFunctionGroup9()
Send the message to set the Momentary state of functions F53 - F60void
setFunction(int functionNum, boolean newState)
Set Loco Function and send to Layout.void
setFunctionMomentary(int momFuncNum, boolean state)
Sets Momentary Function and sends to layout.void
setIsForward(boolean forward)
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.void
setRosterEntry(BasicRosterEntry re)
void
setSpeedSetting(float speed)
setSpeedSetting - Implementing functions should override this function, but should either make a call to super.setSpeedSetting() to notify the listeners at the end of their work, or should notify the listeners themselves.void
setSpeedSetting(float speed, boolean allowDuplicates, boolean allowDuplicatesOnStop)
setSpeedSetting - Implementations should override this method only if they normally suppress messages to the system if, as far as JMRI can tell, the new message would make no difference to the system state (eg.void
setSpeedSettingAgain(float speed)
setSpeedSettingAgain - set the speed and don't ever suppress the sending of messages to the systemvoid
setSpeedStepMode(SpeedStepMode mode)
Set the speed step value.protected void
startClock()
(package private) void
stopClock()
protected abstract void
throttleDispose()
Dispose when finished with this Throttle.void
updateFunction(int fn, boolean state)
Update the state of a single function.void
updateFunctionMomentary(int fn, boolean state)
Update the Momentary state of a single function.-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
-
Methods 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, getLocoAddress, 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 Detail
-
speedSetting
protected float speedSetting
-
speedStepMode
protected SpeedStepMode speedStepMode
Question: should we set a default speed step mode so it's never zero?
-
isForward
protected boolean isForward
-
FUNCTION_GROUPS
protected static final int[] FUNCTION_GROUPS
Constants to represent Function Groups.The are the same groupings for both normal Functions and Momentary.
-
active
protected boolean active
Is this object still usable? Set false after dispose, this variable is used to check for incorrect usage.
-
adapterMemo
protected SystemConnectionMemo adapterMemo
System Connection this throttle is on
-
durationRunning
long durationRunning
-
start
protected long start
-
-
Constructor Detail
-
AbstractThrottle
public AbstractThrottle(SystemConnectionMemo memo)
Create a new AbstractThrottle with Functions 0-28..All function and momentary functions set to Off.
- Parameters:
memo
- System Connection.
-
AbstractThrottle
public AbstractThrottle(SystemConnectionMemo memo, int totalFunctions)
Create a new AbstractThrottle with custom number of functions.All function and momentary functions set to Off.
- Parameters:
memo
- System Connection this throttle is ontotalFunctions
- total number of functions available, including 0
-
-
Method Detail
-
getSpeedSetting
public float getSpeedSetting()
speed - expressed as a value 0.0 -> 1.0. Negative means emergency stop. This is a bound parameter.- Specified by:
getSpeedSetting
in interfaceThrottle
- Returns:
- speed
-
setSpeedSetting
public void setSpeedSetting(float speed)
setSpeedSetting - Implementing functions should override this function, but should either make a call to super.setSpeedSetting() to notify the listeners at the end of their work, or should notify the listeners themselves.- Specified by:
setSpeedSetting
in interfaceThrottle
- Parameters:
speed
- the speed as a 0.0 -> 1.0. fraction of maximum possible speed or -1 for emergency stop.
-
setSpeedSetting
public void setSpeedSetting(float speed, boolean allowDuplicates, boolean allowDuplicatesOnStop)
setSpeedSetting - Implementations should override this method only if they normally suppress messages to the system if, as far as JMRI can tell, the new message would make no difference to the system state (eg. the speed is the same, or effectivly the same, as the existing speed). Then, the boolean options can affect this behaviour.- Specified by:
setSpeedSetting
in interfaceThrottle
- Parameters:
speed
- the new speedallowDuplicates
- don't suppress messagesallowDuplicatesOnStop
- don't suppress messages if the new speed is 'stop'
-
setSpeedSettingAgain
public void setSpeedSettingAgain(float speed)
setSpeedSettingAgain - set the speed and don't ever suppress the sending of messages to the system- Specified by:
setSpeedSettingAgain
in interfaceThrottle
- Parameters:
speed
- the new speed
-
getIsForward
public boolean getIsForward()
direction This is an bound parameter.- Specified by:
getIsForward
in interfaceThrottle
- Returns:
- true if locomotive is running forward
-
setIsForward
public void setIsForward(boolean forward)
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:
setIsForward
in interfaceThrottle
- Parameters:
forward
- true if forward; false otherwise
-
getFunctions
@Nonnull public boolean[] getFunctions()
Get copy of function array. Typically returns array length of 29, i.e. 0-28.- Specified by:
getFunctions
in interfaceThrottle
- Returns:
- function array, length dependant by hardware type.
-
getFunctionsMomentary
@Nonnull public boolean[] getFunctionsMomentary()
Get copy of function momentary status array. Typically returns array length of 29, i.e. 0-28.- Specified by:
getFunctionsMomentary
in interfaceThrottle
- Returns:
- momentary function array, length dependant by hardware type.
-
getFunction
public boolean getFunction(int fN)
Get Loco Function status.- Specified by:
getFunction
in interfaceThrottle
- Parameters:
fN
- Function Number, 0-28- Returns:
- Function State. True on, false off.
-
getFunctionNoWarn
protected boolean getFunctionNoWarn(int fN)
Get Function Number without warning if Throttle does not support. When sending a whole Function Group, a function number may not be present.- Parameters:
fN
- Function Number- Returns:
- Function value, or false if not present.
-
getFunctionMomentary
public boolean getFunctionMomentary(int fN)
Get the Momentary Function Value.- Specified by:
getFunctionMomentary
in interfaceThrottle
- Parameters:
fN
- Momentary function number- Returns:
- true if momentary function is on, else false.
-
getFunctionMomentaryNoWarn
protected boolean getFunctionMomentaryNoWarn(int fN)
Get Momentary Function Number without warning if Throttle does not support. When sending a whole Function Group, a function number may not be present.- Parameters:
fN
- Function Number- Returns:
- Function value, or false if not present.
-
notifyThrottleDisconnect
protected void notifyThrottleDisconnect()
Notify listeners that a Throttle has disconnected and is no longer available for use.For when throttles have been stolen or encounter hardware error, and a normal release / dispose is not possible.
-
notifyThrottleDispatchEnabled
public void notifyThrottleDispatchEnabled(boolean newVal)
Notify listeners that a Throttle has Dispatch enabled or disabled.For systems where dispatch availability is variable.
Does not notify if existing value is unchanged.
- Specified by:
notifyThrottleDispatchEnabled
in interfaceThrottle
- Parameters:
newVal
- true if Dispatch enabled, else false
-
notifyThrottleReleaseEnabled
public void notifyThrottleReleaseEnabled(boolean newVal)
Notify listeners that a Throttle has Release enabled or disabled.For systems where release availability is variable.
Does not notify if existing value is unchanged.
- Specified by:
notifyThrottleReleaseEnabled
in interfaceThrottle
- Parameters:
newVal
- true if Release enabled, else false
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Temporary behaviour only allowing unique PCLs. To support Throttle PCL's ( eg. WiThrottle Server ) that rely on the previous behaviour of only allowing 1 unique PCL instance. To be removed when WiThrottle Server has been updated. Add aPropertyChangeListener
to the listener list.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Overrides:
addPropertyChangeListener
in classPropertyChangeSupport
- Parameters:
l
- The PropertyChangeListener to be added
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove the specified listener from this object.- Specified by:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Overrides:
removePropertyChangeListener
in classPropertyChangeSupport
- Parameters:
l
- ThePropertyChangeListener
to remove.
-
dispose
public void dispose(ThrottleListener l)
Call from a ThrottleListener to dispose of the throttle instance
-
dispatch
public void dispatch(ThrottleListener l)
Finished with this Throttle, tell the layout that the locomotive is available for reuse/reallocation by somebody else. If possible, tell the layout that this locomotive has been dispatched to another user. Not all layouts will implement this, in which case it is synonymous withThrottle.release(jmri.ThrottleListener)
.After this, further usage of this Throttle object will result in a JmriException.
Normally, dispatch ends with a call to dispose.
- Specified by:
dispatch
in interfaceThrottle
- Parameters:
l
-ThrottleListener
to dispatch
-
release
public void release(ThrottleListener l)
Finished with this Throttle, tell the layout that the locomotive is available for reuse/reallocation by somebody else.After this, further usage of this Throttle object will result in a JmriException. Do not call dispose after release.
Normally, release ends with a call to dispose.
- Specified by:
release
in interfaceThrottle
- Parameters:
l
-ThrottleListener
to release. May be null if noThrottleListener
is currently held.
-
throttleDispose
protected abstract void throttleDispose()
Dispose when finished with this Throttle. May be used in tests for cleanup. Throttles normally callfinishRecord()
here.
-
getSpeedIncrement
public float getSpeedIncrement()
Handle quantized speed. Note this can change! Value returned is always positive.- Specified by:
getSpeedIncrement
in interfaceDccThrottle
- Returns:
- 1 divided by the number of speed steps this DCC throttle supports
-
sendFunctionGroup
protected void sendFunctionGroup(int functionNum, boolean momentary)
Send whole (DCC) Function Group for a particular function number.- Parameters:
functionNum
- Function Numbermomentary
- False to send normal function status, true to send momentary.
-
setFunction
public void setFunction(int functionNum, boolean newState)
Set Loco Function and send to Layout.- Specified by:
setFunction
in interfaceThrottle
- Parameters:
functionNum
- Function Number, 0-28newState
- New Function State. True on, false off.
-
updateFunction
public void updateFunction(int fn, boolean state)
Update the state of a single function. Updates function value and ChangeListener. Does not send outward message TO hardware.- Parameters:
fn
- Function Number 0-28state
- On - True, Off - False
-
updateFunctionMomentary
public void updateFunctionMomentary(int fn, boolean state)
Update the Momentary state of a single function. Updates function value and ChangeListener. Does not send outward message TO hardware.- Parameters:
fn
- Momentary Function Number 0-28state
- On - True, Off - False
-
sendFunctionGroup1
protected void sendFunctionGroup1()
Send the message to set the state of functions F0, F1, F2, F3, F4.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup2
protected void sendFunctionGroup2()
Send the message to set the state of functions F5, F6, F7, F8.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup3
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.
-
sendFunctionGroup4
protected void sendFunctionGroup4()
Send the message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup5
protected void sendFunctionGroup5()
Send the message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup6
protected void sendFunctionGroup6()
Send the message to set the state of functions F29 - F36.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup7
protected void sendFunctionGroup7()
Send the message to set the state of functions F37 - F44.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup8
protected void sendFunctionGroup8()
Send the message to set the state of functions F45 - F52.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup9
protected void sendFunctionGroup9()
Send the message to set the state of functions F53 - F60.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
sendFunctionGroup10
protected void sendFunctionGroup10()
Send the message to set the state of functions F61 - F68.This is used in the setFn implementations provided in this class, but a real implementation needs to be provided.
-
setFunctionMomentary
public void setFunctionMomentary(int momFuncNum, boolean state)
Sets Momentary Function and sends to layout. Set Momentary Loco Function and send to Layout.- Specified by:
setFunctionMomentary
in interfaceThrottle
- Parameters:
momFuncNum
- Momentary Function Number, 0-28state
- New Function State. True on, false off.
-
sendMomentaryFunctionGroup1
protected void sendMomentaryFunctionGroup1()
Send the message to set the momentary state of functions F0, F1, F2, F3, F4.This is used in the setFnMomentary implementations provided in this class, a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup2
protected void sendMomentaryFunctionGroup2()
Send the message to set the momentary state of functions F5, F6, F7, F8.This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup3
protected void sendMomentaryFunctionGroup3()
Send the message to set the Momentary state of functions F9, F10, F11, F12This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup4
protected void sendMomentaryFunctionGroup4()
Send the message to set the Momentary state of functions F13, F14, F15, F16, F17, F18, F19, F20This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup5
protected void sendMomentaryFunctionGroup5()
Send the message to set the Momentary state of functions F21, F22, F23, F24, F25, F26, F27, F28This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup6
protected void sendMomentaryFunctionGroup6()
Send the message to set the Momentary state of functions F29 - F36This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup7
protected void sendMomentaryFunctionGroup7()
Send the message to set the Momentary state of functions F37 - F44This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup8
protected void sendMomentaryFunctionGroup8()
Send the message to set the Momentary state of functions F45 - 52This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup9
protected void sendMomentaryFunctionGroup9()
Send the message to set the Momentary state of functions F53 - F60This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
sendMomentaryFunctionGroup10
protected void sendMomentaryFunctionGroup10()
Send the message to set the Momentary state of functions F61 - F68This is used in the setFnMomentary implementations provided in this class, but a real implementation needs to be provided if the hardware supports setting functions momentary.
-
setSpeedStepMode
public void setSpeedStepMode(SpeedStepMode mode)
Set the speed step value. Default should be 128 speed step mode in most cases.Specific implementations should override this function.
- Specified by:
setSpeedStepMode
in interfaceDccThrottle
- Parameters:
mode
- the current speed step mode
-
getSpeedStepMode
public SpeedStepMode getSpeedStepMode()
Description copied from interface:DccThrottle
Get the current speed step value.- Specified by:
getSpeedStepMode
in interfaceDccThrottle
- Returns:
- the current speed step mode
-
record
protected void record(float speed)
Processes updated speed from subclasses. Tracks total operating time for the roster entry by starting the clock if speed is non-zero or stopping the clock otherwise.- Parameters:
speed
- the current speed
-
startClock
protected void startClock()
-
stopClock
void stopClock()
-
finishRecord
protected void finishRecord()
-
setRosterEntry
public void setRosterEntry(BasicRosterEntry re)
- Specified by:
setRosterEntry
in interfaceThrottle
-
getRosterEntry
public BasicRosterEntry getRosterEntry()
- Specified by:
getRosterEntry
in interfaceThrottle
-
intSpeed
protected int intSpeed(float speed)
Get an integer speed for the given raw speed value. This is a convenience method that callsintSpeed(float, int)
with a maxStep of 127.- Parameters:
speed
- the speed as a percentage of maximum possible speed; negative values indicate a need for an emergency stop- Returns:
- an integer in the range 0-127
-
intSpeed
protected static int intSpeed(float speed, int steps)
Get an integer speed for the given raw speed value.- Parameters:
speed
- the speed as a percentage of maximum possible speed; negative values indicate a need for an emergency stopsteps
- number of possible speeds; values less than 2 will cause errors- Returns:
- an integer in the range 0-steps
-
-