diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-30 18:11:01 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-30 18:17:21 -0800 |
commit | e3ab1c0701fceffa370d56bff187d0c0e90d5d21 (patch) | |
tree | a4c3dec2c1de47494f4ceec9e82b8f994c596455 /parse-xml.c | |
parent | 46b64d8e21bd770c908cc883f3627f4f08a2c0a7 (diff) | |
download | subsurface-e3ab1c0701fceffa370d56bff187d0c0e90d5d21.tar.gz |
Update deco handling
This commit makes deco handling in Subsurface more compatible with the way
libdivecomputer creates the data. Previously we assumed that having a
stopdepth or stoptime and no ndl meant that we were in deco. But
libdivecomputer supports many dive computers that provide the deco state
of the diver but with no information about the next stop or the time
needed there. In order to be able to model this in Subsurface this adds an
in_deco flag to the samples. This is only stored to the XML file when it
changes so it doesn't add much overhead but will allow us to display some
deco information on dive computers like the Atomic Aquatics Cobalt or many
of the Suuntos (among others).
The commit also removes the old event based deco code that was commented
out already. And fixes the code so that the deco / ndl information is
stored for the very last sample as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/parse-xml.c b/parse-xml.c index aa9d5e0f5..8232fb041 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -154,7 +154,7 @@ struct { static gboolean in_settings = FALSE; static struct tm cur_tm; static int cur_cylinder_index, cur_ws_index; -static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2; +static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco; static enum import_source { UNKNOWN, @@ -654,6 +654,7 @@ static void try_to_fill_dc(struct divecomputer *dc, const char *name, char *buf) static void try_to_fill_sample(struct sample *sample, const char *name, char *buf) { int len = strlen(name); + int in_deco; start_match("sample", name, buf); if (MATCH(".sample.pressure", pressure, &sample->cylinderpressure)) @@ -674,6 +675,10 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu return; if (MATCH(".sample.ndl", sampletime, &sample->ndl)) return; + if (MATCH(".sample.in_deco", get_index, &in_deco)) { + sample->in_deco = (in_deco == 1); + return; + } if (MATCH(".sample.stoptime", sampletime, &sample->stoptime)) return; if (MATCH(".sample.stopdepth", depth, &sample->stopdepth)) @@ -999,7 +1004,7 @@ static gboolean is_dive(void) static void reset_dc_info(struct divecomputer *dc) { - lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = 0; + lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = lastindeco = 0; } static void reset_dc_settings(void) @@ -1119,6 +1124,7 @@ static void sample_start(void) { cur_sample = prepare_sample(get_dc()); cur_sample->ndl.seconds = lastndl; + cur_sample->in_deco = lastindeco; cur_sample->stoptime.seconds = laststoptime; cur_sample->stopdepth.mm = laststopdepth; cur_sample->cns = lastcns; @@ -1132,6 +1138,7 @@ static void sample_end(void) finish_sample(get_dc()); lastndl = cur_sample->ndl.seconds; + lastindeco = cur_sample->in_deco; laststoptime = cur_sample->stoptime.seconds; laststopdepth = cur_sample->stopdepth.mm; lastcns = cur_sample->cns; |