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