Skip to content

Commit cdab41c

Browse files
committed
Remove Bailout Event Creation.
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]>
1 parent b9a2f35 commit cdab41c

File tree

2 files changed

+3
-53
lines changed

2 files changed

+3
-53
lines changed

src/garmin_parser.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ typedef struct garmin_parser_t {
129129
unsigned int setpoint_low_cbar, setpoint_high_cbar;
130130
unsigned int setpoint_low_switch_depth_mm, setpoint_high_switch_depth_mm;
131131
unsigned int setpoint_low_switch_mode, setpoint_high_switch_mode;
132-
dc_usage_t current_gasmix_usage;
133132
} dive;
134133

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

242-
dc_usage_t gasmix_usage = garmin->cache.GASMIX[data].usage;
243-
if (gasmix_usage != garmin->dive.current_gasmix_usage) {
244-
dc_sample_value_t sample2 = {0};
245-
sample2.event.type = SAMPLE_EVENT_STRING;
246-
if (gasmix_usage == DC_USAGE_DILUENT) {
247-
sample2.event.name = "Switched to closed circuit";
248-
} else {
249-
sample2.event.name = "Switched to open circuit bailout";
250-
}
251-
sample2.event.flags = 2 << SAMPLE_FLAGS_SEVERITY_SHIFT;
252-
253-
garmin->callback(DC_SAMPLE_EVENT, &sample2, garmin->userdata);
254-
255-
garmin->dive.current_gasmix_usage = gasmix_usage;
256-
}
257-
258241
return;
259242
}
260243
}
@@ -674,7 +657,6 @@ DECLARE_FIELD(ACTIVITY, event_group, UINT8) { }
674657
// SPORT
675658
DECLARE_FIELD(SPORT, sub_sport, ENUM) {
676659
garmin->dive.sub_sport = (ENUM) data;
677-
garmin->dive.current_gasmix_usage = DC_USAGE_OPEN_CIRCUIT;
678660
dc_divemode_t val;
679661
switch (data) {
680662
case 55: val = DC_DIVEMODE_GAUGE;
@@ -684,7 +666,6 @@ DECLARE_FIELD(SPORT, sub_sport, ENUM) {
684666
break;
685667
case 63:
686668
val = DC_DIVEMODE_CCR;
687-
garmin->dive.current_gasmix_usage = DC_USAGE_DILUENT;
688669

689670
break;
690671
default: val = DC_DIVEMODE_OC;

src/hw_ostc_parser.c

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ typedef struct hw_ostc_parser_t {
139139
unsigned int initial_setpoint;
140140
unsigned int initial_cns;
141141
hw_ostc_gasmix_t gasmix[NGASMIXES];
142-
unsigned int current_divemode_ccr;
143142
} hw_ostc_parser_t;
144143

145144
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
814813
return DC_STATUS_SUCCESS;
815814
}
816815

817-
818-
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)
819-
{
820-
if (parser->current_divemode_ccr != parser->gasmix[index].diluent) {
821-
dc_sample_value_t sample = {
822-
.event.type = SAMPLE_EVENT_STRING,
823-
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
824-
};
825-
if (parser->gasmix[index].diluent) {
826-
sample.event.name = "Switched to closed circuit";
827-
} else {
828-
sample.event.name = "Switched to open circuit bailout";
829-
}
830-
831-
if (callback) {
832-
callback(DC_SAMPLE_EVENT, &sample, userdata);
833-
}
834-
835-
parser->current_divemode_ccr = parser->gasmix[index].diluent;
836-
}
837-
}
838-
839816
static dc_status_t
840817
hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t callback, void *userdata)
841818
{
@@ -945,7 +922,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
945922

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

950926
unsigned int time = 0;
951927
unsigned int nsamples = 0;
@@ -991,7 +967,7 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
991967
offset += 2;
992968

993969
// Extended sample info.
994-
unsigned int length = data[offset] & 0x7F;
970+
unsigned int length = data[offset] & 0x7F;
995971
offset += 1;
996972

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

1085-
hw_ostc_notify_bailout(parser, data, idx, callback, userdata);
1086-
10871061
offset += 2;
10881062
length -= 2;
10891063
}
@@ -1109,8 +1083,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11091083
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
11101084
tank = id - 1;
11111085

1112-
hw_ostc_notify_bailout(parser, data, idx, callback, userdata);
1113-
11141086
offset++;
11151087
length--;
11161088
}
@@ -1156,8 +1128,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11561128
sample.gasmix = idx;
11571129
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
11581130

1159-
hw_ostc_notify_bailout(parser, data, idx, callback, userdata);
1160-
11611131
offset += 2;
11621132
length -= 2;
11631133
}
@@ -1178,7 +1148,8 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11781148
info[i].divisor = 0;
11791149
continue;
11801150
}
1181-
ERROR (abstract->context, "Buffer overflow detected!");
1151+
1152+
ERROR(abstract->context, "Buffer overflow detected!");
11821153
return DC_STATUS_DATAFORMAT;
11831154
}
11841155

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

1299-
hw_ostc_notify_bailout(parser, data, idx, callback, userdata);
1300-
13011270
offset += 2;
13021271
length -= 2;
13031272
}

0 commit comments

Comments
 (0)