From 6cf3787a0ed150fd7cd996d6ae54e9ed9eab7af5 Mon Sep 17 00:00:00 2001 From: willem ferguson Date: Sat, 1 Nov 2014 06:06:34 +0200 Subject: [PATCH] Remove code that zeroes out duplicate oxygen sensor and temperature values Remove the code that changes all duplicate oxygen sensor, setpoint and temperature values from a dive log to zero. One of the motivations is that a zero setpoint value indicates an Open Circuit dive segment, not Closed Circuit Rebreather. The code in dive.c is removed and the comments for the corresponding restoration code that restores the last known values into sensor or temperature with zero values is [fill_o2_values() in profile.c] is changed to apply to the present situation. Signed-off-by: willem ferguson Signed-off-by: Dirk Hohndel --- dive.c | 26 ++------------------------ profile.c | 27 +++++++++++---------------- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/dive.c b/dive.c index 9e2918183..5bcdf3aa8 100644 --- a/dive.c +++ b/dive.c @@ -1098,15 +1098,14 @@ static void fixup_dc_events(struct divecomputer *dc) static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc) { - int i, j, o2val; + int i, j; double depthtime = 0; int lasttime = 0; int lastindex = -1; int maxdepth = dc->maxdepth.mm; int mintemp = 0; int lastdepth = 0; - int lasto2val[3] = { 0, 0, 0 }; - int lasttemp = 0, lastpressure = 0, lastdiluentpressure = 0; + int lastpressure = 0, lastdiluentpressure = 0; int pressure_delta[MAX_CYLINDERS] = { INT_MAX, }; int first_cylinder; @@ -1164,31 +1163,10 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc) fixup_pressure(dive, sample); if (temp) { - /* - * If we have consecutive identical - * temperature readings, throw away - * the redundant ones. - */ - if (lasttemp == temp) - sample->temperature.mkelvin = 0; - else - lasttemp = temp; - if (!mintemp || temp < mintemp) mintemp = temp; } - // If there are consecutive identical O2 sensor readings, throw away the redundant ones. - for (j = 0; j < dc->no_o2sensors; j++) { // for CCR oxygen sensor data: - o2val = sample->o2sensor[j].mbar; - if (o2val) { - if (lasto2val[j] == o2val) - sample->o2sensor[j].mbar = 0; - else - lasto2val[j] = o2val; - } - } - update_min_max_temperatures(dive, sample->temperature); depthtime += (time - lasttime) * (lastdepth + depth) / 2; diff --git a/profile.c b/profile.c index 4bc94220b..4be3a5b67 100644 --- a/profile.c +++ b/profile.c @@ -928,31 +928,26 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p } void fill_o2_values(struct divecomputer *dc, struct plot_info *pi, struct dive *dive) -/* For CCR: - * In the samples from each dive computer, any duplicate values for the - * oxygen sensors were removed (i.e. set to 0) in order to conserve - * storage space (see function fixup_dive_dc). But for drawing the profile - * a complete series of valid o2 pressure values is required. This function - * takes the oxygen sensor data and setpoint values from the structures - * of plotinfo and re-inserts the duplicate values set to 0 so - * that the oxygen sensor data are complete and ready for plotting. - * The original sequence of oxygen values are recreated without attempting - * any interpolations for values set to zero, recreating the raw data from - * the CCR dive log. This function called by: create_plot_info_new() */ +/* In the samples from each dive computer, there may be uninitialised oxygen + * sensor or setpoint values, e.g. when events were inserted into the dive log + * or if the dive computer does not report o2 values with every sample. But + * for drawing the profile a complete series of valid o2 pressure values is + * required. This function takes the oxygen sensor data and setpoint values + * from the structures of plotinfo and replaces the zero values with their + * last known values so that the oxygen sensor data are complete and ready + * for plotting. This function called by: create_plot_info_new() */ { int i, j; double last_setpoint, last_sensor[3], o2pressure, amb_pressure; for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; - // For 1st iteration, initialise the last_ values if (dc->dctype == CCR) { - if (i == 0) { + if (i == 0) { // For 1st iteration, initialise the last_ values last_setpoint = pi->entry->o2setpoint; for (j = 0; j < dc->no_o2sensors; j++) last_sensor[j] = pi->entry->o2sensor[j]; - } else { - // Now re-insert the missing oxygen pressure values + } else { // Now re-insert the missing oxygen pressure values if (entry->o2setpoint) last_setpoint = entry->o2setpoint; else @@ -962,7 +957,7 @@ void fill_o2_values(struct divecomputer *dc, struct plot_info *pi, struct dive * last_sensor[j] = entry->o2sensor[j]; else entry->o2sensor[j] = last_sensor[j]; - } // having initialised the empty o2 sensor values for this point on the profile, + } // having initialised the empty o2 sensor values for this point on the profile, amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0; o2pressure = calculate_ccr_po2(entry,dc); // ...calculate the po2 based on the sensor data entry->pressures.o2 = MIN(o2pressure, amb_pressure);