WPILib 2012
WPILibRoboticsLibraryforFRC
Timer.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef TIMER_H_
00008 #define TIMER_H_
00009 
00010 #include "semLib.h"
00011 #include "Base.h"
00012 
00013 typedef void (*TimerInterruptHandler)(void *param);
00014 
00015 void Wait(double seconds);
00016 double GetClock();
00017 double GetTime();
00018 
00019 
00027 class Timer
00028 {
00029 public:
00030         Timer();
00031         virtual ~Timer();
00032         double Get();
00033         void Reset();
00034         void Start();
00035         void Stop();
00036         bool HasPeriodPassed(double period);
00037 
00038         static double GetFPGATimestamp();
00039         static double GetPPCTimestamp();
00040 
00041 private:
00042         double m_startTime;
00043         double m_accumulatedTime;
00044         bool m_running;
00045         SEM_ID m_semaphore;
00046         DISALLOW_COPY_AND_ASSIGN(Timer);
00047 };
00048 
00049 #endif
 All Classes Functions Variables