summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-07-06 21:43:53 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-07 13:59:52 -0700
commitf79c659b10ab437e273dd8a13d7c9fed52703f6c (patch)
tree396db443fc9fde3f3a3f2cd9f3c19b332a8fd0b1 /planner.c
parenta7969d108376dee6fd11d50bc22c1c5056a2562d (diff)
downloadsubsurface-f79c659b10ab437e273dd8a13d7c9fed52703f6c.tar.gz
Planner: Show gas consumption in pressure units as well and warn if not enough reserve.
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.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/planner.c b/planner.c
index 768344caa..16152b195 100644
--- a/planner.c
+++ b/planner.c
@@ -638,7 +638,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "Gas consumption:"));
len += snprintf(buffer + len, sizeof(buffer) - len, "</tbody></table></div><div><br>%s<br>", temp);
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
- double volume, deco_volume, deco_pressure;
+ double volume, pressure, deco_volume, deco_pressure;
const char *unit, *pressure_unit;
char warning[1000] = "";
cylinder_t *cyl = &dive->cylinder[gasidx];
@@ -649,6 +649,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
deco_volume = get_volume_units(cyl->deco_gas_used.mliter, NULL, &unit);
if (cyl->type.size.mliter) {
deco_pressure = get_pressure_units(1000.0 * cyl->deco_gas_used.mliter / cyl->type.size.mliter, &pressure_unit);
+ pressure = get_pressure_units(1000.0 * cyl->gas_used.mliter / cyl->type.size.mliter, &pressure_unit);
/* Warn if the plan uses more gas than is available in a cylinder
* This only works if we have working pressure for the cylinder
* 10bar is a made up number - but it seemed silly to pretend you could breathe cylinder down to 0 */
@@ -656,7 +657,13 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
snprintf(warning, sizeof(warning), " &mdash; <span style='color: red;'>%s </span> %s",
translate("gettextFromC", "Warning:"),
translate("gettextFromC", "this is more gas than available in the specified cylinder!"));
- snprintf(temp, sizeof(temp), translate("gettextFromC", "%.0f%s (%.0f%s/%.0f%s in planned ascent) of %s"), volume, unit, deco_volume, unit, deco_pressure, pressure_unit, gasname(&cyl->gasmix));
+ else
+ if ((float) cyl->end.mbar * cyl->type.size.mliter / 1000.0 < (float) cyl->deco_gas_used.mliter)
+ snprintf(warning, sizeof(warning), " &mdash; <span style='color: red;'>%s </span> %s",
+ translate("gettextFromC", "Warning:"),
+ translate("gettextFromC", "not enough reserve for gas sharing on ascent!"));
+
+ snprintf(temp, sizeof(temp), translate("gettextFromC", "%.0f%s/%.0f%s of %s (%.0f%s/%.0f%s in planned ascent)"), volume, unit, pressure, pressure_unit, gasname(&cyl->gasmix), deco_volume, unit, deco_pressure, pressure_unit);
} else {
snprintf(temp, sizeof(temp), translate("gettextFromC", "%.0f%s (%.0f%s during planned ascent) of %s"), volume, unit, deco_volume, unit, gasname(&cyl->gasmix));
}