diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-01 13:02:30 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-04 21:05:26 -0800 |
commit | dcb6574dc4252c4ff598efb17269b7f1255afec1 (patch) | |
tree | c774cd0bb3c85c36988976ce1ab6086c9e996f7b /save-xml.c | |
parent | 7383f7fe0a77c906aafcd61ccfc09dc1866c5416 (diff) | |
download | subsurface-dcb6574dc4252c4ff598efb17269b7f1255afec1.tar.gz |
Improve deco handling and add NDL support
This commit changes the code that was recently introduced to deal with
deco ceilings. Instead of handling these through events we now store the
ceiling (which in reality is the deepest deco stop with all known dive
computers) and the stop time at that ceiling in the samples.
This also adds support for NDL (non stop dive limit) which both dive
computers that appear to give us ceiling / deco information appear to
give us as well (when the diver isn't in deco).
If the mouse hovers over the profile we now add support for displaying the
NDL, the current deco obligation and (if we are able to tell from the
data) whether we are at a safety stop.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/save-xml.c b/save-xml.c index 8d7d7f889..d4bc36cab 100644 --- a/save-xml.c +++ b/save-xml.c @@ -293,7 +293,7 @@ static void show_index(FILE *f, int value, const char *pre, const char *post) fprintf(f, " %s%d%s", pre, value, post); } -static void save_sample(FILE *f, struct sample *sample) +static void save_sample(FILE *f, struct sample *sample, const struct sample *prev) { fprintf(f, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60)); show_milli(f, " depth='", sample->depth.mm, " m", "'"); @@ -301,6 +301,13 @@ static void save_sample(FILE *f, struct sample *sample) show_pressure(f, sample->cylinderpressure, " pressure='", "'"); if (sample->cylinderindex) fprintf(f, " cylinderindex='%d'", sample->cylinderindex); + /* the deco/ndl values are stored whenever they change */ + if (sample->ndl.seconds != prev->ndl.seconds) + fprintf(f, " ndl='%u:%02u min'", FRACTION(sample->ndl.seconds, 60)); + if (sample->stoptime.seconds != prev->stoptime.seconds) + fprintf(f, " stoptime='%u:%02u min'", FRACTION(sample->stoptime.seconds, 60)); + if (sample->stopdepth.mm != prev->stopdepth.mm) + show_milli(f, " stopdepth='", sample->stopdepth.mm, " m", "'"); fprintf(f, " />\n"); } @@ -346,10 +353,20 @@ static void save_trip(FILE *f, dive_trip_t *trip) show_utf8(f, trip->notes, "<notes>","</notes>\n", 0); } -static void save_dc(FILE *f, struct dive *dive, struct divecomputer *dc) +static void save_samples(FILE *f, int nr, struct sample *s) { - int i; + static const struct sample empty_sample; + const struct sample *prev = &empty_sample; + + while (--nr >= 0) { + save_sample(f, s, prev); + prev = s; + s++; + } +} +static void save_dc(FILE *f, struct dive *dive, struct divecomputer *dc) +{ fprintf(f, " <divecomputer"); if (dc->model) show_utf8(f, dc->model, " model='", "'", 1); @@ -361,8 +378,8 @@ static void save_dc(FILE *f, struct dive *dive, struct divecomputer *dc) show_date(f, dc->when); fprintf(f, ">\n"); save_events(f, dc->events); - for (i = 0; i < dc->samples; i++) - save_sample(f, dc->sample+i); + save_samples(f, dc->samples, dc->sample); + fprintf(f, " </divecomputer>\n"); } |