Calculate correct nitrogen and helium gas pressures for CCR after
import from CSV.

Currently the gas pressures stored in structures of pressure are
calculated using the gasmix composition of the currently selected
cylinder. But with CCR dives the default cylinder is the oxygen
cylinder (cylinder index 0). However, the gas pressures need to
be calculated using gasmix data from cylinder 1 (the diluent
cylinder). This patch allows setting the appropriate cylinder
for calculating the values in the structures of pressure. It
also allows for correctly calculating gas pressures for any
open circuit cylinders (e.g. bailout) that a CCR diver may
use. These open circuit cylinders would have cylinder indices
of 2 and larger.

Signed-off-by: willem ferguson <[email protected]>

>From 0bdd317259d0438ba6b3c4eaaea8cddef1497884 Mon Sep 17 00:00:00 2001
From: willem ferguson <[email protected]>
Date: Mon, 3 Nov 2014 08:59:48 +0200
Subject: [PATCH] Calculate correct nitrogen and helium gas pressures for CCR
 after import from CSV.

Currently the gas pressures stored in structures of pressure are
calculated using the gasmix composition of the currently selected
cylinder. But with CCR dives the default cylinder is the oxygen
cylinder (cylinder index 0). However, the gas pressures need to
be calculated using gasmix data from cylinder 1 (the diluent
cylinder). This patch allows setting the appropriate cylinder
for calculating the values in the structures of pressure. It
also allows for correctly calculating gas pressures for any
open circuit cylinders (e.g. bailout) that a CCR diver may
use. These open circuit cylinders would have cylinder indices
of 2 and larger.

Signed-off-by: willem ferguson <[email protected]>
---
 profile.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/profile.c b/profile.c
index 4be3a5b..2a5ec8b 100644
--- a/profile.c
+++ b/profile.c
@@ -901,7 +901,10 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
 		fo2 = get_o2(&dive->cylinder[cylinderindex].gasmix);
 		fhe = get_he(&dive->cylinder[cylinderindex].gasmix);
 
-		fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2);
+		if ((dive->dc.dctype == CCR) && (cylinderindex < 2))
+			fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[1].gasmix, entry->pressures.o2);
+		else	// For OC:
+			fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2);
 
 		/* Calculate MOD, EAD, END and EADD based on partial pressures calculated before
 		 * so there is no difference in calculating between OC and CC
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to