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:
parent
f2a656246d
commit
3917ae15b9
@ -42,7 +42,8 @@ typedef enum dc_sample_type_t {
|
||||
DC_SAMPLE_VENDOR,
|
||||
DC_SAMPLE_SETPOINT,
|
||||
DC_SAMPLE_PPO2,
|
||||
DC_SAMPLE_CNS
|
||||
DC_SAMPLE_CNS,
|
||||
DC_SAMPLE_DECO
|
||||
} dc_sample_type_t;
|
||||
|
||||
typedef enum dc_field_type_t {
|
||||
@ -57,10 +58,7 @@ typedef enum dc_field_type_t {
|
||||
|
||||
typedef enum parser_sample_event_t {
|
||||
SAMPLE_EVENT_NONE,
|
||||
SAMPLE_EVENT_DECOSTOP, /* The event value contains an optional decompression
|
||||
depth (in meters) and time (in seconds), packed as
|
||||
two 16bit integers in respectively the low and
|
||||
high part. */
|
||||
SAMPLE_EVENT_DECOSTOP,
|
||||
SAMPLE_EVENT_RBT,
|
||||
SAMPLE_EVENT_ASCENT,
|
||||
SAMPLE_EVENT_CEILING,
|
||||
@ -87,8 +85,6 @@ typedef enum parser_sample_event_t {
|
||||
SAMPLE_EVENT_GASCHANGE2, /* The event value contains the O2 and He
|
||||
percentages, packed as two 16bit integers in
|
||||
respectively the low and high part. */
|
||||
SAMPLE_EVENT_NDL /* The event value contains an optional no decompression
|
||||
time (in seconds). */
|
||||
} parser_sample_event_t;
|
||||
|
||||
typedef enum parser_sample_flags_t {
|
||||
@ -111,6 +107,13 @@ typedef enum dc_water_t {
|
||||
DC_WATER_SALT
|
||||
} 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 {
|
||||
dc_water_t type;
|
||||
double density;
|
||||
@ -147,6 +150,11 @@ typedef union dc_sample_value_t {
|
||||
double setpoint;
|
||||
double ppo2;
|
||||
double cns;
|
||||
struct {
|
||||
unsigned int type;
|
||||
unsigned int time;
|
||||
double depth;
|
||||
} deco;
|
||||
} dc_sample_value_t;
|
||||
|
||||
typedef struct dc_parser_t dc_parser_t;
|
||||
|
||||
@ -414,15 +414,14 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
break;
|
||||
case 1: // Deco / NDL
|
||||
if (data[offset]) {
|
||||
sample.event.type = SAMPLE_EVENT_DECOSTOP;
|
||||
sample.event.value = data[offset] | ((data[offset + 1] * 60) << 16);
|
||||
sample.deco.type = DC_DECO_DECOSTOP;
|
||||
sample.deco.depth = data[offset];
|
||||
} else {
|
||||
sample.event.type = SAMPLE_EVENT_NDL;
|
||||
sample.event.value = data[offset + 1] * 60;
|
||||
sample.deco.type = DC_DECO_NDL;
|
||||
sample.deco.depth = 0.0;
|
||||
}
|
||||
sample.event.time = 0;
|
||||
sample.event.flags = 0;
|
||||
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
|
||||
sample.deco.time = data[offset + 1] * 60;
|
||||
if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
|
||||
break;
|
||||
case 5: // CNS
|
||||
sample.cns = data[offset] / 100.0;
|
||||
|
||||
@ -251,19 +251,17 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
|
||||
// Deco stop / NDL.
|
||||
unsigned int decostop = array_uint16_be (data + offset + 2);
|
||||
if (decostop) {
|
||||
sample.event.type = SAMPLE_EVENT_DECOSTOP;
|
||||
sample.deco.type = DC_DECO_DECOSTOP;
|
||||
if (units == IMPERIAL)
|
||||
sample.event.value = decostop * FEET + 0.5;
|
||||
sample.deco.depth = decostop * FEET;
|
||||
else
|
||||
sample.event.value = decostop;
|
||||
sample.event.value |= (data[offset + 9] * 60) << 16;
|
||||
sample.deco.depth = decostop;
|
||||
} else {
|
||||
sample.event.type = SAMPLE_EVENT_NDL;
|
||||
sample.event.value = data[offset + 9] * 60;
|
||||
sample.deco.type = DC_DECO_NDL;
|
||||
sample.deco.depth = 0.0;
|
||||
}
|
||||
sample.event.time = 0;
|
||||
sample.event.flags = 0;
|
||||
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
|
||||
sample.deco.time = data[offset + 9] * 60;
|
||||
if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
|
||||
|
||||
offset += SZ_SAMPLE;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user