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 #ifndef __CDETECT_H
00029 #define __CDETECT_H
00030
00031 #include "cobject.h"
00032 #include "cstat.h"
00033
00034
00035 class cTransientDetection;
00036 class cAccuracyDetection;
00037 class cTDExpandingWindows;
00038 class cADByStddev;
00039
00040
00041 class cStatistic;
00042
00047 typedef void (*PostTDFunc)(cTransientDetection *, void *);
00048
00053 typedef void (*PostADFunc)(cAccuracyDetection *, void *);
00054
00055
00056
00062 class SIM_API cTransientDetection : public cObject
00063 {
00064 private:
00065 cStatistic *back;
00066
00067 public:
00070
00074 cTransientDetection(const cTransientDetection& r) : cObject() {setName(r.name());operator=(r);}
00075
00079 explicit cTransientDetection(const char *name=NULL) : cObject(name) {}
00080
00084 virtual ~cTransientDetection() {}
00085
00089 cTransientDetection& operator=(const cTransientDetection&) {copyNotSupported();return *this;}
00091
00094
00098 virtual const char *className() const {return "cTransientDetection";}
00099
00100
00101
00107 virtual int netPack();
00108
00114 virtual int netUnpack();
00116
00119
00123 virtual void collect(double val) = 0;
00124
00128 virtual bool detected() const = 0;
00129
00133 virtual void reset() = 0;
00134
00139 virtual void stop() = 0;
00140
00145 virtual void start() = 0;
00147
00150
00155 virtual void setHostObject(cStatistic *ptr) {back = ptr;}
00156
00160 virtual cStatistic *hostObject() const {return back;}
00162 };
00163
00164
00165
00171 class SIM_API cAccuracyDetection : public cObject
00172 {
00173 private:
00174 cStatistic *back;
00175
00176 public:
00179
00183 cAccuracyDetection(const cAccuracyDetection& r) : cObject() {setName(r.name());operator=(r);}
00184
00188 explicit cAccuracyDetection(const char *name=NULL) : cObject(name) {}
00189
00193 virtual ~cAccuracyDetection() {}
00194
00198 cAccuracyDetection& operator=(const cAccuracyDetection&) {copyNotSupported();return *this;}
00200
00203
00207 virtual const char *className() const {return "cAccuracyDetection";}
00208
00209
00210
00216 virtual int netPack();
00217
00223 virtual int netUnpack();
00225
00228
00232 virtual void collect(double val) = 0;
00233
00237 virtual bool detected() const = 0;
00238
00242 virtual void reset() = 0;
00243
00248 virtual void stop() = 0;
00249
00254 virtual void start() = 0;
00256
00259
00264 virtual void setHostObject(cStatistic *ptr) {back = ptr;}
00265
00269 virtual cStatistic *hostObject() const {return back;}
00271 };
00272
00273
00274
00282 class SIM_API cTDExpandingWindows : public cTransientDetection
00283 {
00284 private:
00285 bool go;
00286 bool transval;
00287 double accuracy;
00288 int minwinds;
00289 double windexp;
00290 int repeats;
00291 int detreps;
00292 int size;
00293 struct xy {double x; double y; xy *next;};
00294 xy *func;
00295 PostTDFunc pdf;
00296 void *pdfdata;
00297
00298 private:
00299
00300 void detectTransient();
00301
00302 public:
00305
00309 cTDExpandingWindows(const cTDExpandingWindows& r);
00310
00314 explicit cTDExpandingWindows(const char *name=NULL,
00315 int reps=3, int minw=4, double wind=1.3, double acc=0.3,
00316 PostTDFunc f=NULL,void *p=NULL);
00317
00321 virtual ~cTDExpandingWindows();
00322
00327 cTDExpandingWindows& operator=(const cTDExpandingWindows& res);
00329
00332
00336 virtual const char *className() const {return "cTDExpandingWindows";}
00337
00342 virtual cObject *dup() const {return new cTDExpandingWindows(*this);}
00344
00347
00351 virtual void collect(double val);
00352
00356 virtual bool detected() const {return transval;}
00357
00361 virtual void reset();
00362
00366 virtual void stop() {go = false;}
00367
00372 virtual void start() {go = true;}
00374
00377
00382
00383 void setPostDetectFunction(PostTDFunc f, void *p) {pdf = f; pdfdata = p;}
00384
00388 void setParameters(int reps=3, int minw=4,
00389 double wind=1.3, double acc=0.3);
00391 };
00392
00393
00394
00395
00403 class SIM_API cADByStddev : public cAccuracyDetection
00404 {
00405 private:
00406 bool go;
00407 bool resaccval;
00408 double accuracy;
00409 long int sctr;
00410 double ssum,sqrsum;
00411 int repeats, detreps;
00412 PostADFunc pdf;
00413 void *pdfdata;
00414
00415 private:
00416
00417 void detectAccuracy();
00418
00419
00420 double stddev();
00421
00422 public:
00425
00429 cADByStddev(const cADByStddev& r);
00430
00434 explicit cADByStddev(const char *name=NULL,
00435 double acc=0.01, int reps=3,
00436 PostADFunc f=NULL, void *p=NULL);
00437
00441 virtual ~cADByStddev() {}
00442
00447 cADByStddev& operator=(const cADByStddev& res);
00449
00452
00456 virtual const char *className() const {return "cADByStddev";}
00457
00462 virtual cObject *dup() const {return new cADByStddev(*this);}
00464
00467
00471 virtual void collect(double val);
00472
00476 virtual bool detected() const {return resaccval;}
00477
00481 virtual void reset();
00482
00486 virtual void stop() {go=false;}
00487
00492 virtual void start() {go=true;}
00494
00497
00502
00503 void setPostDetectFunction(PostADFunc f, void *p) {pdf=f; pdfdata=p;}
00504
00508 void setParameters(double acc=0.1, int reps=3)
00509 {accuracy=acc; repeats=detreps=reps;}
00511 };
00512
00513 #endif
00514