mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Import gas info for Shearwater Desktop
Used gas mixes and gas changes are imported. Also po2, ndl, cns and ceiling are added to profile samples. As far as I can tell, the Searwater Desktop shows ceiling in 3 meter (or feet equivalent) steps, but stores in feet (or probably meters). I just use the value reported, no conversion to 3 meter steps. Fixes #432 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
62e313df35
commit
bbda9dd108
1 changed files with 54 additions and 6 deletions
60
parse-xml.c
60
parse-xml.c
|
@ -1883,6 +1883,32 @@ int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int s
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern int shearwater_cylinders(void *handle, int columns, char **data, char **column)
|
||||
{
|
||||
cylinder_start();
|
||||
if (data[0])
|
||||
cur_dive->cylinder[cur_cylinder_index].gasmix.o2.permille = atof(data[0]) * 1000;
|
||||
if (data[1])
|
||||
cur_dive->cylinder[cur_cylinder_index].gasmix.he.permille = atof(data[1]) * 1000;
|
||||
cylinder_end();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int shearwater_changes(void *handle, int columns, char **data, char **column)
|
||||
{
|
||||
event_start();
|
||||
if (data[0])
|
||||
cur_event.time.seconds = atoi(data[0]);
|
||||
if (data[1]) {
|
||||
cur_event.name = strdup("gaschange");
|
||||
cur_event.value = atof(data[1]) * 100;
|
||||
}
|
||||
event_end();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int shearwater_profile_sample(void *handle, int columns, char **data, char **column)
|
||||
{
|
||||
sample_start();
|
||||
|
@ -1892,6 +1918,14 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha
|
|||
cur_sample->depth.mm = metric ? atof(data[1]) * 1000 : feet_to_mm(atof(data[1]));
|
||||
if (data[2])
|
||||
cur_sample->temperature.mkelvin = metric ? C_to_mkelvin(atof(data[2])) : F_to_mkelvin(atof(data[2]));
|
||||
if (data[3])
|
||||
cur_sample->po2 = atof(data[3]) * 1000;
|
||||
if (data[4])
|
||||
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]));
|
||||
|
||||
/* We don't actually have data[3], but it should appear in the
|
||||
* SQL query at some point.
|
||||
|
@ -1910,10 +1944,10 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
|
|||
float *profileBlob;
|
||||
unsigned char *tempBlob;
|
||||
char *err = NULL;
|
||||
char *location, *site;
|
||||
char get_profile_template[] = "select currentTime,currentDepth,waterTemp from dive_log_records where diveLogId = %d";
|
||||
char get_tags_template[] = "select Text from DiveTag where DiveId = %d";
|
||||
char get_profile_sample[128];
|
||||
char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling 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.diveLogId = %d and b.diveLogId = %d and (a.id - 1) = b.id and (a.fractionO2 != b.fractionO2 or a.fractionHe != b.fractionHe) union select min(currentTime),fractionO2,fractionHe from dive_log_records";
|
||||
char get_buffer[1024];
|
||||
|
||||
dive_start();
|
||||
cur_dive->number = atoi(data[0]);
|
||||
|
@ -1952,8 +1986,22 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
|
|||
dc_settings_end();
|
||||
settings_end();
|
||||
|
||||
snprintf(get_profile_sample, sizeof(get_profile_sample) - 1, get_profile_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_profile_sample, &shearwater_profile_sample, 0, &err);
|
||||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_cylinders failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, cur_dive->number, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_changes failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_profile_sample failed.\n"));
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue