diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-07 20:08:29 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-07 21:03:39 -0800 |
commit | 9d80e7bfe47726e1f27be323088eb7d36f14c854 (patch) | |
tree | 584d33e44d80a1be22abfd36fc0ce296550d2554 /parse-xml.c | |
parent | a72597189ddccf4e495b52d964d175477414abb9 (diff) | |
download | subsurface-9d80e7bfe47726e1f27be323088eb7d36f14c854.tar.gz |
Add CNS and pO2 tracking in the samples
This adds the new members to the sample structure and fills them from
supported dive computers (Uemis SDA and OSTC / Shearwater Predator,
assuming you have libdivecomputer 0.3).
Save relvant values of this to the XML file and load it back. Handle the
new fields when merging dives.
At this stage we don't DO anything with this, all we do is extract them
from the dive computer, save them to the XML file and load them back.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/parse-xml.c b/parse-xml.c index 35299257a..f88d4ef7f 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -168,7 +168,7 @@ static struct { } cur_event; static struct tm cur_tm; static int cur_cylinder_index, cur_ws_index; -static int lastndl, laststoptime, laststopdepth; +static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2; static enum import_source { UNKNOWN, @@ -484,6 +484,13 @@ static void get_index(char *buffer, void *_i) free(buffer); } +static void double_to_permil(char *buffer, void *_i) +{ + int *i = _i; + *i = g_ascii_strtod(buffer, NULL) * 1000.0 + 0.5; + free(buffer); +} + static void hex_value(char *buffer, void *_i) { uint32_t *i = _i; @@ -675,6 +682,10 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu return; if (MATCH(".sample.stopdepth", depth, &sample->stopdepth)) return; + if (MATCH(".sample.cns", get_index, &sample->cns)) + return; + if (MATCH(".sample.po2", double_to_permil, &sample->po2)) + return; switch (import_source) { case DIVINGLOG: @@ -1085,6 +1096,8 @@ static void sample_start(void) cur_sample->ndl.seconds = lastndl; cur_sample->stoptime.seconds = laststoptime; cur_sample->stopdepth.mm = laststopdepth; + cur_sample->cns = lastcns; + cur_sample->po2 = lastpo2; } static void sample_end(void) @@ -1096,6 +1109,8 @@ static void sample_end(void) lastndl = cur_sample->ndl.seconds; laststoptime = cur_sample->stoptime.seconds; laststopdepth = cur_sample->stopdepth.mm; + lastcns = cur_sample->cns; + lastpo2 = cur_sample->po2; cur_sample = NULL; } @@ -1120,7 +1135,7 @@ static void divecomputer_start(void) /* .. this is the one we'll use */ cur_dc = dc; - lastndl = laststoptime = laststopdepth = 0; + lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = 0; } static void divecomputer_end(void) |