|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.AbstractNamedBean
jmri.AbstractTurnout
public abstract class AbstractTurnout
Abstract base for the Turnout interface.
Implements basic feedback modes:
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. Description: Abstract class providing the basic logic of the Turnout interface
| Field Summary | |
|---|---|
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 |
inhibitOperation
|
protected TurnoutOperator |
myOperator
|
protected TurnoutOperation |
myTurnoutOperation
|
| Fields inherited from interface jmri.Turnout |
|---|
CABLOCKOUT, CLOSED, DIRECT, EXACT, INDIRECT, LOCKED, MONITORING, ONESENSOR, PUSHBUTTONLOCKOUT, SIGNAL, THROWN, TWOSENSOR, UNLOCKED |
| Fields inherited from interface jmri.NamedBean |
|---|
INCONSISTENT, UNKNOWN |
| Constructor Summary | |
|---|---|
protected |
AbstractTurnout(String systemName)
|
protected |
AbstractTurnout(String systemName,
String userName)
|
| Method Summary | |
|---|---|
boolean |
canInvert()
Determine if the turnouts can be inverted. |
boolean |
canLock(int turnoutLockout)
Determine if turnout can be locked. |
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. |
int |
getCommandedState()
Query the commanded state. |
int |
getControlType()
Get control type. |
TurnoutOperator |
getCurrentOperator()
|
String |
getDecoderName()
Get a human readable representation of the decoder type for this turnout. |
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. |
Sensor |
getFirstSensor()
Get the first sensor, if defined. |
boolean |
getInhibitOperation()
Get the indicator for whether automatic operation (retry) has been inhibited for this turnout |
boolean |
getInverted()
Get the turnout inverted state. |
int |
getKnownState()
Query the known state. |
boolean |
getLocked(int turnoutLockout)
Determine if turnout is locked. |
int |
getNumberOutputBits()
Get number of output bits. |
boolean |
getReportLocked()
When true, report to console anytime a cab attempts to change the state of a turnout on the layout. |
Sensor |
getSecondSensor()
Get the Second sensor, if defined. |
int |
getState()
Implement a shorter name for getKnownState. |
TurnoutOperation |
getTurnoutOperation()
|
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 |
String[] |
getValidDecoderNames()
Get a human readable representation of the decoder types. |
String[] |
getValidFeedbackNames()
Get a human readable representation of the feedback type. |
int |
getValidFeedbackTypes()
Get a representation of the feedback type. |
boolean |
isConsistentState()
Show whether state is one you can safely run trains over |
protected void |
newCommandedState(int s)
Sets a new Commanded state, if need be notifying the listeners, but does NOT send the command downstream. |
protected void |
newKnownState(int s)
Add a protected 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 |
provideFirstFeedbackSensor(Sensor s)
Provide Sensor objects needed for some feedback types. |
void |
provideSecondFeedbackSensor(Sensor s)
|
protected void |
sensorPropertyChange(PropertyChangeEvent evt)
|
void |
setCommandedState(int s)
Public access to changing turnout state. |
void |
setControlType(int num)
Set control type. |
void |
setDecoderName(String decoderName)
Set a human readable representation of the decoder type for this turnout. |
void |
setFeedbackMode(int mode)
Set the feedback mode from a integer. |
void |
setFeedbackMode(String mode)
Set the feedback mode from a human readable name. |
void |
setInhibitOperation(boolean io)
Change the value of the inhibit operation indicator |
void |
setInitialKnownStateFromFeedback()
Sets the initial known state (CLOSED,THROWN,UNKNOWN) from feedback information, if appropriate. |
void |
setInverted(boolean inverted)
Set turnout inverted If true commands are reversed to layout |
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 |
setTurnoutOperation(TurnoutOperation toper)
set current automation class |
protected void |
turnoutPushbuttonLockout()
|
protected abstract void |
turnoutPushbuttonLockout(boolean locked)
|
| Methods inherited from class jmri.AbstractNamedBean |
|---|
addPropertyChangeListener, firePropertyChange, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setUserName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.NamedBean |
|---|
addPropertyChangeListener, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setUserName |
| Field Detail |
|---|
protected String[] _validFeedbackNames
protected int[] _validFeedbackModes
protected int _validFeedbackTypes
protected int _activeFeedbackType
protected boolean _inverted
protected boolean _cabLockout
protected boolean _pushButtonLockout
protected boolean _enableCabLockout
protected boolean _enablePushButtonLockout
protected boolean _reportLocked
protected String[] _validDecoderNames
protected String _decoderName
protected TurnoutOperator myOperator
protected TurnoutOperation myTurnoutOperation
protected boolean inhibitOperation
| Constructor Detail |
|---|
protected AbstractTurnout(String systemName)
protected AbstractTurnout(String systemName,
String userName)
| Method Detail |
|---|
protected abstract void forwardCommandChangeToLayout(int s)
s - new state valueprotected void forwardCommandChangeToLayout()
protected void newCommandedState(int s)
public int getKnownState()
Turnout
getKnownState in interface Turnoutpublic void setCommandedState(int s)
setCommandedState in interface Turnoutpublic int getCommandedState()
Turnout
getCommandedState in interface Turnoutprotected void newKnownState(int s)
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.
Not intended for general use, e.g. for users to set the KnownState.
s - New state valuepublic boolean isConsistentState()
isConsistentState in interface Turnoutpublic void setState(int s)
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.
setState in interface NamedBeanpublic int getState()
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.
getState in interface NamedBeanpublic int getNumberOutputBits()
TurnoutCurrently must be one or two.
getNumberOutputBits in interface Turnoutpublic void setNumberOutputBits(int num)
TurnoutCurrently must be one or two.
setNumberOutputBits in interface Turnoutpublic int getControlType()
TurnoutCurrently must be either 0 for steady state, or n for pulse for n time units.
getControlType in interface Turnoutpublic void setControlType(int num)
TurnoutCurrently must be either 0 for steady state, or n for pulse for n time units.
setControlType in interface Turnoutpublic int getValidFeedbackTypes()
Turnout
getValidFeedbackTypes in interface Turnoutpublic String[] getValidFeedbackNames()
Turnout
getValidFeedbackNames in interface Turnoutpublic void setFeedbackMode(String mode)
TurnoutTurnout.getValidFeedbackNames() call.
setFeedbackMode in interface Turnoutpublic void setFeedbackMode(int mode)
TurnoutTurnout.getValidFeedbackTypes() call.
Having more than one bit set is an error.
setFeedbackMode in interface Turnoutpublic int getFeedbackMode()
TurnoutTurnout.getValidFeedbackTypes() call.
getFeedbackMode in interface Turnoutpublic String getFeedbackModeName()
TurnoutTurnout.getValidFeedbackNames() call.
getFeedbackModeName in interface Turnoutpublic void setInverted(boolean inverted)
TurnoutIf true commands are reversed to layout
setInverted in interface Turnoutpublic final boolean getInverted()
Used in polling loops in system-specific code, so made final to allow optimization.
getInverted in interface Turnoutpublic boolean canInvert()
canInvert in interface Turnout
public void setLocked(int turnoutLockout,
boolean locked)
setLocked in interface Turnoutlocked - public boolean getLocked(int turnoutLockout)
getLocked in interface Turnoutpublic boolean canLock(int turnoutLockout)
TurnoutIf true turnouts can be locked.
canLock in interface Turnout
public void enableLockOperation(int turnoutLockout,
boolean enabled)
TurnoutIf true the type of lock specified is enabled.
enableLockOperation in interface Turnoutpublic void setReportLocked(boolean reportLocked)
setReportLocked in interface Turnoutpublic boolean getReportLocked()
getReportLocked in interface Turnoutpublic String[] getValidDecoderNames()
Turnout
getValidDecoderNames in interface Turnoutpublic String getDecoderName()
Turnout
getDecoderName in interface Turnoutpublic void setDecoderName(String decoderName)
Turnout
setDecoderName in interface Turnoutprotected abstract void turnoutPushbuttonLockout(boolean locked)
protected void turnoutPushbuttonLockout()
public TurnoutOperator getCurrentOperator()
public TurnoutOperation getTurnoutOperation()
getTurnoutOperation in interface Turnoutpublic void setTurnoutOperation(TurnoutOperation toper)
Turnout
setTurnoutOperation in interface Turnouttoper - TurnoutOperation subclass instanceprotected void operationPropertyChange(PropertyChangeEvent evt)
public boolean getInhibitOperation()
Turnout
getInhibitOperation in interface Turnoutpublic void setInhibitOperation(boolean io)
Turnout
setInhibitOperation in interface Turnoutprotected TurnoutOperator getTurnoutOperator()
protected int getFeedbackModeForOperation()
public void provideFirstFeedbackSensor(Sensor s)
TurnoutThe second sensor can be null if needed.
Sensor-based feedback will not function until these sensors have been provided.
provideFirstFeedbackSensor in interface Turnoutpublic void provideSecondFeedbackSensor(Sensor s)
provideSecondFeedbackSensor in interface Turnoutpublic Sensor getFirstSensor()
TurnoutReturns null if no Sensor recorded.
getFirstSensor in interface Turnoutpublic Sensor getSecondSensor()
TurnoutReturns null if no Sensor recorded.
getSecondSensor in interface Turnoutpublic void setInitialKnownStateFromFeedback()
TurnoutThis 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.
setInitialKnownStateFromFeedback in interface Turnoutpublic void propertyChange(PropertyChangeEvent evt)
propertyChange in interface PropertyChangeListenerprotected void sensorPropertyChange(PropertyChangeEvent evt)
public void dispose()
NamedBeanFor 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.
dispose in interface NamedBeandispose in class AbstractNamedBean
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||