On Sat, Oct 11, 2014 at 10:05:33AM +0200, Willem Ferguson wrote:
> CCR patch: Import and store oxygen sensor data

Thanks for this one. Instead of sitting on it forever or a back and forth
about the minor changes that I want I simply applied the changes and
committed it. Here's my diff on top of yours... you'll see some small
algorithm cleanup (you put that value in o2val, so use o2val instead of
getting the structure member again), whitespace, debug printout...

/D


diff --git a/dive.c b/dive.c
index ea1ff03afbbc..d20a64cc1cc1 100644
--- a/dive.c
+++ b/dive.c
@@ -1113,10 +1113,10 @@ static void fixup_dive_dc(struct dive *dive, struct 
divecomputer *dc)
                for (j = 0; j < dc->no_o2sensors; j++) {  // for CCR oxygen 
sensor data:
                        o2val = sample->o2sensor[j].mbar;
                        if (o2val) {
-                               if (lasto2val[j] == sample->o2sensor[j].mbar)
+                               if (lasto2val[j] == o2val)
                                        sample->o2sensor[j].mbar = 0;
                                else
-                                       lasto2val[j] = sample->o2sensor[j].mbar;
+                                       lasto2val[j] = o2val;
                        }
                }
 
@@ -1134,7 +1134,7 @@ static void fixup_dive_dc(struct dive *dive, struct
divecomputer *dc)
                depthtime += (time - lasttime) * (lastdepth + depth) / 2;
                lastdepth = depth;
                lasttime = time;
-                       if (sample->cns > dive->maxcns)
+               if (sample->cns > dive->maxcns)
                        dive->maxcns = sample->cns;
        }
 
diff --git a/parse-xml.c b/parse-xml.c
index b07505c2d8f4..6e74e8aaf449 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -815,8 +815,8 @@ static void try_to_fill_dc(struct divecomputer *dc, const 
char *name, char *buf)
                return;
        if (MATCH("diveid", hex_value, &dc->diveid))
                return;
-       if (MATCH("dctype", get_dc_type, &dc->dctype)) { printf("TYPE\n");
-               return; }
+       if (MATCH("dctype", get_dc_type, &dc->dctype))
+               return;
        if (MATCH("no_o2sensors", get_sensor, &dc->no_o2sensors))
                return;
        if (match_dc_data_fields(dc, name, buf))
--- a/profile.c 2014-10-11 07:05:54.047560980 -0400
+++ b/profile.c 2014-10-11 07:09:59.319146178 -0400
@@ -551,7 +551,7 @@
                entry->in_deco = sample->in_deco;
                entry->cns = sample->cns;
                entry->pressures.o2 = sample->po2.mbar / 1000.0;
-               entry->o2setpoint = sample->o2setpoint.mbar / 1000.0; // for 
rebreathers
+               entry->o2setpoint = sample->o2setpoint.mbar / 1000.0;   // for 
rebreathers
                entry->o2sensor[0] = sample->o2sensor[0].mbar / 1000.0; // for 
up to three rebreather O2 sensors
                entry->o2sensor[1] = sample->o2sensor[1].mbar / 1000.0;
                entry->o2sensor[2] = sample->o2sensor[2].mbar / 1000.0;
@@ -844,10 +846,10 @@
                entry->end = (entry->depth + 10000) * (1000 - fhe) / 1000.0 - 
10000;
                entry->ead = (entry->depth + 10000) * (1000 - fo2 - fhe) / 
(double)N2_IN_AIR - 10000;
                entry->eadd = (entry->depth + 10000) *
-                               (entry->pressures.o2 / amb_pressure * 
O2_DENSITY +
-                                entry->pressures.n2 / amb_pressure * 
N2_DENSITY +
-                                entry->pressures.he / amb_pressure * 
HE_DENSITY) /
-                               (O2_IN_AIR * O2_DENSITY + N2_IN_AIR * 
N2_DENSITY) * 1000 - 10000;
+                                     (entry->pressures.o2 / amb_pressure * 
O2_DENSITY +
+                                      entry->pressures.n2 / amb_pressure * 
N2_DENSITY +
+                                      entry->pressures.he / amb_pressure * 
HE_DENSITY) /
+                                     (O2_IN_AIR * O2_DENSITY + N2_IN_AIR * 
N2_DENSITY) * 1000 - 10000;
                if (entry->mod < 0)
                        entry->mod = 0;
                if (entry->ead < 0)
@@ -914,9 +916,9 @@
        setup_gas_sensor_pressure(dive, dc, pi);                 /* Try to 
populate our gas pressure knowledge */
        populate_pressure_information(dive, dc, pi, NONDILUENT); /* .. 
calculate missing pressure entries for all gasses except diluent */
        if (dc->dctype == CCR) {                                 /* For CCR 
dives.. */
-               printf("CCR DIVE: %s (%d O2 sensors)\n", 
dc->model,dc->no_o2sensors);
+               printf("CCR DIVE: %s (%d O2 sensors)\n", dc->model, 
dc->no_o2sensors);
                populate_pressure_information(dive, dc, pi, DILUENT); /* .. 
calculate missing diluent gas pressure entries */
 //             fill_o2_values(dc, pi);                          /* .. and 
insert the O2 sensor data having 0 values. */
        }
        calculate_sac(dive, pi); /* Calculate sac */
        calculate_deco_information(dive, dc, pi, false);
_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to