From 848a5352c7afedd530186ae842719e8f67c8c66a Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Wed, 9 Jul 2014 22:13:36 +0200 Subject: Add support divecomputer based TTS Since earlier have we had support for our own calculated TTS. This adds support for holding TTS values reported by a dive computer. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- dive.h | 1 + load-git.c | 4 ++++ parse-xml.c | 2 ++ profile.c | 2 ++ profile.h | 1 + save-git.c | 4 ++++ save-xml.c | 4 ++++ 7 files changed, 18 insertions(+) diff --git a/dive.h b/dive.h index b682265fc..6f0bb99f1 100644 --- a/dive.h +++ b/dive.h @@ -147,6 +147,7 @@ struct sample // BASE TYPE BYTES UNITS RANGE DE duration_t time; // uint32_t 4 seconds (0-68 yrs) elapsed dive time up to this sample duration_t stoptime; // uint32_t 4 seconds (0-18 h) time duration of next deco stop duration_t ndl; // uint32_t 4 seconds (0-18 h) time duration before no-deco limit + duration_t tts; // uint32_t 4 seconds (0-18 h) time duration to reach the surface depth_t depth; // int32_t 4 mm (0-2000 km) dive depth of this sample depth_t stopdepth; // int32_t 4 mm (0-2000 km) depth of next deco stop temperature_t temperature; // int32_t 4 mdegrK (0-2 MdegK) ambient temperature diff --git a/load-git.c b/load-git.c index be0e3539c..e61a0ca13 100644 --- a/load-git.c +++ b/load-git.c @@ -357,6 +357,10 @@ static void parse_sample_keyvalue(void *_sample, const char *key, const char *va sample->ndl = get_duration(value); return; } + if (!strcmp(key, "tts")) { + sample->tts = get_duration(value); + return; + } if (!strcmp(key, "in_deco")) { sample->in_deco = atoi(value); return; diff --git a/parse-xml.c b/parse-xml.c index 01599d61a..5375e3202 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -850,6 +850,8 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu return; if (MATCH("ndl.sample", sampletime, &sample->ndl)) return; + if (MATCH("tts.sample", sampletime, &sample->tts)) + return; if (MATCH("in_deco.sample", get_index, &in_deco)) { sample->in_deco = (in_deco == 1); return; diff --git a/profile.c b/profile.c index 1af7249ee..0a4d9e19a 100644 --- a/profile.c +++ b/profile.c @@ -1316,6 +1316,8 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me } else if (has_ndl) { put_format(b, translate("gettextFromC", "NDL: %umin\n"), DIV_UP(entry->ndl, 60)); } + if (entry->tts) + put_format(b, translate("gettextFromC", "TTS: %umin\n"), DIV_UP(entry->tts, 60)); if (entry->stopdepth_calc && entry->stoptime_calc) { depthvalue = get_depth_units(entry->stopdepth_calc, NULL, &depth_unit); put_format(b, translate("gettextFromC", "Deco: %umin @ %.0f%s (calc)\n"), DIV_UP(entry->stoptime_calc, 60), diff --git a/profile.h b/profile.h index 54d250a2b..99a181e63 100644 --- a/profile.h +++ b/profile.h @@ -29,6 +29,7 @@ struct plot_data { int ceiling; int ceilings[16]; int ndl; + int tts; int stoptime; int stopdepth; int cns; diff --git a/save-git.c b/save-git.c index f7a244a2a..0ba6e9801 100644 --- a/save-git.c +++ b/save-git.c @@ -243,6 +243,10 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl put_format(b, " ndl=%u:%02u", FRACTION(sample->ndl.seconds, 60)); old->ndl = sample->ndl; } + if (sample->tts.seconds != old->tts.seconds) { + put_format(b, " tts=%u:%02u", FRACTION(sample->tts.seconds, 60)); + old->tts = sample->tts; + } if (sample->in_deco != old->in_deco) { put_format(b, " in_deco=%d", sample->in_deco ? 1 : 0); old->in_deco = sample->in_deco; diff --git a/save-xml.c b/save-xml.c index 514600dd4..9c802b82a 100644 --- a/save-xml.c +++ b/save-xml.c @@ -219,6 +219,10 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl put_format(b, " ndl='%u:%02u min'", FRACTION(sample->ndl.seconds, 60)); old->ndl = sample->ndl; } + if (sample->tts.seconds != old->tts.seconds) { + put_format(b, " tts='%u:%02u min'", FRACTION(sample->tts.seconds, 60)); + old->tts = sample->tts; + } if (sample->in_deco != old->in_deco) { put_format(b, " in_deco='%d'", sample->in_deco ? 1 : 0); old->in_deco = sample->in_deco; -- cgit v1.2.3-70-g09d2