Class XNetTurnout
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractTurnout
-
- jmri.jmrix.lenz.XNetTurnout
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,DigitalIO
,AbstractMRListener
,XNetListener
,NamedBean
,Turnout
,VariableControlSpanBean
- Direct Known Subclasses:
EliteXNetTurnout
,Z21XNetTurnout
,ZTC611XNetTurnout
public class XNetTurnout extends AbstractTurnout implements XNetListener
Extend jmri.AbstractTurnout for XNet layoutsTurnout 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 Classes Modifier and Type Class Description protected static class
XNetTurnout.RequestMessage
Internal 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
Fields Modifier and Type Field Description protected int
_mClosed
protected int
_mThrown
protected java.lang.String
_prefix
(package private) jmri.jmrix.lenz.XNetTurnout.XNetTurnoutStateListener
_stateListener
protected static int
COMMANDSENT
protected static int
IDLE
protected int
internalState
protected XNetTurnout.RequestMessage
lastMsg
protected int
mNumber
(package private) static java.lang.String[]
modeNames
(package private) static int[]
modeValues
protected static int
OFFSENT
protected static int
QUEUEDMESSAGE
protected java.util.Queue<XNetTurnout.RequestMessage>
requestList
protected static int
STATUSREQUESTSENT
protected XNetTrafficController
tc
-
Fields 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, thr
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
Fields inherited from interface jmri.Turnout
CABLOCKOUT, CLOSED, DELAYED, DIRECT, EXACT, INDIRECT, LNALTERNATE, LOCKED, MONITORING, ONESENSOR, PUSHBUTTONLOCKOUT, SIGNAL, THROWN, TWOSENSOR, UNLOCKED
-
-
Constructor Summary
Constructors Constructor Description XNetTurnout(java.lang.String prefix, int pNumber, XNetTrafficController controller)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canInvert()
Determine if the turnouts can be inverted.void
dispose()
Deactivate this object, so that it releases as many resources as possible and no longer effects others.protected void
forwardCommandChangeToLayout(int s)
Handle a request to change state, typically by sending a message to the layout in some child class.(package private) static java.lang.String[]
getModeNames()
(package private) static int[]
getModeValues()
int
getNumber()
protected XNetMessage
getOffMessage()
(package private) void
initmessage(XNetReply l)
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.void
message(XNetMessage l)
Listen for the messages to the LI100/LI101.void
message(XNetReply l)
Handle an incoming message from the XpressNet.void
notifyTimeout(XNetMessage msg)
Handle a timeout notification.protected void
queueMessage(XNetMessage m, int s, XNetListener l)
Queue a message.void
requestUpdateFromLayout()
Request an update on status by sending an XpressNet message.protected void
sendOffMessage()
Send an "Off" message to the decoder for this output.protected void
sendQueuedMessage()
Send message from queue.void
setCommandedState(int s)
Set the Commanded State.void
setInverted(boolean inverted)
On change, fires Property Change "inverted".protected void
turnoutPushbuttonLockout(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, vetoableChange
-
Methods 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, updateListenerRef
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods 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, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.Turnout
provideFeedbackSensor
-
-
-
-
Field Detail
-
OFFSENT
protected static final int OFFSENT
- See Also:
- Constant Field Values
-
COMMANDSENT
protected static final int COMMANDSENT
- See Also:
- Constant Field Values
-
STATUSREQUESTSENT
protected static final int STATUSREQUESTSENT
- See Also:
- Constant Field Values
-
QUEUEDMESSAGE
protected static final int QUEUEDMESSAGE
- See Also:
- Constant Field Values
-
IDLE
protected static final int IDLE
- See Also:
- Constant Field Values
-
internalState
protected int internalState
-
modeNames
static java.lang.String[] modeNames
-
modeValues
static int[] modeValues
-
_mThrown
protected int _mThrown
-
_mClosed
protected int _mClosed
-
mNumber
protected int mNumber
-
_stateListener
final jmri.jmrix.lenz.XNetTurnout.XNetTurnoutStateListener _stateListener
-
requestList
protected final java.util.Queue<XNetTurnout.RequestMessage> requestList
-
lastMsg
protected XNetTurnout.RequestMessage lastMsg
-
_prefix
protected final java.lang.String _prefix
-
tc
protected final XNetTrafficController tc
-
-
Constructor Detail
-
XNetTurnout
public XNetTurnout(java.lang.String prefix, int pNumber, XNetTrafficController controller)
-
-
Method Detail
-
getModeValues
static int[] getModeValues()
-
getModeNames
static java.lang.String[] getModeNames()
-
getNumber
public int getNumber()
-
setCommandedState
public void setCommandedState(int s)
Set the Commanded State. This method overidesAbstractTurnout.setCommandedState(int)
.- Specified by:
setCommandedState
in interfaceDigitalIO
- Overrides:
setCommandedState
in classAbstractTurnout
- Parameters:
s
- commanded state to set
-
forwardCommandChangeToLayout
protected void forwardCommandChangeToLayout(int s)
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:
forwardCommandChangeToLayout
in classAbstractTurnout
- Parameters:
s
- new state value
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout(boolean _pushButtonLockout)
- Specified by:
turnoutPushbuttonLockout
in classAbstractTurnout
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Request an update on status by sending an XpressNet message.- Specified by:
requestUpdateFromLayout
in interfaceDigitalIO
- Overrides:
requestUpdateFromLayout
in classAbstractTurnout
-
setInverted
public void setInverted(boolean inverted)
On change, fires Property Change "inverted". Get turnout inverted. When a turnout is inverted theTurnout.CLOSED
andTurnout.THROWN
states are reversed on the layout.- Specified by:
setInverted
in interfaceTurnout
- Overrides:
setInverted
in classAbstractTurnout
- Parameters:
inverted
- true if inverted; false otherwise
-
canInvert
public boolean canInvert()
Description copied from class:AbstractTurnout
Determine if the turnouts can be inverted. If true, inverted turnouts are supported.- Specified by:
canInvert
in interfaceTurnout
- Overrides:
canInvert
in classAbstractTurnout
- Returns:
- invert supported
-
initmessage
void initmessage(XNetReply l)
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
public void message(XNetReply l)
Handle an incoming message from the XpressNet.- Specified by:
message
in 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
public void message(XNetMessage l)
Listen for the messages to the LI100/LI101.- Specified by:
message
in 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
public void notifyTimeout(XNetMessage msg)
Handle a timeout notification.- Specified by:
notifyTimeout
in interfaceXNetListener
- Parameters:
msg
- message which has timed out.
-
sendOffMessage
protected void sendOffMessage()
Send an "Off" message to the decoder for this output.
-
getOffMessage
protected XNetMessage getOffMessage()
-
dispose
public void dispose()
Description copied from class:AbstractTurnout
Deactivate 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:
dispose
in interfaceNamedBean
- Overrides:
dispose
in classAbstractTurnout
-
sendQueuedMessage
protected void sendQueuedMessage()
Send message from queue.
-
queueMessage
protected void queueMessage(XNetMessage m, int s, XNetListener l)
Queue a message.- Parameters:
m
- Message to sends
- sequencel
- Listener to get notification of completion
-
-