aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2013-12-07 23:54:18 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-08 09:42:03 +0100
commit01e32107258c895653ddeeddc6081b8c2bdc0a1a (patch)
tree6e246fa06d5dd0cec7f13414d3f77d05420dd791 /qt-ui/diveplanner.cpp
parenteae1624f2472abc3700dfdb9835da4e59dbff517 (diff)
downloadsubsurface-01e32107258c895653ddeeddc6081b8c2bdc0a1a.tar.gz
Calculate gas consumption for planned dives
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 897ef2920..c6d9fa523 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1454,6 +1454,20 @@ void DivePlannerPointsModel::createPlan()
createTemporaryPlan();
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
+ copy_cylinders(stagingDive, tempDive);
+ int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
+ per_cylinder_mean_depth(tempDive, select_dc(&tempDive->dc), mean, duration);
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ cylinder_t *cyl = tempDive->cylinder+i;
+ if (cylinder_none(cyl))
+ continue;
+ // FIXME: The epic assumption that all the cylinders after the first is deco
+ int sac = i ? diveplan.decosac : diveplan.bottomsac;
+ cyl->start.mbar = cyl->type.workingpressure.mbar;
+ int consumption = ((depth_to_mbar(mean[i], tempDive) * duration[i] / 60) * sac) / ( cyl->type.size.mliter / 1000);
+ cyl->end.mbar = cyl->start.mbar - consumption;
+ }
+
mark_divelist_changed(TRUE);
// Remove and clean the diveplan, so we don't delete