Class SerialTurnout
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractTurnout
-
- jmri.jmrix.cmri.serial.SerialTurnout
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,DigitalIO
,NamedBean
,Turnout
,VariableControlSpanBean
public class SerialTurnout extends AbstractTurnout
Turnout implementation for C/MRI serial systems.This object doesn't listen to the C/MRI communications. This is because it should be the only object that is sending messages for this turnout; more than one Turnout object pointing to a single device is not allowed.
Turnouts on the layout may be controlled by one or two output bits. To control a turnout from one Turnout object via two output bits, the output bits must be on the same node, the Turnout address must point to the first output bit, and the second output bit must follow the output bit at the next address. Valid states for the two bits controlling the two-bit turnout are: ON OFF, and OFF ON for the two bits.
This class can also drive pulsed outputs, which can be combined with the two-bit option in the expected ways.
When a Turnout is configured for pulsed and two-output, a request to go to a new CommandedState sets the desired configuration for the pulse interval, then sets both leads to their off condition.
When a Turnout is configured for pulsed and one output, a request to go to a new CommandedState just sets the output on for the interval; it's assumed that there's something out on the layout that converts that pulse into a "flip to other state" operation.
Finally, this implementation supports the "inverted" option. Inverted applies to the status of the lead on the C/MRI output itself.
For example, a pulsed, two-output, inverted turnout will have both pins set to 1 in the resting state. When THROWN, one lead will be set to 0 for the configured interval, then set back to 1.
For more discussion of this, please see the documentation page.
-
-
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) CMRISystemConnectionMemo
_memo
protected javax.swing.Timer
mPulseClosedTimer
protected javax.swing.Timer
mPulseThrownTimer
protected boolean
mPulseTimerOn
protected int
tBit
protected SerialNode
tNode
(package private) java.lang.String
tSystemName
-
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 SerialTurnout(java.lang.String systemName, java.lang.String userName, CMRISystemConnectionMemo memo)
Create a Turnout object, with both system and user names.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canInvert()
C/MRI turnouts do support inversionint
compareSystemNameSuffix(java.lang.String suffix1, java.lang.String suffix2, NamedBean n)
Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)
operation.protected void
forwardCommandChangeToLayout(int newState)
Handle a request to change state by sending a turnout commandprotected void
sendMessage(boolean closed)
Control the actual layout hardware.protected void
turnoutPushbuttonLockout(boolean _pushButtonLockout)
-
Methods inherited from class jmri.implementation.AbstractTurnout
canLock, describeState, dispose, 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, setBinaryOutput, setCommandedState, setCommandedStateAtInterval, setControlType, setDecoderName, setDivergingSpeed, setFeedbackMode, setFeedbackMode, 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, 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, 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
-
tSystemName
java.lang.String tSystemName
-
tBit
protected int tBit
-
tNode
protected SerialNode tNode
-
mPulseClosedTimer
protected javax.swing.Timer mPulseClosedTimer
-
mPulseThrownTimer
protected javax.swing.Timer mPulseThrownTimer
-
mPulseTimerOn
protected boolean mPulseTimerOn
-
-
Constructor Detail
-
SerialTurnout
public SerialTurnout(@Nonnull java.lang.String systemName, java.lang.String userName, CMRISystemConnectionMemo memo)
Create a Turnout object, with both system and user names.'systemName' was previously validated in SerialTurnoutManager
- Parameters:
systemName
- system nameuserName
- user namememo
- system connection
-
-
Method Detail
-
forwardCommandChangeToLayout
protected void forwardCommandChangeToLayout(int newState)
Handle a request to change state by sending a turnout command- Specified by:
forwardCommandChangeToLayout
in classAbstractTurnout
- Parameters:
newState
- desired new state, one of the Turnout class constants
-
canInvert
public boolean canInvert()
C/MRI turnouts do support inversion- Specified by:
canInvert
in interfaceTurnout
- Overrides:
canInvert
in classAbstractTurnout
- Returns:
- invert supported
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout(boolean _pushButtonLockout)
- Specified by:
turnoutPushbuttonLockout
in classAbstractTurnout
-
sendMessage
protected void sendMessage(boolean closed)
Control the actual layout hardware. The request is for a particular functional setting, e.g. CLOSED or THROWN. The "inverted" status of the output leads is handled here.- Parameters:
closed
- True sets the turnout CLOSED
-
compareSystemNameSuffix
@CheckReturnValue public int compareSystemNameSuffix(@Nonnull java.lang.String suffix1, @Nonnull java.lang.String suffix2, @Nonnull NamedBean n)
Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)
operation. This is intended to be a system-specific comparison that understands the various formats, etc. By default, does an alphanumeric-by-chunks comparison. Sorts by node number and then by bit- Specified by:
compareSystemNameSuffix
in interfaceNamedBean
- Overrides:
compareSystemNameSuffix
in classAbstractNamedBean
- Parameters:
suffix1
- The suffix for the 1st bean in the comparisonsuffix2
- The suffix for the 2nd bean in the comparisonn
- The other (second) NamedBean in the comparison- Returns:
- -1,0,+1 for ordering if the names are well-formed; may not provide proper ordering if the names are not well-formed.
-
-