]> pilppa.org Git - libplp.git/blobdiff - src/DataReader.cc
Updates to set_config_value parameter
[libplp.git] / src / DataReader.cc
index 1c7e9a36121bc85403f80d5552c4c74765c96fe7..0e6ebf380fb2e335fb028956607abd8f430891d7 100644 (file)
@@ -74,7 +74,9 @@ Data *DataReader::get_latest_data() {
 
        ret_val = NULL;
        y_list  = FileUtil::get_subdirectories(device_dir);
-       ret_val = find_latest_data(y_list);
+       if (y_list.size() > 0) {
+               ret_val = find_latest_data(y_list);
+       }
        return ret_val;
 }
 
@@ -282,6 +284,34 @@ DataRange *DataReader::get_monthly_summary(Date *start_date,
        return ret_val;
 }
 
+/*
+ * Get Daily summary from the latest date
+ */
+DataRange *DataReader::get_daily_summary() {
+       if (device_config == NULL) {
+               device_config           = DeviceConfig::get_device_config(device_id);
+               summary_calc_type       = device_config->get_summary_calculation_type();
+       }
+       return get_daily_summary(summary_calc_type);
+}
+
+/*
+ * Get Daily summary specified by the calc_type from the latest date.
+ */
+DataRange *DataReader::get_daily_summary(EnumSummaryCalculationType calc_type_param) {
+       Data            *data;
+       Date            date;
+       DataRange       *ret_val;
+
+       ret_val = NULL;
+       data    = get_latest_data();
+       if (data != NULL) {
+               date    = data->get_date();
+               ret_val = get_daily_summary(&date, calc_type_param);
+       }
+       return ret_val;
+}
+
 DataRange *DataReader::get_daily_summary(Date *date,
                                EnumSummaryCalculationType calc_type_param) {
        return get_summary(date, calc_type_param, PERIOD_DAILY);
@@ -377,8 +407,6 @@ DataRange *DataReader::get_data(Date *start_date,
        EnumSummaryPeriod       period;
 
        ret_val = NULL;
-       start_date->printout();
-       end_date->printout();
        period  = get_period_type(start_date, end_date);
        switch(period) {
                case PERIOD_YEARLY:
@@ -420,7 +448,7 @@ string DataReader::get_device_type() {
 
        if (device_config == NULL) {
                device_config   = DeviceConfig::get_device_config(device_id);
-               ret_val         = device_config->get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
+               ret_val         = device_config->get_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
        }
        return ret_val;
 }