diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-04-26 21:06:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-08 12:28:16 -0700 |
commit | a422aa29860840d7ac7738b25789501ff9f530e1 (patch) | |
tree | 797045ecc46fe699f3f3bcd642ecf9b077bdbc33 /planner.c | |
parent | c3a3c1a1e7d7eedc7aa09ba9842069e9933cb7b2 (diff) | |
download | subsurface-a422aa29860840d7ac7738b25789501ff9f530e1.tar.gz |
Planner: Add waipoints when changing ascend rate in planner
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 | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -610,6 +610,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b bool clear_to_ascend; int clock, previous_point_time; int avg_depth, bottom_time; + int last_ascend_rate; set_gf(diveplan->gflow, diveplan->gfhigh, default_prefs.gf_low_at_maxdepth); if (!diveplan->surface_pressure) @@ -634,6 +635,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b } depth = dive->dc.sample[dive->dc.samples - 1].depth.mm; avg_depth = average_depth(diveplan); + last_ascend_rate = ascend_velocity(depth, avg_depth, bottom_time); /* if all we wanted was the dive just get us back to the surface */ if (!add_deco) { @@ -676,6 +678,12 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b /* Ascend to next stop depth */ assert(deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1) < depth); int deltad = ascend_velocity(depth, avg_depth, bottom_time) * TIMESTEP; + if (ascend_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) { + plan_add_segment(diveplan, clock - previous_point_time, depth, o2, he, po2, false); + previous_point_time = clock; + stopping = false; + last_ascend_rate = ascend_velocity(depth, avg_depth, bottom_time); + } if (depth - deltad < stoplevels[stopidx]) deltad = depth - stoplevels[stopidx]; |