Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.
Temperature.h
00001 #ifndef TEMPERATURE_H 00002 #define TEMPERATURE_H 00003 00004 #include <vector> 00005 #include <string> 00006 00007 /** Temperature class stores historical temperature data and tresholds for temperature alerts 00008 * 00009 */ 00010 class Temperature { 00011 private: 00012 double max_temp_limit, min_temp_limit, period_limit, max_samples_limit; 00013 double min_temp; 00014 double max_temp; 00015 double temp_sample_period; 00016 int max_samples; 00017 int sample_ptr; 00018 bool wrapped_once; 00019 std::vector<std::string> temp_samples; 00020 00021 public: 00022 /** 00023 * Creates a new temperature object. All parameters 00024 * hard coded at first and methods used to set appropriately 00025 * based on user's desires. 00026 */ 00027 Temperature(); 00028 /** 00029 * Returns minimum temperature threshold 00030 * 00031 * @param return - mininum temperature threshold 00032 */ 00033 double get_min(); 00034 /** 00035 * Returns maximum temperature threshold 00036 * 00037 * @param return - maximum temperature threshold 00038 */ 00039 double get_max(); 00040 /** 00041 * Returns temperature sampling period in seconds 00042 * 00043 * @param return - temperature sampling period in seconds 00044 */ 00045 double get_period(); 00046 /** 00047 * Sets the minimum temperature threshold for alerts. 00048 * 00049 * @param min - new minimum temperature threshold for alerts 00050 * @param return - indicates success or failure 00051 */ 00052 bool set_min(double min); 00053 /** 00054 * Sets the maximum temperature threshold for alerts. 00055 * 00056 * @param max - new maximum temperature threshold for alerts 00057 * @param return - indicates success or failure 00058 */ 00059 bool set_max(double max); 00060 /** 00061 * Sets the temperature period in seconds to store temperature samples in DB 00062 * 00063 * @param period - termperature sampling period in seconds 00064 * @param return - pass or fail of attempt 00065 */ 00066 bool set_period(double period); 00067 /** 00068 * Method to add a temperature sample to the database 00069 * 00070 * @param temp_sample - temperature sample to be stored to dB 00071 */ 00072 void add_sample(double temp_sample); 00073 /** 00074 * Changes number of samples in temperature database. 00075 * Current maximum is 100 samples 00076 * WARNING: Changing this may trash samples since vector is resized. 00077 * 00078 * @param num_samples - Number of samples in DB 00079 * @param return - pass fail of attemp 00080 */ 00081 bool change_max_samples(int num_samples); 00082 /** 00083 * Returns database size in temperature DB 00084 * 00085 * @param return - current size of temp DB in samples 00086 */ 00087 int get_max_samples(); 00088 /** 00089 * Returns all temperature samples as strings in the database. 00090 * number returned should match max_samples. 00091 * 00092 * @param return - Reference to vector containing temperature DB as strings 00093 */ 00094 const std::vector<std::string> &get_samples(); 00095 00096 }; 00097 00098 #endif
Generated on Fri Jul 22 2022 02:01:25 by 1.7.2