mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Parse converted DM4 logs on DM5 import
"Converted" DM4 logs are not actually converted, only the database structure is updated. According to Rainer we should be able to read the dive profile from the old format in this case. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5adc3d2cfd
commit
65432a1f6c
1 changed files with 29 additions and 0 deletions
29
parse-xml.c
29
parse-xml.c
|
@ -2101,6 +2101,35 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
|
|||
sample_end();
|
||||
}
|
||||
|
||||
/*
|
||||
* Log was converted from DM4, thus we need to parse the profile
|
||||
* from DM4 format
|
||||
*/
|
||||
|
||||
if (i == 0) {
|
||||
float *profileBlob;
|
||||
unsigned char *tempBlob;
|
||||
int *pressureBlob;
|
||||
|
||||
profileBlob = (float *)data[17];
|
||||
tempBlob = (unsigned char *)data[18];
|
||||
pressureBlob = (int *)data[19];
|
||||
for (i = 0; interval && i * interval < cur_dive->duration.seconds; i++) {
|
||||
sample_start();
|
||||
cur_sample->time.seconds = i * interval;
|
||||
if (profileBlob)
|
||||
cur_sample->depth.mm = profileBlob[i] * 1000;
|
||||
else
|
||||
cur_sample->depth.mm = cur_dive->dc.maxdepth.mm;
|
||||
|
||||
if (data[18] && data[18][0])
|
||||
cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
|
||||
if (data[19] && data[19][0])
|
||||
cur_sample->cylinderpressure.mbar = pressureBlob[i];
|
||||
sample_end();
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
|
|
Loading…
Add table
Reference in a new issue