001package jmri;
002
003import jmri.implementation.AbstractTurnout;
004import jmri.implementation.NoFeedbackTurnoutOperator;
005
006/**
007 * NoFeedBackTurnoutOperation class - specialization of TurnoutOperation to
008 * provide automatic retry for a turnout with no feedback.
009 *
010 * @author John Harper
011 */
012public class NoFeedbackTurnoutOperation extends CommonTurnoutOperation {
013
014    // This class can deal with ANY feedback mode, although it may not be the best one
015    final int feedbackModes
016            = AbstractTurnout.DIRECT | AbstractTurnout.ONESENSOR | AbstractTurnout.TWOSENSOR | AbstractTurnout.INDIRECT | AbstractTurnout.EXACT | AbstractTurnout.MONITORING | AbstractTurnout.LNALTERNATE ;
017
018    /*
019     * Default values and constraints.
020     */
021    static public final int defaultInterval = 300;
022    static public final int defaultMaxTries = 2;
023
024    public NoFeedbackTurnoutOperation(String n, int i, int mt) {
025        super(n, i, mt);
026        setFeedbackModes(feedbackModes);
027    }
028
029    /**
030     * Constructor with default values - this creates the "defining instance" of
031     * the operation type hence it cannot be deleted.
032     */
033    public NoFeedbackTurnoutOperation() { this("NoFeedback", defaultInterval, defaultMaxTries); }
034
035    /**
036     * Return clone with different name.
037     */
038    @Override
039    public TurnoutOperation makeCopy(String n) {
040        return new NoFeedbackTurnoutOperation(n, interval, maxTries);
041    }
042
043    @Override
044    public int getDefaultInterval() {
045        return defaultInterval;
046    }
047
048    @Override
049    public int getDefaultMaxTries() {
050        return defaultMaxTries;
051    }
052
053    static public int getDefaultIntervalStatic() {
054        return defaultInterval;
055    }
056
057    static public int getDefaultMaxTriesStatic() {
058        return defaultMaxTries;
059    }
060
061    /**
062     * Get a TurnoutOperator instance for this operation.
063     *
064     * @return the operator
065     */
066    @Override
067    public TurnoutOperator getOperator(AbstractTurnout t) {
068        return new NoFeedbackTurnoutOperator(t, interval, maxTries);
069    }
070
071}