Planner: warn about high pO2

If the user entered part of the plan exceeds a pO2 of 1.6, include a
warning about that in the notes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-06-02 12:29:40 -07:00
parent 90885bfb8e
commit 9cae50acab

View file

@ -632,6 +632,22 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
}
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%.0f%s of %s%s\n"), volume, unit, gasname(&cyl->gasmix), warning);
}
dp = diveplan->dp;
while (dp) {
if (dp->time != 0) {
int pO2 = depth_to_atm(dp->depth, dive) * dp->gasmix.o2.permille;
if (pO2 > 1600) {
const char *depth_unit;
int decimals;
double depth_value = get_depth_units(dp->depth, &decimals, &depth_unit);
len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len,
translate("gettextFromC", "Warning: high pO2 value %.2f at %d:%02u with gas %s at depth %.*f %s"),
pO2 / 1000.0, FRACTION(dp->time, 60), gasname(&dp->gasmix), depth_value, decimals, depth_unit);
}
}
dp = dp->next;
}
dive->notes = strdup(buffer);
}