Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.
Diff: Motion/Motion.h
- Revision:
- 2:84432add9142
- Parent:
- 0:3f846fc933a2
diff -r 2f5a62eb52ad -r 84432add9142 Motion/Motion.h --- a/Motion/Motion.h Tue Sep 03 08:54:55 2013 +0000 +++ b/Motion/Motion.h Tue Sep 03 20:24:12 2013 +0000 @@ -5,12 +5,16 @@ #include <string> #include "HomeMonUtils.h" +/** Simple structure to hold a motion vector - x, y, and z motion +*/ struct motion_vec { double x; double y; double z; }; +/** Motion class stores historical motion alert data and thresholding for alert generation +*/ class Motion { private: motion_vec min_motion; @@ -21,12 +25,49 @@ std::vector<std::string> motion_samples; public: + /** + * Instantiate a motion class. Initialization hard-coded to + * known good values. Use member functions to modify. + */ Motion(); + /** + * Allows host to retrieve motion threshold as a vector. + * + * @param return - Returns a motion vector structure with x, y, and z threholds for motion. + */ motion_vec get_motion_thresh(void); - bool set_motion_thresh(motion_vec); + /** + * Allows host to set the motion threshold + * + * @param motion_thresh - Motion vector threshold setting + * @param return - pass/faill for set + */ + bool set_motion_thresh(motion_vec motion_thresh); + /** + * Adds a sample to the motion database. Units are time in seconds since device booted. + * + * @param motion_sample - represents seconds since device booted that a motion alert occurred. + */ void add_sample(double motion_sample); + /** + * Returns all motion samples in the motion database. + * + * @param return - vector containing strings for all motion alerts (seconds since device booted) + */ const std::vector<std::string> &get_samples(); - bool change_max_samples(int); + /** + * Allows the host to change the motion database size. + * WARNING: This may cause sample to be lost due to vector resize operation + * + * @param num_samples - new size of motion alert DB (max allowed currently 100) + * @param return - pass/fail of operation + */ + bool change_max_samples(int num_samples); + /** + * Returns current database size + * + * @param return - size in samples of motion alert DB + */ int get_max_samples(); };