VPM-B: Add Boyles compensation to the planner.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
This commit is contained in:
Jan Darowski 2015-08-15 14:16:48 +02:00
parent a828d528f9
commit c0fde4f50f
2 changed files with 11 additions and 1 deletions

1
dive.h
View file

@ -802,6 +802,7 @@ extern void nuclear_regeneration(double time);
extern void vpmb_start_gradient();
extern void vpmb_next_gradient(double deco_time);
extern bool is_vpmb_ok(double pressure);
extern void boyles_law(double first_stop_pressure, double next_stop_pressure);
/* this should be converted to use our types */
struct divedatapoint {

View file

@ -919,6 +919,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
int bottom_depth;
int bottom_gi;
int bottom_stopidx;
int first_stop_pressure;
bool is_final_plan = true;
int deco_time;
int previous_deco_time;
@ -1098,6 +1099,9 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
//CVA
do {
is_final_plan = (prefs.deco_mode == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
if (deco_time != 10000000)
vpmb_next_gradient(deco_time);
previous_deco_time = deco_time;
restore_deco_state(bottom_cache);
@ -1111,12 +1115,12 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
breaktime = -1;
breakcylinder = 0;
o2time = 0;
first_stop_pressure = 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));
current_cylinder = 0;
}
vpmb_next_gradient(deco_time);
while (1) {
/* We will break out when we hit the surface */
@ -1200,6 +1204,11 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
plan_add_segment(diveplan, clock - previous_point_time, depth, gas, po2, false);
previous_point_time = clock;
stopping = true;
// Boyles Law compensation
if (first_stop_pressure == 0)
first_stop_pressure = depth_to_mbar(depth, &displayed_dive);
boyles_law(first_stop_pressure / 1000.0, depth_to_mbar(stoplevels[stopidx], &displayed_dive) / 1000.0);
}
/* Are we waiting to switch gas?