Subject: [PATCH] Update fixup_pressure to calculate CCR oxygen cylinderpressures
Fixup_pressure() needs to calculate the cylinder pressures at the start and at the end of the dive, also for CCR oxygen cylinders. Since, in the case of CCR, the default cylinder is the diluent, this is not automatically done for oxygen. This code provides for fixup_pressure() to be able to do the calculations for oxygen as well. Another change to fixup_dive() invokes fixup_pressure() to calculate the values for the oxygen cylinder. Signed-off-by: willem ferguson <[email protected]> Please ignore the bottom 6 lines of this patch. Ubuntu forced me to re-create the Subsurface folder, thus destroying a previous patch represented by the bottom 6 lines.
>From 379c4189176f68471013f6c2f04915f8d850befb Mon Sep 17 00:00:00 2001 From: willem ferguson <[email protected]> Date: Fri, 21 Nov 2014 15:20:14 +0200 Subject: [PATCH] Update fixup_pressure to calculate CCR oxygen cylinderpressures Fixup_pressure() needs to calculate the cylinder pressures at the start and at the end of the dive, also for CCR oxygen cylinders. Since, in the case of CCR, the default cylinder is the diluent, this is not automatically done for oxygen. This code provides for fixup_pressure() to be able to do the calculations for oxygen as well. Another change to fixup_dive() invokes fixup_pressure() to calculate the values for the oxygen cylinder. Signed-off-by: willem ferguson <[email protected]> --- dive.c | 15 +++++++++++---- save-xml.c | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dive.c b/dive.c index 78ad255..5a8da01 100644 --- a/dive.c +++ b/dive.c @@ -763,15 +763,20 @@ void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *me } } -static void fixup_pressure(struct dive *dive, struct sample *sample) +static void fixup_pressure(struct dive *dive, struct sample *sample, enum cylinderuse cyl_use) { int pressure, index; cylinder_t *cyl; - pressure = sample->cylinderpressure.mbar; + if (cyl_use != OXYGEN) { + pressure = sample->cylinderpressure.mbar; + index = sample->sensor; + } else { // for the CCR oxygen cylinder: + pressure = sample->o2cylinderpressure.mbar; + index = get_cylinder_idx_by_use(dive, OXYGEN); + } if (!pressure) return; - index = sample->sensor; /* FIXME! sensor -> cylinder mapping? */ if (index >= MAX_CYLINDERS) @@ -1221,7 +1226,9 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc) maxdepth = depth; } - fixup_pressure(dive, sample); + fixup_pressure(dive, sample, OC_GAS); + if (dive->dc.dctype == CCR) + fixup_pressure(dive, sample, OXYGEN); if (temp) { if (!mintemp || temp < mintemp) diff --git a/save-xml.c b/save-xml.c index c9adf53..7a27129 100644 --- a/save-xml.c +++ b/save-xml.c @@ -214,8 +214,8 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds, 60)); put_milli(b, " depth='", sample->depth.mm, " m'"); put_temperature(b, sample->temperature, " temp='", " C'"); - put_pressure(b, sample->cylinderpressure, " pdiluent='", " bar'"); - put_pressure(b, sample->o2cylinderpressure, " pressure='", " bar'"); + put_pressure(b, sample->cylinderpressure, " pressure='", " bar'"); + put_pressure(b, sample->o2cylinderpressure, " o2pressure='", " bar'"); /* * We only show sensor information for samples with pressure, and only if it -- 1.9.1
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
