00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _SENSING_H_
00036 #define _SENSING_H_
00037
00038 #include "sensingC.h"
00039
00040
00041 namespace sensix {
00042
00043 class FunctorImpl : public Functor {
00044 public:
00045 FunctorImpl(FunctorList *subfs);
00046 FunctorImpl();
00047 FunctorImpl(FunctorList *subfs, unsigned int seq);
00048 FunctorImpl(unsigned int seq);
00049
00050 uint8_t identifier();
00051 unsigned int sequencer();
00052 Series* results();
00053 void results(Series &data);
00054 ErrorList* errors();
00055 void errors(ErrorList &e);
00056 uint8_t priority();
00057 void priority(uint8_t p);
00058 FunctorList* subfunctors();
00059 void subfunctors(FunctorList &fs);
00060 char *asString();
00061
00062 protected:
00063 uint8_t id;
00064 unsigned int seq_num;
00065 uint8_t importance;
00066 FunctorList *subs;
00067 Series *data_set;
00068 ErrorList *errs;
00069 };
00070
00071
00072 namespace sensing {
00073
00074 class SensoryImpl : public sensix::sensing::Sensory {
00075 public:
00076 SensoryImpl(uint8_t l, uint8_t s, FunctorList *subfs);
00077 SensoryImpl(uint8_t l, uint8_t s);
00078 SensoryImpl(FunctorList *subfs);
00079 SensoryImpl();
00080 SensoryImpl(uint8_t l, uint8_t s, FunctorList *subfs, unsigned int seq);
00081 SensoryImpl(uint8_t l, uint8_t s, unsigned int seq);
00082
00083 uint8_t level();
00084 uint8_t sensor();
00085 unsigned long long timeused();
00086 void timeused(unsigned long long t);
00087 double energyused();
00088 void energyused(double e);
00089
00090 char *asString();
00091 uint8_t identifier();
00092 unsigned int sequencer();
00093 Series *results();
00094 void results(Series &data);
00095 ErrorList *errors();
00096 void errors(ErrorList &e);
00097 uint8_t priority();
00098 void priority(uint8_t p);
00099 FunctorList *subfunctors();
00100 void subfunctors(FunctorList &fs);
00101
00102 protected:
00103 uint8_t sense;
00104 uint8_t h_level;
00105 unsigned long long time;
00106 double energy;
00107 double value;
00108
00109 private:
00110 sensix::FunctorImpl *delegate;
00111 };
00112
00113
00114 class CollectionImpl : public Collection {
00115 public:
00116 CollectionImpl(uint8_t l, Sensory_ptr s);
00117 CollectionImpl(Sensory_ptr s);
00118 CollectionImpl(uint8_t l, Sensory_ptr s, unsigned int seq);
00119
00120 Sensory_ptr sense();
00121 void sense(Sensory_ptr s);
00122 uint8_t sensor();
00123 unsigned long long timeused();
00124 void timeused(unsigned long long t) {};
00125 double energyused();
00126 void energyused(double e) {};
00127 uint8_t priority();
00128 void priority(uint8_t p);
00129 Series* results();
00130 void results(Series &d);
00131 ErrorList* errors();
00132 void errors(ErrorList &e) {};
00133
00134 char *asString();
00135 uint8_t identifier();
00136 unsigned int sequencer();
00137 uint8_t level();
00138 FunctorList *subfunctors();
00139 void subfunctors(FunctorList &fs);
00140
00141 protected:
00142 Sensory_ptr sensory;
00143 Series *data;
00144
00145 private:
00146 SensoryImpl *delegate;
00147 };
00148
00149
00150 class AggregateImpl : public Aggregate {
00151 public:
00152 AggregateImpl(char *n, uint8_t l, CollectionList *c);
00153 AggregateImpl(char *n, CollectionList *c);
00154 AggregateImpl(char *n, uint8_t l, CollectionList *c, unsigned int seq);
00155
00156 SensoryList* senses();
00157 CollectionList* collectors();
00158 void collectors(CollectionList *c);
00159 Sensory_ptr sense();
00160 void sense(Sensory_ptr s) {};
00161 uint8_t sensor();
00162 unsigned long long timeused();
00163 void timeused(unsigned long long t) {};
00164 double energyused();
00165 void energyused(double e) {};
00166 uint8_t priority();
00167 void priority(uint8_t p);
00168 ErrorList* errors();
00169 void errors(ErrorList &e) {};
00170 char *asString();
00171
00172 uint8_t identifier();
00173 unsigned int sequencer();
00174 uint8_t level();
00175 Series* results();
00176 void results(Series &d);
00177 FunctorList *subfunctors();
00178 void subfunctors(FunctorList &fs);
00179
00180 protected:
00181 char *name;
00182 CollectionList *series;
00183
00184 private:
00185 SensoryImpl *delegate;
00186 };
00187
00188
00189 class SenseImpl : public Sense {
00190 public:
00191 SenseImpl(uint8_t l, uint8_t s, double r);
00192 SenseImpl(uint8_t s, double r);
00193 SenseImpl(uint8_t l, uint8_t s);
00194 SenseImpl(uint8_t s);
00195 SenseImpl(uint8_t l, uint8_t s, double r, unsigned int seq);
00196
00197 double rate();
00198 void rate(double r);
00199 uint8_t identifier();
00200 FunctorList *subfunctors() { return NULL; };
00201 void subfunctors(FunctorList &fs) {};
00202 char *asString();
00203
00204 unsigned int sequencer();
00205 uint8_t level();
00206 unsigned long long timeused();
00207 void timeused(unsigned long long t);
00208 double energyused();
00209 void energyused(double e);
00210 Series* results();
00211 void results(Series &d);
00212 uint8_t priority();
00213 void priority(uint8_t p);
00214 ErrorList* errors();
00215 void errors(ErrorList &e);
00216
00217 protected:
00218 double hz;
00219
00220 private:
00221 SensoryImpl *delegate;
00222 };
00223
00224 class PeakSenseImpl : public PeakSense {
00225 public:
00226 PeakSenseImpl(uint8_t l, uint8_t s, double r, double th, bool hi);
00227 PeakSenseImpl(uint8_t l, uint8_t s, double r, double th, double tl);
00228 PeakSenseImpl(uint8_t s, double r, double th, bool hi);
00229 PeakSenseImpl(uint8_t s, double r, double th, double tl);
00230 PeakSenseImpl(uint8_t l, uint8_t s, double th, bool hi);
00231 PeakSenseImpl(uint8_t l, uint8_t s, double th, double tl);
00232 PeakSenseImpl(uint8_t s, double th, bool hi);
00233 PeakSenseImpl(uint8_t s, double th, double tl);
00234 PeakSenseImpl(uint8_t l, uint8_t s, double r, double th, double tl,
00235 unsigned int seq);
00236
00237 double highthreshold();
00238 void highthreshold(double h);
00239 double lowthreshold();
00240 void lowthreshold(double l);
00241 uint8_t identifier();
00242 char *asString();
00243
00244 double rate();
00245 void rate(double r);
00246 unsigned int sequencer();
00247 uint8_t level();
00248 unsigned long long timeused();
00249 void timeused(unsigned long long t);
00250 double energyused();
00251 void energyused(double e);
00252 Series* results();
00253 void results(Series &d);
00254 uint8_t priority();
00255 void priority(uint8_t p);
00256 ErrorList* errors();
00257 void errors(ErrorList &e);
00258 FunctorList *subfunctors();
00259 void subfunctors(FunctorList &fs);
00260
00261 protected:
00262 double threshold_h;
00263 double threshold_l;
00264
00265 private:
00266 SenseImpl* delegate;
00267 };
00268
00269
00270 class TimeSeriesImpl : public TimeSeries {
00271 public:
00272 TimeSeriesImpl(uint8_t l, Sensory_ptr s, unsigned long long t);
00273 TimeSeriesImpl(Sensory_ptr s, unsigned long long t);
00274 TimeSeriesImpl(uint8_t l, Sensory_ptr s, unsigned long long t,
00275 unsigned int seq);
00276
00277 unsigned long long duration();
00278 void duration(unsigned long long t);
00279 uint8_t identifier();
00280 char *asString();
00281
00282 unsigned int sequencer();
00283 uint8_t level();
00284 Sensory_ptr sense();
00285 void sense(Sensory_ptr s);
00286 uint8_t sensor();
00287 unsigned long long timeused();
00288 void timeused(unsigned long long t);
00289 double energyused();
00290 void energyused(double e);
00291 Series* results();
00292 void results(Series &d);
00293 uint8_t priority();
00294 void priority(uint8_t p);
00295 ErrorList* errors();
00296 void errors(ErrorList &e);
00297 FunctorList *subfunctors();
00298 void subfunctors(FunctorList &fs);
00299
00300 protected:
00301 unsigned long long time;
00302
00303 private:
00304 CollectionImpl* delegate;
00305 };
00306
00307
00308 class SpatialSeriesImpl : public SpatialSeries {
00309 public:
00310 SpatialSeriesImpl(uint8_t l, Sensory_ptr s, double angle, double dist);
00311 SpatialSeriesImpl(Sensory_ptr s, double angle, double dist);
00312 SpatialSeriesImpl(uint8_t l, Sensory_ptr s);
00313 SpatialSeriesImpl(Sensory_ptr s);
00314 SpatialSeriesImpl(uint8_t l, Sensory_ptr s, double angle, double dist,
00315 unsigned int seq);
00316
00317 double distance();
00318 void distance(double d);
00319 double angle();
00320 void angle(double a);
00321 uint8_t identifier();
00322 char *asString();
00323
00324 unsigned int sequencer();
00325 uint8_t level();
00326 Sensory_ptr sense();
00327 void sense(Sensory_ptr s);
00328 uint8_t sensor();
00329 unsigned long long timeused();
00330 void timeused(unsigned long long t);
00331 double energyused();
00332 void energyused(double e);
00333 Series* results();
00334 void results(Series &d);
00335 uint8_t priority();
00336 void priority(uint8_t p);
00337 ErrorList* errors();
00338 void errors(ErrorList &e);
00339 FunctorList *subfunctors();
00340 void subfunctors(FunctorList &fs);
00341
00342 protected:
00343 double centirads;
00344 double dist_cm;
00345
00346 private:
00347 CollectionImpl* delegate;
00348 };
00349
00350
00351 class ReciteImpl : public Recite {
00352 public:
00353 ReciteImpl(uint8_t l, CollectionList *c);
00354 ReciteImpl(CollectionList *c);
00355 ReciteImpl(uint8_t l, CollectionList *c, unsigned int seq);
00356
00357 uint8_t identifier();
00358 Series* results();
00359 void results(Series &d) {};
00360
00361 char *asString();
00362 unsigned int sequencer();
00363 uint8_t level();
00364 CollectionList* collectors();
00365 void collectors(CollectionList *c);
00366 SensoryList* senses();
00367 Sensory_ptr sense();
00368 void sense(Sensory_ptr s);
00369 uint8_t sensor();
00370 unsigned long long timeused();
00371 void timeused(unsigned long long t);
00372 double energyused();
00373 void energyused(double e);
00374 uint8_t priority();
00375 void priority(uint8_t p);
00376 ErrorList* errors();
00377 void errors(ErrorList &e);
00378 FunctorList *subfunctors();
00379 void subfunctors(FunctorList &fs);
00380
00381 private:
00382 AggregateImpl* delegate;
00383 };
00384
00385
00386 class SumImpl : public Sum {
00387 public:
00388 SumImpl(uint8_t l, CollectionList *c);
00389 SumImpl(CollectionList *c);
00390 SumImpl(uint8_t l, CollectionList *c, unsigned int seq);
00391
00392 uint8_t identifier();
00393 Series* results();
00394 void results(Series &d) {};
00395
00396 char *asString();
00397 unsigned int sequencer();
00398 uint8_t level();
00399 CollectionList* collectors();
00400 void collectors(CollectionList *c);
00401 SensoryList* senses();
00402 Sensory_ptr sense();
00403 void sense(Sensory_ptr s);
00404 uint8_t sensor();
00405 unsigned long long timeused();
00406 void timeused(unsigned long long t);
00407 double energyused();
00408 void energyused(double e);
00409 uint8_t priority();
00410 void priority(uint8_t p);
00411 ErrorList* errors();
00412 void errors(ErrorList &e);
00413 FunctorList *subfunctors();
00414 void subfunctors(FunctorList &fs);
00415
00416 protected:
00417 Data* getResult(unsigned int idx);
00418
00419 private:
00420 AggregateImpl* delegate;
00421 };
00422
00423
00424 class DeltaImpl : public Delta {
00425 public:
00426 DeltaImpl(uint8_t l, CollectionList *c);
00427 DeltaImpl(CollectionList *c);
00428 DeltaImpl(uint8_t l, CollectionList *c, unsigned int seq);
00429
00430 uint8_t identifier();
00431 Series* results();
00432 void results(Series &d) {};
00433
00434 char *asString();
00435 unsigned int sequencer();
00436 uint8_t level();
00437 CollectionList* collectors();
00438 void collectors(CollectionList *c);
00439 SensoryList* senses();
00440 Sensory_ptr sense();
00441 void sense(Sensory_ptr s);
00442 uint8_t sensor();
00443 unsigned long long timeused();
00444 void timeused(unsigned long long t);
00445 double energyused();
00446 void energyused(double e);
00447 uint8_t priority();
00448 void priority(uint8_t p);
00449 ErrorList* errors();
00450 void errors(ErrorList &e);
00451 FunctorList *subfunctors();
00452 void subfunctors(FunctorList &fs);
00453
00454 protected:
00455 Data* getResult(unsigned int idx);
00456
00457 private:
00458 AggregateImpl* delegate;
00459 };
00460
00461
00462 class MeanImpl : public Mean {
00463 public:
00464 MeanImpl(uint8_t l, CollectionList *c);
00465 MeanImpl(CollectionList *c);
00466 MeanImpl(uint8_t l, CollectionList *c, unsigned int seq);
00467
00468 uint8_t identifier();
00469 Series* results();
00470 void results(Series &d) {};
00471
00472 char *asString();
00473 unsigned int sequencer();
00474 uint8_t level();
00475 CollectionList* collectors();
00476 void collectors(CollectionList *c);
00477 SensoryList* senses();
00478 Sensory_ptr sense();
00479 void sense(Sensory_ptr s);
00480 uint8_t sensor();
00481 unsigned long long timeused();
00482 void timeused(unsigned long long t);
00483 double energyused();
00484 void energyused(double e);
00485 uint8_t priority();
00486 void priority(uint8_t p);
00487 ErrorList* errors();
00488 void errors(ErrorList &e);
00489 FunctorList *subfunctors();
00490 void subfunctors(FunctorList &fs);
00491
00492 protected:
00493 Data* getResult(unsigned int idx);
00494
00495 private:
00496 AggregateImpl* delegate;
00497 };
00498
00499
00500 class SigmaImpl : public Sigma {
00501 public:
00502 SigmaImpl(uint8_t l, CollectionList *c);
00503 SigmaImpl(CollectionList *c);
00504 SigmaImpl(uint8_t l, CollectionList *c, unsigned int seq);
00505
00506 uint8_t identifier();
00507 Series* results();
00508 void results(Series &d) {};
00509
00510 char *asString();
00511 unsigned int sequencer();
00512 uint8_t level();
00513 CollectionList* collectors();
00514 void collectors(CollectionList *c);
00515 SensoryList* senses();
00516 Sensory_ptr sense();
00517 void sense(Sensory_ptr s);
00518 uint8_t sensor();
00519 unsigned long long timeused();
00520 void timeused(unsigned long long t);
00521 double energyused();
00522 void energyused(double e);
00523 uint8_t priority();
00524 void priority(uint8_t p);
00525 ErrorList* errors();
00526 void errors(ErrorList &e);
00527 FunctorList *subfunctors();
00528 void subfunctors(FunctorList &fs);
00529
00530 protected:
00531 Data* getResult(unsigned int idx);
00532
00533 private:
00534 AggregateImpl* delegate;
00535 };
00536
00537
00538 class LambdaImpl : public Lambda {
00539 public:
00540 LambdaImpl(uint8_t l, CollectionList *c);
00541 LambdaImpl(CollectionList *c);
00542 LambdaImpl(uint8_t l, CollectionList *c, unsigned int seq);
00543
00544 uint8_t identifier();
00545 char *code();
00546 void code(char *s);
00547 Series* results();
00548 void results(Series &d) {};
00549
00550 char *asString();
00551 unsigned int sequencer();
00552 uint8_t level();
00553 CollectionList* collectors();
00554 void collectors(CollectionList *c);
00555 SensoryList* senses();
00556 Sensory_ptr sense();
00557 void sense(Sensory_ptr s);
00558 uint8_t sensor();
00559 unsigned long long timeused();
00560 void timeused(unsigned long long t);
00561 double energyused();
00562 void energyused(double e);
00563 uint8_t priority();
00564 void priority(uint8_t p);
00565 ErrorList* errors();
00566 void errors(ErrorList &e);
00567 FunctorList *subfunctors();
00568 void subfunctors(FunctorList &fs);
00569
00570 protected:
00571 Data* getResult(unsigned int idx);
00572 double doScript(double previous, double measure);
00573 char *script;
00574
00575 private:
00576 AggregateImpl* delegate;
00577 };
00578
00579
00580 #define DEFAULT_LAT 35.8880556
00581 #define DEFAULT_LON -106.3063889
00582 #define DEFAULT_ALT 2255.52
00583
00584 class LocationImpl : public Location {
00585 public:
00586 LocationImpl(double latitude=DEFAULT_LAT, double longitude=DEFAULT_LON,
00587 double altitude=DEFAULT_ALT);
00588
00589 uint8_t identifier();
00590 double latitude();
00591 double longitude();
00592 double altitude();
00593 unsigned long long time();
00594 void acquire(Functor_ptr f);
00595
00596 protected:
00597 void getGPS();
00598 double lat, lon, alt;
00599 unsigned long long now;
00600 bool have_device;
00601 };
00602
00603 class PowerImpl : public Power {
00604 public:
00605 PowerImpl();
00606
00607 uint8_t identifier();
00608 double ratio();
00609 void acquire(Functor_ptr f);
00610
00611 protected:
00612 double getBattery();
00613 double starting_energy;
00614 double energy_now;
00615 bool have_device;
00616 };
00617
00618 }
00619 }
00620
00621
00622 #endif // _SENSING_H_