From e7aa686f1658e689d215397d4493859829965646 Mon Sep 17 00:00:00 2001 From: Jan Darowski Date: Fri, 3 Jul 2015 23:24:20 +0200 Subject: VPM-B: add vpm-b based deco checking. Check during the trial_ascent() if existing pressure gradient is smaller than previously calculated max gradient. If not, ascent is impossible from the vpm-b's point of view. Signed-off-by: Jan Darowski --- deco.c | 15 +++++++++++++++ dive.h | 1 + planner.c | 6 +++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/deco.c b/deco.c index ada13fbb0..47b752ee8 100644 --- a/deco.c +++ b/deco.c @@ -210,6 +210,21 @@ double he_factor(int period_in_seconds, int ci) return cache[ci].last_factor; } +bool is_vpmb_ok(double pressure) +{ + int ci; + double gradient; + double gas_tension; + + for (ci = 0; ci < 16; ++ci) { + gas_tension = tissue_n2_sat[ci] + tissue_he_sat[ci] + vpmb_config.other_gases_pressure; + gradient = gas_tension - pressure; + if (gradient > total_gradient[ci]) + return false; + } + return true; +} + void vpmb_start_gradient() { int ci; diff --git a/dive.h b/dive.h index d9885184e..9b44700e7 100644 --- a/dive.h +++ b/dive.h @@ -785,6 +785,7 @@ extern void cache_deco_state(double, char **datap); extern double restore_deco_state(char *data); extern void nuclear_regeneration(double time); extern void vpmb_start_gradient(); +extern bool is_vpmb_ok(double pressure); /* this should be converted to use our types */ struct divedatapoint { diff --git a/planner.c b/planner.c index d376acc7c..0307ea89c 100644 --- a/planner.c +++ b/planner.c @@ -836,11 +836,15 @@ bool trial_ascent(int trial_depth, int stoplevel, int avg_depth, int bottom_time tissue_tolerance = add_segment(depth_to_mbar(trial_depth, &displayed_dive) / 1000.0, gasmix, TIMESTEP, po2, &displayed_dive, prefs.decosac); - if (deco_allowed_depth(tissue_tolerance, surface_pressure, &displayed_dive, 1) > trial_depth - deltad) { + if (prefs.deco_mode != VPMB && deco_allowed_depth(tissue_tolerance, surface_pressure, &displayed_dive, 1) > trial_depth - deltad) { /* We should have stopped */ clear_to_ascend = false; break; } + if (prefs.deco_mode == VPMB && (!is_vpmb_ok(depth_to_mbar(trial_depth, &displayed_dive) / 1000.0))){ + clear_to_ascend = false; + break; + } trial_depth -= deltad; } restore_deco_state(trial_cache); -- cgit v1.2.3-70-g09d2