Subject: CCR Patch: Adapt pressure interpolation for CCR
This patch adapts pressure interpolation (function pr_interpolate_data) in order to process CCR diluent gas as well. A flag diluent_flag is added to the variables for calling this function indicating whether the gas being worked with is diluent gas or not. This is necessitated by the fact that the diluent gas storage is separate from that of the other gases. The data used for interpolation are selected from the appropriate array, depending on the value of diluent_flag. In function fill_missing_tank_pressures, diluent_flag is set to 0 in order for the code to work with the current CCR adaptations. The above constitutes no. 1 of a four-part set of patches that allows pressure calculations for CCR gases. There will be CCR functionality only after the whole set of patches is complete. Signed-off-by: willem ferguson <[email protected]>
>From a432908b64a6b204db520cb04a9ac74cb0d397c6 Mon Sep 17 00:00:00 2001 From: willem ferguson <[email protected]> Date: Wed, 27 Aug 2014 08:13:05 +0200 Subject: [PATCH 3/3] CCR Patch: Adapt pressure interpolation for CCR This patch adapts pressure interpolation (function pr_interpolate_data) in order to process CCR diluent gas as well. A flag diluent_flag is added to the variables for calling this function indicating whether the gas being worked with is diluent gas or not. This is necessitated by the fact that the diluent gas storage is separate from that of the other gases. The data used for interpolation are selected from the appropriate array, depending on nthe value of diluent_flag. In function fill_missing_tank_pressures, diluent_flag is set to 0 in order for the code to work with the current CCR adaptations. The above constitutes no. 1 of a four-part set of patches that allows pressure calculations for CCR gases. There will be CCR functionality only after the whole set of patches is complete. Signed-off-by: willem ferguson <[email protected]> --- gaspressures.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gaspressures.c b/gaspressures.c index 8474f6e..fa1d21f 100644 --- a/gaspressures.c +++ b/gaspressures.c @@ -155,11 +155,12 @@ void dump_pr_interpolate(int i, pr_interpolate_t interpolate_pr) #endif -static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur) -{ +static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur, int diluent_flag) +{ // cur = index to pi->entry corresponding to t_end of segment; diluent_flag=1 indicates diluent cylinder struct pr_interpolate_struct interpolate; int i; struct plot_data *entry; + int pressure; interpolate.start = segment->start; interpolate.end = segment->end; @@ -168,6 +169,11 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, for (i = 0; i < pi->nr; i++) { entry = pi->entry + i; + if (diluent_flag) + pressure = DILUENT_PRESSURE(entry); + else + pressure = SENSOR_PRESSURE(entry); + if (entry->sec < segment->t_start) continue; if (entry->sec >= segment->t_end) { @@ -177,13 +183,13 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, if (entry->sec == segment->t_start) { interpolate.acc_pressure_time = 0; interpolate.pressure_time = 0; - if (SENSOR_PRESSURE(entry)) - interpolate.start = SENSOR_PRESSURE(entry); + if (pressure) + interpolate.start = pressure; continue; } if (i < cur) { - if (SENSOR_PRESSURE(entry)) { - interpolate.start = SENSOR_PRESSURE(entry); + if (pressure) { + interpolate.start = pressure; interpolate.acc_pressure_time = 0; interpolate.pressure_time = 0; } else { @@ -198,8 +204,8 @@ static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, continue; } interpolate.pressure_time += entry->pressure_time; - if (SENSOR_PRESSURE(entry)) { - interpolate.end = SENSOR_PRESSURE(entry); + if (pressure) { + interpolate.end = pressure; break; } } @@ -211,6 +217,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, int cyl, i; struct plot_data *entry; int cur_pr[MAX_CYLINDERS]; + int diluent_flag = 0; #ifdef DEBUG_PR_TRACK /* another great debugging tool */ @@ -252,7 +259,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, continue; } - interpolate = get_pr_interpolate_data(segment, pi, i); + interpolate = get_pr_interpolate_data(segment, pi, i, diluent_flag); #ifdef DEBUG_PR_INTERPOLATE dump_pr_interpolate(i, interpolate); #endif -- 1.9.1
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
