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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-30 21:34:17 -08:00 committed by Jef Driesen
parent 1e77d92307
commit 9854097092

View File

@ -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;
}