Class AbstractTurnout
- All Implemented Interfaces:
PropertyChangeListener
,Comparable<NamedBean>
,EventListener
,PropertyChangeProvider
,DigitalIO
,NamedBean
,Turnout
- Direct Known Subclasses:
AcelaTurnout
,CbusTurnout
,DCCppTurnout
,EasyDccTurnout
,EcosTurnout
,IpocsTurnout
,JMRIClientTurnout
,LnTurnout
,MarklinTurnout
,MqttTurnout
,MrcTurnout
,Mx1Turnout
,NceTurnout
,OlcbTurnout
,RaspberryPiTurnout
,SerialTurnout
,SerialTurnout
,SerialTurnout
,SerialTurnout
,SerialTurnout
,SerialTurnout
,SerialTurnout
,SprogCSTurnout
,SprogTurnout
,SRCPTurnout
,TamsTurnout
,XBeeTurnout
,XNetTurnout
,XpaTurnout
public abstract class AbstractTurnout extends AbstractNamedBean implements Turnout, PropertyChangeListener
Implements basic feedback modes:
- NONE feedback, where the KnownState and CommandedState track each other.
- ONESENSOR feedback where the state of a single sensor specifies THROWN vs CLOSED
- TWOSENSOR feedback, where one sensor specifies THROWN and another CLOSED.
Implements the parameter binding support.
Note that we consider it an error for there to be more than one object that corresponds to a particular physical turnout on the layout.
-
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 int
_activeFeedbackType
protected boolean
_cabLockout
protected String
_decoderName
protected boolean
_enableCabLockout
protected boolean
_enablePushButtonLockout
protected boolean
_inverted
protected boolean
_pushButtonLockout
protected boolean
_reportLocked
protected String[]
_validDecoderNames
Valid stationary decoder names.protected int[]
_validFeedbackModes
protected String[]
_validFeedbackNames
protected int
_validFeedbackTypes
protected boolean
binaryOutput
static int
DELAYED_FEEDBACK_INTERVAL
Duration in Milliseconds of delay for DELAYED feedback mode.protected boolean
inhibitOperation
protected TurnoutOperator
myOperator
protected TurnoutOperation
myTurnoutOperation
protected Runnable
r
protected Thread
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, LOCKED, MONITORING, ONESENSOR, PUSHBUTTONLOCKOUT, SIGNAL, THROWN, TWOSENSOR, UNLOCKED
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTurnout(String systemName)
protected
AbstractTurnout(String systemName, String userName)
-
Method Summary
Modifier and Type Method Description boolean
canInvert()
Determine if the turnouts can be inverted.boolean
canLock(int turnoutLockout)
This implementation by itself doesn't provide locking support.String
describeState(int state)
Provide human-readable, localized version of state value.void
dispose()
Deactivate this object, so that it releases as many resources as possible and no longer effects others.void
enableLockOperation(int turnoutLockout, boolean enabled)
Enable turnout lock operators.protected void
forwardCommandChangeToLayout()
protected abstract void
forwardCommandChangeToLayout(int s)
Handle a request to change state, typically by sending a message to the layout in some child class.String
getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.int
getCommandedState()
Query the commanded state.int
getControlType()
Get control type.TurnoutOperator
getCurrentOperator()
String
getDecoderName()
Get a human readable representation of the locking decoder type for this turnout.float
getDivergingLimit()
String
getDivergingSpeed()
int
getFeedbackMode()
Get the feedback mode in machine readable form.protected int
getFeedbackModeForOperation()
Allow an actual turnout class to transform private feedback types into ones that the generic turnout operations know about.String
getFeedbackModeName()
Get the feedback mode in human readable form.NamedBeanHandle<Sensor>
getFirstNamedSensor()
Get the handle for the first feedback sensor.Sensor
getFirstSensor()
Get the first feedback sensor.boolean
getInhibitOperation()
Get if automatically retrying an operation is blocked for this turnout.boolean
getInverted()
Get the turnout inverted state.int
getKnownState()
Query the known state.Turnout
getLeadingTurnout()
Get the Turnout this Turnout is following.boolean
getLocked(int turnoutLockout)
Determine if turnout is locked.int
getNumberOutputBits()
Type of turnout control - defaults to 0 for /'steady state/'int
getPossibleLockModes()
This implementation by itself doesn't provide locking support.boolean
getReportLocked()
When true, report to console anytime a cab attempts to change the state of a turnout on the layout.NamedBeanHandle<Sensor>
getSecondNamedSensor()
Get the second feedback sensor handle.Sensor
getSecondSensor()
Get the second feedback sensor.int
getState()
Implement a shorter name for getKnownState.float
getStraightLimit()
String
getStraightSpeed()
TurnoutOperation
getTurnoutOperation()
protected TurnoutOperator
getTurnoutOperator()
Find the TurnoutOperation class for this turnout, and get an instance of the corresponding operator.List<NamedBeanUsageReport>
getUsageReport(NamedBean bean)
Get a list of references for the specified bean.String[]
getValidDecoderNames()
Get a human readable representation of the decoder types.Set<Integer>
getValidFeedbackModes()
Get a list of valid feedback types.String[]
getValidFeedbackNames()
Get a human readable representation of the feedback type.int
getValidFeedbackTypes()
Get a representation of the feedback type.boolean
isCanFollow()
Check if this Turnout can follow the state of another Turnout.boolean
isConsistentState()
Show whether state is one you can safely run trains over.boolean
isFollowingCommandedState()
Check if this Turnout is following all states or only the non-commanded states of the leading Turnout.protected void
leadingTurnoutPropertyChange(PropertyChangeEvent evt)
protected void
newCommandedState(int s)
Set a new Commanded state, if need be notifying the listeners, but do NOT send the command downstream.void
newKnownState(int s)
Add a newKnownState() for use by implementations.protected void
operationPropertyChange(PropertyChangeEvent evt)
void
propertyChange(PropertyChangeEvent evt)
React to sensor changes by changing the KnownState if using an appropriate sensor mode.void
provideFirstFeedbackNamedSensor(NamedBeanHandle<Sensor> s)
On change, fires Property Change "TurnoutFeedbackFirstSensorChange".void
provideFirstFeedbackSensor(String pName)
void
provideSecondFeedbackNamedSensor(NamedBeanHandle<Sensor> s)
On change, fires Property Change "TurnoutFeedbackSecondSensorChange".void
provideSecondFeedbackSensor(String pName)
void
requestUpdateFromLayout()
Request an update from the layout soft/hardware.protected void
sensorPropertyChange(PropertyChangeEvent evt)
void
setBinaryOutput(boolean state)
Use a binary output for sending commands.void
setCommandedState(int s)
Public access to changing turnout state.void
setCommandedStateAtInterval(int s)
Before setting commanded state, if required by manager, apply wait interval until outputIntervalEnds() to put less pressure on the connection.void
setControlType(int num)
Set control type.void
setDecoderName(String decoderName)
Set a human readable representation of the locking decoder type for this turnout.void
setDivergingSpeed(String s)
On change, fires Property Change "TurnoutDivergingSpeedChange".void
setFeedbackMode(int mode)
On change, fires Property Change "feedbackchange".void
setFeedbackMode(String mode)
Set the feedback mode from a human readable name.void
setFollowingCommandedState(boolean following)
Set if this Turnout follows all states or only the non-commanded states of the leading Turnout.void
setInhibitOperation(boolean io)
Set if automatically retrying an operation is blocked for this turnout.void
setInitialKnownStateFromFeedback()
Sets the initial known state (CLOSED,THROWN,UNKNOWN) from feedback information, if appropriate.void
setInverted(boolean inverted)
On change, fires Property Change "inverted".(package private) void
setKnownStateToCommanded()
The name pretty much says it.void
setLeadingTurnout(Turnout turnout)
Set the Turnout this Turnout will follow.void
setLeadingTurnout(Turnout turnout, boolean followingCommandedState)
Set both the leading Turnout and if the commanded state of the leading Turnout is followed.void
setLocked(int turnoutLockout, boolean locked)
Turnouts that are locked should only respond to JMRI commands to change state.void
setNumberOutputBits(int num)
Set number of output bits.void
setReportLocked(boolean reportLocked)
When true, report to console anytime a cab attempts to change the state of a turnout on the layout.void
setState(int s)
Implement a shorter name for setCommandedState.void
setStraightSpeed(String s)
On change, fires Property Change "TurnoutStraightSpeedChange".void
setTurnoutOperation(TurnoutOperation toper)
set current automation classboolean
stateChangeCheck(int newState)
Preprocess a Turnout state change request forforwardCommandChangeToLayout(int)
Public access to allow use in tests.protected boolean
statesOk(int state)
Look for the case in which the state is neither Closed nor Thrown, which we can't handle.protected void
turnoutPushbuttonLockout()
protected abstract void
turnoutPushbuttonLockout(boolean locked)
void
vetoableChange(PropertyChangeEvent evt)
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, 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, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
DELAYED_FEEDBACK_INTERVAL
Duration in Milliseconds of delay for DELAYED feedback mode.Defined as "public non-final" so it can be changed in e.g. the jython/SetDefaultDelayedTurnoutDelay script.
-
thr
-
r
-
_validFeedbackNames
-
_validFeedbackModes
-
_validFeedbackTypes
-
_activeFeedbackType
-
_inverted
-
_cabLockout
-
_pushButtonLockout
-
_enableCabLockout
-
_enablePushButtonLockout
-
_reportLocked
-
_validDecoderNames
Valid stationary decoder names. -
_decoderName
-
myOperator
-
myTurnoutOperation
-
inhibitOperation
-
binaryOutput
-
-
Constructor Details
-
Method Details
-
getBeanType
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
forwardCommandChangeToLayout
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.- Parameters:
s
- new state value
-
forwardCommandChangeToLayout
-
stateChangeCheck
Preprocess a Turnout state change request forforwardCommandChangeToLayout(int)
Public access to allow use in tests.- Parameters:
newState
- the Turnout state command value passed- Returns:
- true if a Turnout.CLOSED was requested and Turnout is not set to _inverted
- Throws:
IllegalArgumentException
-
statesOk
Look for the case in which the state is neither Closed nor Thrown, which we can't handle. Separate method to allow it to be used instateChangeCheck(int)
and Xpa/MqttTurnout.- Parameters:
state
- the Turnout state passed- Returns:
- false if s = Turnout.THROWN, which is what we want
-
newCommandedState
Set a new Commanded state, if need be notifying the listeners, but do NOT send the command downstream.This is used when a new commanded state is noticed from another command.
- Parameters:
s
- new state
-
getKnownState
Query the known state. This is a bound parameter, so you can also register a listener to be informed of changes. A result is always returned; if no other feedback method is available, the commanded state will be used.- Specified by:
getKnownState
in interfaceDigitalIO
- Returns:
- the known state
-
setCommandedState
Public access to changing turnout state. Sets the commanded state and, if appropriate, starts a TurnoutOperator to do its thing. If there is no TurnoutOperator (not required or nothing suitable) then just tell the layout and hope for the best.- Specified by:
setCommandedState
in interfaceDigitalIO
- Parameters:
s
- commanded state to set
-
setCommandedStateAtInterval
Before setting commanded state, if required by manager, apply wait interval until outputIntervalEnds() to put less pressure on the connection.Used to insert a delay before calling
DigitalIO.setCommandedState(int)
to spread out a series of output commands, as inMatrixSignalMast.updateOutputs(char[])
andDefaultRoute
class SetRouteThread#run(). Interval value is kept in the Memo per hardware connection, default = 0 Used inDefaultRoute.setRoute()
andMatrixSignalMast.updateOutputs(char[])
.- Specified by:
setCommandedStateAtInterval
in interfaceTurnout
- Parameters:
s
- turnout state to forward
-
getCommandedState
Query the commanded state. This is a bound parameter, so you can also register a listener to be informed of changes.- Specified by:
getCommandedState
in interfaceDigitalIO
- Returns:
- the commanded state
-
newKnownState
Add a newKnownState() for use by implementations.Use this to update internal information when a state change is detected outside the Turnout object, e.g. via feedback from sensors on the layout.
If the layout status of the Turnout is observed to change to THROWN or CLOSED, this also sets the commanded state, because it's assumed that somebody somewhere commanded that move. If it's observed to change to UNKNOWN or INCONSISTENT, that's perhaps either an error or a move in progress, and no change is made to the commanded state.
This implementation sends a command to the layout for the new state if going to THROWN or CLOSED, because there may be others listening to network state.
This method is not intended for general use, e.g. for users to set the KnownState, so it doesn't appear in the Turnout interface.
On change, fires Property Change "KnownState".
- Parameters:
s
- New state value
-
isConsistentState
Show whether state is one you can safely run trains over.- Specified by:
isConsistentState
in interfaceDigitalIO
- Returns:
- true if state is a valid one and the known state is the same as commanded.
-
setKnownStateToCommanded
void setKnownStateToCommanded()The name pretty much says it.Triggers all listeners, etc. For use by the TurnoutOperator classes.
-
setState
Implement a shorter name for setCommandedState.This generally shouldn't be used by Java code; use setCommandedState instead. The is provided to make Jython script access easier to read.
Note that getState() and setState(int) are not symmetric: getState is the known state, and set state modifies the commanded state.
-
getState
Implement a shorter name for getKnownState.This generally shouldn't be used by Java code; use getKnownState instead. The is provided to make Jython script access easier to read.
Note that getState() and setState(int) are not symmetric: getState is the known state, and set state modifies the commanded state.
-
describeState
Provide human-readable, localized version of state value.This method is intended for use when presenting to a human operator.
- Specified by:
describeState
in interfaceNamedBean
- Overrides:
describeState
in classAbstractNamedBean
- Parameters:
state
- the state to describe- Returns:
- the state in localized form
-
getNumberOutputBits
Type of turnout control - defaults to 0 for /'steady state/'- Specified by:
getNumberOutputBits
in interfaceTurnout
- Returns:
- the size of the output, currently 1 or 2
-
setNumberOutputBits
Set number of output bits.- Specified by:
setNumberOutputBits
in interfaceTurnout
- Parameters:
num
- the size of the output, currently 1 or 2
-
getControlType
Get control type.- Specified by:
getControlType
in interfaceTurnout
- Returns:
- 0 for steady state or the number of time units the control pulses
-
setControlType
Set control type.- Specified by:
setControlType
in interfaceTurnout
- Parameters:
num
- 0 for steady state or the number of time units the control pulses
-
getValidFeedbackModes
Get a list of valid feedback types. The valid types depend on the implemented system.- Specified by:
getValidFeedbackModes
in interfaceTurnout
- Returns:
- array of feedback types
-
getValidFeedbackTypes
Get a representation of the feedback type. This is the OR of possible values: DIRECT, EXACT, etc. The valid combinations depend on the implemented system.- Specified by:
getValidFeedbackTypes
in interfaceTurnout
- Returns:
- the ORed combination of feedback types
-
getValidFeedbackNames
Get a human readable representation of the feedback type. The values depend on the implemented system.- Specified by:
getValidFeedbackNames
in interfaceTurnout
- Returns:
- the names of the feedback types or an empty list if no feedback is available
-
setFeedbackMode
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
- Parameters:
mode
- the feedback type name- Throws:
IllegalArgumentException
- if mode is not valid
-
setFeedbackMode
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
- Parameters:
mode
- the feedback type to set- Throws:
IllegalArgumentException
- if mode is not valid
-
getFeedbackMode
Get the feedback mode in machine readable form. This will be one of the bits defined in aTurnout.getValidFeedbackTypes()
call.- Specified by:
getFeedbackMode
in interfaceTurnout
- Returns:
- the feedback type
-
getFeedbackModeName
Get the feedback mode in human readable form. This will be one of the names defined in aTurnout.getValidFeedbackNames()
call.- Specified by:
getFeedbackModeName
in interfaceTurnout
- Returns:
- the feedback type
-
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:
requestUpdateFromLayout
in interfaceDigitalIO
-
setInverted
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
- Parameters:
inverted
- true if inverted; false otherwise
-
getInverted
Get the turnout inverted state. If true, commands sent to the layout are reversed. Thrown becomes Closed, and Closed becomes Thrown.Used in polling loops in system-specific code, so made final to allow optimization.
- Specified by:
getInverted
in interfaceTurnout
- Returns:
- inverted status
-
canInvert
Determine if the turnouts can be inverted. If true, inverted turnouts are supported. -
setLocked
Turnouts that are locked should only respond to JMRI commands to change state. We simulate a locked turnout by monitoring the known state (turnout feedback is required) and if we detect that the known state has changed, negate it by forcing the turnout to return to the commanded state. Turnouts that have local buttons can also be locked if their decoder supports it. On change, fires Property Change "locked".- Specified by:
setLocked
in interfaceTurnout
- Parameters:
turnoutLockout
- lockout state to monitor. Possible valuesTurnout.CABLOCKOUT
,Turnout.PUSHBUTTONLOCKOUT
. Can be combined to monitor both states.locked
- true if turnout to be locked
-
getLocked
Determine if turnout is locked. There are two types of locks: cab lockout, and pushbutton lockout. -
getPossibleLockModes
This implementation by itself doesn't provide locking support. Override this in subclasses that do.- Specified by:
getPossibleLockModes
in interfaceTurnout
- Returns:
- One of 0 for none
-
canLock
This implementation by itself doesn't provide locking support. Override this in subclasses that do. -
enableLockOperation
Enable turnout lock operators. A turnout can be locked to prevent it being thrown from a cab or push button on the layout if supported by the protocol. Not implemented in AbstractTurnout.- Specified by:
enableLockOperation
in interfaceTurnout
- Parameters:
turnoutLockout
- the type of lockenabled
- true if locking is enabled for the given type; false otherwise
-
setReportLocked
When true, report to console anytime a cab attempts to change the state of a turnout on the layout. When a turnout is cab locked, only JMRI is allowed to change the state of a turnout. On setting changed, fires Property Change "reportlocked".- Specified by:
setReportLocked
in interfaceTurnout
- Parameters:
reportLocked
- report locked state
-
getReportLocked
When true, report to console anytime a cab attempts to change the state of a turnout on the layout. When a turnout is cab locked, only JMRI is allowed to change the state of a turnout.- Specified by:
getReportLocked
in interfaceTurnout
- Returns:
- report locked state
-
getValidDecoderNames
Get a human readable representation of the decoder types.- Specified by:
getValidDecoderNames
in interfaceTurnout
- Returns:
- a list of known stationary decoders that can be specified for locking
-
getDecoderName
Get a human readable representation of the locking decoder type for this turnout. In AbstractTurnout this String defaults to PushbuttonPacket.unknown , ie "None"- Specified by:
getDecoderName
in interfaceTurnout
- Returns:
- the name of the decoder type; null indicates none defined
-
setDecoderName
Set a human readable representation of the locking decoder type for this turnout. On change, fires Property Change "decoderNameChange".- Specified by:
setDecoderName
in interfaceTurnout
- Parameters:
decoderName
- the name of the decoder type
-
turnoutPushbuttonLockout
-
turnoutPushbuttonLockout
-
getCurrentOperator
-
getTurnoutOperation
- Specified by:
getTurnoutOperation
in interfaceTurnout
- Returns:
- current operation automation class
-
setTurnoutOperation
set current automation class Fires Property Change "TurnoutOperationState".- Specified by:
setTurnoutOperation
in interfaceTurnout
- Parameters:
toper
- TurnoutOperation subclass instance
-
operationPropertyChange
-
getInhibitOperation
Get if automatically retrying an operation is blocked for this turnout.- Specified by:
getInhibitOperation
in interfaceTurnout
- Returns:
- true if retrying is disabled; false otherwise
-
setInhibitOperation
Set if automatically retrying an operation is blocked for this turnout.- Specified by:
setInhibitOperation
in interfaceTurnout
- Parameters:
io
- true if retrying is to be disabled; false otherwise
-
getTurnoutOperator
Find the TurnoutOperation class for this turnout, and get an instance of the corresponding operator. Override this function if you want another way to choose the operation.- Returns:
- newly-instantiated TurnoutOperator, or null if nothing suitable
-
getFeedbackModeForOperation
Allow an actual turnout class to transform private feedback types into ones that the generic turnout operations know about.- Returns:
- apparent feedback mode for operation lookup
-
provideFirstFeedbackSensor
public void provideFirstFeedbackSensor(String pName) throws JmriException, IllegalArgumentException- Specified by:
provideFirstFeedbackSensor
in interfaceTurnout
- Throws:
JmriException
IllegalArgumentException
-
provideFirstFeedbackNamedSensor
On change, fires Property Change "TurnoutFeedbackFirstSensorChange".- Parameters:
s
- the Handle for First Feedback Sensor
-
getFirstSensor
Get the first feedback sensor.- Specified by:
getFirstSensor
in interfaceTurnout
- Returns:
- the sensor or null if no Sensor set
-
getFirstNamedSensor
Get the handle for the first feedback sensor.- Specified by:
getFirstNamedSensor
in interfaceTurnout
- Returns:
- the sensor handle or null if no Sensor set
-
provideSecondFeedbackSensor
public void provideSecondFeedbackSensor(String pName) throws JmriException, IllegalArgumentException- Specified by:
provideSecondFeedbackSensor
in interfaceTurnout
- Throws:
JmriException
IllegalArgumentException
-
provideSecondFeedbackNamedSensor
On change, fires Property Change "TurnoutFeedbackSecondSensorChange".- Parameters:
s
- the Handle for Second Feedback Sensor
-
getSecondSensor
Get the second feedback sensor.- Specified by:
getSecondSensor
in interfaceTurnout
- Returns:
- the sensor or null if no Sensor set
-
getSecondNamedSensor
Get the second feedback sensor handle.- Specified by:
getSecondNamedSensor
in interfaceTurnout
- Returns:
- the sensor handle or null if no Sensor set
-
setInitialKnownStateFromFeedback
Sets the initial known state (CLOSED,THROWN,UNKNOWN) from feedback information, if appropriate.This method is designed to be called only when Turnouts are loaded and when a new Turnout is defined in the Turnout table.
No change to known state is made if feedback information is not available. If feedback information is inconsistent, or if sensor definition is missing in ONESENSOR and TWOSENSOR feedback, turnout state is set to UNKNOWN.
- Specified by:
setInitialKnownStateFromFeedback
in interfaceTurnout
-
propertyChange
React to sensor changes by changing the KnownState if using an appropriate sensor mode.- Specified by:
propertyChange
in interfacePropertyChangeListener
-
sensorPropertyChange
-
leadingTurnoutPropertyChange
-
setBinaryOutput
Use a binary output for sending commands. This appears to expose a LocoNet-specific feature.- Specified by:
setBinaryOutput
in interfaceTurnout
- Parameters:
state
- true if the outputs are binary; false otherwise
-
dispose
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 classAbstractNamedBean
-
getDivergingLimit
- Specified by:
getDivergingLimit
in interfaceTurnout
-
getDivergingSpeed
- Specified by:
getDivergingSpeed
in interfaceTurnout
-
setDivergingSpeed
On change, fires Property Change "TurnoutDivergingSpeedChange".- Specified by:
setDivergingSpeed
in interfaceTurnout
- Throws:
JmriException
-
getStraightLimit
- Specified by:
getStraightLimit
in interfaceTurnout
-
getStraightSpeed
- Specified by:
getStraightSpeed
in interfaceTurnout
-
setStraightSpeed
On change, fires Property Change "TurnoutStraightSpeedChange".- Specified by:
setStraightSpeed
in interfaceTurnout
- Throws:
JmriException
-
vetoableChange
- Specified by:
vetoableChange
in interfaceNamedBean
- Overrides:
vetoableChange
in classAbstractNamedBean
- Throws:
PropertyVetoException
-
getUsageReport
Get a list of references for the specified bean.- Specified by:
getUsageReport
in interfaceNamedBean
- Parameters:
bean
- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
isCanFollow
Check if this Turnout can follow the state of another Turnout.- Specified by:
isCanFollow
in interfaceTurnout
- Returns:
- true if this Turnout is capable of following; false otherwise
-
getLeadingTurnout
Get the Turnout this Turnout is following.- Specified by:
getLeadingTurnout
in interfaceTurnout
- Returns:
- the leading Turnout or null if none; null if
Turnout.isCanFollow()
is false
-
setLeadingTurnout
Set the Turnout this Turnout will follow.It is valid for two or more turnouts to follow each other in a circular pattern.
It is recommended that a following turnout's feedback mode be
Turnout.DIRECT
.It is recommended to explicitly call
Turnout.setFollowingCommandedState(boolean)
after calling this method or to useTurnout.setLeadingTurnout(jmri.Turnout, boolean)
to ensure this Turnout follows the leading Turnout in the expected manner.- Specified by:
setLeadingTurnout
in interfaceTurnout
- Parameters:
turnout
- the leading Turnout or null if this Turnout should not follow another Turnout; silently ignored ifTurnout.isCanFollow()
is false
-
setLeadingTurnout
Set both the leading Turnout and if the commanded state of the leading Turnout is followed. This is a convenience method for calling bothTurnout.setLeadingTurnout(jmri.Turnout)
andTurnout.setFollowingCommandedState(boolean)
.- Specified by:
setLeadingTurnout
in interfaceTurnout
- Parameters:
turnout
- the leading Turnout or null if this Turnout should not follow another Turnout; silently ignored ifTurnout.isCanFollow()
is falsefollowingCommandedState
- true to have all states match leading turnout; false to only have non-commanded states match
-
isFollowingCommandedState
Check if this Turnout is following all states or only the non-commanded states of the leading Turnout.- Specified by:
isFollowingCommandedState
in interfaceTurnout
- Returns:
- true if following all states; false otherwise
-
setFollowingCommandedState
Set if this Turnout follows all states or only the non-commanded states of the leading Turnout.A Turnout can be commanded to be
Turnout.THROWN
orTurnout.CLOSED
, but can also have additional statesNamedBean.INCONSISTENT
andNamedBean.UNKNOWN
. There are some use cases where a following Turnout should match all states of the leading Turnout, in which case this should be true, but there are also use cases where the following Turnout should only match the INCONSISTENT and UNKNOWN states of the leading Turnout, but should otherwise be independently commanded, in which case this should be false.- Specified by:
setFollowingCommandedState
in interfaceTurnout
- Parameters:
following
- true to have all states match leading turnout; false to only have non-commanded states match
-