Hi Dirk,

Does this patch come too late to be included in 4.2?

It's really straightforward and adds the useful feature of reporting the
OTU and CNS values in the notes for planned dives.

Cheers.

-- 
Gaetan
>From b4b215538670ad6b31902cef74f89e378e8ad61f Mon Sep 17 00:00:00 2001
From: Gaetan Bisson <bis...@archlinux.org>
Date: Mon, 14 Jul 2014 19:47:56 -1000
Subject: [PATCH] Report CNS and OTU in dive plan.

In add_plan_to_notes(), call update_cylinder_related_info() to compute
CNS and OTU data for the planned dive. Report their values in the notes.

Besides CNS and OTU, update_cylinder_related_info() also recomputes the
SAC, which is harmless. Note that both dive->cns and dive->maxcns need
to be zeroed out for the CNS value to actually be recomputed.

Signed-off-by: Gaetan Bisson <bis...@archlinux.org>
---
 planner.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/planner.c b/planner.c
index 630a554..253492e 100644
--- a/planner.c
+++ b/planner.c
@@ -634,9 +634,18 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
 		}
 		lastdepth = dp->depth;
 	} while ((dp = nextdp) != NULL);
+	len += snprintf(buffer + len, sizeof(buffer) - len, "</tbody></table></div>");
+
+	dive->cns = 0;
+	dive->maxcns = 0;
+	update_cylinder_related_info(dive);
+	snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "CNS"));
+	len += snprintf(buffer + len, sizeof(buffer) - len, "<div><br>%s: %i%%", temp, dive->cns);
+	snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "OTU"));
+	len += snprintf(buffer + len, sizeof(buffer) - len, "<br>%s: %i</div>", temp, dive->otu);
 
 	snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "Gas consumption:"));
-	len += snprintf(buffer + len, sizeof(buffer) - len, "</tbody></table></div><div><br>%s<br>", temp);
+	len += snprintf(buffer + len, sizeof(buffer) - len, "<div><br>%s<br>", temp);
 	for (int gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
 		double volume, pressure, deco_volume, deco_pressure;
 		const char *unit, *pressure_unit;
-- 
2.0.1

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to