]> git.itanic.dy.fi Git - log-plotter/commitdiff
data.c: Store cell count and system status into variable array
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 16 Jan 2014 20:21:36 +0000 (22:21 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 16 Jan 2014 20:21:36 +0000 (22:21 +0200)
Make it possible to reference this information via the variable
array. This makes it possible to for example have the log file name to
contain the number of battery cells and charger state.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
data.c
data.h

diff --git a/data.c b/data.c
index 0db2394172131cee49dd6bc97492d24a3e8dddd9..c577a6eafccebc52643d82e065dc63430f80c2ce 100644 (file)
--- a/data.c
+++ b/data.c
@@ -123,6 +123,9 @@ static int parse_logline(const char *buf, struct charger_data *data)
        for (j = 0; j < max_cells; j++, i++) {
                d = atoi(entries[i]);
                ASSIGN_OR_NAN(data->cell_voltage[j], d / 1000.0);
+
+               if (d)
+                       data->cell_count++;
        }
 
        d = atoi(entries[i++]);
@@ -325,6 +328,12 @@ static int read_data(struct eventhandler_entry *h)
                return 0;
 
        if (state_has_changed()) {
+               store_str_variable_value_to_array("status",
+                       state_to_str(plotter_state.system_status), dt->cfg);
+
+               store_int_variable_value_to_array("cell_count",
+                                               data.cell_count, dt->cfg);
+
                ret = open_new_logfile(dt, data.channel);
                if (ret < 0)
                        return ret;
diff --git a/data.h b/data.h
index b9c04c96dd52eddd992e94c1c13c5139825a027f..0906e4cae24a3f40460837c9f4d5d869968bb877 100644 (file)
--- a/data.h
+++ b/data.h
@@ -12,6 +12,7 @@ struct charger_data {
        double input_voltage;
        double charging_voltage;
        double charging_current;
+       int cell_count;
        double cell_voltage[MAX_CELLS];
 
        double total_charge;    /* mAh */