aboutsummaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-07-12 23:17:02 +0530
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-12 13:58:17 -0700
commitc41fd9126125e58932f45919f57462f13b21760e (patch)
tree549f0ceb410b15bee715f2ddebf0270d2c63c126 /parse-xml.c
parent7fffe8aba04b0614b277ab483f084859017f081a (diff)
downloadsubsurface-c41fd9126125e58932f45919f57462f13b21760e.tar.gz
Divinglog import: generate gaschange events
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 991b1e962..fb01d4d63 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;
}