return ret_val;
}
-Device *Factory::create_w1_device(int family_code_param,
+Device *Factory::create_w1_device(int device_w1_family_code_param,
+ string device_type_param,
string device_id_param,
- string type_param,
dirent *direntry_param) {
Device *ret_val;
DeviceConfig *config;
ret_val = NULL;
- if (type_param.empty() == false) {
- switch(family_code_param) {
+ if (device_type_param.empty() == false) {
+ switch(device_w1_family_code_param) {
case 0x10:
case 0x28:
- ret_val = new W1TemperatureSensor(device_id_param, type_param, direntry_param);
+ ret_val = new W1TemperatureSensor(device_id_param, device_type_param, direntry_param);
break;
case 0x1d:
- ret_val = new W1CounterDevice(device_id_param, type_param, direntry_param);
+ ret_val = new W1CounterDevice(device_id_param, device_type_param, direntry_param);
break;
case 0x81:
// 0x81 is the 1-wire USB dongle... No need to create device for it.
break;
default:
- log_debug("Unsupported 1-wire-family code: %#x, device not created: %s\n", family_code_param, device_id_param.c_str());
+ log_debug("Unsupported 1-wire-family code: %#x, device not created: %s\n", device_w1_family_code_param, device_id_param.c_str());
break;
}
if (ret_val != NULL) {
config = DeviceConfig::get_device_config(device_id_param);
if (config != NULL) {
// if not, create default device config
- type_param = config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
- if (type_param.empty() == true) {
- type_param = ret_val->get_type();
- config->set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, type_param);
+ device_type_param = config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+ if (device_type_param.empty() == true) {
+ device_type_param = ret_val->get_type();
+ config->set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, device_type_param);
config->set_config_value(DEVICE_CONFIG_VALUE_KEY__ID, ret_val->get_id());
}
delete(config);
int family_code;
Device *ret_val;
- ret_val = NULL;
+ ret_val = NULL;
if (device_type_param.empty() == false) {
family_code = get_family_code_by_device_type(device_type_param);
if (family_code != -1) {
- ret_val = create_w1_device(family_code, device_type_param, device_id_param, NULL);
+ ret_val = create_w1_device(family_code, device_type_param, device_id_param, NULL);
}
}
return ret_val;
int *err_code_param) {
string folder_name;
string tmp_str;
- string device_name;
+ string device_id;
int pos;
int family_code;
bool suc_flg;
if (family_code != 0x81) {
if (suc_flg == true) {
log_debug("1-wire device family code: %#x\n", family_code);
- device_name = folder_name.substr(pos + 1, folder_name.length() - pos);
+ device_id = folder_name.substr(pos + 1, folder_name.length() - pos);
ret_val = Factory::create_w1_device(family_code,
- device_name,
+ device_id,
direntry_param);
if ((ret_val == NULL) &&
(family_code != 0x81)) {
virtual ~Factory();
static std::list<plp::Device *> get_device_list();
private:
- //int parse_family_code(std::string folder_name);
- static plp::Device *create_w1_device(int family_code_param, string device_id_param, string type_param, dirent *direntry_param);
- static plp::Device *create_w1_device(int family_code, std::string device_id, dirent *direntry_param);
- static plp::Device *create_w1_device(std::string device_type_param, std::string device_id_param);
+ //int parse_family_code(string folder_name);
+ static plp::Device *create_w1_device(int family_code_param, string device_type_param, string device_id_param, dirent *direntry_param);
+ static plp::Device *create_w1_device(int family_code, string device_id, dirent *direntry_param);
+ static plp::Device *create_w1_device(string device_type_param, string device_id_param);
static plp::Device *create_w1_device(dirent *direntry_param, int *err_code_param);
static std::list<plp::DataReader *> get_data_reader_list();
- static int get_family_code_by_device_type(std::string device_type_param);
- static std::string get_device_type_by_family_code(int family_code_param);
+ static int get_family_code_by_device_type(string device_type_param);
+ static string get_device_type_by_family_code(int family_code_param);
};
}
}
W1Device::~W1Device() {
- log_debug("W1Device destructor\n");
+ log_debug("started\n");
save_and_clean_cache();
if (reader != NULL) {
delete(reader);
Data *ret_val;
vector<double> *vect;
- log_debug("get_data() started\n");
ret_val = NULL;
vect = get_raw_data();
if (vect != NULL) {
- log_debug("get_data() got raw data\n");
ret_val = new Data(vect, get_unit());
cache(ret_val);
delete(vect);
- log_debug("get_data() got raw data done\n");
+ log_debug("%s returning new data\n", id.c_str());
}
else {
- log_debug("get_data() try to read old already saved data\n");
- // read old data already saved
+ // read old already saved data
+ log_debug("%s returning old saved data\n", id.c_str());
ret_val = reader->get_latest_data();
- log_debug("get_data() try to read old already saved data done\n");
}
return ret_val;
}
dec_precision = get_data_decimal_precision();
pthread_mutex_lock(&plock);
- log_debug("save_and_clean_cache(): memory cache size: %d\n", memory_cache.size());
+ log_debug("memory cache size: %d\n", memory_cache.size());
StoreDay::save(id, &memory_cache, dec_precision);
while(memory_cache.empty() == false) {
data = memory_cache.back();