|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Turnout
Represent a Turnout on the layout.
A Turnout has two states:
There are a number of reasons that commandedState and knownState differ:
Turnout feedback is involved in the connection between these two states; for more information see the feedback page.
The AbstractTurnout class contains a basic implementation of the state and messaging code, and forms a useful start for a system-specific implementation. Specific implementations in the jmrix package, e.g. for LocoNet and NCE, will convert to and from the layout commands.
The states and names are Java Bean parameters, so that listeners can be registered to be notified of any changes.
A sample use of the Turnout interface can be seen in the jmri.jmrit.simpleturnoutctrl.SimpleTurnoutCtrlFrame class, which provides a simple GUI for controlling a single turnout.
Each Turnout object has a two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, and provides a unique mapping to the layout control system (e.g. LocoNet, NCE, etc) and address within that system.
Turnouts exhibit some complex behaviors. At the same time, they are sometimes used as generic binary outputs where those get in the way. Eventually, we need to have a separate e.g. Output class, but for now you can defeat much of the advanced behaviors with the setBinaryOutput(true) method. This is a configuration property; changing it on the fly may give unexpected results. It's value is not persisted.
This file is part of JMRI.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
TurnoutManager,
InstanceManager,
SimpleTurnoutCtrlFrame| Field Summary | |
|---|---|
static int |
CABLOCKOUT
Constant representing turnout lockout cab commands |
static int |
CLOSED
Constant representing an "closed" state, either in readback or as a commanded state. |
static int |
DIRECT
Constant representing "direct feedback method". |
static int |
EXACT
Constant representing "exact feedback method". |
static int |
INDIRECT
Constant representing "indirect feedback". |
static int |
LOCKED
Constant representing a locked turnout |
static int |
MONITORING
Constant representing "feedback by monitoring sent commands". |
static int |
ONESENSOR
Constant representing "feedback by monitoring one sensor". |
static int |
PUSHBUTTONLOCKOUT
Constant representing turnout lockout pushbuttons |
static int |
SIGNAL
Constant representing "feedback for signals" . |
static int |
THROWN
Constant representing an "thrown" state, either in readback or as a commanded state. |
static int |
TWOSENSOR
Constant representing "feedback by monitoring two sensors". |
static int |
UNLOCKED
Constant representing a unlocked turnout |
| Fields inherited from interface jmri.NamedBean |
|---|
INCONSISTENT, UNKNOWN |
| Method Summary | |
|---|---|
boolean |
canInvert()
Determine if turnout can be inverted If true turnouts can be inverted |
boolean |
canLock(int turnoutLockout)
Determine if turnout can be locked. |
void |
enableLockOperation(int turnoutLockout,
boolean locked)
Enable turnout lock operators. |
int |
getCommandedState()
Query the commanded state. |
int |
getControlType()
Get control type. |
String |
getDecoderName()
Get a human readable representation of the decoder type for this turnout. |
float |
getDivergingLimit()
|
String |
getDivergingSpeed()
|
int |
getFeedbackMode()
Get the feedback mode in machine readable form. |
String |
getFeedbackModeName()
Get the feedback mode in human readable form. |
NamedBeanHandle<Sensor> |
getFirstNamedSensor()
Get the first sensor, if defined. |
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 turnout inverted If true commands are reversed to layout |
int |
getKnownState()
Query the known state. |
boolean |
getLocked(int turnoutLockout)
Get turnout locked If true turnout is locked, must specify which type of lock, will return true if both tested and either type is locked. |
int |
getNumberOutputBits()
Get number of output bits. |
boolean |
getReportLocked()
Determine if we should send a message to console when we detect that a turnout that is locked has been accessed by a cab on the layout. |
NamedBeanHandle<Sensor> |
getSecondNamedSensor()
Get the first sensor, if defined. |
Sensor |
getSecondSensor()
Get the Second sensor, if defined. |
float |
getStraightLimit()
|
String |
getStraightSpeed()
|
TurnoutOperation |
getTurnoutOperation()
|
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 |
void |
provideFirstFeedbackSensor(String pName)
Provide Sensor objects needed for some feedback types. |
void |
provideSecondFeedbackSensor(String pName)
|
void |
setBinaryOutput(boolean state)
Turn this object into just a binary output. |
void |
setCommandedState(int s)
Change the commanded state, which results in the relevant command(s) being sent to the hardware. |
void |
setControlType(int num)
Set control type. |
void |
setDecoderName(String decoderName)
Set a human readable representation of the decoder type for this turnout. |
void |
setDivergingSpeed(String s)
|
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)
Lock a turnout. |
void |
setNumberOutputBits(int num)
Set number of output bits. |
void |
setReportLocked(boolean reportLocked)
Set turnout report If true report any attempts by a cab to modify turnout state |
void |
setStraightSpeed(String s)
|
void |
setTurnoutOperation(TurnoutOperation toper)
set current automation class |
| Field Detail |
|---|
static final int CLOSED
static final int THROWN
static final int DIRECT
static final int EXACT
static final int INDIRECT
static final int MONITORING
static final int ONESENSOR
static final int TWOSENSOR
static final int SIGNAL
static final int CABLOCKOUT
static final int PUSHBUTTONLOCKOUT
static final int UNLOCKED
static final int LOCKED
| Method Detail |
|---|
int getKnownState()
void setCommandedState(int s)
int getCommandedState()
boolean isConsistentState()
int getValidFeedbackTypes()
String[] getValidFeedbackNames()
void setFeedbackMode(String mode)
throws IllegalArgumentException
getValidFeedbackNames() call.
IllegalArgumentException
void setFeedbackMode(int mode)
throws IllegalArgumentException
getValidFeedbackTypes() call.
Having more than one bit set is an error.
IllegalArgumentExceptionString getFeedbackModeName()
getValidFeedbackNames() call.
int getFeedbackMode()
getValidFeedbackTypes() call.
boolean getInhibitOperation()
void setInhibitOperation(boolean io)
io - TurnoutOperation getTurnoutOperation()
void setTurnoutOperation(TurnoutOperation toper)
toper - TurnoutOperation subclass instance
void provideFirstFeedbackSensor(String pName)
throws JmriException
The second sensor can be null if needed.
Sensor-based feedback will not function until these sensors have been provided.
JmriException
void provideSecondFeedbackSensor(String pName)
throws JmriException
JmriExceptionSensor getFirstSensor()
Returns null if no Sensor recorded.
NamedBeanHandle<Sensor> getFirstNamedSensor()
Returns null if no Sensor recorded.
Sensor getSecondSensor()
Returns null if no Sensor recorded.
NamedBeanHandle<Sensor> getSecondNamedSensor()
Returns null if no Sensor recorded.
void setInitialKnownStateFromFeedback()
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.
int getNumberOutputBits()
Currently must be one or two.
void setNumberOutputBits(int num)
Currently must be one or two.
int getControlType()
Currently must be either 0 for steady state, or n for pulse for n time units.
void setControlType(int num)
Currently must be either 0 for steady state, or n for pulse for n time units.
boolean getInverted()
If true commands are reversed to layout
void setInverted(boolean inverted)
If true commands are reversed to layout.
Changing this changes the known state from CLOSED to THROWN and vice-versa, with notifications; UNKNOWN and INCONSISTENT are left unchanged, as is the commanded state.
boolean canInvert()
If true turnouts can be inverted
boolean getLocked(int turnoutLockout)
If true turnout is locked, must specify which type of lock, will return true if both tested and either type is locked.
void enableLockOperation(int turnoutLockout,
boolean locked)
If true the type of lock specified is enabled.
boolean canLock(int turnoutLockout)
If true turnouts can be locked.
void setLocked(int turnoutLockout,
boolean locked)
If true turnout is to be locked.
boolean getReportLocked()
void setReportLocked(boolean reportLocked)
If true report any attempts by a cab to modify turnout state
String[] getValidDecoderNames()
String getDecoderName()
void setDecoderName(String decoderName)
void setBinaryOutput(boolean state)
float getDivergingLimit()
String getDivergingSpeed()
void setDivergingSpeed(String s)
throws JmriException
JmriExceptionfloat getStraightLimit()
String getStraightSpeed()
void setStraightSpeed(String s)
throws JmriException
JmriException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||