iCub-main
statExt.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /* Copyright (C) 2012 iCub Facility, Istituto Italiano di Tecnologia
4  * Author: Valentina Gaggero
5  * email: valentina.gaggero@iit.it
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17  */
18 
19 
20 #ifndef __statExt__
21 #define __statExt__
22 
23 // System includes
24 #include <yarp/os/Ping.h>
25 #include <float.h>
26 
27 
28 
29 //this class contains all info about pkts received from pc104
30 class StatExt: public yarp::os::Stat
31 {
32 private:
33  double min;
34  double max;
35 public:
36 
37  StatExt() {
38  clear();
39  }
40 
41  void clear() {
42  min = DBL_MAX;
43  max = 0;
44  yarp::os::Stat::clear();
45  }
46 
47  void add(double val) {
48  if(val < min)
49  min = val;
50 
51  if(val > max)
52  max = val;
53 
55  }
56 
57  bool addAndCheckLimits(double val) {
58  bool updatedLimits=false;
59  if(val < min)
60  {
61  min = val;
62  updatedLimits=true;
63  }
64 
65  if(val > max)
66  {
67  max = val;
68  updatedLimits=true;
69  }
70 
72  return updatedLimits;
73  }
74 
75 // void add(const StatExt& alt) {
76 //
77 // if( alt.min < min)
78 // min = alt.min;
79 //
80 // if(alt.max > max)
81 // max = alt.max;
82 //
83 // Stat::add((Stat*)alt);
84 // }
85 
86 
87 
88 // double mean();
89 //
90 // double deviation();
91 //
92 // double count();
93 
94 
95  using yarp::os::Stat::mean;
96  using yarp::os::Stat::deviation;
97  using yarp::os::Stat::count;
98 
99 
100 
101  double getMin(void){
102  return min;
103  }
104 
105 
106  double getMax(void){
107  return max;
108  }
109 };
110 
111 
112 
113 
114 
115 #endif
116 
117 // eof
118 
119 
void clear()
Definition: statExt.h:41
void add(double val)
Definition: statExt.h:47
double getMax(void)
Definition: statExt.h:106
double getMin(void)
Definition: statExt.h:101
StatExt()
Definition: statExt.h:37
bool addAndCheckLimits(double val)
Definition: statExt.h:57
Q15 add(const Q15 a, const Q15 b)
Definition: strain.cpp:1209