Now you can download a copy of these docs so you can use them offline! Download now

#include <Timer.h>

Public Member Functions

 Timer ()
 
double Get ()
 
void Reset ()
 
void Start ()
 
void Stop ()
 
bool HasPeriodPassed (double period)
 

Static Public Member Functions

static double GetFPGATimestamp ()
 
static double GetPPCTimestamp ()
 

Detailed Description

Timer objects measure accumulated time in seconds. The timer object functions like a stopwatch. It can be started, stopped, and cleared. When the timer is running its value counts up in seconds. When stopped, the timer holds the current value. The implementation simply records the time when started and subtracts the current time whenever the value is requested.

Definition at line 27 of file Timer.h.

Constructor & Destructor Documentation

Timer::Timer ( )

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.

Definition at line 61 of file Timer.cpp.

Member Function Documentation

double Timer::Get ( )

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.

Returns
unsigned Current time value for this timer in seconds

Definition at line 85 of file Timer.cpp.

bool Timer::HasPeriodPassed ( double  period)

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.

Parameters
periodThe period to check for (in seconds).
Returns
If the period has passed.

Definition at line 158 of file Timer.cpp.

void Timer::Reset ( )

Reset the timer by setting the time to 0.

Make the timer startTime the current time so new requests will be relative to now

Definition at line 110 of file Timer.cpp.

void Timer::Start ( )

Start the timer running. Just set the running flag to true indicating that all time requests should be relative to the system clock.

Definition at line 122 of file Timer.cpp.

void Timer::Stop ( )

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.

Definition at line 138 of file Timer.cpp.


The documentation for this class was generated from the following files:

Generated on Sat Apr 26 2014 12:26:47 for WPILibC++ by doxygen 1.8.6