diff options
author | Robert C. Helling <helling@lmu.de> | 2013-02-22 16:41:28 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-23 16:15:18 -0800 |
commit | e5b73d9cb788bd254164320e443b07552ae5a223 (patch) | |
tree | bf32dc77dd56d4342ead7f0d6227367519be496e /planner.c | |
parent | 39fb9244a4ac817fa178750b2a2a13d0fc778c2e (diff) | |
download | subsurface-e5b73d9cb788bd254164320e443b07552ae5a223.tar.gz |
Planner: fix wait time calculations
The problem is that when we reach the gas change depth and compute the
stop time, no gas change event is created yet but time_at_last_depth tries
to determine the gas for the stop from events.
So instead we pass o2 and he as parameters of that function and calculate
the wait time based on that information.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -177,9 +177,9 @@ double tissue_at_end(struct dive *dive, char **cached_datap) } /* how many seconds until we can ascend to the next stop? */ -int time_at_last_depth(struct dive *dive, int next_stop, char **cached_data_p) +int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p) { - int depth, gasidx, o2, he; + int depth, gasidx; double surface_pressure, tissue_tolerance; int wait = 0; struct sample *sample; @@ -190,10 +190,6 @@ int time_at_last_depth(struct dive *dive, int next_stop, char **cached_data_p) tissue_tolerance = tissue_at_end(dive, cached_data_p); sample = &dive->dc.sample[dive->dc.samples - 1]; depth = sample->depth.mm; - /* we always start with gas 0 (unless an event tells us otherwise) */ - o2 = dive->cylinder[0].gasmix.o2.permille; - he = dive->cylinder[0].gasmix.he.permille; - get_gas_from_events(&dive->dc, sample->time.seconds, &o2, &he); gasidx = get_gasidx(dive, o2, he); while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) { wait++; @@ -690,7 +686,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep) #endif gi--; } - wait_time = time_at_last_depth(dive, stoplevels[stopidx - 1], cached_datap); + wait_time = time_at_last_depth(dive, o2, he, stoplevels[stopidx - 1], cached_datap); /* typically deco plans are done in one minute increments; we may want to * make this configurable at some point */ wait_time = ((wait_time + 59) / 60) * 60; |