dtimer.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*- 
00002  *
00003  *  Description:  Driver timer class
00004  *
00005  *  Copyright (C) 2009 Austin Robot Technology                    
00006  *
00007  *  License: Modified BSD Software License Agreement
00008  *
00009  *  $Id: dtimer.h 1161 2011-03-26 02:10:49Z jack.oquin $
00010  */
00011 
00012 #ifndef _D_TIMER_HH_
00013 #define _D_TIMER_HH_
00014 
00015 #include <sys/time.h>
00016 #include <time.h>
00017 #include <art_msgs/ArtHertz.h>
00018 
00020 class DriverTimer
00021 {
00022  public:
00023 
00025   DriverTimer()
00026     {
00027       this->Cancel();
00028     };
00029 
00030   virtual ~DriverTimer() {};
00031 
00033   virtual void Cancel(void)
00034   {
00035     timer_running = false;
00036   }
00037 
00045   virtual bool Check(void)
00046   {
00047     if (!timer_running)
00048       return false;                     // timer not set
00049 
00050     // decrement time remaining by the duration of one cycle
00051     time_remaining -= (1.0 / art_msgs::ArtHertz::STEERING);
00052     return (time_remaining <= 0.0);
00053   }
00054 
00059   virtual void Restart(double duration)
00060   {
00061     if (timer_running && time_remaining > 0.0)
00062       return;
00063 
00064     Start(duration);
00065   }
00066 
00068   virtual void Start(double duration)
00069   {
00070     timer_running = true;
00071     time_remaining = duration;
00072   }
00073 
00074  protected:
00075 
00076   double time_remaining;                //< time remaining until done
00077   bool timer_running;                   //< true when timer running
00078 };
00079 
00080 #endif // _D_TIMER_HH_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


art_servo
Author(s): Austin Robot Technology, Jack O'Quin
autogenerated on Tue Sep 24 2013 10:43:22