summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-23 17:18:30 +0300
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-23 18:01:16 +0300
commit2b2b6775de0ebdd086bb7cd4afc5ac461100524d (patch)
treea4a5de9b4d18e293b8e8c1456c7b8479be3d7202 /profile.c
parent41a1cf4b1967c689f4c3dab60ac284a1313bb9b4 (diff)
downloadsubsurface-2b2b6775de0ebdd086bb7cd4afc5ac461100524d.tar.gz
Split the cylinder pressure analysis into a second loop
For the dive computers that give cylinder change events, we want to re-write the cylinder index and pressure information with the event information before we start analyzing the pressures. So instead of filling the plot info and analyzing in one loop, split it up into two phases. We'll do the "fix up cylinder pressure info based on events" in between those phases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/profile.c b/profile.c
index 7832dccaf..bdce4261d 100644
--- a/profile.c
+++ b/profile.c
@@ -887,9 +887,6 @@ static struct plot_info *create_plot_info(struct dive *dive)
sec = 0;
lastindex = 0;
lastdepth = -1;
- for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) /* initialize the start pressures */
- track_pr[cyl] = pr_track_alloc(dive->cylinder[cyl].start.mbar, -1);
- current = track_pr[dive->sample[0].cylinderindex];
for (i = 0; i < dive->samples; i++) {
int depth;
struct sample *sample = dive->sample+i;
@@ -897,9 +894,27 @@ static struct plot_info *create_plot_info(struct dive *dive)
entry = pi->entry + i + 2;
sec = entry->sec = sample->time.seconds;
depth = entry->depth = sample->depth.mm;
- entry->same_cylinder = sample->cylinderindex == cylinderindex;
- entry->cylinderindex = cylinderindex = sample->cylinderindex;
+ entry->cylinderindex = sample->cylinderindex;
SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar;
+ entry->temperature = sample->temperature.mkelvin;
+
+ if (depth || lastdepth)
+ lastindex = i+2;
+
+ lastdepth = depth;
+ if (depth > pi->maxdepth)
+ pi->maxdepth = depth;
+ }
+
+ for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) /* initialize the start pressures */
+ track_pr[cyl] = pr_track_alloc(dive->cylinder[cyl].start.mbar, -1);
+ current = track_pr[dive->sample[0].cylinderindex];
+ for (i = 0; i < dive->samples; i++) {
+ entry = pi->entry + i + 2;
+
+ entry->same_cylinder = entry->cylinderindex == cylinderindex;
+ cylinderindex = entry->cylinderindex;
+
/* track the segments per cylinder and their pressure/time integral */
if (!entry->same_cylinder) {
current->end = SENSOR_PRESSURE(entry-1);
@@ -921,15 +936,8 @@ static struct plot_info *create_plot_info(struct dive *dive)
current->pressure_time += (entry->sec - (entry-1)->sec) *
(1 + entry->depth / 10000.0);
missing_pr |= !SENSOR_PRESSURE(entry);
- entry->temperature = sample->temperature.mkelvin;
-
- if (depth || lastdepth)
- lastindex = i+2;
-
- lastdepth = depth;
- if (depth > pi->maxdepth)
- pi->maxdepth = depth;
}
+
current->t_end = entry->sec;
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { /* initialize the end pressures */
int pr = dive->cylinder[cyl].end.mbar;