summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
Diffstat (limited to 'planner.c')
-rw-r--r--planner.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/planner.c b/planner.c
index aca5a0594..5afc11771 100644
--- a/planner.c
+++ b/planner.c
@@ -939,6 +939,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
int *decostoplevels;
int decostoplevelcount;
unsigned int *stoplevels = NULL;
+ int vpmb_first_stop;
bool stopping = false;
bool pendinggaschange = false;
bool clear_to_ascend;
@@ -996,6 +997,13 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
create_dive_from_plan(diveplan, is_planner);
return(false);
}
+ calc_crushing_pressure(depth_to_mbar(depth, &displayed_dive) / 1000.0);
+ nuclear_regeneration(clock);
+ clear_deco(displayed_dive.surface_pressure.mbar / 1000.0);
+ vpmb_start_gradient();
+ previous_deco_time = 100000000;
+ deco_time = 10000000;
+
tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap);
displayed_dive.surface_pressure.mbar = diveplan->surface_pressure;
@@ -1100,6 +1108,22 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
bottom_gi = gi;
bottom_gas = gas;
bottom_stopidx = stopidx;
+
+ // Find first stop used for VPM-B Boyle's law compensation
+ if (prefs.deco_mode == VPMB) {
+ vpmb_first_stop = deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000, &displayed_dive, 1);
+ if (vpmb_first_stop > 0) {
+ while (stoplevels[stopidx] > vpmb_first_stop) {
+ stopidx--;
+ }
+ stopidx++;
+ vpmb_first_stop = stoplevels[stopidx];
+ }
+ first_stop_pressure.mbar = depth_to_mbar(vpmb_first_stop, &displayed_dive);
+ } else {
+ first_stop_pressure.mbar = 0;
+ }
+
//CVA
do {
is_final_plan = (prefs.deco_mode == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
@@ -1107,7 +1131,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0);
previous_deco_time = deco_time;
- restore_deco_state(bottom_cache);
+ tissue_tolerance = restore_deco_state(bottom_cache);
depth = bottom_depth;
gi = bottom_gi;
@@ -1119,7 +1143,6 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
breaktime = -1;
breakcylinder = 0;
o2time = 0;
- first_stop_pressure.mbar = 0;
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
@@ -1160,8 +1183,6 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
stopping = true;
// Boyles Law compensation
- if (first_stop_pressure.mbar == 0)
- first_stop_pressure.mbar = depth_to_mbar(depth, &displayed_dive);
boyles_law(depth_to_mbar(stoplevels[stopidx], &displayed_dive) / 1000.0);
/* Check we need to change cylinder.
@@ -1215,8 +1236,6 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
stopping = true;
// Boyles Law compensation
- if (first_stop_pressure.mbar == 0)
- first_stop_pressure.mbar = depth_to_mbar(depth, &displayed_dive);
boyles_law(depth_to_mbar(stoplevels[stopidx], &displayed_dive) / 1000.0);
}