[PATCH 17/17] Divinglog import: generate gaschange events

Miika Turkia miika.turkia at gmail.com
Sun Jul 12 10:47:02 PDT 2015


Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 parse-xml.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/parse-xml.c b/parse-xml.c
index 991b1e9..fb01d4d 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2883,6 +2883,7 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu
 	int sinterval = 0;
 	unsigned long i, len, lenprofile2 = 0;
 	char *ptr, temp[4], pres[5];
+	short oldcyl = -1;
 
 	/* We do not have samples */
 	if (!data[1])
@@ -2982,6 +2983,26 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu
 		ptr += 12;
 	}
 
+	for (i = 0; i * 11 < lenprofile2; ++i) {
+		short tank = data[2][i * 11 + 7] - '0';
+		if (oldcyl != tank) {
+			struct gasmix *mix = &cur_dive->cylinder[tank].gasmix;
+			int o2 = get_o2(mix);
+			int he = get_he(mix);
+
+			event_start();
+			cur_event.time.seconds = sinterval * i;
+			strcpy(cur_event.name, "gaschange");
+
+			o2 = (o2 + 5) / 10;
+			he = (he + 5) / 10;
+			cur_event.value = o2 + (he << 16);
+
+			event_end();
+			oldcyl = tank;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.1.4



More information about the subsurface mailing list