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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
willem ferguson 2014-08-27 08:13:05 +02:00 committed by Dirk Hohndel
parent dba3aa12a3
commit 0fa324d775

View file

@ -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