summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-01 07:33:08 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-01 07:55:28 -0700
commit81e3f774478f4b3e28ffb59fc95f15ed8e397702 (patch)
treea5aa4767a121564f675b02746aab6258783bab5f /planner.c
parentac1168f1860a78fee0e6e576054a6e3d9b39d185 (diff)
downloadsubsurface-81e3f774478f4b3e28ffb59fc95f15ed8e397702.tar.gz
Planner: add warning if the plan consumes more gas than provided
If we have size information including working pressure for a cylinder, we already track the expected pressure at each way point - this way we can also alert the user if more gas is consumed than is available in the cylinder. This does not include sound planning strategies like "rule of thirds". It simply assumes that you won't be able to breathe down the cylinder past about 10bar (using 0 as cutoff seemed silly). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r--planner.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/planner.c b/planner.c
index f062ee699..13480410f 100644
--- a/planner.c
+++ b/planner.c
@@ -601,14 +601,21 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
double volume;
const char *unit;
char gas[64];
+ const char *warning = "";
cylinder_t *cyl = &dive->cylinder[gasidx];
if (cylinder_none(cyl))
break;
int consumed = mbar_to_atm(cyl->start.mbar - cyl->end.mbar) * cyl->type.size.mliter;
+ /* 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 */
+ if (cyl->type.workingpressure.mbar && cyl->end.mbar < 10000)
+ warning = translate("gettextFromC", "WARNING: this is more gas than available in the specified cylinder!");
+
len = strlen(buffer);
volume = get_volume_units(consumed, NULL, &unit);
get_gas_string(get_o2(&cyl->gasmix), get_he(&cyl->gasmix), gas, sizeof(gas));
- snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%.0f%s of %s\n"), volume, unit, gas);
+ snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%.0f%s of %s%s\n"), volume, unit, gas, warning);
}
dive->notes = strdup(buffer);
}