2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#include "frc2/command/CommandState.h"
|
|
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
#include <frc/Timer.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
using namespace frc2;
|
|
|
|
|
CommandState::CommandState(bool interruptible)
|
|
|
|
|
: m_interruptible{interruptible} {
|
|
|
|
|
StartTiming();
|
|
|
|
|
StartRunning();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandState::StartTiming() {
|
|
|
|
|
m_startTime = frc::Timer::GetFPGATimestamp();
|
|
|
|
|
}
|
2021-05-28 22:06:59 -07:00
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
void CommandState::StartRunning() {
|
2021-05-28 22:06:59 -07:00
|
|
|
m_startTime = -1_s;
|
2020-12-28 12:58:06 -08:00
|
|
|
}
|
2021-05-28 22:06:59 -07:00
|
|
|
|
|
|
|
|
units::second_t CommandState::TimeSinceInitialized() const {
|
|
|
|
|
return m_startTime != -1_s ? frc::Timer::GetFPGATimestamp() - m_startTime
|
|
|
|
|
: -1_s;
|
2019-08-25 23:55:59 -04:00
|
|
|
}
|