2016-11-18 17:42:40 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
2016-11-18 17:42:40 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/Twine.h>
|
2016-11-18 17:42:40 -05:00
|
|
|
|
|
|
|
|
#include "Commands/Command.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
|
2016-11-19 00:26:22 -08:00
|
|
|
/**
|
2017-11-16 00:33:51 -08:00
|
|
|
* A TimedCommand will wait for a timeout before finishing.
|
|
|
|
|
*
|
|
|
|
|
* TimedCommand is used to execute a command for a given amount of time.
|
2016-11-19 00:26:22 -08:00
|
|
|
*/
|
2016-11-18 17:42:40 -05:00
|
|
|
class TimedCommand : public Command {
|
|
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Creates a new TimedCommand with the given name and timeout.
|
|
|
|
|
*
|
|
|
|
|
* @param name the name of the command
|
|
|
|
|
* @param timeout the time (in seconds) before this command "times out"
|
|
|
|
|
*/
|
2018-04-29 23:33:19 -07:00
|
|
|
TimedCommand(const wpi::Twine& name, double timeout);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new WaitCommand with the given timeout.
|
|
|
|
|
*
|
|
|
|
|
* @param timeout the time (in seconds) before this command "times out"
|
|
|
|
|
*/
|
2016-11-18 17:42:40 -05:00
|
|
|
explicit TimedCommand(double timeout);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
2016-11-18 17:42:40 -05:00
|
|
|
virtual ~TimedCommand() = default;
|
|
|
|
|
|
|
|
|
|
protected:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Ends command when timed out.
|
|
|
|
|
*/
|
2016-11-19 00:26:22 -08:00
|
|
|
bool IsFinished() override;
|
2016-11-18 17:42:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace frc
|