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 /profile.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 'profile.c')
-rw-r--r-- | profile.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -31,7 +31,7 @@ static struct plot_data *last_pi_entry = NULL; typedef enum { STABLE, SLOW, MODERATE, FAST, CRAZY } velocity_t; struct plot_data { - unsigned int same_cylinder:1; + unsigned int same_cylinder:1, in_deco:1; unsigned int cylinderindex; int sec; /* pressure[0] is sensor pressure @@ -1531,6 +1531,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer int cylinderindex = -1; int lastdepth, lastindex; int i, pi_idx, nr, sec, cyl, stoptime, ndl, stopdepth, cns; + gboolean in_deco; struct plot_info *pi; pr_track_t *track_pr[MAX_CYLINDERS] = {NULL, }; pr_track_t *pr_track, *current; @@ -1578,6 +1579,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer continue; } entry = pi->entry + i + pi_idx; + in_deco = sample->in_deco; ndl = sample->ndl.seconds; pi->has_ndl |= ndl; stopdepth = sample->stopdepth.mm; @@ -1606,9 +1608,11 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer entry->ndl = ndl; entry->cns = cns; entry->po2 = po2; + entry->in_deco = in_deco; (entry + 1)->stopdepth = stopdepth; (entry + 1)->stoptime = stoptime; (entry + 1)->ndl = ndl; + (entry + 1)->in_deco = in_deco; (entry + 1)->cns = cns; (entry + 1)->po2 = po2; pi_idx += 2; @@ -1624,6 +1628,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer entry->stopdepth = stopdepth; entry->stoptime = stoptime; entry->ndl = ndl; + entry->in_deco = in_deco; entry->cns = cns; entry->po2 = po2; pi_idx++; @@ -1636,6 +1641,7 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer entry->stopdepth = stopdepth; entry->stoptime = stoptime; entry->ndl = ndl; + entry->in_deco = in_deco; entry->cns = cns; entry->po2 = po2; entry->cylinderindex = sample->cylinderindex; @@ -1965,6 +1971,10 @@ static void plot_string(struct plot_data *entry, char *buf, size_t bufsize, snprintf(buf, bufsize, "%s\nDeco:unkn time @ %.0f %s", buf2, depthvalue, depth_unit); } + } else if (entry->in_deco) { + /* this means we had in_deco set but don't have a stop depth */ + memcpy(buf2, buf, bufsize); + snprintf(buf, bufsize, "%s\nIn deco", buf2); } else if (has_ndl) { memcpy(buf2, buf, bufsize); snprintf(buf, bufsize, "%s\nNDL:%umin", buf2, entry->ndl / 60); |