[gnome-battery-bench] Remove charge related fields from GbbPowerState



commit 705e8c952d1d7590617b9d44c52b02c216a180f7
Author: Christian Kellner <gicmo gnome org>
Date:   Mon Mar 20 15:27:19 2017 +0000

    Remove charge related fields from GbbPowerState
    
    We are now returning only energy values from GbbBattery, so we can
    get rid of the charge related fields/functions/calculations from
    everywhere that is not the GbbBattery itself.

 src/commandline.c   |    2 --
 src/power-monitor.c |   26 --------------------------
 src/power-monitor.h |    3 ---
 src/test-run.c      |   18 ------------------
 4 files changed, 0 insertions(+), 49 deletions(-)
---
diff --git a/src/commandline.c b/src/commandline.c
index 702ae7d..9483c79 100644
--- a/src/commandline.c
+++ b/src/commandline.c
@@ -181,8 +181,6 @@ on_power_monitor_changed(GbbPowerMonitor *monitor,
     g_print("AC: %s\n", state->online ? "online" : "offline");
     if (state->energy_now >= 0)
         g_print("Energy: %.2f WH (%.2f%%)\n", state->energy_now, gbb_power_state_get_percent(state));
-    else if (state->charge_now >= 0)
-        g_print("Charge: %.2f AH (%.2f%%)\n", state->energy_now, gbb_power_state_get_percent(state));
     else if (state->capacity_now >= 0)
         g_print("Capacity: %.2f%%\n", gbb_power_state_get_percent(state));
 
diff --git a/src/power-monitor.c b/src/power-monitor.c
index 96f5dc5..288ca9a 100644
--- a/src/power-monitor.c
+++ b/src/power-monitor.c
@@ -42,8 +42,6 @@ gbb_power_state_get_percent (const GbbPowerState *state)
 {
     if (state->energy_full >= 0)
         return 100 * state->energy_now / state->energy_full;
-    else if (state->charge_full >= 0)
-        return 100 * state->charge_now / state->charge_full;
     else if (state->capacity_now >= 0)
         return 100 * state->capacity_now;
     else
@@ -150,9 +148,6 @@ gbb_power_state_init(GbbPowerState *state)
     state->energy_now = -1.0;
     state->energy_full = -1.0;
     state->energy_full_design = -1.0;
-    state->charge_now = -1.0;
-    state->charge_full = -1.0;
-    state->charge_full_design = -1.0;
     state->capacity_now = -1.0;
     state->voltage_now = -1.0;
 }
@@ -274,27 +269,6 @@ gbb_power_statistics_compute (const GbbPowerState   *base,
             if (base->energy_full_design >= 0)
                 statistics->battery_life_design = 3600 * base->energy_full_design / statistics->power;
         }
-    } else if (current->charge_now >= 0 && time_elapsed > 0) {
-        double charge_used = base->charge_now - current->charge_now;
-
-        if (charge_used > 0) {
-            statistics->current = 3600 * (charge_used) / time_elapsed;
-            if (base->charge_full >= 0)
-                statistics->battery_life = 3600 * base->charge_full / statistics->current;
-            if (base->charge_full_design >= 0)
-                statistics->battery_life_design = 3600 * base->charge_full_design / statistics->current;
-
-            /* We can approximate the power used using the current and the voltage; the
-             * more the voltage is constant, the more accurate this will be. We could
-             * improve this by looking at intermediate statistics, but since reporting
-             * capacity in watts is clearly preferred by the relevant standards, too much
-             * complexity to improve this doesn't seem to make sense.
-             */
-            if (current->voltage_now >= 0) {
-                double average_voltage = (base->voltage_now + current->voltage_now) / 2;
-                statistics->power = 3600 * average_voltage * charge_used / time_elapsed;
-            }
-        }
     } else if (current->capacity_now >= 0 && time_elapsed > 0) {
         double capacity_used = base->capacity_now - current->capacity_now;
         if (capacity_used > 0)
diff --git a/src/power-monitor.h b/src/power-monitor.h
index efe25cc..cb4b205 100644
--- a/src/power-monitor.h
+++ b/src/power-monitor.h
@@ -21,9 +21,6 @@ struct _GbbPowerState {
     double energy_now; /* WH */
     double energy_full;
     double energy_full_design;
-    double charge_now; /* AH */
-    double charge_full;
-    double charge_full_design;
     double capacity_now; /* 0 - 1.0 */
     double voltage_now;
 };
diff --git a/src/test-run.c b/src/test-run.c
index b00eb88..a2eed1c 100644
--- a/src/test-run.c
+++ b/src/test-run.c
@@ -401,18 +401,6 @@ gbb_test_run_write_to_file(GbbTestRun *run,
             json_builder_set_member_name(builder, "energy-full-design");
             add_int_value_1e6(builder, state->energy_full_design);
         }
-        if (state->charge_now >= 0) {
-            json_builder_set_member_name(builder, "charge");
-            add_int_value_1e6(builder, state->charge_now);
-        }
-        if (state->charge_full >= 0 && (!last_state || state->charge_full != last_state->charge_full)) {
-            json_builder_set_member_name(builder, "charge-full");
-            add_int_value_1e6(builder, state->charge_full);
-        }
-        if (state->charge_full_design >= 0 && (!last_state || state->charge_full_design != 
last_state->charge_full_design)) {
-            json_builder_set_member_name(builder, "charge-full-design");
-            add_int_value_1e6(builder, state->charge_full_design);
-        }
         if (state->capacity_now >= 0) {
             json_builder_set_member_name(builder, "capacity");
             add_int_value_1e6(builder, state->capacity_now);
@@ -736,12 +724,6 @@ read_from_file(GbbTestRun *run,
                 goto out;
             if (get_int_1e6(node_object, "energy-full-design", &state->energy_full_design, error) == ERROR)
                 goto out;
-            if (get_int_1e6(node_object, "charge", &state->charge_now, error) == ERROR)
-                goto out;
-            if (get_int_1e6(node_object, "charge-full", &state->charge_full, error) == ERROR)
-                goto out;
-            if (get_int_1e6(node_object, "charge-full-design", &state->charge_full_design, error) == ERROR)
-                goto out;
             if (get_int_1e6(node_object, "capacity", &state->capacity_now, error) == ERROR)
                 goto out;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]