2 * W1TemperatureSensor.cc
4 * Created on: Oct 20, 2010
11 #include "W1TemperatureSensor.hh"
16 W1TemperatureSensor::W1TemperatureSensor(dirent *direntry, int family_code_param, string id_param): W1Device(direntry, family_code_param, id_param) {
17 ifstream ifs(slave_file.c_str());
18 if (ifs.is_open() == false) {
21 text = get_time() + ": device type = temperature sensor, id = " + id + ", could not read file: " + slave_file;
23 cout << "verify that you have w1_therm kernel module loaded" << endl;
30 W1TemperatureSensor::~W1TemperatureSensor() {
33 bool W1TemperatureSensor::is_supported_family_code(int family_code) {
46 string W1TemperatureSensor::get_value() {
47 vector<string> text_file;
54 ret_val = "<could not read>";
55 ifstream ifs(slave_file.c_str());
56 if (ifs.is_open() == true) {
57 while(getline(ifs, temp)) {
58 if (temp.length() > 0) {
60 //cout << ret_val << endl;
64 length = last_line.length();
66 pos = last_line.find("t=");
69 ret_val = last_line.substr(pos + 2);
76 string W1TemperatureSensor::get_unit() {
80 void W1TemperatureSensor::printout() {
83 text = get_time() + ": device type = temperature sensor, id = " + id + ", value = " + get_value();