iCub-main
mcEventDownsampler.h
Go to the documentation of this file.
1 
2 #ifndef __EVENT_DOWNSAMPLER_H_
3 #define __EVENT_DOWNSAMPLER_H_
4 
5 #include <string>
6 #include <mutex>
7 
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <yarp/os/Timer.h>
11 #include <yarp/os/Time.h>
12 #include <yarp/os/LogStream.h>
13 #include <yarp/os/LogComponent.h>
14 
15 namespace mced {
16 
18  {
19  public:
20 
25  struct Config
26  {
27  double period {.01};
28  size_t threshold {10};
29  std::string subcomponent {""};
30  std::string info {""};
31  };
32 
38 
44 
49  bool start();
50 
55  bool stop();
56 
62  bool canprint();
64 
65  private:
75  bool step(const yarp::os::YarpTimerEvent &event);
76 
81  void printreport();
82 
84  yarp::os::Timer* timer {nullptr};
85 
87  double expire_time;
88 
92  bool isdownsampling {false};
93 
95  size_t counter {0};
96 
98  size_t latch_1{0};
99 
101  size_t latch_2{0};
102 
104  std::mutex *mutex {nullptr};
105  };
106 
107 } // mced
108 
109 #endif // __EVENT_DOWNSAMPLER_H_
~mcEventDownsampler()
Destroy the Event Downsampler object.
bool start()
Instantiates the yarp::os::Timer object and starts it.
mcEventDownsampler()
Construct a new Event Downsampler object and instantiates the mutex needed by the timer.
bool canprint()
Called by the object that implements the downsampler.
bool stop()
Stops the timer.