Class LnTurnout
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractTurnout
-
- jmri.jmrix.loconet.LnTurnout
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,DigitalIO
,NamedBean
,Turnout
,VariableControlSpanBean
public class LnTurnout extends AbstractTurnout
Extend jmri.AbstractTurnout for LocoNet layoutsThis implementation implements the "SENT" feedback, where LocoNet messages originating on the layout can change both KnownState and CommandedState. We change both because we consider a LocoNet message to reflect how the turnout should be, even if it's a readback status message. E.g. if you use a DS54 local input to change the state, resulting in a status message, we still consider that to be a commanded state change.
Adds several additional feedback modes:
- MONITORING - listen to the LocoNet, so that commands from other LocoNet sources (e.g. throttles) are properly reflected in the turnout state. This is the default for LnTurnout objects as created.
- INDIRECT - listen to the LocoNet for messages back from a DS54 that has a microswitch attached to its Switch input.
- EXACT - listen to the LocoNet for messages back from a DS54 that has two microswitches, one connected to the Switch input and one to the Aux input.
- ALTERNATE - listen to the LocoNet for messages back from a MGP decoders that has reports servo moving.
-
-
Nested Class Summary
-
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 (package private) int
_number
protected java.lang.String
_prefix
(package private) boolean
_useOffSwReqAsConfirmation
(package private) static int
CONSISTENCYTIMER
(package private) LocoNetInterface
controller
(package private) boolean
feedbackDeliberatelySet
True when setFeedbackMode has specified the mode; false when the mode is just left over from initialization.(package private) static int
METERINTERVAL
(package private) static java.lang.String[]
modeNames
(package private) static int[]
modeValues
(package private) int
noConsistencyTimersRunning
(package private) boolean
pending
-
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 LnTurnout(java.lang.String prefix, int number, LocoNetInterface controller)
-
Method Summary
All 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 newstate)
Handle a request to change state, typically by sending a message to the layout in some child class.int
getNumber()
boolean
isByPassBushbyBit()
boolean
isSendOnAndOff()
void
messageFromManager(LocoNetMessage l)
(package private) void
sendOpcSwReqMessage(int state, boolean on)
Send a single OPC_SW_REQ message for this turnout, with the CLOSED/THROWN ON/OFF state.(package private) void
sendSetOffMessage(int state)
Set the turnout DCC C bit to OFF.void
setBinaryOutput(boolean state)
Use a binary output for sending commands.void
setFeedbackMode(int mode)
On change, fires Property Change "feedbackchange".void
setFeedbackMode(java.lang.String mode)
Set the feedback mode from a human readable name.void
setUseOffSwReqAsConfirmation(boolean state)
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, requestUpdateFromLayout, sensorPropertyChange, setCommandedState, setCommandedStateAtInterval, setControlType, setDecoderName, setDivergingSpeed, setFollowingCommandedState, setInhibitOperation, setInitialKnownStateFromFeedback, setInverted, 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
-
controller
LocoNetInterface controller
-
_prefix
protected java.lang.String _prefix
-
feedbackDeliberatelySet
boolean feedbackDeliberatelySet
True when setFeedbackMode has specified the mode; false when the mode is just left over from initialization. This is intended to indicate (when true) that a configuration file has set the value; message-created turnouts have it false.
-
modeNames
static java.lang.String[] modeNames
-
modeValues
static int[] modeValues
-
_useOffSwReqAsConfirmation
boolean _useOffSwReqAsConfirmation
-
pending
boolean pending
-
_number
int _number
-
METERINTERVAL
static final int METERINTERVAL
- See Also:
- Constant Field Values
-
CONSISTENCYTIMER
static final int CONSISTENCYTIMER
- See Also:
- Constant Field Values
-
noConsistencyTimersRunning
int noConsistencyTimersRunning
-
-
Constructor Detail
-
LnTurnout
public LnTurnout(java.lang.String prefix, int number, LocoNetInterface controller) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
-
Method Detail
-
setBinaryOutput
public void setBinaryOutput(boolean state)
Description copied from class:AbstractTurnout
Use a binary output for sending commands. This appears to expose a LocoNet-specific feature.- Specified by:
setBinaryOutput
in interfaceTurnout
- Overrides:
setBinaryOutput
in classAbstractTurnout
- Parameters:
state
- true if the outputs are binary; false otherwise
-
setFeedbackMode
public void setFeedbackMode(@Nonnull java.lang.String mode) throws java.lang.IllegalArgumentException
Description copied from class:AbstractTurnout
Set the feedback mode from a human readable name. This must be one of the names defined in a previousTurnout.getValidFeedbackNames()
call.- Specified by:
setFeedbackMode
in interfaceTurnout
- Overrides:
setFeedbackMode
in classAbstractTurnout
- Parameters:
mode
- the feedback type name- Throws:
java.lang.IllegalArgumentException
- if mode is not valid
-
setFeedbackMode
public void setFeedbackMode(int mode) throws java.lang.IllegalArgumentException
Description copied from class:AbstractTurnout
On change, fires Property Change "feedbackchange". Set the feedback mode from a integer. This must be one of the bit values defined in a previousTurnout.getValidFeedbackTypes()
call. Having more than one bit set is an error.- Specified by:
setFeedbackMode
in interfaceTurnout
- Overrides:
setFeedbackMode
in classAbstractTurnout
- Parameters:
mode
- the feedback type to set- Throws:
java.lang.IllegalArgumentException
- if mode is not valid
-
getNumber
public int getNumber()
-
setUseOffSwReqAsConfirmation
public void setUseOffSwReqAsConfirmation(boolean state)
-
isByPassBushbyBit
public boolean isByPassBushbyBit()
-
isSendOnAndOff
public boolean isSendOnAndOff()
-
forwardCommandChangeToLayout
protected void forwardCommandChangeToLayout(int newstate)
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.- Specified by:
forwardCommandChangeToLayout
in classAbstractTurnout
- Parameters:
newstate
- new state value
-
sendOpcSwReqMessage
void sendOpcSwReqMessage(int state, boolean on)
Send a single OPC_SW_REQ message for this turnout, with the CLOSED/THROWN ON/OFF state.Inversion is to already have been handled.
- Parameters:
state
- the state to seton
- if true the C bit of the NMRA DCC packet is 1; if false the C bit is 0
-
sendSetOffMessage
void sendSetOffMessage(int state)
Set the turnout DCC C bit to OFF. This is typically used to set a C bit that was set ON to OFF after a timeout.- Parameters:
state
- the turnout state
-
messageFromManager
public void messageFromManager(LocoNetMessage l)
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout(boolean _pushButtonLockout)
- Specified by:
turnoutPushbuttonLockout
in classAbstractTurnout
-
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
-
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
-
-