diff options
author | James Wobser <james.wobser@gmail.com> | 2020-07-16 21:40:46 -0400 |
---|---|---|
committer | Miika Turkia <miika.turkia@gmail.com> | 2020-09-04 15:54:08 +0300 |
commit | 4f3b26f9b6296273e37ec317bc68f32f94f546dc (patch) | |
tree | f160a23badd7e705a47513385d2449000f51befb /core/file.c | |
parent | 52aa7d83b6eb0200702c75425972223720fde00a (diff) | |
download | subsurface-4f3b26f9b6296273e37ec317bc68f32f94f546dc.tar.gz |
Implement Seac SeacSync databaser parser.
Dives for the seac action computer are imported by the seacsync
program into two tables in an sqlite3 database.
The dive information is read from the headers_dive table.
The dive_data table is then queried for each dive to get samples.
The seac action computer is the only current supported computer
by the seacsync program. It only supports two gas mixes, so the
parser will toggle between two cylinders whenever it detects a
change in the active O2 mix.
Dive start time is stored in UTC with a timezone offset.
A helper function to read this was added to qthelper.
Default cases have been added to some switch statements
to assist in future development for other dive types and
salinity.
Example database has been added to ./dives/TestDiveSeacSync.db
Signed-off-by: James Wobser <james.wobser@gmail.com>
Diffstat (limited to 'core/file.c')
-rw-r--r-- | core/file.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/file.c b/core/file.c index ed00b7948..619ec5724 100644 --- a/core/file.c +++ b/core/file.c @@ -136,6 +136,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div char shearwater_cloud_test[] = "select count(*) from sqlite_master where type='table' and name='SyncV3MetadataDiveLog' and sql like '%CreatedDevice%'"; char cobalt_test[] = "select count(*) from sqlite_master where type='table' and name='TrackPoints' and sql like '%DepthPressure%'"; char divinglog_test[] = "select count(*) from sqlite_master where type='table' and name='DBInfo' and sql like '%PrgName%'"; + char seacsync_test[] = "select count(*) from sqlite_master where type='table' and name='dive_data' and sql like '%ndl_tts_s%'"; int retval; retval = sqlite3_open(filename, &handle); @@ -193,6 +194,15 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div return retval; } + /* Testing if DB schema resembles Seac database format */ + retval = sqlite3_exec(handle, seacsync_test, &db_test_func, 0, NULL); + if (!retval) { + retval = parse_seac_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + sqlite3_close(handle); + return retval; + } + + sqlite3_close(handle); return retval; |