00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if !defined(__DATAPOINT_HPP)
00032 #define __DATAPOINT_HPP
00033
00034 #include "libecs.hpp"
00035
00036
00037 #include "Polymorph.hpp"
00038
00039 namespace libecs
00040 {
00041
00042
00043
00044
00045
00046
00047
00048 class LongDataPoint;
00049 class DataPoint;
00050
00051
00052
00053
00054
00055
00056
00057 class DataPoint
00058 {
00059
00060
00061 public:
00062
00063 DataPoint()
00064 :
00065 theTime ( 0.0 ),
00066 theValue( 0.0 )
00067 {
00068 ;
00069 }
00070
00071 DataPoint( RealParam aTime, RealParam aValue )
00072 :
00073 theTime ( aTime ),
00074 theValue( aValue )
00075 {
00076 ;
00077 }
00078
00079
00080
00081 ~DataPoint()
00082 {
00083 ;
00084 }
00085
00086 const Real getTime() const
00087 {
00088 return theTime;
00089 }
00090
00091 const Real getValue() const
00092 {
00093 return theValue;
00094 }
00095
00096 const Real getAvg() const
00097 {
00098 return theValue;
00099 }
00100
00101 const Real getMin() const
00102 {
00103 return theValue;
00104 }
00105
00106 const Real getMax() const
00107 {
00108 return theValue;
00109 }
00110
00111
00112 void setTime( RealParam aReal )
00113 {
00114 theTime = aReal;
00115 }
00116
00117 void setValue( RealParam aReal )
00118 {
00119 theValue = aReal;
00120 }
00121
00122 void setAvg( RealParam aReal )
00123 {
00124 ;
00125 }
00126
00127 void setMin( RealParam aReal )
00128 {
00129 ;
00130 }
00131
00132 void setMax( RealParam aReal )
00133 {
00134 ;
00135 }
00136
00137 static const size_t getElementSize()
00138 {
00139 return sizeof( Real );
00140 }
00141
00142 static const int getElementNumber()
00143 {
00144 return 2;
00145 }
00146
00147 DataPointRef operator= ( LongDataPointCref aLongDataPoint );
00148
00149 protected:
00150
00151 Real theTime;
00152 Real theValue;
00153
00154 };
00155
00156
00157
00158 class LongDataPoint
00159 :
00160 public DataPoint
00161 {
00162
00163 public:
00164
00165 LongDataPoint()
00166 :
00167 theAvg( 0.0 ),
00168 theMax( 0.0 ),
00169 theMin( 0.0 )
00170 {
00171 ;
00172 }
00173
00174
00175 LongDataPoint( RealParam aTime, RealParam aValue )
00176 :
00177 DataPoint( aTime, aValue ),
00178 theAvg( aValue ),
00179 theMax( aValue ),
00180 theMin( aValue )
00181 {
00182 ;
00183 }
00184
00185 LongDataPoint( RealParam aTime, RealParam aValue,
00186 RealParam anAvg,
00187 RealParam aMax,
00188 RealParam aMin )
00189 :
00190 DataPoint( aTime, aValue ),
00191 theAvg( anAvg ),
00192 theMin( aMin ),
00193 theMax( aMax )
00194 {
00195 ;
00196 }
00197
00198
00199 LongDataPoint( DataPointCref aDataPoint )
00200 :
00201 DataPoint( aDataPoint ),
00202 theAvg( aDataPoint.getAvg() ),
00203 theMin( aDataPoint.getMin() ),
00204 theMax( aDataPoint.getMax() )
00205 {
00206 ;
00207 }
00208
00209 ~LongDataPoint()
00210 {
00211 ;
00212 }
00213
00214 const Real getTime() const
00215 {
00216 return theTime;
00217 }
00218
00219 const Real getValue() const
00220 {
00221 return theValue;
00222 }
00223
00224 const Real getAvg() const
00225 {
00226 return theAvg;
00227 }
00228
00229 const Real getMin() const
00230 {
00231 return theMin;
00232 }
00233
00234 const Real getMax() const
00235 {
00236 return theMax;
00237 }
00238
00239
00240 void setTime( RealParam aReal )
00241 {
00242 theTime = aReal;
00243 }
00244
00245 void setValue( RealParam aReal )
00246 {
00247 theValue = aReal;
00248 }
00249
00250 void setAvg( RealParam aReal )
00251 {
00252 theAvg = aReal;
00253 }
00254
00255 void setMin( RealParam aReal )
00256 {
00257 theMin = aReal;
00258 }
00259
00260 void setMax( RealParam aReal )
00261
00262 {
00263 theMax = aReal;
00264 }
00265
00266 static const size_t getElementSize()
00267 {
00268 return sizeof( Real );
00269 }
00270
00271 static const int getElementNumber()
00272 {
00273 return 5;
00274 }
00275
00276 protected:
00277
00278 Real theAvg;
00279 Real theMin;
00280 Real theMax;
00281
00282 };
00283
00284
00285 class DataPointAggregator
00286 {
00287
00288 public:
00289
00290 DataPointAggregator();
00291
00292 DataPointAggregator( LongDataPointCref );
00293
00294
00295 ~DataPointAggregator();
00296
00297 void aggregate( LongDataPointCref );
00298
00299 LongDataPointCref getData();
00300
00301 void beginNextPoint();
00302
00303 LongDataPoint getLastPoint();
00304
00305 private:
00306 void store( LongDataPointCref );
00307
00308 bool stockpile( LongDataPointRef, LongDataPointCref );
00309 void calculate( LongDataPointCref );
00310 void calculateMinMax( LongDataPointRef, LongDataPointCref );
00311
00312 LongDataPoint theAccumulator;
00313 LongDataPoint theCollector;
00314 LongDataPoint thePreviousPoint;
00315
00316 };
00317
00318
00319
00320
00321 }
00322
00323
00324 #endif