diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-03 20:47:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-03 11:03:03 -0800 |
commit | 65432a1f6cd1b349fd6cff3518f7a36bb2129048 (patch) | |
tree | a4a19b54b4e7e499678e193343739e492981b53c /parse-xml.c | |
parent | 5adc3d2cfdd8b9ca6534198611d1af0d32a015cf (diff) | |
download | subsurface-65432a1f6cd1b349fd6cff3518f7a36bb2129048.tar.gz |
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>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c index a3461687d..456af4d39 100644 --- a/parse-xml.c +++ b/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) { |