From e38eb77e30c2d0d06eb61db0cd1bdf3f5e164e8d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 9 Nov 2011 07:41:41 -0800 Subject: [PATCH] Correctly plot dives ending below the surface I thought we had fixed this before - but I guess it got broken again somewhere. We now make sure that the plot_info ends on an entry with depth 0. Added test14 to verify the fix. Also fixed cut'n'paste errors in a few test dive files. Signed-off-by: Dirk Hohndel --- dives/test1.xml | 5 +++-- dives/test11.xml | 2 +- dives/test12.xml | 2 +- dives/test13.xml | 2 +- dives/test14.xml | 39 +++++++++++++++++++++++++++++++++++++++ dives/test2.xml | 2 +- dives/test4.xml | 2 +- dives/test9.xml | 2 +- profile.c | 9 ++++++--- 9 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 dives/test14.xml diff --git a/dives/test1.xml b/dives/test1.xml index 8ea8b7b..6aa7973 100644 --- a/dives/test1.xml +++ b/dives/test1.xml @@ -2,6 +2,7 @@ - Second test dive, this one with location + First test dive, this one with location + Yes, the previous dive is dive 0, that one with no location. - \ No newline at end of file + diff --git a/dives/test11.xml b/dives/test11.xml index 4bd52e0..5e77f61 100644 --- a/dives/test11.xml +++ b/dives/test11.xml @@ -3,7 +3,7 @@ - 10th test dive, 3 tanks, 2 tank changes + 11th test dive, 3 tanks, 2 tank changes Shows three pressure plots, each from 200 to 100bar and gaschange events at 10 and 20 min mark. diff --git a/dives/test12.xml b/dives/test12.xml index efaad68..cfc8d31 100644 --- a/dives/test12.xml +++ b/dives/test12.xml @@ -3,7 +3,7 @@ - 10th test dive, 3 tanks, 3 tank changes + 12th test dive, 3 tanks, 3 tank changes Shows three pressure plots, each from 200 to 100bar and gaschange events at 10, 20 and 25 min mark. Last change is back to first tank. diff --git a/dives/test13.xml b/dives/test13.xml index e5555d8..0668f4d 100644 --- a/dives/test13.xml +++ b/dives/test13.xml @@ -3,7 +3,7 @@ - 10th test dive, 3 tanks, 3 tank changes + 13th test dive, 3 tanks, 3 tank changes Shows three pressure plots, each from 200 to 100bar and gaschange events at 10, 20 and 25 min mark. Last change is back to first tank Now with samples. We have a sample at the first tank change but not the 2nd and 3rd diff --git a/dives/test14.xml b/dives/test14.xml new file mode 100644 index 0000000..a6a1fae --- /dev/null +++ b/dives/test14.xml @@ -0,0 +1,39 @@ + + + + + + 14th test dive - no depth 0 samples + This should show 1m depth at the 30min mark and then a tick up to the surface 20sec later + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dives/test2.xml b/dives/test2.xml index 826445d..286f1f6 100644 --- a/dives/test2.xml +++ b/dives/test2.xml @@ -2,7 +2,7 @@ - 3rd test dive, add cylinder with no start/end pressure + 2nd test dive, add cylinder with no start/end pressure diff --git a/dives/test4.xml b/dives/test4.xml index 903e0fd..df17b1b 100644 --- a/dives/test4.xml +++ b/dives/test4.xml @@ -3,7 +3,7 @@ - 4rd test dive, add temp + 4th test dive, add temp SAC should be 0.46 cuft/min or 13.1 l/min diff --git a/dives/test9.xml b/dives/test9.xml index ff6a874..ba0f19b 100644 --- a/dives/test9.xml +++ b/dives/test9.xml @@ -3,7 +3,7 @@ - 8th test dive, with temperature in samples + 9th test dive, with temperature in samples End temperature is not plotted as correct text diff --git a/profile.c b/profile.c index 173032a..60e0f42 100644 --- a/profile.c +++ b/profile.c @@ -1098,7 +1098,7 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str entry->temperature = sample->temperature.mkelvin; if (depth || lastdepth) - lastindex = i+pi_idx; + lastindex = i + pi_idx; lastdepth = depth; if (depth > pi->maxdepth) @@ -1162,9 +1162,12 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str i = nr + 2; pi->entry[i].sec = sec + 20; pi->entry[i+1].sec = sec + 40; - /* the number of actual entries - we may have allocated more if there - * were gas change events, but this is how many were filled */ + /* the number of actual entries - some computers have lots of + * depth 0 samples at the end of a dive, we want to make sure + * we have exactly one of them at the end */ pi->nr = lastindex+1; + while (pi->nr <= i+2 && pi->entry[pi->nr-1].depth > 0) + pi->nr++; pi->maxtime = pi->entry[lastindex].sec; pi->endpressure = pi->minpressure = dive->cylinder[0].end.mbar; -- 2.43.0