001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.command;
006
007/**
008 * A {@link TimedCommand} will wait for a timeout before finishing. {@link TimedCommand} is used to
009 * execute a command for a given amount of time.
010 */
011public class TimedCommand extends Command {
012  /**
013   * Instantiates a TimedCommand with the given name and timeout.
014   *
015   * @param name the name of the command
016   * @param timeout the time the command takes to run (seconds)
017   */
018  public TimedCommand(String name, double timeout) {
019    super(name, timeout);
020  }
021
022  /**
023   * Instantiates a TimedCommand with the given timeout.
024   *
025   * @param timeout the time the command takes to run (seconds)
026   */
027  public TimedCommand(double timeout) {
028    super(timeout);
029  }
030
031  /**
032   * Instantiates a TimedCommand with the given name and timeout.
033   *
034   * @param name the name of the command
035   * @param timeout the time the command takes to run (seconds)
036   * @param subsystem the subsystem that this command requires
037   */
038  public TimedCommand(String name, double timeout, Subsystem subsystem) {
039    super(name, timeout, subsystem);
040  }
041
042  /**
043   * Instantiates a TimedCommand with the given timeout.
044   *
045   * @param timeout the time the command takes to run (seconds)
046   * @param subsystem the subsystem that this command requires
047   */
048  public TimedCommand(double timeout, Subsystem subsystem) {
049    super(timeout, subsystem);
050  }
051
052  /** Ends command when timed out. */
053  @Override
054  protected boolean isFinished() {
055    return isTimedOut();
056  }
057}