diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-07-01 09:37:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-01 07:05:01 -0700 |
commit | 1b7abab9b9c5b5f3c9e9ea6aba7dc32b705316f2 (patch) | |
tree | ba4e21ce56379d3631318ba2afa052ed18a144b4 /planner.c | |
parent | 2766ed8093947c6993477a98a1bd25fc53b2d14d (diff) | |
download | subsurface-1b7abab9b9c5b5f3c9e9ea6aba7dc32b705316f2.tar.gz |
Show ascent gas consumption separately in planner
In the worst gase you have to provide gas for your buddy during all the
ascent. So you should have the amount of gas used in ascent as a reserve.
This patch makes the planner notes display that value separately.
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.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -217,7 +217,7 @@ static int verify_gas_exists(struct dive *dive, struct gasmix mix_in) /* calculate the new end pressure of the cylinder, based on its current end pressure and the * latest segment. */ -static void update_cylinder_pressure(struct dive *d, int old_depth, int new_depth, int duration, int sac, cylinder_t *cyl) +static void update_cylinder_pressure(struct dive *d, int old_depth, int new_depth, int duration, int sac, cylinder_t *cyl, bool in_deco) { volume_t gas_used; pressure_t delta_p; @@ -228,6 +228,8 @@ static void update_cylinder_pressure(struct dive *d, int old_depth, int new_dept mean_depth.mm = (old_depth + new_depth) / 2; gas_used.mliter = depth_to_atm(mean_depth.mm, d) * sac / 60 * duration; cyl->gas_used.mliter += gas_used.mliter; + if (in_deco) + cyl->deco_gas_used.mliter += gas_used.mliter; if (cyl->type.size.mliter) { delta_p.mbar = gas_used.mliter * 1000.0 / cyl->type.size.mliter; cyl->end.mbar -= delta_p.mbar; @@ -320,7 +322,7 @@ static struct dive *create_dive_from_plan(struct diveplan *diveplan, struct dive sample->time.seconds = lasttime = time; sample->depth.mm = lastdepth = depth; update_cylinder_pressure(dive, sample[-1].depth.mm, depth, time - sample[-1].time.seconds, - dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl); + dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered); sample->cylinderpressure.mbar = cyl->end.mbar; finish_sample(dc); dp = dp->next; @@ -637,15 +639,17 @@ 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; - const char *unit; + double volume, deco_volume, deco_pressure; + const char *unit, *pressure_unit; char warning[1000] = ""; cylinder_t *cyl = &dive->cylinder[gasidx]; if (cylinder_none(cyl)) break; volume = get_volume_units(cyl->gas_used.mliter, NULL, &unit); + 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); /* 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 */ @@ -653,8 +657,10 @@ 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 { + snprintf(temp, sizeof(temp), translate("gettextFromC", "%.0f%s (%.0f%s during planned ascent) of %s"), volume, unit, deco_volume, unit, gasname(&cyl->gasmix)); } - snprintf(temp, sizeof(temp), translate("gettextFromC", "%.0f%s of %s"), volume, unit, gasname(&cyl->gasmix)); len += snprintf(buffer + len, sizeof(buffer) - len, "%s%s<br>", temp, warning); } dp = diveplan->dp; |