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    static final int SUPPORTED_FEEDBACK_MODES
016            = AbstractTurnout.DIRECT | AbstractTurnout.ONESENSOR | AbstractTurnout.TWOSENSOR
017            | AbstractTurnout.INDIRECT | AbstractTurnout.EXACT | AbstractTurnout.DELAYED
018            | AbstractTurnout.MONITORING | AbstractTurnout.LNALTERNATE ;
019
020    /*
021     * Default values and constraints.
022     */
023    static public final int defaultInterval = 300;
024    static public final int defaultMaxTries = 2;
025
026    public NoFeedbackTurnoutOperation(String n, int i, int mt) {
027        super(n, i, mt);
028        setFeedbackModes(SUPPORTED_FEEDBACK_MODES);
029    }
030
031    /**
032     * Constructor with default values - this creates the "defining instance" of
033     * the operation type hence it cannot be deleted.
034     */
035    public NoFeedbackTurnoutOperation() { this("NoFeedback", defaultInterval, defaultMaxTries); }
036
037    /**
038     * Return clone with different name.
039     */
040    @Override
041    public TurnoutOperation makeCopy(String n) {
042        return new NoFeedbackTurnoutOperation(n, interval, maxTries);
043    }
044
045    @Override
046    public int getDefaultInterval() {
047        return defaultInterval;
048    }
049
050    @Override
051    public int getDefaultMaxTries() {
052        return defaultMaxTries;
053    }
054
055    static public int getDefaultIntervalStatic() {
056        return defaultInterval;
057    }
058
059    static public int getDefaultMaxTriesStatic() {
060        return defaultMaxTries;
061    }
062
063    /**
064     * Get a TurnoutOperator instance for this operation.
065     *
066     * @return the operator
067     */
068    @Override
069    public TurnoutOperator getOperator(AbstractTurnout t) {
070        return new NoFeedbackTurnoutOperator(t, interval, maxTries);
071    }
072
073    @Override
074    public String getToolTip(){
075        return Bundle.getMessage("TurnoutOperationNoFeedbackTip");
076    }
077
078}