Class DCCppTurnout
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractTurnout
-
- jmri.jmrix.dccpp.DCCppTurnout
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.lang.Comparable<NamedBean>,java.util.EventListener,PropertyChangeProvider,DigitalIO,AbstractMRListener,DCCppListener,NamedBean,Turnout,VariableControlSpanBean
public class DCCppTurnout extends AbstractTurnout implements DCCppListener
Extends jmri.AbstractTurnout for DCCpp layoutsTurnouts on DCC++ are controlled (as of V1.5 Firmware) with unidirectional Stationary Decoder commands, or with bidirectional (predefined) Turnout commands, or with bidirectional (predefined) Output commands. DCC++ Has three ways to activate a turnout (output)
- Accessory Command "a" : sends a DCC packet to a stationary decoder out there on the bus somewhere. NO RETURN VALUE to JMRI.
- Turnout Command "T" : Looks up a DCC address from an internal table in the Base Station and sends that Stationary Decoder a packet. Returns a (basically faked) "H" response to JMRI indicating the (supposed) current state of the turnout. Or "X" if the indexed turnout is not in the list.
- Output Command "z" : Looks up a Base Station Arduino Pin number from an internal lookup table, and sets/toggles the state of that pin. Returns a "Y" response indicating the actual state of the pin. Or "X" if the indexed pin is not in the list.
- DIRECT: No actual feedback, uses Stationary Decoder command and fakes the response.
- MONITORING: Uses the Turnout command, lets the Base Station fake the response :)
- EXACT: Uses the Output command to directly address an Arduino pin.
- set the commanded state, and, Send request to command station to start sending DCC operations packet to track
-
-
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 protected java.lang.String_prefix(package private) jmri.jmrix.dccpp.DCCppTurnout.DCCppTurnoutStateListener_stateListenerprotected static intCOMMANDSENTprotected static intIDLEprotected intinternalStateprotected intmNumber(package private) static java.lang.String[]modeNames(package private) static int[]modeValuesprotected static intSTATUSREQUESTSENTprotected DCCppTrafficControllertc-
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 DCCppTurnout(java.lang.String prefix, int pNumber, DCCppTrafficController controller)
-
Method Summary
All Methods Static 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 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()intgetNumber()(package private) voidinitmessage(DCCppReply l)initmessage is a package proteceted 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.voidmessage(DCCppMessage l)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout.voidmessage(DCCppReply l)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.voidnotifyTimeout(DCCppMessage msg)Member function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.voidrequestUpdateFromLayout()request an update on status by sending a DCC++ messagevoidsetCommandedState(int s)Set the Commanded 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, setBinaryOutput, 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, 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
-
COMMANDSENT
protected static final int COMMANDSENT
- See Also:
- Constant Field Values
-
STATUSREQUESTSENT
protected static final int STATUSREQUESTSENT
- 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
-
_prefix
protected java.lang.String _prefix
-
tc
protected DCCppTrafficController tc
-
mNumber
protected int mNumber
-
_stateListener
jmri.jmrix.dccpp.DCCppTurnout.DCCppTurnoutStateListener _stateListener
-
-
Constructor Detail
-
DCCppTurnout
public DCCppTurnout(java.lang.String prefix, int pNumber, DCCppTrafficController 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:
setCommandedStatein interfaceDigitalIO- Overrides:
setCommandedStatein 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 a DCC++ command.- Specified by:
forwardCommandChangeToLayoutin classAbstractTurnout- Parameters:
s- new state value
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout(boolean _pushButtonLockout)
- Specified by:
turnoutPushbuttonLockoutin classAbstractTurnout
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
request an update on status by sending a DCC++ message- Specified by:
requestUpdateFromLayoutin interfaceDigitalIO- Overrides:
requestUpdateFromLayoutin 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
-
initmessage
void initmessage(DCCppReply l)
initmessage is a package proteceted 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- Init message
-
message
public void message(DCCppReply l)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.- Specified by:
messagein interfaceDCCppListener- Parameters:
l- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
public void message(DCCppMessage l)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout. Normally, this function will do nothing.- Specified by:
messagein interfaceDCCppListener- Parameters:
l- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
public void notifyTimeout(DCCppMessage msg)
Description copied from interface:DCCppListenerMember function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeoutin interfaceDCCppListener- Parameters:
msg- the message that timed out.
-
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
-
-