Package jmri.jmrix.lenz
Class XNetThrottle
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrix.AbstractThrottle
jmri.jmrix.lenz.XNetThrottle
- All Implemented Interfaces:
EventListener,PropertyChangeFirer,PropertyChangeProvider,DccThrottle,AbstractMRListener,XNetListener,Throttle
- Direct Known Subclasses:
EliteXNetThrottle,RocoXNetThrottle
An implementation of DccThrottle with code specific to an XpressNet
connection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classInternal class to hold a request message, along with the associated throttle state. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanprotected LinkedBlockingQueue<XNetThrottle.RequestMessage>protected intprotected static final intprotected TimerTaskprotected XNetTrafficControllerprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intFields 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
ConstructorsConstructorDescriptionXNetThrottle(XNetSystemConnectionMemo memo, XNetTrafficController controller) ConstructorXNetThrottle(XNetSystemConnectionMemo memo, LocoAddress address, XNetTrafficController controller) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckForFunctionMomentaryValueChange(int funcNum, int bytevalue, int bitmask, boolean currentValue) protected booleanprotected booleanintprotected intprotected intLocomotive address.voidMember function that will be invoked by an XNetInterface implementation to forward an XNet message sent to the layout.voidMember function that will be invoked by an XNetInterface implementation to forward an XNet message from the layout.protected voidnotifyNewDirection(boolean forward) protected voidvoidnotifyTimeout(XNetMessage msg) Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.protected voidparseFunctionHighInformation(int b3, int b4) protected voidparseFunctionHighMomentaryInformation(int b3, int b4) protected voidparseFunctionInformation(int b3, int b4) protected voidparseFunctionMomentaryInformation(int b3, int b4) protected voidparseSpeedAndAvailability(int b1) Get SpeedStep and availability information.protected voidparseSpeedAndDirection(int b2) Get Speed and Direction information.protected voidqueueMessage(XNetMessage m, int s) Queue a message.protected voidSince XpressNet has a seperate Opcode for emergency stop, we're setting this up as a seperate protected function.protected voidSend the XpressNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4.protected voidSend the XpressNet message to set the state of functions F61-68protected voidSend the XpressNet message to set the state of functions F5, F6, F7, F8.protected voidSend the XpressNet message to set the state of functions F9, F10, F11, F12.protected voidSend the XpressNet message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20.protected voidSend the XpressNet message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28.protected voidSend the XpressNet message to set the state of functions F29-36protected voidSend the XpressNet message to set the state of functions F37-44protected voidSend the XpressNet message to set the state of functions F45-52protected voidSend the XpressNet message to set the state of functions F53-60protected voidSend a request to get the on/off status of functions 13-28 from the command station.protected voidSend a request to get the status of functions from the command station.protected voidSend a request to get the status of functions from the command station.protected voidSend the XpressNet message to set the Momentary state of locomotive functions F0, F1, F2, F3, F4.protected voidSend the XpressNet message to set the momentary state of functions F61-68protected voidSend the XpressNet message to set the momentary state of functions F5, F6, F7, F8.protected voidSend the XpressNet message to set the momentary state of functions F9, F10, F11, F12.protected voidSend the XpressNet message to set the momentary state of functions F13, F14, F15, F16, F17, F18, F19, F20.protected voidSend the XpressNet message to set the momentary state of functions F21, F22, F23, F24, F25, F26, F27, F28.protected voidSend the XpressNet message to set the momentary state of functions F29-36protected voidSend the XpressNet message to set the momentary state of functions F37-44protected voidSend the XpressNet message to set the momentary state of functions F45-52protected voidSend the XpressNet message to set the momentary state of functions F53-60protected voidSend message from queue.protected voidSend a request to get the speed, direction and function status from the command station.intsetDccAddress(int newaddress) protected voidsetIsAvailable(boolean available) Set the internal isAvailable property.voidsetIsForward(boolean forward) When we set the direction, we're going to set the speed to zero as well.voidsetSpeedSetting(float speed) Notify listeners and send the new speed to the command station.voidSet the speed step value and the related speedIncrement value.voidsetXNetTrafficController(XNetTrafficController controller) protected voidSet up the status timer, and start it.protected voidStop the Status TimervoidDispose when finished with this object.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, 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, toString, 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
-
isAvailable
-
statusTask
-
statTimeoutValue
- See Also:
-
tc
-
THROTTLEIDLE
- See Also:
-
THROTTLESTATSENT
- See Also:
-
THROTTLESPEEDSENT
- See Also:
-
THROTTLEFUNCSENT
- See Also:
-
THROTTLEMOMSTATSENT
- See Also:
-
THROTTLEHIGHSTATSENT
- See Also:
-
THROTTLEHIGHMOMSTATSENT
- See Also:
-
requestState
-
address
-
requestList
-
-
Constructor Details
-
XNetThrottle
Constructor- Parameters:
memo- system connection.controller- system connection traffic controller.
-
XNetThrottle
public XNetThrottle(XNetSystemConnectionMemo memo, LocoAddress address, XNetTrafficController controller) Constructor.- Parameters:
memo- system connection.address- loco address.controller- system connection traffic controller.
-
-
Method Details
-
setXNetTrafficController
-
csVersionSupportFn13to28
-
csVersionSupportFn29to68
-
sendFunctionGroup1
Send the XpressNet message to set the state of locomotive direction and functions F0, F1, F2, F3, F4.- Overrides:
sendFunctionGroup1in classAbstractThrottle
-
sendFunctionGroup2
Send the XpressNet message to set the state of functions F5, F6, F7, F8.- Overrides:
sendFunctionGroup2in classAbstractThrottle
-
sendFunctionGroup3
Send the XpressNet message to set the state of functions F9, F10, F11, F12.- Overrides:
sendFunctionGroup3in classAbstractThrottle
-
sendFunctionGroup4
Send the XpressNet message to set the state of functions F13, F14, F15, F16, F17, F18, F19, F20.- Overrides:
sendFunctionGroup4in classAbstractThrottle
-
sendFunctionGroup5
Send the XpressNet message to set the state of functions F21, F22, F23, F24, F25, F26, F27, F28.- Overrides:
sendFunctionGroup5in classAbstractThrottle
-
sendFunctionGroup6
Send the XpressNet message to set the state of functions F29-36- Overrides:
sendFunctionGroup6in classAbstractThrottle
-
sendFunctionGroup7
Send the XpressNet message to set the state of functions F37-44- Overrides:
sendFunctionGroup7in classAbstractThrottle
-
sendFunctionGroup8
Send the XpressNet message to set the state of functions F45-52- Overrides:
sendFunctionGroup8in classAbstractThrottle
-
sendFunctionGroup9
Send the XpressNet message to set the state of functions F53-60- Overrides:
sendFunctionGroup9in classAbstractThrottle
-
sendFunctionGroup10
Send the XpressNet message to set the state of functions F61-68- Overrides:
sendFunctionGroup10in classAbstractThrottle
-
sendMomentaryFunctionGroup1
Send the XpressNet message to set the Momentary state of locomotive functions F0, F1, F2, F3, F4.- Overrides:
sendMomentaryFunctionGroup1in classAbstractThrottle
-
sendMomentaryFunctionGroup2
Send the XpressNet message to set the momentary state of functions F5, F6, F7, F8.- Overrides:
sendMomentaryFunctionGroup2in classAbstractThrottle
-
sendMomentaryFunctionGroup3
Send the XpressNet message to set the momentary state of functions F9, F10, F11, F12.- Overrides:
sendMomentaryFunctionGroup3in classAbstractThrottle
-
sendMomentaryFunctionGroup4
Send the XpressNet message to set the momentary state of functions F13, F14, F15, F16, F17, F18, F19, F20.- Overrides:
sendMomentaryFunctionGroup4in classAbstractThrottle
-
sendMomentaryFunctionGroup5
Send the XpressNet message to set the momentary state of functions F21, F22, F23, F24, F25, F26, F27, F28.- Overrides:
sendMomentaryFunctionGroup5in classAbstractThrottle
-
sendMomentaryFunctionGroup6
Send the XpressNet message to set the momentary state of functions F29-36- Overrides:
sendMomentaryFunctionGroup6in classAbstractThrottle
-
sendMomentaryFunctionGroup7
Send the XpressNet message to set the momentary state of functions F37-44- Overrides:
sendMomentaryFunctionGroup7in classAbstractThrottle
-
sendMomentaryFunctionGroup8
Send the XpressNet message to set the momentary state of functions F45-52- Overrides:
sendMomentaryFunctionGroup8in classAbstractThrottle
-
sendMomentaryFunctionGroup9
Send the XpressNet message to set the momentary state of functions F53-60- Overrides:
sendMomentaryFunctionGroup9in classAbstractThrottle
-
sendMomentaryFunctionGroup10
Send the XpressNet message to set the momentary state of functions F61-68- Overrides:
sendMomentaryFunctionGroup10in classAbstractThrottle
-
setSpeedSetting
Notify listeners and send the new speed to the command station.- Specified by:
setSpeedSettingin interfaceThrottle- Overrides:
setSpeedSettingin classAbstractThrottle- Parameters:
speed- the speed as a 0.0 -> 1.0. fraction of maximum possible speed or -1 for emergency stop.
-
sendEmergencyStop
Since XpressNet has a seperate Opcode for emergency stop, we're setting this up as a seperate protected function. -
setIsForward
When we set the direction, we're going to set the speed to zero as well.- Specified by:
setIsForwardin interfaceThrottle- Overrides:
setIsForwardin classAbstractThrottle- Parameters:
forward- true if forward; false otherwise
-
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
-
throttleDispose
Dispose when finished with this object. After this, further usage of this Throttle object will result in a JmriException.This is quite problematic, because a using object doesn't know when it's the last user.
- Specified by:
throttleDisposein classAbstractThrottle
-
setDccAddress
-
getDccAddress
-
getDccAddressHigh
-
getDccAddressLow
-
sendStatusInformationRequest
Send a request to get the speed, direction and function status from the command station. -
sendFunctionStatusInformationRequest
Send a request to get the status of functions from the command station. -
sendFunctionHighInformationRequest
Send a request to get the on/off status of functions 13-28 from the command station. -
sendFunctionHighMomentaryStatusRequest
Send a request to get the status of functions from the command station. -
message
Description copied from interface:XNetListenerMember function that will be invoked by an XNetInterface implementation to forward an XNet message from the layout.- Specified by:
messagein interfaceXNetListener- Parameters:
l- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
Member function that will be invoked by an XNetInterface implementation to forward an XNet message sent to the layout. Normally, this function will do nothing.- Specified by:
messagein interfaceXNetListener- Parameters:
l- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeoutin interfaceXNetListener- Parameters:
msg- message which has timed out.
-
parseSpeedAndAvailability
Get SpeedStep and availability information.- Parameters:
b1- 1st byte of message to examine
-
notifyNewSpeedStepMode
-
parseSpeedAndDirection
Get Speed and Direction information.- Parameters:
b2- 2nd byte of message to examine
-
notifyNewDirection
-
parseFunctionInformation
-
parseFunctionHighInformation
-
parseFunctionMomentaryInformation
-
parseFunctionHighMomentaryInformation
-
checkForFunctionMomentaryValueChange
protected void checkForFunctionMomentaryValueChange(int funcNum, int bytevalue, int bitmask, boolean currentValue) -
setIsAvailable
Set the internal isAvailable property.- Parameters:
available- true if available; false otherwise
-
startStatusTimer
Set up the status timer, and start it. -
stopStatusTimer
Stop the Status Timer -
getLocoAddress
Description copied from interface:ThrottleLocomotive 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:
getLocoAddressin interfaceThrottle- Returns:
- The locomotive address
-
sendQueuedMessage
Send message from queue. -
queueMessage
Queue a message.- Parameters:
m- message to sends- state
-