Convert decostop / ndl to samples

Having these as events seems less useful since for many dive computers
there are data with every sample - so it makes much more sense to have
these as part of the sample.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-09 11:51:30 -08:00 committed by Jef Driesen
parent f2a656246d
commit 3917ae15b9
3 changed files with 28 additions and 23 deletions

View File

@ -42,7 +42,8 @@ typedef enum dc_sample_type_t {
DC_SAMPLE_VENDOR, DC_SAMPLE_VENDOR,
DC_SAMPLE_SETPOINT, DC_SAMPLE_SETPOINT,
DC_SAMPLE_PPO2, DC_SAMPLE_PPO2,
DC_SAMPLE_CNS DC_SAMPLE_CNS,
DC_SAMPLE_DECO
} dc_sample_type_t; } dc_sample_type_t;
typedef enum dc_field_type_t { typedef enum dc_field_type_t {
@ -57,10 +58,7 @@ typedef enum dc_field_type_t {
typedef enum parser_sample_event_t { typedef enum parser_sample_event_t {
SAMPLE_EVENT_NONE, SAMPLE_EVENT_NONE,
SAMPLE_EVENT_DECOSTOP, /* The event value contains an optional decompression SAMPLE_EVENT_DECOSTOP,
depth (in meters) and time (in seconds), packed as
two 16bit integers in respectively the low and
high part. */
SAMPLE_EVENT_RBT, SAMPLE_EVENT_RBT,
SAMPLE_EVENT_ASCENT, SAMPLE_EVENT_ASCENT,
SAMPLE_EVENT_CEILING, SAMPLE_EVENT_CEILING,
@ -87,8 +85,6 @@ typedef enum parser_sample_event_t {
SAMPLE_EVENT_GASCHANGE2, /* The event value contains the O2 and He SAMPLE_EVENT_GASCHANGE2, /* The event value contains the O2 and He
percentages, packed as two 16bit integers in percentages, packed as two 16bit integers in
respectively the low and high part. */ respectively the low and high part. */
SAMPLE_EVENT_NDL /* The event value contains an optional no decompression
time (in seconds). */
} parser_sample_event_t; } parser_sample_event_t;
typedef enum parser_sample_flags_t { typedef enum parser_sample_flags_t {
@ -111,6 +107,13 @@ typedef enum dc_water_t {
DC_WATER_SALT DC_WATER_SALT
} dc_water_t; } dc_water_t;
typedef enum dc_deco_type_t {
DC_DECO_NDL,
DC_DECO_DECOSTOP,
DC_DECO_DEEPSTOP,
DC_DECO_SAFETYSTOP
} dc_deco_type_t;
typedef struct dc_salinity_t { typedef struct dc_salinity_t {
dc_water_t type; dc_water_t type;
double density; double density;
@ -147,6 +150,11 @@ typedef union dc_sample_value_t {
double setpoint; double setpoint;
double ppo2; double ppo2;
double cns; double cns;
struct {
unsigned int type;
unsigned int time;
double depth;
} deco;
} dc_sample_value_t; } dc_sample_value_t;
typedef struct dc_parser_t dc_parser_t; typedef struct dc_parser_t dc_parser_t;

View File

@ -414,15 +414,14 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
break; break;
case 1: // Deco / NDL case 1: // Deco / NDL
if (data[offset]) { if (data[offset]) {
sample.event.type = SAMPLE_EVENT_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.event.value = data[offset] | ((data[offset + 1] * 60) << 16); sample.deco.depth = data[offset];
} else { } else {
sample.event.type = SAMPLE_EVENT_NDL; sample.deco.type = DC_DECO_NDL;
sample.event.value = data[offset + 1] * 60; sample.deco.depth = 0.0;
} }
sample.event.time = 0; sample.deco.time = data[offset + 1] * 60;
sample.event.flags = 0; if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
break; break;
case 5: // CNS case 5: // CNS
sample.cns = data[offset] / 100.0; sample.cns = data[offset] / 100.0;

View File

@ -251,19 +251,17 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Deco stop / NDL. // Deco stop / NDL.
unsigned int decostop = array_uint16_be (data + offset + 2); unsigned int decostop = array_uint16_be (data + offset + 2);
if (decostop) { if (decostop) {
sample.event.type = SAMPLE_EVENT_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
if (units == IMPERIAL) if (units == IMPERIAL)
sample.event.value = decostop * FEET + 0.5; sample.deco.depth = decostop * FEET;
else else
sample.event.value = decostop; sample.deco.depth = decostop;
sample.event.value |= (data[offset + 9] * 60) << 16;
} else { } else {
sample.event.type = SAMPLE_EVENT_NDL; sample.deco.type = DC_DECO_NDL;
sample.event.value = data[offset + 9] * 60; sample.deco.depth = 0.0;
} }
sample.event.time = 0; sample.deco.time = data[offset + 9] * 60;
sample.event.flags = 0; if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
offset += SZ_SAMPLE; offset += SZ_SAMPLE;
} }