Do more dive fixup for each dive computer

In commit b6c9301e58 ("Move more dive computer filled data to the
divecomputer structure") we moved the fields that get filled in by the
dive computers to be per-divecomputer data structures.

This patch re-creates some of those fields back in the "struct dive",
but now the fields are initialized to be a reasonable average from the
dive computer data.  We already did some of this for the temperature
min/max fields for the statistics, so this just continues that trend.

The goal is to make it easy to look at "dive values" without having to
iterate over dive computers every time you do.  Just do it once in
"fixup_dive()" instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-02-09 11:15:18 +11:00 committed by Dirk Hohndel
parent b286ea638c
commit 926fcef2a1
7 changed files with 86 additions and 51 deletions

View file

@ -655,7 +655,7 @@ static int calculate_otu(struct dive *dive)
po2 = sample->po2;
} else {
int o2 = active_o2(dive, dc, sample->time);
po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive, &dive->dc);
po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);
}
if (po2 >= 500)
otu += pow((po2 - 500) / 1000.0, 0.83) * t / 30.0;
@ -720,7 +720,7 @@ static int calculate_sac(struct dive *dive)
}
}
/* Mean pressure in bar (SAC calculations are in bar*l/min) */
pressure = depth_to_mbar(dive->dc.meandepth.mm, dive, &dive->dc) / 1000.0;
pressure = depth_to_mbar(dive->dc.meandepth.mm, dive) / 1000.0;
sac = airuse / pressure * 60 / duration;
/* milliliters per minute.. */
@ -744,7 +744,7 @@ static void add_dive_to_deco(struct dive *dive)
for (j = t0; j < t1; j++) {
int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0);
(void) add_segment(depth_to_mbar(depth, dive, &dive->dc) / 1000.0,
(void) add_segment(depth_to_mbar(depth, dive) / 1000.0,
&dive->cylinder[sample->sensor].gasmix, 1, sample->po2, dive);
}
}