X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FW1CounterDevice.cc;h=c77b872db77786d3da509746e232645f9ad7cbaa;hb=e3fdbdfff2fc5e4ca6bc42e71ba8265c0e5c3719;hp=3ebdbd47c50ae61404d5f5e15b74e5809d79321c;hpb=6dea0b59503a71874c4476c05044fff3c5ae26a5;p=lib1wire.git diff --git a/src/W1CounterDevice.cc b/src/W1CounterDevice.cc index 3ebdbd4..c77b872 100644 --- a/src/W1CounterDevice.cc +++ b/src/W1CounterDevice.cc @@ -12,6 +12,8 @@ #include +#include + #include "W1CounterDevice.hh" using namespace std; @@ -26,16 +28,15 @@ bool string_to_number(NumberDataType& result, return !(iss >> format >> result).fail(); } -W1CounterDevice::W1CounterDevice(int family_code_param, - string device_id_param, - dirent *direntry_param): W1Device(family_code_param, device_id_param, direntry_param) { +W1CounterDevice::W1CounterDevice(string device_id_param, + string device_type_param, + dirent *direntry_param): W1Device(device_id_param, device_type_param, direntry_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_type().c_str(), slave_file.c_str()); + log_error("Verify that you have w1_ds2423 kernel module loaded.\n"); ifs.close(); } } @@ -44,23 +45,11 @@ W1CounterDevice::~W1CounterDevice() { // TODO Auto-generated destructor stub } -bool W1CounterDevice::is_supported_w1_family_code(int family_code) { - bool ret_val; - - ret_val = false; - switch(family_code) { - case 0x1d: - ret_val = true; - break; - } - return ret_val; -} - vector *W1CounterDevice::get_raw_data() { int pos; int b_cnt; string val_str; - int val_dbl; + int val_int; vector *ret_val; ret_val = NULL; @@ -76,8 +65,8 @@ vector *W1CounterDevice::get_raw_data() { ret_val = new vector(); } val_str = val_str.substr(pos + 10); - string_to_number(val_dbl, val_str, dec); - ret_val->push_back(val_dbl); + string_to_number(val_int, val_str, dec); + ret_val->push_back(val_int); } } } @@ -90,6 +79,6 @@ string W1CounterDevice::get_unit() { return ""; } -string W1CounterDevice::get_device_type() { - return "Counter Device"; +unsigned int W1CounterDevice::get_data_decimal_precision() { + return 0; }