diff options
author | Willem Ferguson <willemferguson@zoology.up.ac.za> | 2014-11-21 15:33:05 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-21 07:33:52 -0800 |
commit | e288751353ad86dfb05a820f8a71dc2b75fcfb79 (patch) | |
tree | 062198d4ccde45eeabfd427439cc9f00f17fa1b2 /dive.c | |
parent | 27d19b605b8cc319d196123f7abcf48a6968f369 (diff) | |
download | subsurface-e288751353ad86dfb05a820f8a71dc2b75fcfb79.tar.gz |
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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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) |