From 98540970922cd8623aa7973546148f2d0459268f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 30 Dec 2012 21:34:17 -0800 Subject: [PATCH] Deco and ndl support for the Atomic Aquatics Cobalt The Cobalt tracks only the NDL time in the samples. There are however two indications when the dive changes into a decompression dive, but they don't always occur at the same time and may or may not appear in the same sample. The first indication is that the NDL time goes to zero and the other is the first occurrence of the "deco schedule computed" bit (0x02) in the violation byte of the sample. As soon as the NDL time goes to zero, an attempt is made to generate a deco schedule. Depending upon the algorithm used, a schedule may or may not have any stops, even though the NDL time is zero. If the schedule does generate deco stops, the deco schedule computed bit is set in the violation byte of the sample. This bit is set each time a non-zero schedule is computed. But because this bit is immediately cleared after the sample has been stored, and only set again at the completion of the next schedule computation, not every sample will have this bit set. Signed-off-by: Dirk Hohndel --- src/atomics_cobalt_parser.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/atomics_cobalt_parser.c b/src/atomics_cobalt_parser.c index acc8d6a..ada8941 100644 --- a/src/atomics_cobalt_parser.c +++ b/src/atomics_cobalt_parser.c @@ -228,6 +228,7 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int time = 0; + unsigned int in_deco = 0; unsigned int offset = header; while (offset + SZ_SEGMENT <= size) { dc_sample_value_t sample = {0}; @@ -288,6 +289,20 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); } + // NDL & deco + unsigned int ndl = data[offset + 5] * 60; + if (ndl > 0) + in_deco = 0; + else if (ndl == 0 && (violation & 0x02)) + in_deco = 1; + if (in_deco) + sample.deco.type = DC_DECO_DECOSTOP; + else + sample.deco.type = DC_DECO_NDL; + sample.deco.time = ndl; + sample.deco.depth = 0.0; + if (callback) callback (DC_SAMPLE_DECO, sample, userdata); + offset += SZ_SEGMENT; }