summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2018-05-27 09:06:09 +0300
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-05-27 23:18:01 +0300
commit295c63211c6ea6d818c320f6df2e56f93e67b18b (patch)
tree9ec3c395451f94b87e3c6a4e0a19013a21c10a22 /core
parentddd35bc9412dca364f014296cb6fc9018f558673 (diff)
downloadsubsurface-295c63211c6ea6d818c320f6df2e56f93e67b18b.tar.gz
Shearwater import: support for DC reported ceiling
This adds support for DC reported ceiling when importing the Shearwater Desktop database. Both AI and non-AI versions are tested, but not all possible paths. For non-AI the DC reported ceiling was from firstStopDepth and for the AI version it was from the decoCeiling field. I do not currently know when each of these fields are used, but at least this works on my test data. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/import-shearwater.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/core/import-shearwater.c b/core/import-shearwater.c
index 644688cce..2ad90cc7c 100644
--- a/core/import-shearwater.c
+++ b/core/import-shearwater.c
@@ -97,8 +97,24 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha
cur_sample->ndl.seconds = atoi(data[4]) * 60;
if (data[5])
cur_sample->cns = atoi(data[5]);
- if (data[6])
- cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6]));
+ if (data[6]) {
+ if (atoi(data[6]) > 0) {
+ cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6]));
+ cur_sample->in_deco = 1;
+ } else if (data[7]) {
+ if (atoi(data[7]) > 0) {
+ cur_sample->stopdepth.mm = metric ? atoi(data[7]) * 1000 : feet_to_mm(atoi(data[7]));
+ if (data[8]) {
+ cur_sample->stoptime.seconds = atoi(data[8]) * 60;
+ }
+ cur_sample->in_deco = 1;
+ } else {
+ cur_sample->in_deco = 0;
+ }
+ } else {
+ cur_sample->in_deco = 0;
+ }
+ }
/* We don't actually have data[3], but it should appear in the
* SQL query at some point.
@@ -130,8 +146,24 @@ extern int shearwater_ai_profile_sample(void *handle, int columns, char **data,
cur_sample->ndl.seconds = atoi(data[4]) * 60;
if (data[5])
cur_sample->cns = atoi(data[5]);
- if (data[6])
- cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6]));
+ if (data[6]) {
+ if (atoi(data[6]) > 0) {
+ cur_sample->stopdepth.mm = metric ? atoi(data[6]) * 1000 : feet_to_mm(atoi(data[6]));
+ cur_sample->in_deco = 1;
+ } else if (data[9]) {
+ if (atoi(data[9]) > 0) {
+ cur_sample->stopdepth.mm = metric ? atoi(data[9]) * 1000 : feet_to_mm(atoi(data[9]));
+ if (data[10]) {
+ cur_sample->stoptime.seconds = atoi(data[10]) * 60;
+ }
+ cur_sample->in_deco = 1;
+ } else {
+ cur_sample->in_deco = 0;
+ }
+ } else {
+ cur_sample->in_deco = 0;
+ }
+ }
/* Weird unit conversion but seems to produce correct results.
* Also missing values seems to be reported as a 4092 (564 bar) */
@@ -165,8 +197,8 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
int retval = 0;
sqlite3 *handle = (sqlite3 *)param;
char *err = NULL;
- char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling from dive_log_records where diveLogId=%d";
- char get_profile_template_ai[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,aiSensor0_PressurePSI,aiSensor1_PressurePSI from dive_log_records where diveLogId = %d";
+ char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,firstStopDepth,firstStopTime from dive_log_records where diveLogId=%d";
+ char get_profile_template_ai[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,aiSensor0_PressurePSI,aiSensor1_PressurePSI,firstStopDepth,firstStopTime from dive_log_records where diveLogId = %d";
char get_cylinder_template[] = "select fractionO2,fractionHe from dive_log_records where diveLogId = %d group by fractionO2,fractionHe";
char get_changes_template[] = "select a.currentTime,a.fractionO2,a.fractionHe from dive_log_records as a,dive_log_records as b where (a.id - 1) = b.id and (a.fractionO2 != b.fractionO2 or a.fractionHe != b.fractionHe) and a.diveLogId=b.divelogId and a.diveLogId = %d";
char get_mode_template[] = "select distinct currentCircuitSetting from dive_log_records where diveLogId = %d";