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() == false) {
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;
32 W1CounterDevice::~W1CounterDevice() {
33 // TODO Auto-generated destructor stub
36 bool W1CounterDevice::is_supported_family_code(int family_code) {
48 string W1CounterDevice::get_value() {
55 ret_val = "<could not read>";
56 ifstream ifs(slave_file.c_str());
57 if (ifs.is_open() == true) {
59 while(getline(ifs, value_line)) {
60 length = value_line.length();
62 pos = value_line.find("crc=YES c=");
64 (pos + 10 < length)) {
65 value_line = value_line.substr(pos + 10);
74 if (ret_val.length() == 0) {
78 ret_val = ret_val + "|" + value_line;
86 string W1CounterDevice::get_unit() {
90 string W1CounterDevice::get_devicetype_name() {
91 return "Counter Device";