Class XNetTurnout
- All Implemented Interfaces:
PropertyChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,DigitalIO,AbstractMRListener,XNetListener,NamedBean,Turnout,VariableControlSpanBean
- Direct Known Subclasses:
EliteXNetTurnout,Z21XNetTurnout,ZTC611XNetTurnout
Turnout operation on XpressNet based systems goes through the following sequence:
- set the commanded state, and, Send request to command station to start sending DCC operations packet to track
- Wait for response message from command station. (valid response list follows)
- Send request to command station to stop sending DCC operations packet to track
- Wait for response from command station
- If Success Message, set Known State to Commanded State
- If error message, repeat previous step
NOTE: Some XpressNet Command stations take no action when the message generated during the third step is received.
Valid response messages are command station dependent, but there are 4 possibilities:
- a "Command Successfully Received..." (aka "OK") message
- a "Feedback Response Message" indicating the message is for a turnout with feedback
- a "Feedback Response Message" indicating the message is for a turnout without feedback
- The XpressNet protocol allows for no response.
Response NOTE 1: The "Command Successfully Received..." message is generated by the lenz LIxxx interfaces when it successfully transfers the command to the command station. When this happens, the command station generates no useable response message.
Response NOTE 2: Currently the only command stations known to generate Feedback response messages are the Lenz LZ100 and LZV100.
Response NOTE 3: Software version 3.2 and above LZ100 and LZV100 may send either a Feedback response or no response at all. All other known command stations generate no response.
Response NOTE 4: The Feedback response messages may be generated asynchronously
Response NOTE 5: Feedback response messages may contain feedback for more
than one device. The devices included in the response may or may not be
stationary decoders (they can also be feedback encoders see
XNetSensor).
Response NOTE 6: The last situation situation is not currently handled. The supported interfaces garantee at least an "OK" message will be sent to the computer
What is done with each of the response messages depends on which feedback mode is in use. "DIRECT,"MONITORING", and "EXACT" feedback mode are supported directly by this class.
"DIRECT" mode instantly triggers step 3 when any valid response message for this turnout is received from the command station or computer interface.
"SIGNAL" mode is identical to "DIRECT" mode, except it skips step 2. i.e. it triggers step 3 without receiving any reply from the command station.
"MONITORING" mode is an extention to direct mode. In monitoring mode, a feedback response message (for a turnout with or without feedback) is interpreted to set the known state of the turnout based on information provided by the command station.
"MONITORING" mode will interpret the feedback response messages when they are generated by external sources (fascia controls or other XpressNet devices) and that information is received by the computer.
"EXACT" mode is an extention of "MONITORING" mode. In addition to interpretting all feedback messages from the command station, "EXACT" mode will monitor the "motion complete" bit of the feedback response.
For turnouts without feedback, the motion complete bit is always set, so "EXACT" mode handles these messages as though the specified feedback mode is "MONITORING" mode.
For turnouts with feedback, "EXACT" mode polls the command station until the motion complete bit is set before triggering step 3 of the turnout operation sequence.
"EXACT" mode will interpret the feedback response messages when they are generated by external sources (fascia controls or other XpressNet devices) and that information is received by the computer.
NOTE: For LZ100 and LZV100 command stations prior to version 3.2, it may be necessary to poll for the feedback response data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classInternal class to hold a request message, along with the associated throttle state.Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected final String(package private) final jmri.jmrix.lenz.XNetTurnout.XNetTurnoutStateListenerprotected static final intprotected static final intprotected intprotected XNetTurnout.RequestMessageprotected int(package private) static String[](package private) static int[]protected static final intprotected static final intprotected final Queue<XNetTurnout.RequestMessage>protected static final intprotected final XNetTrafficControllerFields inherited from class jmri.implementation.AbstractTurnout
_activeFeedbackType, _cabLockout, _decoderName, _enableCabLockout, _enablePushButtonLockout, _inverted, _pushButtonLockout, _reportLocked, _validDecoderNames, _validFeedbackModes, _validFeedbackNames, _validFeedbackTypes, binaryOutput, DELAYED_FEEDBACK_INTERVAL, inhibitOperation, myOperator, myTurnoutOperation, r, thrFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWNFields inherited from interface jmri.Turnout
CABLOCKOUT, CLOSED, DELAYED, DIRECT, EXACT, INDIRECT, LNALTERNATE, LOCKED, MONITORING, ONESENSOR, PROPERTY_COMMANDED_STATE, PROPERTY_DECODER_NAME, PROPERTY_FEEDBACK_MODE, PROPERTY_INVERTED, PROPERTY_LEADING_TURNOUT, PROPERTY_LOCKED, PROPERTY_REPORT_LOCKED, PROPERTY_TURNOUT_DIVERGING_SPEED, PROPERTY_TURNOUT_FEEDBACK_FIRST_SENSOR, PROPERTY_TURNOUT_FEEDBACK_SECOND_SENSOR, PROPERTY_TURNOUT_OPERATION_STATE, PROPERTY_TURNOUT_STRAIGHT_SPEED, PUSHBUTTONLOCKOUT, SIGNAL, THROWN, TWOSENSOR, UNLOCKED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if the turnouts can be inverted.voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.protected voidforwardCommandChangeToLayout(int s) Handle a request to change state, typically by sending a message to the layout in some child class.(package private) static String[](package private) static int[]intprotected XNetMessage(package private) voidPackage protected class which allows the Manger to send a feedback message at initialization without changing the state of the turnout with respect to whether or not a feedback request was sent.voidListen for the messages to the LI100/LI101.voidHandle an incoming message from the XpressNet.voidnotifyTimeout(XNetMessage msg) Handle a timeout notification.protected voidqueueMessage(XNetMessage m, int s, XNetListener l) Queue a message.voidRequest an update on status by sending an XpressNet message.protected voidSend an "Off" message to the decoder for this output.protected voidSend message from queue.voidsetCommandedState(int s) Set the Commanded State.voidsetInverted(boolean inverted) On change, fires Property Change "inverted".protected voidturnoutPushbuttonLockout(boolean _pushButtonLockout) Methods inherited from class jmri.implementation.AbstractTurnout
canLock, describeState, enableLockOperation, forwardCommandChangeToLayout, getBeanType, getCommandedState, getControlType, getCurrentOperator, getDecoderName, getDivergingLimit, getDivergingSpeed, getFeedbackMode, getFeedbackModeForOperation, getFeedbackModeName, getFirstNamedSensor, getFirstSensor, getInhibitOperation, getInverted, getKnownState, getLeadingTurnout, getLocked, getNumberControlBits, getPossibleLockModes, getReportLocked, getSecondNamedSensor, getSecondSensor, getState, getStraightLimit, getStraightSpeed, getTurnoutOperation, getTurnoutOperator, getUsageReport, getValidDecoderNames, getValidFeedbackModes, getValidFeedbackNames, getValidFeedbackTypes, isCanFollow, isConsistentState, isFollowingCommandedState, leadingTurnoutPropertyChange, newCommandedState, newKnownState, operationPropertyChange, propertyChange, provideFirstFeedbackNamedSensor, provideFirstFeedbackSensor, provideSecondFeedbackNamedSensor, provideSecondFeedbackSensor, sensorPropertyChange, setBinaryOutput, setCommandedStateAtInterval, setControlType, setDecoderName, setDivergingSpeed, setFeedbackMode, setFeedbackMode, setFollowingCommandedState, setInhibitOperation, setInitialKnownStateFromFeedback, setLeadingTurnout, setLeadingTurnout, setLocked, setNumberControlBits, setReportLocked, setState, setStraightSpeed, setTurnoutOperation, stateChangeCheck, statesOk, turnoutPushbuttonLockout, vetoableChangeMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRefMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.Turnout
provideFeedbackSensor
-
Field Details
-
OFFSENT
- See Also:
-
COMMANDSENT
- See Also:
-
STATUSREQUESTSENT
- See Also:
-
QUEUEDMESSAGE
- See Also:
-
IDLE
- See Also:
-
internalState
-
modeNames
-
modeValues
-
_mThrown
-
_mClosed
-
mNumber
-
_stateListener
-
requestList
-
lastMsg
-
_prefix
-
tc
-
-
Constructor Details
-
XNetTurnout
-
-
Method Details
-
getModeValues
-
getModeNames
-
getNumber
-
setCommandedState
Set the Commanded State. This method overidesAbstractTurnout.setCommandedState(int).- Specified by:
setCommandedStatein interfaceDigitalIO- Overrides:
setCommandedStatein classAbstractTurnout- Parameters:
s- commanded state to set
-
forwardCommandChangeToLayout
Handle a request to change state, typically by sending a message to the layout in some child class. Public version (used by TurnoutOperator) sends the current commanded state without changing it. Implementing classes will typically check the value of s and send a system specific sendMessage command. Sends an XpressNet command.- Specified by:
forwardCommandChangeToLayoutin classAbstractTurnout- Parameters:
s- new state value
-
turnoutPushbuttonLockout
- Specified by:
turnoutPushbuttonLockoutin classAbstractTurnout
-
requestUpdateFromLayout
Request an update on status by sending an XpressNet message.- Specified by:
requestUpdateFromLayoutin interfaceDigitalIO- Overrides:
requestUpdateFromLayoutin classAbstractTurnout
-
setInverted
On change, fires Property Change "inverted". Get turnout inverted. When a turnout is inverted theTurnout.CLOSEDandTurnout.THROWNstates are reversed on the layout.- Specified by:
setInvertedin interfaceTurnout- Overrides:
setInvertedin classAbstractTurnout- Parameters:
inverted- true if inverted; false otherwise
-
canInvert
Description copied from class:AbstractTurnoutDetermine if the turnouts can be inverted. If true, inverted turnouts are supported.- Specified by:
canInvertin interfaceTurnout- Overrides:
canInvertin classAbstractTurnout- Returns:
- invert supported
-
initmessage
Package protected class which allows the Manger to send a feedback message at initialization without changing the state of the turnout with respect to whether or not a feedback request was sent. This is used only when the turnout is created by on layout feedback.- Parameters:
l- Message to initialize
-
message
Handle an incoming message from the XpressNet.- 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
Listen for the messages to the LI100/LI101.- 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
Handle a timeout notification.- Specified by:
notifyTimeoutin interfaceXNetListener- Parameters:
msg- message which has timed out.
-
sendOffMessage
Send an "Off" message to the decoder for this output. -
getOffMessage
-
dispose
Description copied from class:AbstractTurnoutDeactivate this object, so that it releases as many resources as possible and no longer effects others.For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.
It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.
Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.
- Specified by:
disposein interfaceNamedBean- Overrides:
disposein classAbstractTurnout
-
sendQueuedMessage
Send message from queue. -
queueMessage
Queue a message.- Parameters:
m- Message to sends- sequencel- Listener to get notification of completion
-