summaryrefslogtreecommitdiffstats
path: root/core/planner.c
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2017-11-02 19:34:45 +1100
committerGravatar Robert C. Helling <helling@atdotde.de>2017-11-08 15:22:32 +0100
commit4a727c64d9ac56e926eea43ee7be7685ef6d76ec (patch)
treec69b6dc57dc90b02242edb9dfb3c4460c1ea5d4a /core/planner.c
parenta06848c23759d8d8fad5abe19351262eb859e086 (diff)
downloadsubsurface-4a727c64d9ac56e926eea43ee7be7685ef6d76ec.tar.gz
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 <rickmwalsh@gmail.com>
Diffstat (limited to 'core/planner.c')
-rw-r--r--core/planner.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/planner.c b/core/planner.c
index e13fdf9a3..ab53dc0be 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -1056,8 +1056,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;