Commit 705e8c95 authored by Christian Kellner's avatar Christian Kellner
Browse files

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.
parent f66ff9b1
......@@ -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));
......
......@@ -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)
......
......@@ -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;
};
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment