]> pilppa.org Git - lib1wire.git/blobdiff - src/W1Device.cc
storage data cleanup. allow specifying storage dir location
[lib1wire.git] / src / W1Device.cc
index 7f52c43f5795341c5943eb8610c5fd71f43d96a4..fef721c55ff7fc757767d9570de0ec66af7567cd 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <time.h>
 
+#include "W1Store.hh"
 #include "W1Device.hh"
 
 using namespace w1;
@@ -71,15 +72,18 @@ void W1Device::printout() {
 
 string W1Device::get_formatted_data() {
        string ret_val;
+       string val;
 
-       ret_val = get_formatted_data(get_value());
+       val     = get_value();
+       ret_val = get_formatted_data(val);
        return ret_val;
 }
 
 string W1Device::get_formatted_data(string value) {
        string ret_val;
 
-       ret_val = get_time() + ": device type = " + get_devicetype_name() + ", id = " + id + ", value = " + value + " " + get_unit();
+       ret_val = get_time() + "|" + get_devicetype_name() + "|" + id + "|" + value + " " + get_unit();
+       add_to_memory_cache(ret_val);
        return ret_val;
 }
 
@@ -89,6 +93,8 @@ void W1Device::add_to_memory_cache(std::string formatted_data) {
 }
 
 void W1Device::store() {
+       W1Store::store(id, memory_cache);
+/*
        string file_path = "/tmp/" + id + ".txt";
        string text_line;
        ofstream data_file(file_path.c_str(), ios::app);
@@ -109,4 +115,5 @@ void W1Device::store() {
        else {
                cout << "could not open file " << file_path << " for writing data." << endl;
        }
+*/
 }