[Powertop] [PATCH 20/29] report: redesign Device Power Report css & html

Alexandra Yates <alexandra.yates at linux.intel.com>
Newsgroups dev.linux.lists.powertop
Message-ID <1383168080-18233-21-git-send-email-alexandra.yates@linux.intel.com>
Redesign Device Power Report table part of "Device Info" section.

Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/devices/device.cpp |   72 +++++++++++++++++++++++-------------------------
 1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/src/devices/device.cpp b/src/devices/device.cpp
index 00ec5e6..1d9b1d4 100644
--- a/src/devices/device.cpp
+++ b/src/devices/device.cpp
@@ -49,6 +49,7 @@ using namespace std;
 #include "../lib.h"
 #include "../report/report.h"
 #include "../report/report-maker.h"
+#include "../report/report-data-html.h"
 #include "../measurement/measurement.h"
 #include "../devlist.h"
 #include <unistd.h>
@@ -217,43 +218,35 @@ void report_devices(void)
 void show_report_devices(void)
 {
 	unsigned int i;
-	int show_power;
-	double pw;
+	int show_power, cols, rows, idx;
 
 	show_power = global_power_valid();
 	sort(all_devices.begin(), all_devices.end(), power_device_sort);
 
-	report.begin_section(SECTION_DEVPOWER);
-	report.add_header("Device Power Report");
+	/* div attr css_class and css_id */
+        tag_attr div_attr;
+        init_div(&div_attr, "", "device");
 
-	pw = global_joules_consumed();
-	if (pw > 0.0001) {
-		char buf[32];
+        /* Set Table attributes, rows, and cols */
+        table_attributes std_table_css;
+	cols=2;
+        if (show_power)
+                cols=3;
 
-		report.begin_paragraph();
-		report.addf("The battery reports a discharge rate of %sW",
-			    fmt_prefix(pw, buf));
-	}
+	idx = cols;
+ 	rows= all_devices.size() + 1;
+        init_std_table_attr(&std_table_css, rows, cols);
 
-	if (show_power) {
-		char buf[32];
+        /* Set Title attributes */
+        tag_attr title_attr;
+        init_title_attr(&title_attr);
 
-		report.begin_paragraph();
-		report.addf("System baseline power is estimated at %sW",
-			    fmt_prefix(get_parameter_value("base power"), buf));
-	}
-
-	report.begin_table(TABLE_WIDE);
-	report.begin_row();
-	if (show_power) {
-		report.begin_cell(CELL_DEVPOWER_HEADER);
-		report.add("Power est.");
-	}
-
-	report.begin_cell(CELL_DEVPOWER_HEADER);
-	report.add("Usage");
-	report.begin_cell(CELL_DEVPOWER_DEV_NAME);
-	report.add("Device name");
+        /* Set array of data in row Major order */
+	string device_data[cols * rows];
+	device_data[0]= "Usage";
+	device_data[1]= "Device Name";
+	if (show_power)
+		device_data[2]= "PW Estimate";
 
 	for (i = 0; i < all_devices.size(); i++) {
 		double P;
@@ -278,17 +271,22 @@ void show_report_devices(void)
 		if (!show_power || !all_devices[i]->power_valid())
 			strcpy(power, "           ");
 
-		report.begin_row(ROW_DEVPOWER);
+		device_data[idx]= string(util);
+		idx+=1;
+
+		device_data[idx]= string(all_devices[i]->human_name());
+		idx+=1;
+
 		if (show_power) {
-			report.begin_cell(CELL_DEVPOWER_POWER);
-			report.add(power);
+			device_data[idx]= string(power);
+			idx+=1;
 		}
-
-		report.begin_cell(CELL_DEVPOWER_UTIL);
-		report.add(util);
-		report.begin_cell();
-		report.add(all_devices[i]->human_name());
 	}
+	/* Report Output */
+	report.add_div(&div_attr);
+	report.add_title(&title_attr,"Device Power Report");
+	report.add_table(device_data, &std_table_css);
+	report.end_div();
 }
 
 
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.