diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-07 08:38:55 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-07 08:38:55 -0800 |
commit | 1b0ddfbbe218e25001512a18e5cc9224aabf8698 (patch) | |
tree | 7642bf4a3e572e5bfa71fd657b4a630c727f0cbc | |
parent | 85ed689dc0d6ab07386153151f6ac232adb91a8f (diff) | |
download | subsurface-1b0ddfbbe218e25001512a18e5cc9224aabf8698.tar.gz |
Dive planner: add gas change events & start dive with the correct gas
When incrementally building dives with gas changes there are still some
serious issues and inconsistencies. But at least now the gases in the dive
we create appear to be correct.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | planner.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -108,13 +108,19 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) dc = &dive->dc; dc->model = "Simulated Dive"; dp = diveplan->dp; + /* let's start with the gas given on the first segment */ + if(dp) + add_gas(dive, dp->o2, dp->he); while (dp && dp->time) { int i, depth; if (dp->o2 != dive->cylinder[gasused].gasmix.o2.permille || - dp->he != dive->cylinder[gasused].gasmix.he.permille) + dp->he != dive->cylinder[gasused].gasmix.he.permille) { + int value; gasused = add_gas(dive, dp->o2, dp->he); - + value = dp->o2 / 10 | (dp->he / 10) << 16; + add_event(dc, dp->time, 11, 0, value, "gaschange"); + } for (i = t; i < dp->time; i += 10) { depth = lastdepth + (i - t) * (dp->depth - lastdepth) / (dp->time - t); sample = prepare_sample(dc); @@ -198,8 +204,13 @@ void add_depth_to_nth_dp(struct diveplan *diveplan, int idx, int depth) void add_gas_to_nth_dp(struct diveplan *diveplan, int idx, int o2, int he) { struct divedatapoint *dp = get_nth_dp(diveplan, idx); - dp->o2 = o2; - dp->he = he; + if (o2 > 206 && o2 < 213 && he == 0) { + /* we treat air in a special case */ + dp->o2 = dp->he = 0; + } else { + dp->o2 = o2; + dp->he = he; + } } void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp) { |