[PATCH 5/6] Calculate gas consumption for planned dives

Anton Lundin glance at acc.umu.se
Sat Dec 7 14:54:18 UTC 2013


Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/diveplanner.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 897ef29..c6d9fa5 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
-- 
1.8.3.2



More information about the subsurface mailing list