From d15779a27c34cfdb956598f98801e6104e3b0a1e Mon Sep 17 00:00:00 2001 From: Rick Walsh Date: Thu, 2 Nov 2017 19:34:45 +1100 Subject: [PATCH] VPMB: calculate deco_time assuming final ascent always takes the same time If we consider the actual time to ascend from the final stop when calculating deco_time, then slowing the final ascent can lead to the final stop being extended, which is completely nonsensical. For consistency with the original VPMB implementation, we can't ignore the final ascent time completely, but if we assume it is always the same (take default ascent rate of 9m/min) then slower the final ascent won't lead to a longer final stop. Signed-off-by: Rick Walsh --- core/planner.c | 7 +++++-- core/profile.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/planner.c b/core/planner.c index e82f83e68..64dbf0691 100644 --- a/core/planner.c +++ b/core/planner.c @@ -1060,8 +1060,11 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec stopping = false; } } - - deco_time = clock - deco_state->bottom_time; + /* When calculating deco_time, we should pretend the final ascent rate is always the same, + * otherwise odd things can happen, such as CVA causing the final ascent to start *later* + * if the ascent rate is slower, which is completely nonsensical. + * Assume final ascent takes 20s, which is the time taken to ascend at 9m/min from 3m */ + deco_time = clock - deco_state->bottom_time - stoplevels[2] / last_ascend_rate + 20; } while (!is_final_plan); decostoptable[decostopcounter].depth = 0; diff --git a/core/profile.c b/core/profile.c index ef4650cfc..228f8cbdf 100644 --- a/core/profile.c +++ b/core/profile.c @@ -1084,9 +1084,9 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru if (final_tts > 0) deco_time = pi->maxtime + final_tts - time_deep_ceiling; else if (time_clear_ceiling > 0) - /* Consistent with planner, deco_time ends after ascending (20-40s @9m/min from 3-6m) + /* Consistent with planner, deco_time ends after ascending (20s @9m/min from 3m) at end of whole minute after clearing ceiling */ - deco_time = ROUND_UP(time_clear_ceiling, 60) + 30 - time_deep_ceiling; + deco_time = ROUND_UP(time_clear_ceiling, 60) + 20 - time_deep_ceiling; vpmb_next_gradient(deco_time, surface_pressure / 1000.0); final_tts = 0; last_ndl_tts_calc_time = 0;