Commit graph

66 commits

Author SHA1 Message Date
Salvador Cuñat
5c757d5c38 smtk-import - Change cylinder import logic
Until now, we did the cylinder import based on its initial pressure (a
tank without pressure is an unused tank). Based in this assumption, we
just dropped those tanks whose initial press was 0, losing user
introduced tank definitions  and getting some duplicities due to one
cylinder being numbered (e.g.) 2 by libdivecomputer and 3 by SmartTrak.

The new workflow is: get every single tank reported by SmartTrak (giving
preference to libdivecomputer parsed data), then clean the cylinder
table reverse order, dropping tanks without description and  init or end
pressures, and checkig them against the previous cylinder to do a merge,
if they look the same, and try to avoid duplicities.

The new logic assumes a heavier workload for the benefit of lower data
loss (e.g. a user may get his/her tanks descriptions despite he/she
hasn't recorded their pressures because forgot the values or had an issue
with the gas transmitter).

Suggested-by: Alessandro Volpi <volpial@gmail.com>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
16d37c254c smtk-import - Remove tank number limitation
In the past subsurface managed up to 8 tanks, but now it manages up to
20.  SmartTrak manages 10 (3 in older no trimix versions) so there is no
more need to drop the last tanks.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
20b348579b smtk-import rework smtk_build_tank_info()
The cylinder info is built one by one. This way, instead of passing dive
and tank number parameters, just passing a pointer to the tank been
worked seems preferable.

It also introduces lrint() in the function to round the doubles values
obtained from libmdb for tank size and workingpressure.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
36658d87f3 smtk-import - Add helper funcs to manage tank info
Framed in a full rework of the cylinders info import management, this
funcs will be used in next patches.

Functions merge_cylinder_type(), merge_cylinder_mix() and
merge_cylinder_info(), have been shamelessly copied from dive.c as they
have been removed by 162767aa dated 2017-03-11 just when I was going to
use them.

Macros MERGE_MAX() and MERGE_MIN() have just been copied from dive.c,
but they could be moved to dive.h so they could be used elsewhere if
needed.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
2cef8395b5 smtk-import Use lrint() when rounding to integer values
As commented on mailing list. Most numerical values from libmdb are
doubles obtained via strtod(), so, rounding them instead of just
truncating seems the correct way.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
9ddf2d2ad8 smtk-import Add smarttrak bookmarks parse capability
User can manually add bookmarks on the profile display of SmartTrak.
These are stored in a table with column names which made me think of
cartesian spatial coordinates. In the end the X coordinate is the time.
This makes possible to build subsurface events in those moments of the
dive. The other interesting data is just the text entered by the user.

Suggested-by: Alessandro Volpi <volpial@gmail.com>
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
9073c3a860 smtk-import - Add function smtk_free()
Group some reiterative freeing task under the imaginative function name
of smtk_free().

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Salvador Cuñat
1413b910a2 smtk-import - Fix memory leaks
Fixes some memory leaks, most of them excesive use of copy_string() in
places where it was unnecesary.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-03-18 08:33:31 -07:00
Martin Měřinský
5fa64fd1ea SankTime > Sank Time 2017-03-04 12:08:17 -08:00
Salvador Cuñat
c2997c33c7 smtk-import: Fix freeing unallocated memory
hdr_buffer pointer was not always allocated (just on dc dives), but was
always freed.
This should cause a crash while processing a manually added dive (or a dive
whose dc model couldn't be stablished), but not always does, crashes only
if the pointed memory hasn't been previously allocated. In most cases causes
memory corruption, which goes easily unnoticed as it is correctly freed in
next parse run.
This means, obviously, I have some work TODO fixing leaks with valgrind.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-02-25 09:19:48 -08:00
Salvador Cuñat
8b2de77f91 smtk-import-change mktime with timegm
There were 1 or 2 hour differences between real dive time and the
imported time  because of the time zones and energy saving in some locales.
Using timegm() ensures us UTC times instead of localized times.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-02-10 20:30:58 -08:00
Salvador Cuñat
f7045c57cd smtk-import-improve smtk_time_to_secs()
Can't remember what I was thinking when wrote that crappy thing. A
simple sscanf call will do the job, and a sanity check, off course.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-02-10 20:30:58 -08:00
Salvador Cuñat
7c91cdd89e smtk-import-Fix crash due to localization issues
Libmdbº:xturns localized strings while parsing the data bases. This is
bad for time calculations as we may end with different strings formats
(e.g. en_US vs almost the rest of the world). Solution is simple: set a
fixed locale and parse only this format.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-02-10 20:30:58 -08:00
Dirk Hohndel
22267762ce Smart Trak tool compile fix
In commit 70e2404492 ("Stop accessing the internals of
dc_descriptor_t") the structure definition of the libdivecomputer
descriptor was removed from Subsurface and replaced with accessor
functions. This adapts the Smart Trakl import tool to use the same
accessor functions, which allows it to compile again in current master.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-17 09:57:40 -08:00
Salvador Cuñat
a71224b350 Locate included header files
After commit 7be962b some directories changed their names.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-01-05 13:14:17 -08:00
Salvador Cuñat
dc4d8f26ec SmartTrak import - Support for .slg files import
SmartTrak is a Windows based propietary dive log software by Uwatec, which has
been the reference software for every Scubapro/Uwatec IRda based devices,
ranging from Smart to Galileo. It has just been recently that began to be
substituted by newer softwares like LogTrak and JTrak (these only supports
Galileo or newer devices and don't import SmartTrak's .slg files).i

SmartTrak also supports importing dives from older DataTrak software (oldest
Aladin series, serial based DCs) so most divers using Scubapro/Uwatec products
have probably their dives registered in this log, even those who have just moved
to newest Scubapro/Uwatec DCs.

SmartTrak is based in MS Access database with support for recreational and
technical dives up to 10 tanks, trimix (in later versions, prior versions had
support for just 3 tanks with Nitrox) and SCR/CCR.

In Linux, MsAccess databases are supported via libmdb which in turn depends on
libglib2, so this work has a hard dependency on these two libraries.
Libmdb sees very little (or null) development activity today so it can be
considered a mature library, which, in my opinion, makes it independent of
progresses of libglib2, this way, the tool should build on most Linux
distributions, even oldest ones (well, this will actually be false because of
the other dependencies of Subsurface).

Final note: It hasn't been until very recently that libdivecomputer has included
support for some of the data downloaded from Galileo devices, even today
understanding some of these data is WIP (e.g. alarms, are interpreted as
bookmarks at this moment, and there is a lot of noise coming from the
tanks/gases area in libdc)

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-12 07:39:10 -08:00