mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
7383f7fe0a
commit
dcb6574dc4
6 changed files with 151 additions and 93 deletions
27
save-xml.c
27
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_samples(FILE *f, int nr, struct sample *s)
|
||||
{
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue