diff options
author | willem ferguson <willemferguson@zoology.up.ac.za> | 2014-10-12 14:46:20 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-10-12 12:40:34 -0400 |
commit | 49c9ad199f22f379a93bbc625a9e0b6339cf8110 (patch) | |
tree | 03f51ace381383a56a034a87a69a8f9b99510a78 /profile.c | |
parent | 3b30009d7a6e5fe91af6109e72e4bfa04f577eef (diff) | |
download | subsurface-49c9ad199f22f379a93bbc625a9e0b6339cf8110.tar.gz |
CCR patch: Oxygen partial pressures
This patch does three things:
1) A new function fill_o2_values() is added to profile.c. This
fills all oxygen sesnsor and setpoint values that have been
zeroed before in order to save space in the dive log. This
recreates the full set of sensor values obtained from the
original CCR xml log file.
2) Function fill_o2_values() is activated in function create_
plot_info_new() in profile.c
3) The calling parameters to function fill_pressures() in dive.c
are changed. The last parameter is now a pointer to a structure
of divecomputer. This will be needed in the last patch of the
present series of three patches.
[Dirk Hohndel: minor whitespace cleanup]
Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -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); |