mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Change C++ WaitCommand to use units (#1865)
Also remove unique_ptr usage.
This commit is contained in:
@@ -9,19 +9,18 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
WaitCommand::WaitCommand(double seconds) : m_duration{seconds} {
|
||||
auto secondsStr = std::to_string(seconds);
|
||||
SetName(wpi::Twine(m_name) + ": " + wpi::Twine(secondsStr) + " seconds");
|
||||
m_timer = std::make_unique<frc::Timer>();
|
||||
WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
|
||||
auto durationStr = std::to_string(duration.to<double>());
|
||||
SetName(wpi::Twine(m_name) + ": " + wpi::Twine(durationStr) + " seconds");
|
||||
}
|
||||
|
||||
void WaitCommand::Initialize() {
|
||||
m_timer->Reset();
|
||||
m_timer->Start();
|
||||
m_timer.Reset();
|
||||
m_timer.Start();
|
||||
}
|
||||
|
||||
void WaitCommand::End(bool interrupted) { m_timer->Stop(); }
|
||||
void WaitCommand::End(bool interrupted) { m_timer.Stop(); }
|
||||
|
||||
bool WaitCommand::IsFinished() { return m_timer->HasPeriodPassed(m_duration); }
|
||||
bool WaitCommand::IsFinished() { return m_timer.HasPeriodPassed(m_duration); }
|
||||
|
||||
bool WaitCommand::RunsWhenDisabled() const { return true; }
|
||||
|
||||
Reference in New Issue
Block a user