001package jmri;
002
003import jmri.implementation.AbstractTurnout;
004import jmri.implementation.RawTurnoutOperator;
005
006/**
007 * RawTurnoutOperation class - specialization of TurnoutOperation to provide
008 * automatic retry for a turnout with no feedback by sending raw NMRA commands
009 * to the turnout. This class is based on the NoTurnoutOperation class.
010 *
011 * @author Paul Bender
012 */
013public class RawTurnoutOperation extends CommonTurnoutOperation {
014
015    // This class should only be used with DIRECT, ONESENSOR or TWOSENSOR
016    // feedback modes.
017    static final int SUPPORTED_FEEDBACK_MODES
018            = Turnout.DIRECT | Turnout.EXACT | Turnout.INDIRECT
019            | Turnout.ONESENSOR | Turnout.TWOSENSOR | Turnout.LNALTERNATE ;
020
021    /*
022     * Default values and constraints.
023     */
024    static public final int defaultInterval = 300;
025    static public final int defaultMaxTries = 1;
026
027    public RawTurnoutOperation(String n, int i, int mt) {
028        super(n, i, mt);
029        setFeedbackModes(SUPPORTED_FEEDBACK_MODES);
030    }
031
032    /**
033     * Constructor with default values - this creates the "defining instance" of
034     * the operation type hence it cannot be deleted.
035     */
036    public RawTurnoutOperation() { this("Raw", defaultInterval, defaultMaxTries); }
037
038    /**
039     * Return clone with different name.
040     */
041    @Override
042    public TurnoutOperation makeCopy(String n) {
043        return new RawTurnoutOperation(n, interval, maxTries);
044    }
045
046    @Override
047    public int getDefaultInterval() {
048        return defaultInterval;
049    }
050
051    @Override
052    public int getDefaultMaxTries() {
053        return defaultMaxTries;
054    }
055
056    static public int getDefaultIntervalStatic() {
057        return defaultInterval;
058    }
059
060    static public int getDefaultMaxTriesStatic() {
061        return defaultMaxTries;
062    }
063
064    /**
065     * Get a TurnoutOperator instance for this operation.
066     *
067     * @return the operator
068     */
069    @Override
070    public TurnoutOperator getOperator(AbstractTurnout t) {
071        return new RawTurnoutOperator(t, interval, maxTries);
072    }
073
074    @Override
075    public String getToolTip(){
076        return Bundle.getMessage("TurnoutOperationRawTip");
077    }
078
079}