4 * Created on: Oct 30, 2010
11 #include "W1CounterDevice.hh"
16 W1CounterDevice::W1CounterDevice(dirent *direntry,
17 int family_code_param,
18 string id_param): W1Device(direntry, family_code_param, id_param) {
19 ifstream ifs(slave_file.c_str());
20 if (ifs.is_open() == true) {
23 text = get_time() + ": device type = " + get_devicetype_name() + ", id = " + id + ", could not read file: " + slave_file;
25 cout << "verify that you have w1_ds2423 kernel module loaded." << endl;
30 W1CounterDevice::~W1CounterDevice() {
31 // TODO Auto-generated destructor stub
34 bool W1CounterDevice::is_supported_family_code(int family_code) {
46 string W1CounterDevice::get_raw_value() {
53 ret_val = "<could not read>";
54 ifstream ifs(slave_file.c_str());
55 if (ifs.is_open() == true) {
57 while(getline(ifs, value_line)) {
58 length = value_line.length();
60 pos = value_line.find("crc=YES c=");
62 (pos + 10 < length)) {
63 value_line = value_line.substr(pos + 10);
72 if (ret_val.length() == 0) {
76 ret_val = ret_val + "|" + value_line;
84 string W1CounterDevice::get_unit() {
88 string W1CounterDevice::get_devicetype_name() {
89 return "Counter Device";