Class AbstractTurnout
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractTurnout
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,DigitalIO
,NamedBean
,Turnout
,VariableControlSpanBean
- Direct Known Subclasses:
AcelaTurnout
,BiDiBTurnout
,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, java.beans.PropertyChangeListener
Abstract base for the Turnout interface.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 java.lang.String
_decoderName
protected boolean
_enableCabLockout
protected boolean
_enablePushButtonLockout
protected boolean
_inverted
protected boolean
_pushButtonLockout
protected boolean
_reportLocked
protected java.lang.String[]
_validDecoderNames
Valid stationary decoder names.protected int[]
_validFeedbackModes
protected java.lang.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 java.lang.Runnable
r
protected java.lang.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, LNALTERNATE, LOCKED, MONITORING, ONESENSOR, PUSHBUTTONLOCKOUT, SIGNAL, THROWN, TWOSENSOR, UNLOCKED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTurnout(java.lang.String systemName)
protected
AbstractTurnout(java.lang.String systemName, java.lang.String userName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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.java.lang.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.java.lang.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()
java.lang.String
getDecoderName()
Get a human readable representation of the locking decoder type for this turnout.float
getDivergingLimit()
java.lang.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.java.lang.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
getNumberControlBits()
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()
java.lang.String
getStraightSpeed()
TurnoutOperation
getTurnoutOperation()
protected TurnoutOperator
getTurnoutOperator()
Find the TurnoutOperation class for this turnout, and get an instance of the corresponding operator.java.util.List<NamedBeanUsageReport>
getUsageReport(NamedBean bean)
Get a list of references for the specified bean.java.lang.String[]
getValidDecoderNames()
Get a human readable representation of the decoder types.java.util.Set<java.lang.Integer>
getValidFeedbackModes()
Get a list of valid feedback types.java.lang.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(java.beans.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(java.beans.PropertyChangeEvent evt)
void
propertyChange(java.beans.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(java.lang.String pName)
void
provideSecondFeedbackNamedSensor(NamedBeanHandle<Sensor> s)
On change, fires Property Change "TurnoutFeedbackSecondSensorChange".void
provideSecondFeedbackSensor(java.lang.String pName)
void
requestUpdateFromLayout()
Request an update from the layout soft/hardware.protected void
sensorPropertyChange(java.beans.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(java.lang.String decoderName)
Set a human readable representation of the locking decoder type for this turnout.void
setDivergingSpeed(java.lang.String s)
On change, fires Property Change "TurnoutDivergingSpeedChange".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
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
setNumberControlBits(int num)
Set number of input/output bits this bean controls.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(java.lang.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(java.beans.PropertyChangeEvent evt)
-
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
-
DELAYED_FEEDBACK_INTERVAL
public static int 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
protected java.lang.Thread thr
-
r
protected java.lang.Runnable r
-
_validFeedbackNames
protected java.lang.String[] _validFeedbackNames
-
_validFeedbackModes
protected int[] _validFeedbackModes
-
_validFeedbackTypes
protected int _validFeedbackTypes
-
_activeFeedbackType
protected int _activeFeedbackType
-
_inverted
protected boolean _inverted
-
_cabLockout
protected boolean _cabLockout
-
_pushButtonLockout
protected boolean _pushButtonLockout
-
_enableCabLockout
protected boolean _enableCabLockout
-
_enablePushButtonLockout
protected boolean _enablePushButtonLockout
-
_reportLocked
protected boolean _reportLocked
-
_validDecoderNames
protected java.lang.String[] _validDecoderNames
Valid stationary decoder names.
-
_decoderName
protected java.lang.String _decoderName
-
myOperator
protected TurnoutOperator myOperator
-
myTurnoutOperation
protected TurnoutOperation myTurnoutOperation
-
inhibitOperation
protected boolean inhibitOperation
-
binaryOutput
protected boolean binaryOutput
-
-
Constructor Detail
-
AbstractTurnout
protected AbstractTurnout(java.lang.String systemName)
-
AbstractTurnout
protected AbstractTurnout(java.lang.String systemName, java.lang.String userName)
-
-
Method Detail
-
getBeanType
@Nonnull public java.lang.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.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
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. 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
protected void forwardCommandChangeToLayout()
-
stateChangeCheck
public boolean stateChangeCheck(int newState) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
-
statesOk
protected boolean statesOk(int state)
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
protected void newCommandedState(int s)
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
public int 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 void setCommandedState(int s)
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
public void setCommandedStateAtInterval(int s)
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
public int 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
public void newKnownState(int s)
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
public boolean 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
public void setState(int s)
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
public int 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
@Nonnull public java.lang.String describeState(int state)
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
-
getNumberControlBits
public int getNumberControlBits()
Type of turnout control - defaults to 0 for /'steady state/'- Specified by:
getNumberControlBits
in interfaceVariableControlSpanBean
- Returns:
- the number of bits
-
setNumberControlBits
public void setNumberControlBits(int num)
Set number of input/output bits this bean controls.- Specified by:
setNumberControlBits
in interfaceVariableControlSpanBean
- Parameters:
num
- the size of the input/output, currently 1 or 2
-
getControlType
public int getControlType()
Get control type.- Specified by:
getControlType
in interfaceTurnout
- Returns:
- 0 for steady state or the number of time units the control pulses
-
setControlType
public void setControlType(int num)
Set control type.- Specified by:
setControlType
in interfaceTurnout
- Parameters:
num
- 0 for steady state or the number of time units the control pulses
-
getValidFeedbackModes
public java.util.Set<java.lang.Integer> 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
public int 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
@Nonnull public java.lang.String[] 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
public void setFeedbackMode(@Nonnull java.lang.String mode) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
- if mode is not valid
-
setFeedbackMode
public void setFeedbackMode(int mode) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
- if mode is not valid
-
getFeedbackMode
public int 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
@Nonnull public java.lang.String 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
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:
requestUpdateFromLayout
in interfaceDigitalIO
-
setInverted
public void setInverted(boolean inverted)
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
public final boolean 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
public boolean canInvert()
Determine if the turnouts can be inverted. If true, inverted turnouts are supported.
-
setLocked
public void setLocked(int turnoutLockout, boolean locked)
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
public boolean getLocked(int turnoutLockout)
Determine if turnout is locked. There are two types of locks: cab lockout, and pushbutton lockout.
-
getPossibleLockModes
public int 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
public boolean canLock(int turnoutLockout)
This implementation by itself doesn't provide locking support. Override this in subclasses that do.
-
enableLockOperation
public void enableLockOperation(int turnoutLockout, boolean enabled)
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
public void setReportLocked(boolean reportLocked)
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
public boolean 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
@Nonnull public java.lang.String[] 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
public java.lang.String 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
public void setDecoderName(java.lang.String decoderName)
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
protected abstract void turnoutPushbuttonLockout(boolean locked)
-
turnoutPushbuttonLockout
protected void turnoutPushbuttonLockout()
-
getCurrentOperator
public TurnoutOperator getCurrentOperator()
-
getTurnoutOperation
public TurnoutOperation getTurnoutOperation()
- Specified by:
getTurnoutOperation
in interfaceTurnout
- Returns:
- current operation automation class
-
setTurnoutOperation
public void setTurnoutOperation(TurnoutOperation toper)
set current automation class Fires Property Change "TurnoutOperationState".- Specified by:
setTurnoutOperation
in interfaceTurnout
- Parameters:
toper
- TurnoutOperation subclass instance
-
operationPropertyChange
protected void operationPropertyChange(java.beans.PropertyChangeEvent evt)
-
getInhibitOperation
public boolean 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
public void setInhibitOperation(boolean io)
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
protected TurnoutOperator 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
protected int 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(java.lang.String pName) throws JmriException, java.lang.IllegalArgumentException
- Specified by:
provideFirstFeedbackSensor
in interfaceTurnout
- Throws:
JmriException
java.lang.IllegalArgumentException
-
provideFirstFeedbackNamedSensor
public void provideFirstFeedbackNamedSensor(NamedBeanHandle<Sensor> s)
On change, fires Property Change "TurnoutFeedbackFirstSensorChange".- Parameters:
s
- the Handle for First Feedback Sensor
-
getFirstSensor
public Sensor getFirstSensor()
Get the first feedback sensor.- Specified by:
getFirstSensor
in interfaceTurnout
- Returns:
- the sensor or null if no Sensor set
-
getFirstNamedSensor
public NamedBeanHandle<Sensor> 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(java.lang.String pName) throws JmriException, java.lang.IllegalArgumentException
- Specified by:
provideSecondFeedbackSensor
in interfaceTurnout
- Throws:
JmriException
java.lang.IllegalArgumentException
-
provideSecondFeedbackNamedSensor
public void provideSecondFeedbackNamedSensor(NamedBeanHandle<Sensor> s)
On change, fires Property Change "TurnoutFeedbackSecondSensorChange".- Parameters:
s
- the Handle for Second Feedback Sensor
-
getSecondSensor
@CheckForNull public Sensor getSecondSensor()
Get the second feedback sensor.- Specified by:
getSecondSensor
in interfaceTurnout
- Returns:
- the sensor or null if no Sensor set
-
getSecondNamedSensor
@CheckForNull public NamedBeanHandle<Sensor> getSecondNamedSensor()
Get the second feedback sensor handle.- Specified by:
getSecondNamedSensor
in interfaceTurnout
- Returns:
- the sensor handle or null if no Sensor set
-
setInitialKnownStateFromFeedback
public void 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
public void propertyChange(java.beans.PropertyChangeEvent evt)
React to sensor changes by changing the KnownState if using an appropriate sensor mode.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
sensorPropertyChange
protected void sensorPropertyChange(java.beans.PropertyChangeEvent evt)
-
leadingTurnoutPropertyChange
protected void leadingTurnoutPropertyChange(java.beans.PropertyChangeEvent evt)
-
setBinaryOutput
public void setBinaryOutput(boolean state)
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
public void 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
public float getDivergingLimit()
- Specified by:
getDivergingLimit
in interfaceTurnout
-
getDivergingSpeed
public java.lang.String getDivergingSpeed()
- Specified by:
getDivergingSpeed
in interfaceTurnout
-
setDivergingSpeed
public void setDivergingSpeed(java.lang.String s) throws JmriException
On change, fires Property Change "TurnoutDivergingSpeedChange".- Specified by:
setDivergingSpeed
in interfaceTurnout
- Throws:
JmriException
-
getStraightLimit
public float getStraightLimit()
- Specified by:
getStraightLimit
in interfaceTurnout
-
getStraightSpeed
public java.lang.String getStraightSpeed()
- Specified by:
getStraightSpeed
in interfaceTurnout
-
setStraightSpeed
public void setStraightSpeed(java.lang.String s) throws JmriException
On change, fires Property Change "TurnoutStraightSpeedChange".- Specified by:
setStraightSpeed
in interfaceTurnout
- Throws:
JmriException
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
- Specified by:
vetoableChange
in interfaceNamedBean
- Overrides:
vetoableChange
in classAbstractNamedBean
- Throws:
java.beans.PropertyVetoException
-
getUsageReport
public java.util.List<NamedBeanUsageReport> getUsageReport(NamedBean bean)
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
public boolean 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
@CheckForNull public Turnout 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
public void setLeadingTurnout(@CheckForNull Turnout turnout)
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
public void setLeadingTurnout(@CheckForNull Turnout turnout, boolean followingCommandedState)
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
public boolean 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
public void setFollowingCommandedState(boolean following)
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
-
-