comparison include/VirtualClock.h @ 135:e77e2e712fbc ClockSync

To work with the ClockSync plugin
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 12 Sep 2015 20:05:55 +0100
parents
children 44d07fa9bd03
comparison
equal deleted inserted replaced
133:04b1678614c9 135:e77e2e712fbc
1 #ifndef VIRTUAL_CLOCK_H_INCLUDED
2 #define VIRTUAL_CLOCK_H_INCLUDED
3
4 #include "stats.hpp"
5 #include "Clock.h"
6
7 class VirtualClock{
8 private:
9 myClock_t startTime;
10 myClock_t lastSync;
11 bool firstRun;
12 double period;
13 MovingAverage<double> movingAverage;
14 public:
15 void init();
16 VirtualClock();
17 /**
18 Call this method at regular intervals to sync che virtual clock
19 */
20 void sync();
21 /**
22 Call this method asynchronously, passing a number of equally spaced events that have elapsed since the last call.
23 */
24 void sync(double count);
25 /**
26 Get the current time according to the VirtualClock.
27
28 @return Time elapsed since the first call to sync(), in period units.
29 */
30 double getNow();
31 /**
32 Get the length of the period.
33
34 Get the length of the period (difference between calls to sync() after various filtering operations)
35 */
36 double getPeriod();
37 };
38
39 #endif /* VIRTUAL_CLOCK_H_INCLUDED */