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