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_numberprotected java.lang.String_prefix(package private) boolean_useOffSwReqAsConfirmation(package private) static intCONSISTENCYTIMER(package private) LocoNetInterfacecontroller(package private) booleanfeedbackDeliberatelySetTrue when setFeedbackMode has specified the mode; false when the mode is just left over from initialization.(package private) static intMETERINTERVAL(package private) static java.lang.String[]modeNames(package private) static int[]modeValues(package private) intnoConsistencyTimersRunning-
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_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN
-
Fields 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 Constructor Description LnTurnout(java.lang.String prefix, int number, LocoNetInterface controller)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanInvert()Determine 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 newstate)Handle a request to change state, typically by sending a message to the layout in some child class.intgetNumber()booleanisByPassBushbyBit()booleanisSendOnAndOff()voidmessageFromManager(LocoNetMessage l)voidrequestUpdateFromLayout()Request an update from the layout soft/hardware.(package private) voidsendOpcSwReqMessage(int state, boolean on)Send a single OPC_SW_REQ message for this turnout, with the CLOSED/THROWN ON/OFF state.(package private) voidsendSetOffMessage(int state)Set the turnout DCC C bit to OFF.voidsetBinaryOutput(boolean state)Use a binary output for sending commands.voidsetFeedbackMode(int mode)On change, fires Property Change "feedbackchange".voidsetFeedbackMode(java.lang.String mode)Set the feedback mode from a human readable name.voidsetUseOffSwReqAsConfirmation(boolean state)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, 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
-
_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:AbstractTurnoutUse a binary output for sending commands. This appears to expose a LocoNet-specific feature.- Specified by:
setBinaryOutputin interfaceTurnout- Overrides:
setBinaryOutputin 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:AbstractTurnoutSet the feedback mode from a human readable name. This must be one of the names defined in a previousTurnout.getValidFeedbackNames()call.- Specified by:
setFeedbackModein interfaceTurnout- Overrides:
setFeedbackModein 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:AbstractTurnoutOn 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:
setFeedbackModein interfaceTurnout- Overrides:
setFeedbackModein 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:
forwardCommandChangeToLayoutin 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)
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Request an update from the layout soft/hardware. May not even happen, and if it does it will happen later; listen for the result.- Specified by:
requestUpdateFromLayoutin interfaceDigitalIO- Overrides:
requestUpdateFromLayoutin classAbstractTurnout
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout(boolean _pushButtonLockout)
- Specified by:
turnoutPushbuttonLockoutin classAbstractTurnout
-
dispose
public void 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
-
canInvert
public boolean 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
-
-