diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-28 09:58:51 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 06:42:49 -0800 |
commit | b000e1b59189a16dd70473f8f93d258e8ad4f095 (patch) | |
tree | 47ae84f71817e733f302a8750162ca44ab37c5a1 /parse-xml.c | |
parent | 5cb20ee4c91932ac44960bc21af6f0bbec823e6c (diff) | |
download | subsurface-b000e1b59189a16dd70473f8f93d258e8ad4f095.tar.gz |
Support gaschange events on Divesoft Freedom import
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.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c index 218268dc3..1da36f0bb 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -2534,7 +2534,8 @@ int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buffer, in int parse_dlf_buffer(char *buffer, size_t size) { char *ptr = (char *)buffer; - bool event; + bool event, found; + int i; /* Skipping the dive header for now */ ptr += 32; @@ -2545,6 +2546,33 @@ int parse_dlf_buffer(char *buffer, size_t size) event = ptr[0] & 0x0f; if (event == 1) { /* dive event */ + switch(ptr[4]) { + case 5: + event_start(); + cur_event.time.seconds = ((ptr[0] >> 4) & 0x0f) + + ((ptr[1] << 4) & 0xff0) + + (ptr[2] & 0x0f) * 3600; /* hours */ + strcpy(cur_event.name, "gaschange"); + cur_event.type = 25; + cur_event.value = ptr[6]; + event_end(); + + found = false; + for (i = 0; i < cur_cylinder_index; ++i) { + if (cur_dive->cylinder[i].gasmix.o2.permille == ptr[6] * 10 && cur_dive->cylinder[i].gasmix.he.permille == ptr[7] * 10) + found = true; + break; + } + if (!found) { + cylinder_start(); + cur_dive->cylinder[cur_cylinder_index].gasmix.o2.permille = ptr[6] * 10; + cur_dive->cylinder[cur_cylinder_index].gasmix.he.permille = ptr[7] * 10; + cylinder_end(); + } + break; + default: + fprintf(stderr, "DEBUG (event): %d\n", ptr[4]); + } } else { sample_start(); cur_sample->time.seconds = ((ptr[0] >> 4) & 0x0f) + |