Data *DeviceData::find_oldest_data(vector<string> year_vector) {
unsigned int ii;
- string year_dir;
- string month_dir;
- vector<string> month_vector;
- vector<string> data_vector;
+ string year_dr;
+ string mon_dr;
+ vector<string> mon_vcr;
+ vector<string> d_vcr;
string f_name;
W1Store *store;
Data *ret_val;
ret_val = NULL;
if (year_vector.size() > 0) {
// dirs are alphabetically sorted
- year_dir = year_vector.at(0);
- year_dir = W1Util::concat_paths(device_dir, year_dir);
- month_vector = W1Util::get_subdirectories(year_dir);
- for (ii = 0; ii < month_vector.size(); ii++) {
- month_dir = month_vector.at(ii);
- month_dir = W1Util::concat_paths(year_dir, month_dir);
+ year_dr = year_vector.at(0);
+ year_dr = W1Util::concat_paths(device_dir, year_dr);
+ mon_vcr = W1Util::get_subdirectories(year_dr);
+ for (ii = 0; ii < mon_vcr.size(); ii++) {
+ mon_dr = mon_vcr.at(ii);
+ mon_dr = W1Util::concat_paths(year_dr, mon_dr);
// scan data files from month dir
- data_vector = W1Util::get_data_files(month_dir);
- if (data_vector.size() > 0) {
- f_name = data_vector.at(0);
- f_name = W1Util::concat_paths(month_dir, f_name);
+ d_vcr = W1Util::get_data_files(mon_dr);
+ if (d_vcr.size() > 0) {
+ f_name = d_vcr.at(0);
+ f_name = W1Util::concat_paths(mon_dr, f_name);
store = new W1Store(f_name);
ret_val = store->get_oldest_data();
delete(store);
Data *DeviceData::find_newest_data(vector<string> year_vector) {
int ii;
- string year_dir;
- string month_dir;
- vector<string> month_vector;
- vector<string> data_vector;
+ string year_dr;
+ string mon_dr;
+ vector<string> mon_vcr;
+ vector<string> d_vcr;
string f_name;
Data *ret_val;
int size;
size = year_vector.size();
if (size > 0) {
// dirs are alphabetically sorted
- year_dir = year_vector.at(size - 1);
- year_dir = W1Util::concat_paths(device_dir, year_dir);
- month_vector = W1Util::get_subdirectories(year_dir);
- for (ii = month_vector.size() - 1; ii >= 0; ii--) {
- month_dir = month_vector.at(ii);
- month_dir = W1Util::concat_paths(year_dir, month_dir);
+ year_dr = year_vector.at(size - 1);
+ year_dr = W1Util::concat_paths(device_dir, year_dr);
+ mon_vcr = W1Util::get_subdirectories(year_dr);
+ for (ii = mon_vcr.size() - 1; ii >= 0; ii--) {
+ mon_dr = mon_vcr.at(ii);
+ mon_dr = W1Util::concat_paths(year_dr, mon_dr);
// scan data files from month dir
- data_vector = W1Util::get_data_files(month_dir);
- size = data_vector.size();
+ d_vcr = W1Util::get_data_files(mon_dr);
+ size = d_vcr.size();
if (size > 0) {
- f_name = data_vector.at(size - 1);
- f_name = W1Util::concat_paths(month_dir, f_name);
+ f_name = d_vcr.at(size - 1);
+ f_name = W1Util::concat_paths(mon_dr, f_name);
store = new W1Store(f_name);
ret_val = store->get_newest_data();
delete(store);
DataRange *DeviceData::get_hourly_summary(Date *start_date,
Date *end_date) {
- DataRange *ret_val;
- vector<Data *> dta_list;
- Data *data;
- Date *date;
+ DataRange *ret_val;
+ vector<Data *> dta_list;
+ Data *data;
+ Date *date;
+ vector<Data *>::iterator iter;
ret_val = NULL;
date = start_date->clone();
while(date->before(*end_date)) {
dta_list = get_hourly_summary(date);
- for(vector<Data *>::iterator list_iter = dta_list.begin(); list_iter != dta_list.end(); list_iter++) {
- data = (Data *)*list_iter;
+ for(iter = dta_list.begin(); iter != dta_list.end(); iter++) {
+ data = (Data *)*iter;
if (data != NULL) {
if (ret_val == NULL) {
ret_val = new DataRange(*data);