]> pilppa.com Git - libplp.git/commitdiff
support for querying daily summary from the latest date.
authorMika Laitio <lamikr@pilppa.org>
Wed, 9 Mar 2011 00:45:12 +0000 (02:45 +0200)
committerMika Laitio <lamikr@pilppa.org>
Wed, 9 Mar 2011 00:45:12 +0000 (02:45 +0200)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/DataReader.cc
src/DataReader.hh

index 1c7e9a36121bc85403f80d5552c4c74765c96fe7..9ba287284c9526792713029aed21490e49e6f937 100644 (file)
@@ -282,6 +282,29 @@ 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;
+
+       data    = get_latest_data();
+       date    = data->get_date();
+       return get_daily_summary(&date, calc_type_param);
+}
+
 DataRange *DataReader::get_daily_summary(Date *date,
                                EnumSummaryCalculationType calc_type_param) {
        return get_summary(date, calc_type_param, PERIOD_DAILY);
@@ -377,8 +400,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:
index 3266ec221f4812e59ef2cd59e8dc0d5edb0d423e..23a39d3912ec43afa02657838da46477d2e146f8 100644 (file)
@@ -37,16 +37,27 @@ namespace plp {
                        DataRange *get_monthly_summary(Date *date, EnumSummaryCalculationType calc_type);
                        DataRange *get_monthly_summary(Date *date);
                        DataRange *get_monthly_summary(Date *start_date, Date *end_date);
+
                        /**
                         * Get daily summary data calculated from the daily data items.
                         * Depending from the device type, it may be daily mean value, daily delta, highest value, etc...
                         */
+                       /*
+                        * Get Daily summary from the latest date
+                        */
+                       DataRange *get_daily_summary();
+                       /*
+                        * Get Daily summary specified by the calc_type from the latest date.
+                        */
+                       DataRange *get_daily_summary(EnumSummaryCalculationType calc_type);
                        DataRange *get_daily_summary(Date *date, EnumSummaryCalculationType calc_type);
                        DataRange *get_daily_summary(Date *date);
                        DataRange *get_daily_summary(Date *start_date, Date *end_date);
+
                        DataRange *get_hourly_summary(Date *date, EnumSummaryCalculationType calc_type);
                        DataRange *get_hourly_summary(Date *date);
                        DataRange *get_hourly_summary(Date *start_date, Date *end_date);
+
                        DataRange *get_data(Date *start_date, Date *end_date);
                        std::string get_device_id();
                        std::string get_device_type();