Prepare non-w1 functionality be separated from the w1 specific one.
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
#include "Date.hh"
-namespace w1 {
+namespace plp {
class Data {
public:
Data(int size);
#include "W1Util.hh"
#include "DeviceData.hh"
-#include "W1Store.hh"
+#include "Store.hh"
#include "DeviceConfig.hh"
#include "Factory.hh"
vector<string> mon_vcr;
vector<string> dta_vcr;
string f_name;
- W1Store *store;
+ Store *store;
Data *ret_val;
ret_val = NULL;
if (dta_vcr.size() > 0) {
f_name = dta_vcr.at(0);
f_name = W1Util::concat_paths(mon_dr, f_name);
- store = new W1Store(f_name);
+ store = new Store(f_name);
ret_val = store->get_oldest_data();
delete(store);
break;
string f_name;
Data *ret_val;
int size;
- W1Store *store;
+ Store *store;
ret_val = NULL;
size = year_vector.size();
if (size > 0) {
f_name = d_vcr.at(size - 1);
f_name = W1Util::concat_paths(mon_dr, f_name);
- store = new W1Store(f_name);
+ store = new Store(f_name);
ret_val = store->get_newest_data();
delete(store);
break;
Data *DeviceData::get_daily_summary(Date *date,
int calc_type) {
Data *ret_val;
- W1Store *store;
+ Store *store;
bool suc_flg;
+ //Store *cache_store;
ret_val = NULL;
- store = new W1Store(device_id, date);
+ store = new Store(device_id, date);
if (store != NULL) {
suc_flg = store->load();
if (suc_flg == true) {
vector<Data *> *DeviceData::get_hourly_summary(Date *date,
int calc_type) {
vector<Data *> *ret_val;
- W1Store *store;
+ Store *store;
ret_val = NULL;
- store = new W1Store(device_id, date);
+ store = new Store(device_id, date);
store->load();
switch(calc_type) {
case SUM:
public:
DeviceData(std::string device_id);
virtual ~DeviceData();
- DataRange *get_data_range();
- Data *get_daily_summary(plp::Date *date, int calc_type);
+ plp::DataRange *get_data_range();
+ plp::Data *get_daily_summary(plp::Date *date, int calc_type);
/**
* Get summary data calculated from the daily data items that is meaning full.
* Depending from the device type, it may be daily mean value, daily delta, highest value, etc...
*/
- Data *get_daily_summary(plp::Date *date);
- DataRange *get_daily_summary(plp::Date *start_date, plp::Date *end_date);
- std::vector<Data *> *get_hourly_summary(plp::Date *date, int calc_type);
- std::vector<Data *> *get_hourly_summary(plp::Date *date);
- DataRange *get_hourly_summary(plp::Date *start_date, plp::Date *end_date);
- DataRange *get_data(plp::Date *start_date, plp::Date *end_date);
+ plp::Data *get_daily_summary(plp::Date *date);
+ plp::DataRange *get_daily_summary(plp::Date *start_date, plp::Date *end_date);
+ std::vector<plp::Data *> *get_hourly_summary(plp::Date *date, int calc_type);
+ std::vector<plp::Data *> *get_hourly_summary(plp::Date *date);
+ plp::DataRange *get_hourly_summary(plp::Date *start_date, plp::Date *end_date);
+ plp::DataRange *get_data(plp::Date *start_date, plp::Date *end_date);
protected:
std::string device_id;
std::string device_dir;
std::string device_ch_dir;
w1::DeviceConfig *device_config;
enum_summary_calculation summary_calc_type;
- Data *find_oldest_data(std::vector<std::string> year_vector);
- Data *find_newest_data(std::vector<std::string> year_vector);
+ plp::Data *find_oldest_data(std::vector<std::string> year_vector);
+ plp::Data *find_newest_data(std::vector<std::string> year_vector);
};
}
lib1wire_la_SOURCES = \
Factory.cc Factory.hh \
W1Device.cc W1Device.hh \
- W1Store.cc W1Store.hh \
+ Store.cc Store.hh \
W1TemperatureSensor.cc W1TemperatureSensor.hh \
W1CounterDevice.cc W1CounterDevice.hh \
W1Util.cc W1Util.hh \
Factory.hh \
W1CounterDevice.hh \
W1Device.hh \
- W1Store.hh \
+ Store.hh \
W1TemperatureSensor.hh \
W1Util.hh
\ No newline at end of file
/*
- * W1Store.cc
+ * Store.cc
*
* Created on: Oct 31, 2010
* Author: lamikr
#include "DeviceConfig.hh"
#include "W1Configure.hh"
-#include "W1Store.hh"
+#include "Store.hh"
#include "W1Util.hh"
using namespace std;
using namespace w1;
using namespace plp;
-W1Store::W1Store(string device_id,
+Store::Store(string device_id,
Date *date_time) {
store_data = NULL;
range_data = NULL;
log_debug("data file name: %s\n", store_file_name.c_str());
}
-W1Store::W1Store(string file_name_param) {
+Store::Store(string file_name_param) {
store_data = NULL;
range_data = NULL;
store_file_name = file_name_param;
}
-W1Store::~W1Store() {
+Store::~Store() {
if (store_data != NULL) {
delete(store_data);
store_data = NULL;
}
}
-string W1Store::get_dir_name(string device_id, Date *date_time) {
+string Store::get_dir_name(string device_id, Date *date_time) {
string ret_val;
char buffer[30];
string d_name;
return ret_val;
}
-string W1Store::get_file_name(string device_id, Date *date_time) {
+string Store::get_file_name(string device_id, Date *date_time) {
string ret_val;
string fname;
char buffer[30];
return ret_val;
}
-void W1Store::save(string device_id,
+void Store::save(string device_id,
std::list<Data *> *data_list,
int dec_precision) {
string n_path;
}
}
-bool W1Store::load() {
+bool Store::load() {
Data *data;
ifstream in;
string data_str;
return ret_val;
}
-Data *W1Store::get_sum() {
+Data *Store::get_sum() {
int row_count;
int col_count;
double new_val;
return ret_val;
}
-Data *W1Store::get_delta() {
+Data *Store::get_delta() {
int row_count;
int col_count;
Data *o_data;
return ret_val;
}
-Data *W1Store::get_mean() {
+Data *Store::get_mean() {
int row_count;
int col_count;
int ii;
return ret_val;
}
-Data *W1Store::get_max() {
+Data *Store::get_max() {
int row_count;
int col_count;
double new_val;
return ret_val;
}
-Data *W1Store::get_min() {
+Data *Store::get_min() {
int row_count;
int col_count;
double new_val;
return ret_val;
}
-vector<Data *> *W1Store::get_sum(int freq_sec) {
+vector<Data *> *Store::get_sum(int freq_sec) {
int row_count;
int col_count;
int jj;
return ret_val;
}
-vector<Data *> *W1Store::get_mean(int freq_sec) {
+vector<Data *> *Store::get_mean(int freq_sec) {
int row_count;
int col_count;
int d_count;
return ret_val;
}
-vector<Data *> *W1Store::get_delta(int freq_sec) {
+vector<Data *> *Store::get_delta(int freq_sec) {
int row_count;
int col_count;
int jj;
return ret_val;
}
-vector<Data *> *W1Store::get_max_or_min(int freq_sec, bool max) {
+vector<Data *> *Store::get_max_or_min(int freq_sec, bool max) {
int row_count;
int col_count;
int jj;
return ret_val;
}
-vector<Data *> *W1Store::get_max(int freq_sec) {
+vector<Data *> *Store::get_max(int freq_sec) {
vector<Data *> *ret_val;
ret_val = get_max_or_min(freq_sec, true);
return ret_val;
}
-vector<Data *> *W1Store::get_min(int freq_sec) {
+vector<Data *> *Store::get_min(int freq_sec) {
vector<Data *> *ret_val;
ret_val = get_max_or_min(freq_sec, false);
return ret_val;
}
-DataRange *W1Store::get_oldest_and_newest_data() {
+DataRange *Store::get_oldest_and_newest_data() {
DataRange *ret_val;
ifstream in;
Data *o_data;
return ret_val;
}
-Data *W1Store::get_oldest_data() {
+Data *Store::get_oldest_data() {
int row_count;
Data *ret_val;
DataRange *dr;
return ret_val;
}
-Data *W1Store::get_newest_data() {
+Data *Store::get_newest_data() {
int row_count;
Data *ret_val;
DataRange *dr;
--- /dev/null
+/*
+ * Store.hh
+ *
+ * Created on: Oct 31, 2010
+ * Author: lamikr
+ */
+
+#ifndef W1STORE_HH_
+#define W1STORE_HH_
+
+#include <string>
+#include <list>
+#include <vector>
+
+#include <stdbool.h>
+
+#include "Data.hh"
+#include "Date.hh"
+
+namespace plp {
+ class Store {
+ public:
+ Store(std::string device_id,
+ plp::Date *date_time);
+ Store(std::string file_name_param);
+ virtual ~Store();
+ 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 save(std::string device_id, std::list<plp::Data *> *data_list, int dec_precision);
+ bool load();
+ plp::Data *get_sum();
+ plp::Data *get_delta();
+ plp::Data *get_mean();
+ plp::Data *get_max();
+ plp::Data *get_min();
+ std::vector<plp::Data *> *get_sum(int freq_sec);
+ std::vector<plp::Data *> *get_mean(int freq_sec);
+ std::vector<plp::Data *> *get_delta(int freq_sec);
+ std::vector<plp::Data *> *get_max(int freq_sec);
+ std::vector<plp::Data *> *get_min(int freq_sec);
+ plp::Data *get_oldest_data();
+ plp::Data *get_newest_data();
+ plp::DataRange *get_oldest_and_newest_data();
+ protected:
+ std::string store_file_name;
+ plp::DataRange *store_data;
+ plp::DataRange *range_data;
+ std::vector<plp::Data *> *get_max_or_min(int freq_sec, bool max);
+ };
+}
+
+#endif /* W1STORE_HH_ */
#include "DeviceConfig.hh"
#include "Factory.hh"
-#include "W1Store.hh"
+#include "Store.hh"
#include "W1Device.hh"
-using namespace w1;
using namespace std;
+using namespace w1;
+using namespace plp;
W1Device::W1Device(int family_code_param,
string device_id_param,
int dec_precision;
dec_precision = get_data_decimal_precision();
- W1Store::save(id, &memory_cache, dec_precision);
+ Store::save(id, &memory_cache, dec_precision);
for(iter = memory_cache.begin(); iter != memory_cache.end(); iter++) {
data = (Data *)*iter;
delete(data);
void set_name(std::string name_param);
virtual std::string get_unit() = 0;
virtual std::string get_device_type() = 0;
- Data *get_and_collect_data();
+ plp::Data *get_and_collect_data();
virtual void save_data();
virtual void printout();
protected:
virtual std::vector<double> *get_raw_data() = 0;
virtual unsigned int get_data_decimal_precision() = 0;
- void collect_data(Data *data);
+ void collect_data(plp::Data *data);
std::string to_string(double val, int digit_count);
//Data *get_formatted_data(Data *data);
virtual bool is_supported_w1_family_code(int family_code) = 0;
std::string name;
std::string dir_path;
std::string slave_file;
- std::list<w1::Data *> memory_cache;
+ std::list<plp::Data *> memory_cache;
};
}
+++ /dev/null
-/*
- * W1Store.hh
- *
- * Created on: Oct 31, 2010
- * Author: lamikr
- */
-
-#ifndef W1STORE_HH_
-#define W1STORE_HH_
-
-#include <string>
-#include <list>
-#include <vector>
-
-#include <stdbool.h>
-
-#include "Data.hh"
-#include "Date.hh"
-
-namespace w1 {
- class W1Store {
- public:
- W1Store(std::string device_id,
- plp::Date *date_time);
- W1Store(std::string file_name_param);
- virtual ~W1Store();
- 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 save(std::string device_id, std::list<Data *> *data_list, int dec_precision);
- bool load();
- Data *get_sum();
- Data *get_delta();
- Data *get_mean();
- Data *get_max();
- Data *get_min();
- std::vector<w1::Data *> *get_sum(int freq_sec);
- std::vector<w1::Data *> *get_mean(int freq_sec);
- std::vector<w1::Data *> *get_delta(int freq_sec);
- std::vector<w1::Data *> *get_max(int freq_sec);
- std::vector<w1::Data *> *get_min(int freq_sec);
- w1::Data *get_oldest_data();
- w1::Data *get_newest_data();
- w1::DataRange *get_oldest_and_newest_data();
- protected:
- std::string store_file_name;
- DataRange *store_data;
- DataRange *range_data;
- std::vector<Data *> *get_max_or_min(int freq_sec, bool max);
- };
-}
-
-#endif /* W1STORE_HH_ */
#include "Factory.hh"
#include "W1Util.hh"
-using namespace w1;
using namespace std;
+using namespace plp;
+using namespace w1;
bool try_parse_long(const char *str, long *result) {
int new_result;