LDFLAGS="$LDFLAGS"
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
-AC_MSG_NOTICE([objective c Makefile])
+CXXFLAGS="$CXXFLAGS -ggdb -Wall -Werror"
+AC_SUBST(CXXFLAGS)
+AC_MSG_NOTICE([lib1wire Makefile])
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
}
Data::Data(vector<double> vector_param, Date *date_param) {
- int ii;
- int size;
+ unsigned int ii;
+ unsigned int size;
size = vector_param.size();
//log_debug("Data(), value count: %d\n", size);
value_arr.resize(size);
- for (int ii = 0; ii < vector_param.size(); ii++) {
+ for (ii = 0; ii < vector_param.size(); ii++) {
value_arr[ii] = vector_param.at(ii);
//log_debug("Data(), value[%d]: %f\n", ii, value_arr[ii]);
}
}
Data::Data(std::valarray<double> value_arr_param, Date *date_param) {
+ unsigned int ii;
+
value_arr.resize(value_arr_param.size());
- for (int ii = 0; ii < value_arr_param.size(); ii++) {
+
+ for (ii = 0; ii < value_arr_param.size(); ii++) {
value_arr[ii] = value_arr_param[ii];
}
date_time.copy(date_param);
}
void Data::printout() {
- int ii;
+ unsigned int ii;
date_time.printout();
for (ii = 0; ii < value_arr.size(); ii++) {
}
DataRange::~DataRange() {
- int ii;
- Date *date;
+ unsigned int ii;
+ Date *date;
if (val_matrix != NULL) {
free(val_matrix);
}
void DataRange::add_data(Data data) {
- int ii;
- int r_count;
- int indx;
- Date date;
+ unsigned int ii;
+ int indx;
+ Date date;
//log_debug("old row_count: %d, column_count: %d, value_arr_size: %d\n", row_count, column_count, data.value_arr.size());
val_matrix = (double *)realloc(val_matrix, ((row_count + 1) * column_count) * sizeof(double));
#include <string>
#include <valarray>
#include <vector>
-#include <hash_map>
#include "Date.hh"
ret_val = false;
if ((year % 4 == 0) &&
- (year % 400 == 0) || (year % 100 != 0)) {
+ ((year % 400 == 0) || (year % 100 != 0))) {
ret_val = true;
}
return ret_val;
char buffer[30];
string ret_val;
- int n, a=5, b=3;
sprintf(buffer, "%016d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec);
ret_val = buffer;
return ret_val;
#include "DeviceConfig.hh"
+#include <string.h>
+#include <malloc.h>
+
+#include <plp/log.h>
+#include "W1Util.hh"
+#include "W1Configure.hh"
+
+#include "Factory.hh"
+
using namespace std;
using namespace w1;
+string DeviceConfig::store_base_dir = DEFAULT_STORAGE_BASE_DIR;
+
+ConfigHandle::ConfigHandle(uci_context *ctx_param, uci_package *pkg_param) {
+ ctx = ctx_param;
+ pkg = pkg_param;
+}
+
+ConfigHandle::~ConfigHandle() {
+ uci_unload(ctx, pkg);
+ uci_free_context(ctx);
+}
+
DeviceConfig::DeviceConfig(string device_id_param) {
device_id = device_id_param;
+ uci_handle = load_device_config(device_id_param);
+ if (uci_handle != NULL) {
+ device_type = get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+ }
+ else {
+ log_error("Could not read device config\n");
+ }
}
DeviceConfig::~DeviceConfig() {
+ if (uci_handle != NULL) {
+ delete(uci_handle);
+ uci_handle = NULL;
+ }
+}
+
+void DeviceConfig::set_base_dir_name(string store_param) {
+ int pos;
+ int b_count;
+
+ pos = store_param.find_last_of("/");
+ b_count = store_param.length();
+ if (pos == (b_count - 1)) {
+ store_base_dir = store_param;
+ }
+ else {
+ store_base_dir = store_param + "/";
+ }
+}
+
+string DeviceConfig::get_base_dir_name() {
+ return store_base_dir;
+}
+
+string DeviceConfig::get_dir_name(string device_id_param) {
+ string ret_val;
+ string d_name;
+
+ d_name = DeviceConfig::get_base_dir_name();
+ ret_val = W1Util::concat_paths(d_name, device_id_param);
+ return ret_val;
+}
+
+string DeviceConfig::get_file_name(string device_id_param) {
+ string ret_val;
+ string fname;
+
+ fname = DEVICE_CONFIG__FILE_NAME;
+ ret_val = get_dir_name(device_id);
+ ret_val = W1Util::concat_paths(ret_val, fname);
+ return ret_val;
+}
+
+string DeviceConfig::get_cfg_value(string key) {
+ struct uci_section *section;
+ struct uci_option *option;
+ string ret_val;
+
+ if (uci_handle != NULL) {
+ section = uci_lookup_section(uci_handle->ctx, uci_handle->pkg, DEVICE_CONFIG__SECTION_NAME);
+ if (section != NULL) {
+ option = uci_lookup_option(uci_handle->ctx, section, key.c_str());
+ switch (option->type) {
+ case UCI_TYPE_STRING:
+ log_info("config file: key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string);
+ ret_val = option->v.string;
+ break;
+ default:
+ log_error("config file: key: %s can not parse parameter value\n", key.c_str());
+ break;
+ }
+ }
+ }
+ return ret_val;
}
-string DeviceConfig::get_config_value(string key) {
- return NULL;
+void DeviceConfig::set_cfg_value(string key, string value) {
+ string cfg_dir;
+ string cfg_fl;
+
+ cfg_dir = get_dir_name(device_id);
+ cfg_fl = DEVICE_CONFIG__FILE_NAME;
+
+ set_config_value(cfg_dir.c_str(),
+ cfg_fl.c_str(),
+ DEVICE_CONFIG__SECTION_TYPE,
+ DEVICE_CONFIG__SECTION_NAME,
+ key.c_str(),
+ value.c_str());
}
enum_summary_calculation DeviceConfig::get_summary_calculation_type() {
- return MEAN;
+ enum_summary_calculation ret_val;
+
+ ret_val = MEAN;
+ if (device_type.empty() == false) {
+ if (device_type.compare("counter") == 0) {
+ ret_val = DELTA;
+ }
+ }
+ return ret_val;;
+}
+
+ConfigHandle *DeviceConfig::load_device_config(string device_id_param) {
+ int err_flg;
+ struct uci_context *ctx;
+ struct uci_package *pkg;
+ string cfg_fl;
+ string cfg_dir;
+ ConfigHandle *ret_val;
+
+ ret_val = NULL;
+ cfg_dir = get_dir_name(device_id_param);
+ if (cfg_dir.empty() == false) {
+ cfg_fl = get_file_name(device_id_param);
+ ctx = uci_alloc_context();
+ if (ctx != NULL) {
+ log_debug("uci_set_confdir: %s\n", cfg_dir.c_str());
+ uci_set_confdir(ctx, cfg_dir.c_str());
+ if (access(cfg_fl.c_str(), R_OK) != 0) {
+ log_debug("loading file: %s\n", cfg_fl.c_str());
+ err_flg = uci_load(ctx, cfg_fl.c_str(), &pkg);
+ if (err_flg == UCI_OK) {
+ log_debug("Loaded device configuration: %s, UCI_OK: %d, err flg: %d\n.", cfg_fl.c_str(), UCI_OK, err_flg);
+ ret_val = new ConfigHandle(ctx, pkg);
+ }
+ else {
+ log_debug("Failed to load file: %s, UCI_OK: %d, err flg: %d\n.", cfg_fl.c_str(), UCI_OK, err_flg);
+ set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "unknowntype");
+ }
+ }
+ }
+ else {
+ log_error("Failed to load device device configurations, invalid device id: %s.\n", cfg_dir.c_str());
+ }
+ }
+ return ret_val;
}
#include <string>
+extern "C" {
+#include <uci.h>
+#include <plp/config.h>
+}
+
+#define DEVICE_CONFIG__FILE_NAME "dev_cfg.txt"
+#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__NAME "name"
+
namespace w1 {
enum enum_summary_calculation {SUM, DELTA, MEAN, MAX, MIN};
+ struct ConfigHandle {
+ public:
+ ConfigHandle(uci_context *ctx_param, uci_package *pkg_param);
+ ~ConfigHandle();
+ struct uci_context *ctx;
+ struct uci_package *pkg;
+ };
+
class DeviceConfig {
public:
DeviceConfig(std::string device_id_param);
virtual ~DeviceConfig();
- std::string get_config_value(std::string key);
+ static std::string get_base_dir_name();
+ static void set_base_dir_name(std::string store_param);
+ std::string get_cfg_value(std::string key);
+ void set_cfg_value(std::string key, std::string value);
enum_summary_calculation get_summary_calculation_type();
private:
- std::string device_id;
+ static std::string store_base_dir;
+ std::string device_id;
+ std::string device_type;
+ ConfigHandle *uci_handle;
+ ConfigHandle *load_device_config(std::string device_id_param);
+ std::string get_dir_name(std::string device_id);
+ std::string get_file_name(std::string device_id_param);
};
}
--- /dev/null
+/*
+ * Factory.cc
+ *
+ * Created on: Dec 11, 2010
+ * Author: lamikr
+ */
+
+#include <plp/log.h>
+#include "Factory.hh"
+#include "W1TemperatureSensor.hh"
+#include "W1CounterDevice.hh"
+
+using namespace w1;
+using namespace std;
+
+Factory::Factory() {
+ // TODO Auto-generated constructor stub
+}
+
+Factory::~Factory() {
+ // TODO Auto-generated destructor stub
+}
+
+W1Device *Factory::get_device(int family_code,
+ string device_id,
+ dirent *direntry_param) {
+ W1Device *ret_val;
+ DeviceConfig *config;
+
+ ret_val = NULL;
+ log_debug("family_code: %d\n", family_code);
+ switch(family_code) {
+ case 0x10:
+ case 0x28:
+ ret_val = new W1TemperatureSensor(family_code, device_id, direntry_param);
+ log_debug("temperature sensor: %d\n", ret_val->get_family_code());
+ break;
+ case 0x1d:
+ ret_val = new W1CounterDevice(family_code, device_id, direntry_param);
+ log_debug("counter device: %d\n", family_code);
+ break;
+ default:
+ log_debug("device not created, unsupported device type: %d\n", family_code);
+ break;
+ }
+ if (ret_val != NULL) {
+ // check that device config exist
+ // if not, create default...
+ config = get_device_config(device_id);
+ if (config != NULL) {
+ string type;
+ type = config->get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+ if (type.empty() == true) {
+ type = ret_val->get_device_type();
+ config->set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, type);
+ }
+ }
+ }
+ return ret_val;
+}
+
+DeviceConfig *Factory::get_device_config(string device_id) {
+ DeviceConfig *ret_val;
+
+ ret_val = new DeviceConfig(device_id);
+ return ret_val;
+}
--- /dev/null
+/*
+ * Factory.hh
+ *
+ * Created on: Dec 11, 2010
+ * Author: lamikr
+ */
+
+#ifndef FACTORY_HH_
+#define FACTORY_HH_
+
+#include <string>
+
+#include <dirent.h>
+
+#include "DeviceConfig.hh"
+#include "W1Device.hh"
+
+namespace w1 {
+ class Factory {
+ public:
+ Factory();
+ virtual ~Factory();
+ static W1Device *get_device(int family_code, std::string device_id, dirent *direntry_param);
+ static DeviceConfig *get_device_config(std::string device_id);
+ };
+}
+
+#endif /* FACTORY_HH_ */
lib_LTLIBRARIES = lib1wire.la
lib1wire_la_SOURCES = \
+ Factory.cc Factory.hh \
W1Device.cc W1Device.hh \
W1Scanner.cc W1Scanner.hh \
W1Store.cc W1Store.hh \
Date.cc Date.hh \
W1Configure.hh
lib1wire_la_LDFLAGS = $(SRC_LIBS) $(all_libraries) -version-info 1:0:0 -no-undefined
-AM_CPPFLAGS = $(SRC_CFLAGS) -Iidl
+AM_CPPFLAGS = $(SRC_CFLAGS)
DISTCLEANFILES = Makefile.in
using namespace std;
using namespace w1;
-W1CounterDevice::W1CounterDevice(dirent *direntry,
- int family_code_param,
- string id_param): W1Device(direntry, family_code_param, id_param) {
+W1CounterDevice::W1CounterDevice(int family_code_param,
+ string device_id_param,
+ dirent *direntry_param): W1Device(family_code_param, device_id_param, direntry_param) {
+ string text;
+
ifstream ifs(slave_file.c_str());
if (ifs.is_open() == true) {
- string text;
-
- text = get_time() + ": device type = " + get_devicetype_name() + ", id = " + id + ", could not read file: " + slave_file;
+ text = get_time() + ": device type = " + get_device_type() + ", id = " + id + ", could not read file: " + slave_file;
cout << text << endl;
cout << "verify that you have w1_ds2423 kernel module loaded." << endl;
ifs.close();
}
string W1CounterDevice::get_raw_value() {
- string ret_val;
- string value_line;
- int pos;
- int length;
- int ii;
+ string ret_val;
+ string value_line;
+ int pos;
+ int length;
ret_val = "<could not read>";
ifstream ifs(slave_file.c_str());
return "";
}
-string W1CounterDevice::get_devicetype_name() {
+string W1CounterDevice::get_device_type() {
return "Counter Device";
}
namespace w1 {
class W1CounterDevice: public w1::W1Device {
public:
- W1CounterDevice(dirent *direntry, int family_code_param, std::string id_param);
+ W1CounterDevice(int family_code_param,
+ std::string device_id_param,
+ dirent *direntry_param);
virtual ~W1CounterDevice();
std::string get_raw_value();
std::string get_unit();
- std::string get_devicetype_name();
+ std::string get_device_type();
protected:
bool is_supported_family_code(int family_code);
};
#include "W1Util.hh"
#include "W1DataList.hh"
#include "W1Store.hh"
+#include "DeviceConfig.hh"
#include "plp/log.h"
device_config = new DeviceConfig(device_id_param);
summary_calc_type = device_config->get_summary_calculation_type();
device_id = device_id_param;
- base_dir = W1Store::get_base_dir_name();
+ base_dir = DeviceConfig::get_base_dir_name();
device_dir = W1Util::concat_paths(base_dir, device_id);
device_ch_dir = W1Util::concat_paths(base_dir, "cache");
device_ch_dir = W1Util::concat_paths(device_ch_dir, device_id);
}
Data *W1DataList::find_oldest_data(vector<string> year_vector) {
- int ii;
+ unsigned int ii;
string year_dir;
string month_dir;
vector<string> month_vector;
DataRange *W1DataList::get_data_range() {
DataRange *ret_val;
- DIR *data_dir;
- struct dirent *year_dirent;
vector<string> year_list;
Data *first_data;
Data *newest_data;
#include <fstream>
#include <time.h>
+#include <plp/log.h>
#include "W1Store.hh"
#include "W1Device.hh"
using namespace w1;
using namespace std;
-W1Device::W1Device(dirent *direntry,
- int family_code_param,
- string id_param) {
+W1Device::W1Device(int family_code_param,
+ string device_id_param,
+ dirent *direntry_param) {
string rootdir;
string device_dir;
string temp_str;
rootdir = W1_SCAN_ROOTDIR;
temp_str = W1_SLAVE_FILE;
- dir_path = rootdir + "/" + direntry->d_name;
+ dir_path = rootdir + "/" + direntry_param->d_name;
slave_file = dir_path + "/" + temp_str;
+ log_debug("w1 data file: %s\n", slave_file.c_str());
family_code = family_code_param;
- id = id_param;
- name = id_param;
+ id = device_id_param;
+ name = device_id_param;
}
W1Device::~W1Device() {
string W1Device::get_formatted_value(string value) {
string ret_val;
- ret_val = get_time() + "|" + get_devicetype_name() + "|" + id + "|" + value + " " + get_unit();
+ ret_val = get_time() + "|" + get_device_type() + "|" + id + "|" + value + " " + get_unit();
add_to_memory_cache(ret_val);
return ret_val;
}
namespace w1 {
class W1Device {
public:
- W1Device(dirent *direntry, int family_code_param, std::string id_param);
+ W1Device(int family_code_param,
+ std::string device_id_param,
+ dirent *direntry_param);
virtual ~W1Device();
int get_family_code();
std::string get_id();
virtual std::string get_raw_value() = 0;
std::string get_formatted_value();
virtual std::string get_unit() = 0;
- virtual std::string get_devicetype_name() = 0;
+ virtual std::string get_device_type() = 0;
std::string get_time();
virtual void printout();
virtual void store();
#include "W1Scanner.hh"
#include "W1TemperatureSensor.hh"
#include "W1CounterDevice.hh"
+#include "Factory.hh"
using namespace w1;
using namespace std;
W1Scanner::~W1Scanner() {
}
-W1Device *W1Scanner::create_device(dirent *direntry) {
+W1Device *W1Scanner::create_device(dirent *direntry_param) {
string folder_name;
string tmp_str;
string device_name;
W1Device *ret_val;
ret_val = NULL;
- folder_name = direntry->d_name;
+ folder_name = direntry_param->d_name;
pos = folder_name.find("-");
if (pos > 0) {
tmp_str = folder_name.substr(0, pos);
if (suc_flg == true) {
log_debug("family_code: %d\n", family_code);
device_name = folder_name.substr(pos + 1, folder_name.length() - pos);
- switch(family_code) {
- case 0x10:
- case 0x28:
- ret_val = new W1TemperatureSensor(direntry, family_code, device_name);
- log_debug("temperature sensor: %d\n", ret_val->get_family_code());
- break;
- case 0x1d:
- log_debug("counter device: %d\n", family_code);
- ret_val = new W1CounterDevice(direntry, family_code, device_name);
- break;
- default:
- log_debug("device not created the device, unsupported device type: %d\n", family_code);
- break;
- }
+ ret_val = Factory::get_device(family_code,
+ device_name,
+ direntry_param);
}
}
return ret_val;
std::list<W1Device *> get_device_list();
private:
//int parse_family_code(std::string folder_name);
- W1Device *create_device(dirent *direntry);
+ W1Device *create_device(dirent *direntry_param);
};
}
using namespace w1;
using namespace plp;
-std::string W1Store::store_base_dir = DEFAULT_STORAGE_BASE_DIR;
-
W1Store::W1Store(string device_id,
Date *date_time) {
store_data = NULL;
}
}
-void W1Store::set_base_dir_name(string store_param) {
- int pos;
- int b_count;
-
- pos = store_param.find_last_of("/");
- b_count = store_param.length();
- if (pos == (b_count - 1)) {
- store_base_dir = store_param;
- }
- else {
- store_base_dir = store_param + "/";
- }
-}
-
-string W1Store::get_base_dir_name() {
- return store_base_dir;
-}
-
string W1Store::get_dir_name(string device_id, Date *date_time) {
string ret_val;
char buffer[30];
+ string d_name;
+ d_name = DeviceConfig::get_base_dir_name();
snprintf(buffer, 30, "%d/%02d", date_time->year, date_time->month);
- ret_val = W1Util::concat_paths(store_base_dir, device_id);
+ ret_val = W1Util::concat_paths(d_name, device_id);
ret_val = ret_val + "/" + buffer;
return ret_val;
}
double new_val;
int ii;
int jj;
- Date *date;
Data *data;
Data *ret_val;
double new_val;
int ii;
int jj;
- Date *date;
Data *data;
Data *ret_val;
double min_val;
double new_val;
int ii;
int jj;
- Date *date;
Data *data;
Data *ret_val;
double max_val;
Data *W1Store::get_oldest_data() {
int row_count;
- int col_count;
Data *ret_val;
DataRange *dr;
Data *W1Store::get_newest_data() {
int row_count;
- int col_count;
Data *ret_val;
DataRange *dr;
plp::Date *date_time);
W1Store(std::string file_name_param);
virtual ~W1Store();
- static std::string get_base_dir_name();
- static void set_base_dir_name(std::string store_param);
static std::string get_dir_name(std::string device_id, plp::Date *ltime);
static std::string get_file_name(std::string device_id, plp::Date *ltime);
static void store(std::string device_id, std::list<std::string> *string_list);
w1::Data *get_newest_data();
w1::DataRange *get_oldest_and_newest_data();
protected:
- static std::string store_base_dir;
std::string store_file_name;
DataRange *store_data;
DataRange *range_data;
string convert_celcius_value_to_three_digits(string raw_value) {
string ret_val;
- int int_val;
bool suc_flg;
double dbl_val;
return ret_val;
}
-W1TemperatureSensor::W1TemperatureSensor(dirent *direntry,
- int family_code_param,
- string id_param): W1Device(direntry, family_code_param, id_param) {
+W1TemperatureSensor::W1TemperatureSensor(int family_code_param,
+ string device_id_param,
+ dirent *direntry_param): W1Device(family_code_param, device_id_param, direntry_param) {
+ string text;
+
log_debug("trying to open file: %s\n", slave_file.c_str());
ifstream ifs(slave_file.c_str());
if (ifs.is_open() == false) {
- string text;
-
- text = get_time() + ": device type = " + get_devicetype_name() + ", id = " + id + ", could not read file: " + slave_file + "\n";
+ text = get_time() + ": device type = " + get_device_type() + ", id = " + id + ", could not read file: " + slave_file + "\n";
log_debug(text.c_str());
log_debug("verify that you have w1_therm kernel module loaded.\n");
ifs.close();
string last_line;
int pos;
int length;
- string formatted_data;
- int int_value;
+ string format;
ret_val = "<could not read>";
ifstream ifs(slave_file.c_str());
return "C";
}
-string W1TemperatureSensor::get_devicetype_name() {
+string W1TemperatureSensor::get_device_type() {
return "Temperature Sensor";
}
namespace w1 {
class W1TemperatureSensor : public W1Device {
public:
- W1TemperatureSensor(dirent *direntry, int family_code_param, std::string id_param);
+ W1TemperatureSensor(int family_code_param,
+ std::string device_id_param,
+ dirent *direntry_param);
virtual ~W1TemperatureSensor();
std::string get_raw_value();
std::string get_unit();
- std::string get_devicetype_name();
+ std::string get_device_type();
protected:
bool is_supported_family_code(int family_code);
};
std::ofstream *W1Util::open_for_writing(const char *f_path) {
char *d_path;
- char *p;
size_t b_count;
- int ii;
ofstream *ret_val;
bool b_flg;
test_w1_datalog_write_SOURCES = test_w1_datalog_write.cc
test_w1_datalog_write_LDADD = $(SRC_LIBS) ../src/.libs/lib1wire.a
-AM_CPPFLAGS = $(SRC_CFLAGS) -I../src
+AM_CPPFLAGS = -I../src
DISTCLEANFILES = Makefile.in
\ No newline at end of file
#include <plp/log.h>
#include "W1DataList.hh"
-#include "W1Store.hh"
+#include "DeviceConfig.hh"
#include "W1Scanner.hh"
+#include "Date.hh"
#include "W1Util.hh"
using namespace w1;
}
int main(int argc, char** argv) {
- int round;
string loc;
- bool err_flg;
Data *fdata;
Data *ldata;
W1DataList *dlist;
else {
log_warning("No storage location parameter given, using default location: %s\n", loc.c_str());
}
- W1Store::set_base_dir_name(loc);
+ DeviceConfig::set_base_dir_name(loc);
dlist = new W1DataList("0008014e9e09");
if (dlist != NULL) {
dr = dlist->get_data_range();
ldata = dr->get_last_data();
if (ldata != NULL) {
ldata->printout();
- dr2 = dlist->get_data(&fdata->get_date(), &ldata->get_date());
+ plp::Date d1;
+ plp::Date d2;
+
+ d1 = fdata->get_date();
+ d2 = ldata->get_date();
+ dr2 = dlist->get_data(&d1, &d2);
delete(ldata);
if (dr2 != NULL) {
delete(dr2);
#include <plp/log.h>
-#include "W1Store.hh"
+#include "DeviceConfig.hh"
#include "W1Scanner.hh"
using namespace w1;
long scan_interval;
long store_interval;
string location;
- bool err_flg;
W1Device *device;
// default values than can be overwritten with parameters
if (argc > 3) {
try_parse_long(argv[3], &store_interval);
}
- log_info("start scanning, data saved to location: %s, scan interval: %d, store interval: %d\n", location.c_str(), scan_interval, store_interval);
- W1Store::set_base_dir_name(location);
+ log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", location.c_str(), scan_interval, store_interval);
+ DeviceConfig::set_base_dir_name(location);
scanner = new W1Scanner();
device_list = scanner->get_device_list();
round = 0;
round++;
for(list<W1Device *>::iterator list_iter = device_list.begin(); list_iter != device_list.end(); list_iter++) {
device = (W1Device *)*list_iter;
-
device->printout();
sleep(1);
if (round >= store_interval) {