]> pilppa.com Git - lib1wire.git/commitdiff
cleanups, renamed get_*_values functions to get_*_data
authorMika Laitio <lamikr@pilppa.org>
Mon, 27 Dec 2010 17:21:07 +0000 (19:21 +0200)
committerMika Laitio <lamikr@pilppa.org>
Mon, 27 Dec 2010 17:21:07 +0000 (19:21 +0200)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/DeviceData.cc
src/W1CounterDevice.cc
src/W1CounterDevice.hh
src/W1Device.cc
src/W1Device.hh
src/W1Store.cc
src/W1TemperatureSensor.cc
src/W1TemperatureSensor.hh
src_test/test_w1_datalog_write.cc

index 13c28aa22f63207e323f26eb2dfd2532f87ed787..59327ba68c0a1abdd6c561ce6b94ac31c60b467d 100644 (file)
@@ -39,10 +39,10 @@ DeviceData::~DeviceData() {
 
 Data *DeviceData::find_oldest_data(vector<string> year_vector) {
        unsigned int    ii;
-       string          year_dir;
-       string          month_dir;
-       vector<string>  month_vector;
-       vector<string>  data_vector;
+       string          year_dr;
+       string          mon_dr;
+       vector<string>  mon_vcr;
+       vector<string>  d_vcr;
        string          f_name;
        W1Store         *store;
        Data            *ret_val;
@@ -50,17 +50,17 @@ Data *DeviceData::find_oldest_data(vector<string> year_vector) {
        ret_val = NULL;
        if (year_vector.size() > 0) {
                // dirs are alphabetically sorted
-               year_dir        = year_vector.at(0);
-               year_dir        = W1Util::concat_paths(device_dir, year_dir);
-               month_vector    = W1Util::get_subdirectories(year_dir);
-               for (ii = 0; ii < month_vector.size(); ii++) {
-                       month_dir       = month_vector.at(ii);
-                       month_dir       = W1Util::concat_paths(year_dir, month_dir);
+               year_dr = year_vector.at(0);
+               year_dr = W1Util::concat_paths(device_dir, year_dr);
+               mon_vcr = W1Util::get_subdirectories(year_dr);
+               for (ii = 0; ii < mon_vcr.size(); ii++) {
+                       mon_dr  = mon_vcr.at(ii);
+                       mon_dr  = W1Util::concat_paths(year_dr, mon_dr);
                        // scan data files from month dir
-                       data_vector     = W1Util::get_data_files(month_dir);
-                       if (data_vector.size() > 0) {
-                               f_name  = data_vector.at(0);
-                               f_name  = W1Util::concat_paths(month_dir, f_name);
+                       d_vcr   = W1Util::get_data_files(mon_dr);
+                       if (d_vcr.size() > 0) {
+                               f_name  = d_vcr.at(0);
+                               f_name  = W1Util::concat_paths(mon_dr, f_name);
                                store   = new W1Store(f_name);
                                ret_val = store->get_oldest_data();
                                delete(store);
@@ -73,10 +73,10 @@ Data *DeviceData::find_oldest_data(vector<string> year_vector) {
 
 Data *DeviceData::find_newest_data(vector<string> year_vector) {
        int             ii;
-       string          year_dir;
-       string          month_dir;
-       vector<string>  month_vector;
-       vector<string>  data_vector;
+       string          year_dr;
+       string          mon_dr;
+       vector<string>  mon_vcr;
+       vector<string>  d_vcr;
        string          f_name;
        Data            *ret_val;
        int             size;
@@ -86,18 +86,18 @@ Data *DeviceData::find_newest_data(vector<string> year_vector) {
        size    = year_vector.size();
        if (size > 0) {
                // dirs are alphabetically sorted
-               year_dir        = year_vector.at(size - 1);
-               year_dir        = W1Util::concat_paths(device_dir, year_dir);
-               month_vector    = W1Util::get_subdirectories(year_dir);
-               for (ii = month_vector.size() - 1; ii >= 0; ii--) {
-                       month_dir       = month_vector.at(ii);
-                       month_dir       = W1Util::concat_paths(year_dir, month_dir);
+               year_dr = year_vector.at(size - 1);
+               year_dr = W1Util::concat_paths(device_dir, year_dr);
+               mon_vcr = W1Util::get_subdirectories(year_dr);
+               for (ii = mon_vcr.size() - 1; ii >= 0; ii--) {
+                       mon_dr  = mon_vcr.at(ii);
+                       mon_dr  = W1Util::concat_paths(year_dr, mon_dr);
                        // scan data files from month dir
-                       data_vector     = W1Util::get_data_files(month_dir);
-                       size    = data_vector.size();
+                       d_vcr   = W1Util::get_data_files(mon_dr);
+                       size    = d_vcr.size();
                        if (size > 0) {
-                               f_name  = data_vector.at(size - 1);
-                               f_name  = W1Util::concat_paths(month_dir, f_name);
+                               f_name  = d_vcr.at(size - 1);
+                               f_name  = W1Util::concat_paths(mon_dr, f_name);
                                store   = new W1Store(f_name);
                                ret_val = store->get_newest_data();
                                delete(store);
@@ -274,17 +274,18 @@ vector<Data *> DeviceData::get_hourly_summary(Date *date) {
 
 DataRange *DeviceData::get_hourly_summary(Date *start_date,
                                        Date *end_date) {
-       DataRange       *ret_val;
-       vector<Data *>  dta_list;
-       Data            *data;
-       Date            *date;
+       DataRange                       *ret_val;
+       vector<Data *>                  dta_list;
+       Data                            *data;
+       Date                            *date;
+       vector<Data *>::iterator        iter;
 
        ret_val = NULL;
        date    = start_date->clone();
        while(date->before(*end_date)) {
                dta_list        = get_hourly_summary(date);
-               for(vector<Data *>::iterator list_iter = dta_list.begin(); list_iter != dta_list.end(); list_iter++) {
-                       data    = (Data *)*list_iter;
+               for(iter = dta_list.begin(); iter != dta_list.end(); iter++) {
+                       data    = (Data *)*iter;
                        if (data != NULL) {
                                if (ret_val == NULL) {
                                        ret_val = new DataRange(*data);
index 53c95f93a0751cd97ed55087b0b24ed77ba10c1e..d4a20f69de840644343d6d7c7bdad809506cb975 100644 (file)
@@ -43,7 +43,7 @@ bool W1CounterDevice::is_supported_family_code(int family_code) {
        return ret_val;
 }
 
-string W1CounterDevice::get_raw_value() {
+string W1CounterDevice::get_raw_data() {
        string  ret_val;
        string  value_line;
        int     pos;
index 837488c248cc6e0112c70e9b028865d304cbc557..c5198bdfbb8c6fa4aa3b153705729fcd8071a911 100644 (file)
@@ -17,7 +17,7 @@ namespace w1 {
                                        std::string device_id_param,
                                        dirent *direntry_param);
                        virtual ~W1CounterDevice();
-                       std::string get_raw_value();
+                       std::string get_raw_data();
                        std::string get_unit();
                        std::string get_device_type();
                protected:
index 46e5b7046e7e173e0ddc54a64ac319c304de31fa..6719be76c32ea428a363f4c85d17986ebebb8e44 100644 (file)
@@ -68,23 +68,23 @@ string W1Device::get_time() {
 void W1Device::printout() {
        string text;
 
-       text    = get_formatted_value();
+       text    = get_formatted_data();
        cout << text << endl;
 }
 
-string W1Device::get_formatted_value() {
+string W1Device::get_formatted_data() {
        string ret_val;
        string val;
 
-       val     = get_raw_value();
-       ret_val = get_formatted_value(val);
+       val     = get_raw_data();
+       ret_val = get_formatted_data(val);
        return ret_val;
 }
 
-string W1Device::get_formatted_value(string value) {
+string W1Device::get_formatted_data(string raw_data) {
        string ret_val;
 
-       ret_val = get_time() + "|" + value + " " + get_unit();
+       ret_val = get_time() + "|" + raw_data + " " + get_unit();
        add_to_memory_cache(ret_val);
        return ret_val;
 }
index a6902f72526379d20325fd1473934a8ff8b1f3c7..73cd8f5ff7b65cfd50cee68a4cbdcc0dfdd8e57a 100644 (file)
@@ -33,8 +33,8 @@ namespace w1 {
                        std::string get_id();
                        std::string get_name();
                        void set_name(std::string name_param);
-                       virtual std::string get_raw_value() = 0;
-                       std::string get_formatted_value();
+                       virtual std::string get_raw_data() = 0;
+                       std::string get_formatted_data();
                        virtual std::string get_unit() = 0;
                        virtual std::string get_device_type() = 0;
                        std::string get_time();
@@ -42,7 +42,7 @@ namespace w1 {
                        virtual void store();
                protected:
                        void add_to_memory_cache(std::string formatted_data);
-                       std::string get_formatted_value(std::string value);
+                       std::string get_formatted_data(std::string raw_data);
                        virtual bool is_supported_family_code(int family_code) = 0;
                        int family_code;
                        std::string id;
index 9913d0dcd8cefad6787cdcf299accf15fd56b210..09ff70636538ab54fae2d998d7f1cffd9c0698c3 100644 (file)
@@ -74,8 +74,8 @@ string W1Store::get_file_name(string device_id, Date *date_time) {
        return ret_val;
 }
 
-void W1Store::store(std::string device_id,
-               std::list<std::string> *string_list) {
+void W1Store::store(string device_id,
+               list<string> *string_list) {
        string          f_path;
        string          line;
        ofstream        *ostream;
index b02bb29dd01518738b2fd59136d3b94f8a7d37d4..9c282b3e8daef69b334d490f3d527af400182141 100644 (file)
@@ -75,7 +75,7 @@ bool W1TemperatureSensor::is_supported_family_code(int family_code) {
        return ret_val;
 }
 
-string W1TemperatureSensor::get_raw_value() {
+string W1TemperatureSensor::get_raw_data() {
        string          temp;
        string          ret_val;
        string          last_line;
index 6946c5cc10c57e1f84e3ba6ffa4d7997a72eeaa1..a6372228bbd46c649ccf04bd26a4ded7526ba685 100644 (file)
@@ -17,7 +17,7 @@ namespace w1 {
                                        std::string device_id_param,
                                        dirent *direntry_param);
                        virtual ~W1TemperatureSensor();
-                       std::string get_raw_value();
+                       std::string get_raw_data();
                        std::string get_unit();
                        std::string get_device_type();
                protected:
index d0cd8e9943b1fd62c709c9cde8e5175ba547a288..88d4c5fc0b7d1a8ff8ed8948e33d18236cac9cec 100644 (file)
@@ -43,12 +43,13 @@ bool try_parse_long(const char *str, long *result) {
 }
 
 int main(int argc, char** argv) {
-       list<W1Device *>        device_list;
-       int                     round;
-       long                    scan_interval;
-       long                    store_interval;
-       string                  loc;
-       W1Device                *device;
+       list<W1Device *>                device_list;
+       int                             round;
+       long                            scan_interval;
+       long                            store_interval;
+       string                          loc;
+       W1Device                        *device;
+       list<W1Device *>::iterator      iter;
 
        // default values than can be overwritten with parameters
        loc     = "/tmp/w1data";
@@ -74,8 +75,8 @@ int main(int argc, char** argv) {
        if (device_list.size() > 0) {
                while(1) {
                        round++;
-                       for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
-                               device = (W1Device *)*list_iter;
+                       for(iter = device_list.begin(); iter != device_list.end(); iter++) {
+                               device = (W1Device *)*iter;
                                device->printout();
                                sleep(1);
                                if (round >= store_interval) {