diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-29 14:36:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-29 14:43:24 -0700 |
commit | d054e8c457c2113b39a7d8fe21215c99a86d1d9d (patch) | |
tree | e59c1a2a1948078e8970d157a619eaf3381cffc5 /equipment.c | |
parent | 56395b38946d4b7de9e485098e928e8e432ef920 (diff) | |
download | subsurface-d054e8c457c2113b39a7d8fe21215c99a86d1d9d.tar.gz |
Planner: track gas consumption in cylinders and samples
This commit is a little bigger than I usually prefer, but it's all
somewhat interconnected.
- we pass around the cylinders throughout the planning process and as we
create the plan we calculate the gas consumption in every segment and
track this both in the end pressure of the cylinder and over time in
the samples
- because of that we no longer try to calculate the gas consumption after
being done planning; we just use what we calculated along the way
- we also no longer add gases during the planning process - all gases
have to come from the list of cylinders passed in (which makes sense
as we should only use those gases that the user added in the UI or
inherited from a the selected dive (when starting to plan with a dive
already selected)
With this patch I think we are close do being able to move all of the
planning logic back into the planner.c code where it belongs. The one
issue that still bothers me is that we are juggling so many dive
structures and then keep copying content around. It seems like we should
be able to reduce that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'equipment.c')
-rw-r--r-- | equipment.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/equipment.c b/equipment.c index 548f15b5e..fd0d6ee0c 100644 --- a/equipment.c +++ b/equipment.c @@ -181,3 +181,12 @@ void remove_weightsystem(struct dive *dive, int idx) memmove(ws, ws + 1, nr * sizeof(*ws)); memset(ws + nr, 0, sizeof(*ws)); } + +void reset_cylinders(struct dive *dive) +{ + int i; + for (i = 0; i < MAX_CYLINDERS; i++) { + if (dive->cylinder[i].type.workingpressure.mbar) + dive->cylinder[i].start.mbar = dive->cylinder[i].end.mbar = dive->cylinder[i].type.workingpressure.mbar; + } +} |