001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ 003/* Open Source Software - may be modified and shared by FRC teams. The code */ 004/* must be accompanied by the FIRST BSD license file in the root directory of */ 005/* the project. */ 006/*----------------------------------------------------------------------------*/ 007 008package edu.wpi.first.wpilibj.command; 009 010/** 011 * A {@link TimedCommand} will wait for a timeout before finishing. 012 * {@link TimedCommand} is used to execute a command for a given amount of time. 013 */ 014public class TimedCommand extends Command { 015 /** 016 * Instantiates a TimedCommand with the given name and timeout. 017 * 018 * @param name the name of the command 019 * @param timeout the time the command takes to run (seconds) 020 */ 021 public TimedCommand(String name, double timeout) { 022 super(name, timeout); 023 } 024 025 /** 026 * Instantiates a TimedCommand with the given timeout. 027 * 028 * @param timeout the time the command takes to run (seconds) 029 */ 030 public TimedCommand(double timeout) { 031 super(timeout); 032 } 033 034 /** 035 * Ends command when timed out. 036 */ 037 protected boolean isFinished() { 038 return isTimedOut(); 039 } 040}