From cdab41c40f4a9d34bc671cc99eb10b74eb7f4110 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Mon, 30 Dec 2024 21:22:18 +1300 Subject: [PATCH] Remove Bailout Event Creation. With https://github.com/subsurface/subsurface/pull/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 --- src/garmin_parser.c | 19 ------------------- src/hw_ostc_parser.c | 37 +++---------------------------------- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/src/garmin_parser.c b/src/garmin_parser.c index 5535dac0..d28b5f26 100644 --- a/src/garmin_parser.c +++ b/src/garmin_parser.c @@ -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. @@ -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; } } @@ -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; @@ -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; diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index e3b95005..5426c6f8 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -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); @@ -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) { @@ -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; @@ -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. @@ -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; } @@ -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--; } @@ -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; } @@ -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; } @@ -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; }