summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deco.c2
-rw-r--r--dive.c2
-rw-r--r--dive.h5
-rw-r--r--profile.c45
4 files changed, 49 insertions, 5 deletions
diff --git a/deco.c b/deco.c
index ec281b1fe..42580d317 100644
--- a/deco.c
+++ b/deco.c
@@ -190,7 +190,7 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s
int fo2 = get_o2(gasmix), fhe = get_he(gasmix);
struct gas_pressures pressures;
- fill_pressures(&pressures, pressure, gasmix, (double) ccpo2 / 1000.0, dive->dc.dctype);
+ fill_pressures(&pressures, pressure, gasmix, (double) ccpo2 / 1000.0, &(dive->dc));
if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive)
gf_low_pressure_this_dive = pressure;
diff --git a/dive.c b/dive.c
index e7bf685e6..775367b58 100644
--- a/dive.c
+++ b/dive.c
@@ -1521,7 +1521,7 @@ int gasmix_distance(const struct gasmix *a, const struct gasmix *b)
}
/* Compute partial gas pressures in bar from gasmix and ambient pressures, possibly for OC or CCR, to be extended to PSCT */
-extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const enum dive_comp_type type)
+extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const struct divecomputer *dc)
{
if (po2) {
/* we have an O₂ partial pressure in the sample - so this
diff --git a/dive.h b/dive.h
index 55396d8fe..68421fec1 100644
--- a/dive.h
+++ b/dive.h
@@ -137,7 +137,6 @@ struct gas_pressures {
double o2, n2, he;
};
-extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const enum dive_comp_type type);
extern void sanitize_gasmix(struct gasmix *mix);
extern int gasmix_distance(const struct gasmix *a, const struct gasmix *b);
extern struct gasmix *get_gasmix_from_event(struct event *ev);
@@ -260,6 +259,10 @@ struct divecomputer {
struct divecomputer *next;
};
+
+extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const struct divecomputer *dc);
+
+
#define MAX_CYLINDERS (8)
#define MAX_WEIGHTSYSTEMS (6)
#define W_IDX_PRIMARY 0
diff --git a/profile.c b/profile.c
index 4f6517b77..653c5b9dd 100644
--- a/profile.c
+++ b/profile.c
@@ -834,7 +834,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
fo2 = get_o2(&dive->cylinder[cylinderindex].gasmix);
fhe = get_he(&dive->cylinder[cylinderindex].gasmix);
- fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, dive->dc.dctype);
+ fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, &(dive->dc));
/* Calculate MOD, EAD, END and EADD based on partial pressures calculated before
* so there is no difference in calculating between OC and CC
@@ -860,6 +860,47 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
}
}
+void fill_o2_values(struct divecomputer *dc, struct plot_info *pi)
+/* 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 fuxup_dive_dc). But for drawing the prodile
+ * 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() */
+{
+ int i, j;
+ double last_setpoint;
+ double last_sensor[3];
+
+ for (i = 0; i < pi->nr; i++) {
+ struct plot_data *entry = pi->entry + i;
+
+ // For 1st iteration, initialise the last_ values
+ if (i == 0) {
+ 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
+ if (entry->o2setpoint)
+ last_setpoint = entry->o2setpoint;
+ else
+ entry->o2setpoint = last_setpoint;
+
+ for (j = 0; j < dc->no_o2sensors; j++)
+ if (entry->o2sensor[j])
+ last_sensor[j] = entry->o2sensor[j];
+ else
+ entry->o2sensor[j] = last_sensor[j];
+ }
+ }
+}
+
#ifdef DEBUG_GAS
/* A CCR debug function that writes the cylinder pressure and the oxygen values to the file debug_print_profiledata.dat:
* Called in create_plot_info_new()
@@ -915,7 +956,7 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo
if (dc->dctype == CCR) { /* For CCR dives.. */
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. */
+ 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);