#include <time.h>
#include <plp/log.h>
+#include "DeviceConfig.hh"
+#include "Factory.hh"
#include "W1Store.hh"
#include "W1Device.hh"
log_debug("w1 data file: %s\n", slave_file.c_str());
family_code = family_code_param;
id = device_id_param;
- name = device_id_param;
+ name = "";
}
W1Device::~W1Device() {
}
string W1Device::get_name() {
+ DeviceConfig *cfg;
+
+ if (name.empty() == true) {
+ cfg = Factory::get_device_config(id);
+ if (cfg != NULL) {
+ name = cfg->get_cfg_value("name");
+ delete(cfg);
+ }
+ }
return name;
}
void W1Device::set_name(string name_param) {
+ DeviceConfig *cfg;
+
name = name_param;
+ cfg = Factory::get_device_config(id);
+ if (cfg != NULL) {
+ cfg->set_cfg_value("name", name_param);
+ delete(cfg);
+ }
}
void W1Device::printout() {
if (argc > 3) {
try_parse_long(argv[3], &store_interval);
}
- log_info("start scanning, data saved to location: %s, scan interval: %ld, store interval: %ld\n", loc.c_str(), scan_interval, store_interval);
+ log_info("scanning 1-wire devices\n");
+ log_info("data save dir: %s, scan interval: %ld, save interval: %ld\n", loc.c_str(), scan_interval, store_interval);
DeviceConfig::set_base_dir_name(loc);
device_list = Factory::get_device_list();
round = 0;
if (device_list.size() > 0) {
- int ii = 0;
- while(ii < 6) {
- ii++;
+ while(1) {
round++;
for(iter = device_list.begin(); iter != device_list.end(); iter++) {
device = (W1Device *)*iter;