4 * Created on: Oct 30, 2010
11 #include "W1CounterDevice.hh"
16 W1CounterDevice::W1CounterDevice(int family_code_param,
17 string device_id_param,
18 dirent *direntry_param): W1Device(family_code_param, device_id_param, direntry_param) {
21 ifstream ifs(slave_file.c_str());
22 if (ifs.is_open() == true) {
23 text = get_time() + ": device type = " + get_device_type() + ", 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_data() {
52 ret_val = "<could not read>";
53 ifstream ifs(slave_file.c_str());
54 if (ifs.is_open() == true) {
56 while(getline(ifs, value_line)) {
57 length = value_line.length();
59 pos = value_line.find("crc=YES c=");
61 (pos + 10 < length)) {
62 value_line = value_line.substr(pos + 10);
71 if (ret_val.length() == 0) {
75 ret_val = ret_val + "|" + value_line;
83 string W1CounterDevice::get_unit() {
87 string W1CounterDevice::get_device_type() {
88 return "Counter Device";