mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
a7969d1083
commit
f79c659b10
1 changed files with 9 additions and 2 deletions
11
planner.c
11
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), " — <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), " — <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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue