Package jmri.jmrix.mrc
Class MrcThrottle
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrix.AbstractThrottle
jmri.jmrix.mrc.MrcThrottle
- All Implemented Interfaces:
PropertyChangeFirer
,PropertyChangeProvider
,DccThrottle
,MrcTrafficListener
,Throttle
public class MrcThrottle extends AbstractThrottle implements MrcTrafficListener
An implementation of DccThrottle with code specific to an MRC connection.
Addresses of 99 and below are considered short addresses, and over 100 are considered long addresses. This is not the MRC system standard, but is used as an expedient here.
Based on Glen Oberhauser's original LnThrottleManager implementation
-
Field Summary
Fields Modifier and Type Field Description (package private) DccLocoAddress
address
(package private) int
addressHi
(package private) int
addressLo
Fields inherited from class jmri.jmrix.AbstractThrottle
active, adapterMemo, isForward, speedSetting, speedStepMode, start
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, FUNCTION_GROUPS, ISFORWARD, SPEEDINCREMENT, SPEEDSETTING, SPEEDSTEPMODE, SPEEDSTEPS
-
Constructor Summary
Constructors Constructor Description MrcThrottle(MrcSystemConnectionMemo memo, DccLocoAddress address)
Throttle Constructor. -
Method Summary
Modifier and Type Method Description LocoAddress
getLocoAddress()
Locomotive address.void
notifyFailedXmit(Date timestamp, MrcMessage m)
void
notifyRcv(Date timestamp, MrcMessage m)
void
notifyXmit(Date timestamp, MrcMessage m)
protected void
sendFunctionGroup1()
Send the message to set the state of functions F0, F1, F2, F3, F4.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, F12, F11, F12.protected void
sendFunctionGroup4()
Send the message to set the state of functions F13 to F20.protected void
sendFunctionGroup5()
Send the message to set the state of functions F21 to F28.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
setSpeedSetting(float speed)
Set the speed and direction.void
throttleDispose()
Dispose when finished with this Throttle.String
toString()
Methods inherited from class jmri.jmrix.AbstractThrottle
addPropertyChangeListener, dispatch, dispose, finishRecord, getFunction, getFunctionMomentary, getFunctions, getFunctionsMomentary, getIsForward, getListeners, getRosterEntry, getSpeedIncrement, getSpeedSetting, getSpeedStepMode, intSpeed, intSpeed, notifyPropertyChangeListener, notifyThrottleDisconnect, notifyThrottleDispatchEnabled, notifyThrottleReleaseEnabled, record, release, removePropertyChangeListener, sendFunctionGroup, sendMomentaryFunctionGroup1, sendMomentaryFunctionGroup2, sendMomentaryFunctionGroup3, sendMomentaryFunctionGroup4, sendMomentaryFunctionGroup5, setFunction, setFunctionMomentary, setRosterEntry, setSpeedSetting, setSpeedSettingAgain, setSpeedStepMode, startClock, updateFunction, updateFunctionMomentary
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, 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, 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
-
Constructor Details
-
MrcThrottle
Throttle Constructor.- Parameters:
memo
- system connection memoaddress
- DCC loco address for throttle
-
-
Method Details
-
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 property.
- Specified by:
getLocoAddress
in interfaceThrottle
- Returns:
- The locomotive address
-
sendFunctionGroup1
Description copied from class:AbstractThrottle
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.
- Overrides:
sendFunctionGroup1
in classAbstractThrottle
-
sendFunctionGroup2
Send the message to set the state of functions F5, F6, F7, F8.- Overrides:
sendFunctionGroup2
in classAbstractThrottle
-
sendFunctionGroup3
Send the message to set the state of functions F9, F12, F11, F12.- Overrides:
sendFunctionGroup3
in classAbstractThrottle
-
sendFunctionGroup4
Send the message to set the state of functions F13 to F20. MRC Group 4 and 5- Overrides:
sendFunctionGroup4
in classAbstractThrottle
-
sendFunctionGroup5
Send the message to set the state of functions F21 to F28. MRC Group 6- Overrides:
sendFunctionGroup5
in classAbstractThrottle
-
setSpeedSetting
Set the speed and direction.- Specified by:
setSpeedSetting
in interfaceThrottle
- Overrides:
setSpeedSetting
in classAbstractThrottle
- Parameters:
speed
- Number from 0 to 1, or less than zero for emergency stop
-
setIsForward
Description copied from class:AbstractThrottle
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
- Overrides:
setIsForward
in classAbstractThrottle
- Parameters:
forward
- true if forward; false otherwise
-
throttleDispose
Description copied from class:AbstractThrottle
Dispose when finished with this Throttle. May be used in tests for cleanup. Throttles normally callAbstractThrottle.finishRecord()
here.- Specified by:
throttleDispose
in classAbstractThrottle
-
toString
-
notifyRcv
- Specified by:
notifyRcv
in interfaceMrcTrafficListener
-
notifyXmit
- Specified by:
notifyXmit
in interfaceMrcTrafficListener
-
notifyFailedXmit
- Specified by:
notifyFailedXmit
in interfaceMrcTrafficListener
-