From 6c332c9dfe49d7fe08478946decce32a8f577ef4 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Wed, 22 Dec 2010 02:15:37 +0200 Subject: [PATCH] Support for seting and changing values from device specific config files. Signed-off-by: Mika Laitio --- src/Data.cc | 4 +--- src/DeviceConfig.hh | 1 + src/Factory.cc | 1 + src/W1Device.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Data.cc b/src/Data.cc index 388dbef..29325b7 100644 --- a/src/Data.cc +++ b/src/Data.cc @@ -105,9 +105,7 @@ Data *Data::parse_data_string(const string& dataline) { // parse date date = W1Util::parse_date_str(item); } - // skip the device type and device id fields - // TODO: store device type and id to own file - else if (ii >= 3) { + else if (ii >= 1) { suc_flg = string_to_number(val, item, dec); if (suc_flg) { //log_debug("adding number: %f\n", val); diff --git a/src/DeviceConfig.hh b/src/DeviceConfig.hh index c2cfb31..cd86954 100644 --- a/src/DeviceConfig.hh +++ b/src/DeviceConfig.hh @@ -19,6 +19,7 @@ extern "C" { #define DEVICE_CONFIG__SECTION_TYPE "device" #define DEVICE_CONFIG__SECTION_NAME "base_data" #define DEVICE_CONFIG_VALUE_KEY__TYPE "type" +#define DEVICE_CONFIG_VALUE_KEY__ID "id" #define DEVICE_CONFIG_VALUE_KEY__NAME "name" namespace w1 { diff --git a/src/Factory.cc b/src/Factory.cc index e9637a4..c81dbe1 100644 --- a/src/Factory.cc +++ b/src/Factory.cc @@ -53,6 +53,7 @@ W1Device *Factory::get_device(int family_code, if (type.empty() == true) { type = ret_val->get_device_type(); config->set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, type); + config->set_cfg_value(DEVICE_CONFIG_VALUE_KEY__ID, ret_val->get_id()); } } } diff --git a/src/W1Device.cc b/src/W1Device.cc index 467a335..46e5b70 100644 --- a/src/W1Device.cc +++ b/src/W1Device.cc @@ -84,7 +84,7 @@ string W1Device::get_formatted_value() { string W1Device::get_formatted_value(string value) { string ret_val; - ret_val = get_time() + "|" + get_device_type() + "|" + id + "|" + value + " " + get_unit(); + ret_val = get_time() + "|" + value + " " + get_unit(); add_to_memory_cache(ret_val); return ret_val; } -- 2.41.1