Moved C++ comments from source files to headers (#1111)

Also sorted functions in C++ sources to match order in related headers.
This commit is contained in:
Tyler Veness
2018-05-31 20:47:15 -07:00
committed by Peter Johnson
parent d9971a705a
commit 8c680a26f8
234 changed files with 9936 additions and 9309 deletions

View File

@@ -17,34 +17,12 @@
namespace frc {
/**
* Pause the task for a specified time.
*
* Pause the execution of the program for a specified period of time given in
* seconds. Motors will continue to run at their last assigned values, and
* sensors will continue to update. Only the task containing the wait will pause
* until the wait time is expired.
*
* @param seconds Length of time to pause, in seconds.
*/
void Wait(double seconds) {
std::this_thread::sleep_for(std::chrono::duration<double>(seconds));
}
/**
* Return the FPGA system clock time in seconds.
*
* This is deprecated and just forwards to Timer::GetFPGATimestamp().
*
* @return Robot running time in seconds.
*/
double GetClock() { return Timer::GetFPGATimestamp(); }
/**
* @brief Gives real-time clock system time with nanosecond resolution
* @return The time, just in case you want the robot to start autonomous at 8pm
* on Saturday.
*/
double GetTime() {
using std::chrono::duration;
using std::chrono::duration_cast;
@@ -60,21 +38,9 @@ using namespace frc;
// for compatibility with msvc12--see C2864
const double Timer::kRolloverTime = (1ll << 32) / 1e6;
/**
* Create a new timer object.
*
* Create a new timer object and reset the time to zero. The timer is initially
* not running and must be started.
*/
Timer::Timer() { Reset(); }
/**
* Get the current time from the timer. If the clock is running it is derived
* from the current system clock the start time stored in the timer class. If
* the clock is not running, then return the time when it was last stopped.
*
* @return Current time value for this timer in seconds
*/
double Timer::Get() const {
double result;
double currentTime = GetFPGATimestamp();
@@ -96,24 +62,12 @@ double Timer::Get() const {
return result;
}
/**
* Reset the timer by setting the time to 0.
*
* Make the timer startTime the current time so new requests will be relative to
* now.
*/
void Timer::Reset() {
std::lock_guard<wpi::mutex> lock(m_mutex);
m_accumulatedTime = 0;
m_startTime = GetFPGATimestamp();
}
/**
* Start the timer running.
*
* Just set the running flag to true indicating that all time requests should be
* relative to the system clock.
*/
void Timer::Start() {
std::lock_guard<wpi::mutex> lock(m_mutex);
if (!m_running) {
@@ -122,13 +76,6 @@ void Timer::Start() {
}
}
/**
* Stop the timer.
*
* This computes the time as of now and clears the running flag, causing all
* subsequent time requests to be read from the accumulated time rather than
* looking at the system clock.
*/
void Timer::Stop() {
double temp = Get();
@@ -139,14 +86,6 @@ void Timer::Stop() {
}
}
/**
* Check if the period specified has passed and if it has, advance the start
* time by that period. This is useful to decide if it's time to do periodic
* work without drifting later by the time it took to get around to checking.
*
* @param period The period to check for (in seconds).
* @return True if the period has passed.
*/
bool Timer::HasPeriodPassed(double period) {
if (Get() > period) {
std::lock_guard<wpi::mutex> lock(m_mutex);
@@ -158,34 +97,11 @@ bool Timer::HasPeriodPassed(double period) {
return false;
}
/**
* Return the FPGA system clock time in seconds.
*
* Return the time from the FPGA hardware clock in seconds since the FPGA
* started. Rolls over after 71 minutes.
*
* @returns Robot running time in seconds.
*/
double Timer::GetFPGATimestamp() {
// FPGA returns the timestamp in microseconds
return RobotController::GetFPGATime() * 1.0e-6;
}
/**
* Return the approximate match time.
*
* The FMS does not send an official match time to the robots, but does send an
* approximate match time. The value will count down the time remaining in the
* current period (auto or teleop).
*
* Warning: This is not an official time (so it cannot be used to dispute ref
* calls or guarantee that a function will trigger before the match ends).
*
* The Practice Match function of the DS approximates the behaviour seen on the
* field.
*
* @return Time remaining in current match period (auto or teleop)
*/
double Timer::GetMatchTime() {
return DriverStation::GetInstance().GetMatchTime();
}