Skip to content

Commit

Permalink
Remove Bailout Event Creation.
Browse files Browse the repository at this point in the history
With subsurface/subsurface#4399, switching
between on-loop and off-loop is visualised based on gas usage.
For this reason, explicit bailout switch events are no longer needed.

Signed-off-by: Michael Keller <[email protected]>
  • Loading branch information
mikeller committed Dec 30, 2024
1 parent b9a2f35 commit cdab41c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 53 deletions.
19 changes: 0 additions & 19 deletions src/garmin_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ typedef struct garmin_parser_t {
unsigned int setpoint_low_cbar, setpoint_high_cbar;
unsigned int setpoint_low_switch_depth_mm, setpoint_high_switch_depth_mm;
unsigned int setpoint_low_switch_mode, setpoint_high_switch_mode;
dc_usage_t current_gasmix_usage;
} dive;

// I count nine (!) different GPS fields Hmm.
Expand Down Expand Up @@ -239,22 +238,6 @@ static void garmin_event(struct garmin_parser_t *garmin,
sample.gasmix = data;
garmin->callback(DC_SAMPLE_GASMIX, &sample, garmin->userdata);

dc_usage_t gasmix_usage = garmin->cache.GASMIX[data].usage;
if (gasmix_usage != garmin->dive.current_gasmix_usage) {
dc_sample_value_t sample2 = {0};
sample2.event.type = SAMPLE_EVENT_STRING;
if (gasmix_usage == DC_USAGE_DILUENT) {
sample2.event.name = "Switched to closed circuit";
} else {
sample2.event.name = "Switched to open circuit bailout";
}
sample2.event.flags = 2 << SAMPLE_FLAGS_SEVERITY_SHIFT;

garmin->callback(DC_SAMPLE_EVENT, &sample2, garmin->userdata);

garmin->dive.current_gasmix_usage = gasmix_usage;
}

return;
}
}
Expand Down Expand Up @@ -674,7 +657,6 @@ DECLARE_FIELD(ACTIVITY, event_group, UINT8) { }
// SPORT
DECLARE_FIELD(SPORT, sub_sport, ENUM) {
garmin->dive.sub_sport = (ENUM) data;
garmin->dive.current_gasmix_usage = DC_USAGE_OPEN_CIRCUIT;
dc_divemode_t val;
switch (data) {
case 55: val = DC_DIVEMODE_GAUGE;
Expand All @@ -684,7 +666,6 @@ DECLARE_FIELD(SPORT, sub_sport, ENUM) {
break;
case 63:
val = DC_DIVEMODE_CCR;
garmin->dive.current_gasmix_usage = DC_USAGE_DILUENT;

break;
default: val = DC_DIVEMODE_OC;
Expand Down
37 changes: 3 additions & 34 deletions src/hw_ostc_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ typedef struct hw_ostc_parser_t {
unsigned int initial_setpoint;
unsigned int initial_cns;
hw_ostc_gasmix_t gasmix[NGASMIXES];
unsigned int current_divemode_ccr;
} hw_ostc_parser_t;

static dc_status_t hw_ostc_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime);
Expand Down Expand Up @@ -814,28 +813,6 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned
return DC_STATUS_SUCCESS;
}


static void hw_ostc_notify_bailout(hw_ostc_parser_t *parser, const unsigned char *data, unsigned int index, dc_sample_callback_t callback, void *userdata)
{
if (parser->current_divemode_ccr != parser->gasmix[index].diluent) {
dc_sample_value_t sample = {
.event.type = SAMPLE_EVENT_STRING,
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
};
if (parser->gasmix[index].diluent) {
sample.event.name = "Switched to closed circuit";
} else {
sample.event.name = "Switched to open circuit bailout";
}

if (callback) {
callback(DC_SAMPLE_EVENT, &sample, userdata);
}

parser->current_divemode_ccr = parser->gasmix[index].diluent;
}
}

static dc_status_t
hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t callback, void *userdata)
{
Expand Down Expand Up @@ -945,7 +922,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t

// Get the CCR mode.
unsigned int ccr = hw_ostc_is_ccr (divemode, version);
parser->current_divemode_ccr = ccr;

unsigned int time = 0;
unsigned int nsamples = 0;
Expand Down Expand Up @@ -991,7 +967,7 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
offset += 2;

// Extended sample info.
unsigned int length = data[offset] & 0x7F;
unsigned int length = data[offset] & 0x7F;
offset += 1;

// Check for buffer overflows.
Expand Down Expand Up @@ -1082,8 +1058,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);

hw_ostc_notify_bailout(parser, data, idx, callback, userdata);

offset += 2;
length -= 2;
}
Expand All @@ -1109,8 +1083,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
tank = id - 1;

hw_ostc_notify_bailout(parser, data, idx, callback, userdata);

offset++;
length--;
}
Expand Down Expand Up @@ -1156,8 +1128,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);

hw_ostc_notify_bailout(parser, data, idx, callback, userdata);

offset += 2;
length -= 2;
}
Expand All @@ -1178,7 +1148,8 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
info[i].divisor = 0;
continue;
}
ERROR (abstract->context, "Buffer overflow detected!");

ERROR(abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}

Expand Down Expand Up @@ -1296,8 +1267,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);

hw_ostc_notify_bailout(parser, data, idx, callback, userdata);

offset += 2;
length -= 2;
}
Expand Down

0 comments on commit cdab41c

Please sign in to comment.