summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2015-06-20 00:02:38 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-19 09:15:51 -0700
commit845030a8ad9b2c6b245e215430a8bce95578055d (patch)
tree8ad1520c31596938853c321cb8e61ec0d8397bb4
parent4dfdea1e1dd631fbd335c5dfa5ef8e7a2cbea780 (diff)
downloadsubsurface-845030a8ad9b2c6b245e215430a8bce95578055d.tar.gz
Enforce planner minimum gas switch duration
Enforce a minimum duration for gas switching in the planner. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--planner.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/planner.c b/planner.c
index 9b2d355fa..63f1f6364 100644
--- a/planner.c
+++ b/planner.c
@@ -1040,12 +1040,21 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
previous_point_time = clock;
stopping = true;
- current_cylinder = gaschanges[gi].gasidx;
- gas = displayed_dive.cylinder[current_cylinder].gasmix;
+ /* Check we need to change cylinder.
+ * We might not if the cylinder was chosen by the user */
+ if (current_cylinder != gaschanges[gi].gasidx) {
+ current_cylinder = gaschanges[gi].gasidx;
+ gas = displayed_dive.cylinder[current_cylinder].gasmix;
#if DEBUG_PLAN & 16
- printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
- (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
+ printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
+ (get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
#endif
+ /* Stop for the minimum duration to switch gas */
+ tissue_tolerance = add_segment(depth_to_mbar(depth, &displayed_dive) / 1000.0,
+ &displayed_dive.cylinder[current_cylinder].gasmix,
+ prefs.min_switch_duration, po2, &displayed_dive, prefs.decosac);
+ clock += prefs.min_switch_duration;
+ }
gi--;
}