rate.h
Go to the documentation of this file.
1 #ifndef RATE_H
2 #define RATE_H
3 
4 #include <time.h>
5 #include <sys/time.h>
6 #include <argos3/core/utility/math/general.h>
7 
8 namespace argos {
9 
10  class CRate {
11 
12  public:
13 
14  CRate(Real f_rate);
15 
16  ~CRate() {}
17 
18  void Sleep();
19 
20  inline Real GetRate() const {
21  return m_fNominalRate;
22  }
23 
24  void SetRate(Real f_rate);
25 
26  private:
27 
28  Real m_fNominalRate;
29  UInt64 m_unNominalPeriod;
30  ::timespec m_tSleepPeriod;
31  ::timeval m_tPast;
32  ::timeval m_tNow;
33  ::timeval m_tDiff;
34 
35  };
36 
37 }
38 
39 #endif // RATE_H
CRate(Real f_rate)
Definition: rate.cpp:9
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
void SetRate(Real f_rate)
Definition: rate.cpp:46
Real GetRate() const
Definition: rate.h:20
unsigned long long UInt64
64-bit unsigned integer.
Definition: datatypes.h:107
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
void Sleep()
Definition: rate.cpp:17
~CRate()
Definition: rate.h:16