X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FW1Device.cc;h=a765cd36a6091432b4d2577ae6828efc3f36694b;hb=d58713adbc518552c11fd19bd21ae8bd11ab434f;hp=7bb44183c489287c846d95487dbafa44abe25773;hpb=6dea0b59503a71874c4476c05044fff3c5ae26a5;p=lib1wire.git diff --git a/src/W1Device.cc b/src/W1Device.cc index 7bb4418..a765cd3 100644 --- a/src/W1Device.cc +++ b/src/W1Device.cc @@ -36,6 +36,14 @@ W1Device::W1Device(int family_code_param, } W1Device::~W1Device() { + list::iterator iter; + Data *data; + + for(iter = memory_cache.begin(); iter != memory_cache.end(); iter++) { + data = (Data *)*iter; + delete(data); + } + memory_cache.clear(); } int W1Device::get_w1_family_code() { @@ -54,19 +62,6 @@ void W1Device::set_name(string name_param) { name = name_param; } -string W1Device::get_time() { - time_t wtime; - struct tm *ltime; - char buffer[80]; - string ret_val; - - time(&wtime); - ltime = localtime(&wtime); - strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", ltime); - ret_val = buffer; - return ret_val; -} - void W1Device::printout() { Data *data; string text; @@ -105,16 +100,6 @@ Data *W1Device::get_and_collect_data() { return ret_val; } -/* -Data *W1Device::get_formatted_data(Data *data) { - Data *ret_val; - - ret_val = get_time() + "|" + raw_data + " " + get_unit(); - add_to_save_fifo(ret_val); - return ret_val; -} -*/ - void W1Device::collect_data(Data *data) { // TODO: add mutex for memory_cache memory_cache.push_back(data); @@ -123,8 +108,10 @@ void W1Device::collect_data(Data *data) { void W1Device::save_data() { list::iterator iter; Data *data; + int dec_precision; - W1Store::save(id, &memory_cache); + dec_precision = get_data_decimal_precision(); + W1Store::save(id, &memory_cache, dec_precision); for(iter = memory_cache.begin(); iter != memory_cache.end(); iter++) { data = (Data *)*iter; delete(data);