mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
VPM-B: Add Boyles compensation to the planner.
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
This commit is contained in:
parent
a828d528f9
commit
c0fde4f50f
2 changed files with 11 additions and 1 deletions
1
dive.h
1
dive.h
|
@ -802,6 +802,7 @@ extern void nuclear_regeneration(double time);
|
||||||
extern void vpmb_start_gradient();
|
extern void vpmb_start_gradient();
|
||||||
extern void vpmb_next_gradient(double deco_time);
|
extern void vpmb_next_gradient(double deco_time);
|
||||||
extern bool is_vpmb_ok(double pressure);
|
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 */
|
/* this should be converted to use our types */
|
||||||
struct divedatapoint {
|
struct divedatapoint {
|
||||||
|
|
11
planner.c
11
planner.c
|
@ -919,6 +919,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
||||||
int bottom_depth;
|
int bottom_depth;
|
||||||
int bottom_gi;
|
int bottom_gi;
|
||||||
int bottom_stopidx;
|
int bottom_stopidx;
|
||||||
|
int first_stop_pressure;
|
||||||
bool is_final_plan = true;
|
bool is_final_plan = true;
|
||||||
int deco_time;
|
int deco_time;
|
||||||
int previous_deco_time;
|
int previous_deco_time;
|
||||||
|
@ -1098,6 +1099,9 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
||||||
//CVA
|
//CVA
|
||||||
do {
|
do {
|
||||||
is_final_plan = (prefs.deco_mode == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
|
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;
|
previous_deco_time = deco_time;
|
||||||
restore_deco_state(bottom_cache);
|
restore_deco_state(bottom_cache);
|
||||||
|
|
||||||
|
@ -1111,12 +1115,12 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
||||||
breaktime = -1;
|
breaktime = -1;
|
||||||
breakcylinder = 0;
|
breakcylinder = 0;
|
||||||
o2time = 0;
|
o2time = 0;
|
||||||
|
first_stop_pressure = 0;
|
||||||
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
||||||
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
|
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
|
||||||
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
||||||
current_cylinder = 0;
|
current_cylinder = 0;
|
||||||
}
|
}
|
||||||
vpmb_next_gradient(deco_time);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* We will break out when we hit the surface */
|
/* 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);
|
plan_add_segment(diveplan, clock - previous_point_time, depth, gas, po2, false);
|
||||||
previous_point_time = clock;
|
previous_point_time = clock;
|
||||||
stopping = true;
|
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?
|
/* Are we waiting to switch gas?
|
||||||
|
|
Loading…
Add table
Reference in a new issue