napabaselibs / monl / plugins / clockdrift_measure.h @ d1e0f2ca
History  View  Annotate  Download (2.22 KB)
1 
/***************************************************************************


2 
* Copyright (C) 2009 by Robert Birke

3 
* robert.birke@polito.it

4 
*

5 
* This library is free software; you can redistribute it and/or

6 
* modify it under the terms of the GNU Lesser General Public

7 
* License as published by the Free Software Foundation; either

8 
* version 2.1 of the License, or (at your option) any later version.

9 

10 
* This library is distributed in the hope that it will be useful,

11 
* but WITHOUT ANY WARRANTY; without even the implied warranty of

12 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

13 
* Lesser General Public License for more details.

14 

15 
* You should have received a copy of the GNU Lesser General Public

16 
* License along with this library; if not, write to the Free Software

17 
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 021101301 USA

18 
***********************************************************************/

19  
20 
#ifndef _CLOCKDRIFT_MEASURE_H_

21 
#define _CLOCKDRIFT_MEASURE_H_

22  
23 
#include "measure_plugin.h" 
24 
#include "mon_measure.h" 
25 
#include <algorithm> 
26  
27 
struct clockdrift_sample {

28 
double tx_time;

29 
double delay;

30 
}; 
31  
32 
class ClockdriftMeasure : public MonMeasure { 
33 
double x_axis_inter(double a1, double b1, double a2, double b2); 
34 
double y_axis_inter(double a1, double b1, double a2, double b2); 
35  
36 
int pos;

37 
int *n;

38 
int pnum;

39  
40 
double sum_t, sum_d, sum_t_v, sum_d_v, sum_td_v;

41  
42 
public:

43 
double a, b, first_tx;

44  
45 
std::vector<struct clockdrift_sample> samples;

46  
47 
ClockdriftMeasure(class MeasurePlugin *m, MeasurementCapabilities mc, class MeasureDispatcher *md); 
48 
virtual ~ClockdriftMeasure(); 
49 
virtual result RxPkt(result *r, ExecutionList *el); 
50 
virtual result RxData(result *r, ExecutionList *el); 
51 
virtual void stop();

52 
virtual void init();

53 
virtual int paramChange(MonParameterType ph, MonParameterValue p);

54 
}; 
55  
56 
class ClockdriftMeasurePlugin : public MeasurePlugin { 
57 
virtual ~ClockdriftMeasurePlugin() {}; 
58  
59 
virtual MeasurementCapabilities getCaps() { 
60 
return IN_BAND  PACKET  DATA  TXRXUNI;

61 
}; 
62  
63  
64 
virtual MonMeasure* createMeasure (MeasurementCapabilities mc, class MeasureDispatcher *md) { 
65 
return new ClockdriftMeasure(this, mc, md);

66 
}; 
67 
public:

68 
ClockdriftMeasurePlugin(); 
69 
}; 
70  
71 
#endif /* _CLOCKDRIFT_MEASURE_H_ */ 
72 