]> pilppa.org Git - lib1wire.git/blobdiff - src/W1CounterDevice.cc
Optimization for year and monthly data calculation.
[lib1wire.git] / src / W1CounterDevice.cc
index 3ebdbd47c50ae61404d5f5e15b74e5809d79321c..58e9a55ef742e5a9d9ef8e98142dc6f98b04f809 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <vector>
 
+#include <plp/log.h>
+
 #include "W1CounterDevice.hh"
 
 using namespace std;
@@ -32,10 +34,9 @@ W1CounterDevice::W1CounterDevice(int family_code_param,
        string text;
 
        ifstream ifs(slave_file.c_str());
-       if (ifs.is_open() == true) {
-               text    = get_time() + ": device type = " + get_device_type() + ", id = " + id + ", could not read file: " + slave_file;
-               cout << text << endl;
-               cout << "verify that you have w1_ds2423 kernel module loaded." << endl;
+       if (ifs.is_open() == false) {
+               log_error("%s: %s failed to read data from file: %s\n", id.c_str(), get_device_type().c_str(), slave_file.c_str());
+               log_error("Verify that you have w1_ds2423 kernel module loaded.\n");
                ifs.close();
        }
 }
@@ -60,7 +61,7 @@ vector<double> *W1CounterDevice::get_raw_data() {
        int             pos;
        int             b_cnt;
        string          val_str;
-       int             val_dbl;
+       int             val_int;
        vector<double>  *ret_val;
 
        ret_val = NULL;
@@ -76,8 +77,8 @@ vector<double> *W1CounterDevice::get_raw_data() {
                                                ret_val = new vector<double>();
                                        }
                                        val_str = val_str.substr(pos + 10);
-                                       string_to_number<int>(val_dbl, val_str, dec);
-                                       ret_val->push_back(val_dbl);
+                                       string_to_number<int>(val_int, val_str, dec);
+                                       ret_val->push_back(val_int);
                                }
                        }
                }
@@ -93,3 +94,7 @@ string W1CounterDevice::get_unit() {
 string W1CounterDevice::get_device_type() {
        return "Counter Device";
 }
+
+unsigned int W1CounterDevice::get_data_decimal_precision() {
+       return 0;
+}