Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ class DiveImportService {
entryLongitude: dive.entryLongitude,
exitLatitude: dive.exitLatitude,
exitLongitude: dive.exitLongitude,
minTemperature: dive.minTemperature,
maxTemperature: dive.maxTemperature,
);

return diveId;
Expand Down Expand Up @@ -563,6 +565,8 @@ class DiveImportService {
entryLongitude: dive.entryLongitude,
exitLatitude: dive.exitLatitude,
exitLongitude: dive.exitLongitude,
minTemperature: dive.minTemperature,
maxTemperature: dive.maxTemperature,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ class ReparseService {

await db.batch((batch) {
for (final e in parsed.events) {
final eventType = _mapEventTypeString(e.type);
final eventType = _mapEventTypeString(
e.type,
flags: e.data != null ? int.tryParse(e.data!['flags'] ?? '') : null,
);
if (eventType == null) continue;

batch.insert(
Expand Down Expand Up @@ -696,14 +699,15 @@ class ReparseService {
}

/// Map libdivecomputer event type strings to ProfileEventType enum names.
static String? _mapEventTypeString(String type) {
static String? _mapEventTypeString(String type, {int? flags}) {
switch (type) {
case 'safetystop':
case 'safetystop_voluntary':
case 'safetystop_mandatory':
return 'safetyStopStart';
case 'deco':
case 'deepstop':
if (flags == 2) return 'decoStopEnd';
return 'decoStopStart';
case 'violation':
return 'decoViolation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ class DiveComputerRepository {
double? entryLongitude,
double? exitLatitude,
double? exitLongitude,
double? minTemperature,
double? maxTemperature,
}) async {
try {
_log.info('Importing profile from computer $computerId');
Expand Down Expand Up @@ -894,6 +896,7 @@ class DiveComputerRepository {
entryLongitude: Value(entryLongitude),
exitLatitude: Value(exitLatitude),
exitLongitude: Value(exitLongitude),
waterTemp: Value(minTemperature),
),
);

Expand Down Expand Up @@ -1149,7 +1152,10 @@ class DiveComputerRepository {
if (events != null && events.isNotEmpty) {
await _db.batch((batch) {
for (final event in events) {
final eventType = _mapEventTypeString(event.type);
final eventType = _mapEventTypeString(
event.type,
flags: event.flags,
);
if (eventType == null) continue;

// Find depth at event time from profile points
Expand Down Expand Up @@ -1451,14 +1457,16 @@ class DiveComputerRepository {
///
/// Only maps to values that exist in [ProfileEventType]. Returns null for
/// unknown event types that should be skipped.
String? _mapEventTypeString(String type) {
String? _mapEventTypeString(String type, {int? flags}) {
switch (type) {
case 'safetystop':
case 'safetystop_voluntary':
case 'safetystop_mandatory':
return 'safetyStopStart';
case 'deco':
case 'deepstop':
// flags: 1=BEGIN, 2=END
if (flags == 2) return 'decoStopEnd';
return 'decoStopStart';
case 'violation':
return 'decoViolation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,29 +444,30 @@ class DiveComputerHostApiImpl(
private fun mapEventType(type: Int): String = when (type) {
0 -> "none"
1 -> "deco"
2 -> "ascent"
3 -> "ceiling"
4 -> "workload"
5 -> "transmitter"
6 -> "violation"
7 -> "bookmark"
8 -> "surface"
9 -> "safetystop"
10 -> "gaschange"
11 -> "safetystop_voluntary"
12 -> "safetystop_mandatory"
13 -> "deepstop"
14 -> "ceiling_safetystop"
15 -> "floor"
16 -> "divetime"
17 -> "maxdepth"
18 -> "OLF"
19 -> "PO2"
20 -> "airtime"
21 -> "rgbm"
22 -> "heading"
23 -> "tissuelevel"
24 -> "gaschange2"
2 -> "rbt"
3 -> "ascent"
4 -> "ceiling"
5 -> "workload"
6 -> "transmitter"
7 -> "violation"
8 -> "bookmark"
9 -> "surface"
10 -> "safetystop"
11 -> "gaschange"
12 -> "safetystop_voluntary"
13 -> "safetystop_mandatory"
14 -> "deepstop"
15 -> "ceiling_safetystop"
16 -> "floor"
17 -> "divetime"
18 -> "maxdepth"
19 -> "OLF"
20 -> "PO2"
21 -> "airtime"
22 -> "rgbm"
23 -> "heading"
24 -> "tissuelevel"
25 -> "gaschange2"
else -> "unknown_$type"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -583,29 +583,30 @@ class DiveComputerHostApiImpl: DiveComputerHostApi {
switch type {
case 0: return "none"
case 1: return "deco"
case 2: return "ascent"
case 3: return "ceiling"
case 4: return "workload"
case 5: return "transmitter"
case 6: return "violation"
case 7: return "bookmark"
case 8: return "surface"
case 9: return "safetystop"
case 10: return "gaschange"
case 11: return "safetystop_voluntary"
case 12: return "safetystop_mandatory"
case 13: return "deepstop"
case 14: return "ceiling_safetystop"
case 15: return "floor"
case 16: return "divetime"
case 17: return "maxdepth"
case 18: return "OLF"
case 19: return "PO2"
case 20: return "airtime"
case 21: return "rgbm"
case 22: return "heading"
case 23: return "tissuelevel"
case 24: return "gaschange2"
case 2: return "rbt"
case 3: return "ascent"
case 4: return "ceiling"
case 5: return "workload"
case 6: return "transmitter"
case 7: return "violation"
case 8: return "bookmark"
case 9: return "surface"
case 10: return "safetystop"
case 11: return "gaschange"
case 12: return "safetystop_voluntary"
case 13: return "safetystop_mandatory"
case 14: return "deepstop"
case 15: return "ceiling_safetystop"
case 16: return "floor"
case 17: return "divetime"
case 18: return "maxdepth"
case 19: return "OLF"
case 20: return "PO2"
case 21: return "airtime"
case 22: return "rgbm"
case 23: return "heading"
case 24: return "tissuelevel"
case 25: return "gaschange2"
default: return "unknown_\(type)"
}
}
Expand Down
47 changes: 24 additions & 23 deletions packages/libdivecomputer_plugin/linux/dive_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ const char* map_event_type(unsigned int type) {
switch (type) {
case 0: return "none";
case 1: return "deco";
case 2: return "ascent";
case 3: return "ceiling";
case 4: return "workload";
case 5: return "transmitter";
case 6: return "violation";
case 7: return "bookmark";
case 8: return "surface";
case 9: return "safetystop";
case 10: return "gaschange";
case 11: return "safetystop_voluntary";
case 12: return "safetystop_mandatory";
case 13: return "deepstop";
case 14: return "ceiling_safetystop";
case 15: return "floor";
case 16: return "divetime";
case 17: return "maxdepth";
case 18: return "OLF";
case 19: return "PO2";
case 20: return "airtime";
case 21: return "rgbm";
case 22: return "heading";
case 23: return "tissuelevel";
case 24: return "gaschange2";
case 2: return "rbt";
case 3: return "ascent";
case 4: return "ceiling";
case 5: return "workload";
case 6: return "transmitter";
case 7: return "violation";
case 8: return "bookmark";
case 9: return "surface";
case 10: return "safetystop";
case 11: return "gaschange";
case 12: return "safetystop_voluntary";
case 13: return "safetystop_mandatory";
case 14: return "deepstop";
case 15: return "ceiling_safetystop";
case 16: return "floor";
case 17: return "divetime";
case 18: return "maxdepth";
case 19: return "OLF";
case 20: return "PO2";
case 21: return "airtime";
case 22: return "rgbm";
case 23: return "heading";
case 24: return "tissuelevel";
case 25: return "gaschange2";
default: return "unknown";
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/src/cressi_leonardo_parser.c b/src/cressi_leonardo_parser.c
index df382c5..9f65434 100644
--- a/src/cressi_leonardo_parser.c
+++ b/src/cressi_leonardo_parser.c
@@ -177,6 +177,8 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
gasmix = gasmix_previous;
}

+ unsigned int deco_previous = 0;
+
unsigned int offset = SZ_HEADER;
while (offset + 2 <= size) {
dc_sample_value_t sample = {0};
@@ -199,6 +201,7 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
} else {
unsigned int value = array_uint16_le (data + offset);
unsigned int depth = value & 0x07FF;
+ unsigned int deco = (value & 0x0800) >> 11;
unsigned int ascent = (value & 0xC000) >> 14;

// Time (seconds).
@@ -217,8 +220,35 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
gasmix_previous = gasmix;
}

- // Ascent rate
- if (ascent) {
+ // Deco obligation
+ if (deco) {
+ sample.deco.type = DC_DECO_DECOSTOP;
+ } else {
+ sample.deco.type = DC_DECO_NDL;
+ }
+ sample.deco.time = 0;
+ sample.deco.depth = 0.0;
+ sample.deco.tts = 0;
+ if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
+
+ // Deco obligation start/end event
+ if (deco && !deco_previous) {
+ sample.event.type = SAMPLE_EVENT_DECOSTOP;
+ sample.event.time = 0;
+ sample.event.flags = SAMPLE_FLAGS_BEGIN;
+ sample.event.value = 0;
+ if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
+ } else if (!deco && deco_previous) {
+ sample.event.type = SAMPLE_EVENT_DECOSTOP;
+ sample.event.time = 0;
+ sample.event.flags = SAMPLE_FLAGS_END;
+ sample.event.value = 0;
+ if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
+ }
+ deco_previous = deco;
+
+ // Ascent rate warning (only level 3 triggers audible alarm)
+ if (ascent == 3) {
sample.event.type = SAMPLE_EVENT_ASCENT;
sample.event.time = 0;
sample.event.flags = 0;
47 changes: 24 additions & 23 deletions packages/libdivecomputer_plugin/windows/dive_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,30 @@ std::string MapEventType(unsigned int type) {
switch (type) {
case 0: return "none";
case 1: return "deco";
case 2: return "ascent";
case 3: return "ceiling";
case 4: return "workload";
case 5: return "transmitter";
case 6: return "violation";
case 7: return "bookmark";
case 8: return "surface";
case 9: return "safetystop";
case 10: return "gaschange";
case 11: return "safetystop_voluntary";
case 12: return "safetystop_mandatory";
case 13: return "deepstop";
case 14: return "ceiling_safetystop";
case 15: return "floor";
case 16: return "divetime";
case 17: return "maxdepth";
case 18: return "OLF";
case 19: return "PO2";
case 20: return "airtime";
case 21: return "rgbm";
case 22: return "heading";
case 23: return "tissuelevel";
case 24: return "gaschange2";
case 2: return "rbt";
case 3: return "ascent";
case 4: return "ceiling";
case 5: return "workload";
case 6: return "transmitter";
case 7: return "violation";
case 8: return "bookmark";
case 9: return "surface";
case 10: return "safetystop";
case 11: return "gaschange";
case 12: return "safetystop_voluntary";
case 13: return "safetystop_mandatory";
case 14: return "deepstop";
case 15: return "ceiling_safetystop";
case 16: return "floor";
case 17: return "divetime";
case 18: return "maxdepth";
case 19: return "OLF";
case 20: return "PO2";
case 21: return "airtime";
case 22: return "rgbm";
case 23: return "heading";
case 24: return "tissuelevel";
case 25: return "gaschange2";
default: return "unknown_" + std::to_string(type);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ class MockDiveComputerRepository extends _i1.Mock
double? entryLongitude,
double? exitLatitude,
double? exitLongitude,
double? minTemperature,
double? maxTemperature,
}) =>
(super.noSuchMethod(
Invocation.method(#importProfile, [], {
Expand Down Expand Up @@ -372,6 +374,8 @@ class MockDiveComputerRepository extends _i1.Mock
#entryLongitude: entryLongitude,
#exitLatitude: exitLatitude,
#exitLongitude: exitLongitude,
#minTemperature: minTemperature,
#maxTemperature: maxTemperature,
}),
returnValue: _i7.Future<String>.value(
_i10.dummyValue<String>(
Expand Down Expand Up @@ -403,6 +407,8 @@ class MockDiveComputerRepository extends _i1.Mock
#entryLongitude: entryLongitude,
#exitLatitude: exitLatitude,
#exitLongitude: exitLongitude,
#minTemperature: minTemperature,
#maxTemperature: maxTemperature,
}),
),
),
Expand Down
Loading
Loading