diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-10 09:46:34 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-16 17:14:17 +0200 |
commit | 3e67bfaea6ff4f379c4b84784c31736cf822a7d3 (patch) | |
tree | a5f5b2e5e42d73675e410493a4be1556d43285c6 /core/planner.c | |
parent | 80a2cd7b1bf6df00adf84a13b1e6f16910a0bdeb (diff) | |
download | subsurface-3e67bfaea6ff4f379c4b84784c31736cf822a7d3.tar.gz |
In planner prefer best_first_ascend_cylinder for gas breaks
Up to now the cylinder for gas breaks was hardcoded to first cylinder.
With this change the best_first_ascend_cylinder is used if its
O2 is <=32%.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/planner.c b/core/planner.c index d823a0a39..5a50130fd 100644 --- a/core/planner.c +++ b/core/planner.c @@ -675,7 +675,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec struct gasmix gas, bottom_gas; int o2time = 0; int breaktime = -1; - int breakcylinder = 0; + int break_cylinder = -1, breakfrom_cylinder = 0; int error = 0; bool decodive = false; int first_stop_depth = 0; @@ -855,7 +855,6 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec first_stop_depth = 0; stopidx = bottom_stopidx; breaktime = -1; - breakcylinder = 0; o2time = 0; deco_state->first_ceiling_pressure.mbar = depth_to_mbar(deco_allowed_depth(tissue_tolerance_calc(dive, depth_to_bar(depth, dive)), @@ -1006,18 +1005,24 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec o2breaking = false; if (prefs.doo2breaks) { /* The backgas breaks option limits time on oxygen to 12 minutes, followed by 6 minutes on - * backgas (first defined gas). This could be customized if there were demand. + * backgas. This could be customized if there were demand. */ + if (break_cylinder == -1) { + if (get_o2(&dive->cylinder[best_first_ascend_cylinder].gasmix) <= 320) + break_cylinder = best_first_ascend_cylinder; + else + break_cylinder = 0; + } if (get_o2(&dive->cylinder[current_cylinder].gasmix) == 1000) { if (laststoptime >= 12 * 60) { laststoptime = 12 * 60; o2breaking = true; breaktime = 0; - breakcylinder = current_cylinder; + breakfrom_cylinder = current_cylinder; if (is_final_plan) plan_add_segment(diveplan, clock + laststoptime - previous_point_time, depth, current_cylinder, po2, false); previous_point_time = clock + laststoptime; - current_cylinder = 0; + current_cylinder = break_cylinder; gas = dive->cylinder[current_cylinder].gasmix; } } else { @@ -1029,7 +1034,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec if (is_final_plan) plan_add_segment(diveplan, clock + laststoptime - previous_point_time, depth, current_cylinder, po2, false); previous_point_time = clock + laststoptime; - current_cylinder = breakcylinder; + current_cylinder = breakfrom_cylinder; gas = dive->cylinder[current_cylinder].gasmix; breaktime = -1; } |