Files
allwpilib/wpilibc/include/Timer.h
Brad Miller 69d9ad70ab CMake Changes
This is the changes made by Patrick Plenefisch converting the native
code to use CMake and the CMake Maven Plugin, as opposed to the
native Maven plugin. This is to allow for compatibility with newer
versions of the GCC toolchain. All the cpp sources were moved from
maven style directories to cpp style directories for CMake.

Change-Id: I67f5e3608948f37c83b0990d232105a3784f8593
2014-04-01 11:18:29 -04:00

50 lines
1.3 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#ifndef TIMER_H_
#define TIMER_H_
#include "HAL/Semaphore.h"
#include "Base.h"
typedef void (*TimerInterruptHandler)(void *param);
void Wait(double seconds);
double GetClock();
double GetTime();
/**
* 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.
*/
class Timer
{
public:
Timer();
virtual ~Timer();
double Get();
void Reset();
void Start();
void Stop();
bool HasPeriodPassed(double period);
static double GetFPGATimestamp();
static double GetPPCTimestamp();
private:
double m_startTime;
double m_accumulatedTime;
bool m_running;
MUTEX_ID m_semaphore;
DISALLOW_COPY_AND_ASSIGN(Timer);
};
#endif