Commit graph

83 commits

Author SHA1 Message Date
Miika Turkia
3c9897d247 DLF import: document deco event
These are Deco N2 Low/High and Deco He Low/High events. They all appear
to be recorded at the same time, different events at same second.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
Miika Turkia
dac90e3fde DLF import: comment measured He
Measured He is documented (in comment). Will need information if all
measurements are needed or just start/end. First case would be added to
dive prifle, possibly cluttering it, second would be extra data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
Miika Turkia
aae2403ddd DLF import: Record battery status
This will record the ending battery status to extra data. Would need
info from CCR divers whether this suffices or if we should record also
the starting volatage or even every single reading.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-09-09 12:26:45 -07:00
Berthold Stoeger
59a68fe9b5 Parser: split out name-comparison from match() function
The match() function in parse-xml.c calls a very specific callback,
which doesn't take a context-parameter. To be able to call other
callbacks, split out the actual name-comparison.

Moreover, remove the "plen" parameter, as this was called with
strlen(pattern) in all cases anyway. Replace the old logic which
potentially accessed a byte beyond the end of name with a simply
classical C-style loop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-30 13:32:09 -07:00
Berthold Stoeger
2de8e70ab0 Parser: move match() into core/parse-xml.c
The match() function compares a pattern with a name with
a twist: The name may either end in '\0' or '.'. If pattern
and name match, a parsing function is called on a buffer and
a destination value. The result of the parsing is not checked.

This seems awfully XML-specific and therefore move the function
from the general parse.c to the specialized parse-xml.c unit
and make it of local linkage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-30 13:32:09 -07:00
Berthold Stoeger
d815e0c947 Parse: pass dive_table argument to parse_file()
To enable undo of divelog-importing it is crucial that parse_file()
can parse into arbitrary dive tables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 10:17:12 -07:00
Berthold Stoeger
360f07e453 Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to
return by value. For consistency, also pass gasmix by value.

Note that on common 64-bit platforms struct gasmix is the size
of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the
same space on the stack. On 32-bit platforms, the stack use
is probably doubled, but in return a dereference is avoided.

Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an
invasive change that going back to pointers is probably the
least of our worries.

This commit is a step in const-ifying input parameters (passing
by value is the ultimate way of signaling that the input parameter
will not be changed [unless there are references to said parameter]).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
f3ef38ca0d Dive pictures: remove hashes
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).

Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
jan Iversen
061be82e31 core: replace (void) with UNUSED(x) and include ssrf.h
Unused parameters in C are "silenced" by adding UNUSED(x)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
Robert C. Helling
969dfee9ec Rename enum dive_comp_type to divemode_t
...as the usuage is not anymore about a computer but
a momentary dive mode. Rename the end indicator as well.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Willem Ferguson
b9174332d5 Read and write divemode changes (xml and git)
This provides for reading of divemode change events from dive logs
and for writing them to dive logs. This applies to xml and git
divelogs. Divemode change events have the following structure:
event->name = "modechange"
event->value = integer corresponding to enum dive_comp_type (dive.c),
reflecting the type of divemode change (OC, CCR, PSCR, etc).

In the dive log file, the event value is written as a string that
corresponds to each of the enum values, e.g.
<event name='modechange' divemode='OC' />
This xml is also read from the dive log file and translated to an
appropriate value of event->value.

The file diveeventitem.cpp was udated to reflect this new way of
dealing with divemode change events.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
bdc470a80e Cleanup: Remove hash field from picture-structure
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.

Therefore, make this explicit by removing the hash field from the
picture structure.

Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Berthold Stoeger
0fa6422a04 Warning Fix: add missing include to core/parse-xml.c
Fallout from commit #cd5e17cf79c2f1eb896efd0436c103221de446ae

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-02 02:46:31 +02:00
Berthold Stoeger
cd5e17cf79 Cleanup: Unify qthelper.h and qthelperfromc.h
Since all qt-helpers are defined in qthelper.cpp, there seems to be
no reason to have two include files. By unifying the two files,
duplication and inconsistencies are removed. The C++-only part is
simply compiled away with #ifdefs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 19:06:02 +02:00
Willem Ferguson
9a8bab21c9 Improve profile display in planner
This patch allows the planner to save the last manually-entered
dive planner point of a dive plan. When the plan has been saved
and re-opened for edit, the time of the last-entered dive planner
point is used to ensure that dive planning continues from the same
point in the profile as was when the original dive plan was saved.
Mechanism:

1) In dive.h, create a new dc attribute dc->last_manual_time
   with data type of duration_t.
2) In diveplanner.c, ensure that the last manually-entered
   dive planner point is saved in dc->last_manual_time.
3) In save-xml.c, create a new XML attribute for the <divecomputer>
   element, named last-manual-time. For dive plans, the element would
   now look like:
   <divecomputer model='planned dive' last-manual-time='31:17 min'>
4) In parse-xml.c, insert code that recognises the last-manual-time
   XML attribute, reads the time value and assigns this time to
   dc->last_manual_time.
5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive,
   insert code that sets the appropriate boolean value to dp->entered
   by comparing newtime (i.e. time of dp) with dc->last_manual_time.
6) Diveplannermodel.cpp also accepts profile data from normal dives in
   the dive log, whether hand-entered or loaded from dive computer. It
   looks like the reduction of dive points for dives with >100 points
   continues to work ok.
The result is that when a dive plan is saved with manually entered
points up to e.g. 10 minutes into the dive, it can be re-opened for edit
in the dive planner and the planner re-creates the plan with manually
entered points up to 10 minutes. The rest of the points are "soft"
points, shaped by the deco calculations of the planner.

Improvements: Improve code for profile display in dive planner

This responds to #1052.
Change load-git.c and save-git.c so that the last-manual-time is
also saved in the git-format dive log.

Several stylistic changes in text for consistent C source code.

Improvement of dive planner profile display:

Do some simplification of my alterations to diveplannermodel.cpp

Two small style changes in planner.c and diveplannermodel.cpp
as requested ny @neolit123

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19 12:38:11 +02:00
Berthold Stoeger
afeb2e3652 Make a few functions of static linkage
Make functions in core/file.c, core/parse.c and core/import-csv.c
that were not used outside their translation unit of static linkage.

parse_date is moved from core/file.c to core/import-csv.c, since it
is used only there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 09:52:55 +02:00
Berthold Stoeger
fa5865a566 Remove unused function parse_mkvi_buffer()
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 09:52:55 +02:00
Berthold Stoeger
5960718075 parse-xml.c: add get_bool() function
The boolean "autogroup" was parsed as an integer. In principle OK, but
let's make the type more explicit by introducing a get_bool() function.

Suggested-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Dirk Hohndel
169a55d6e8 Cleanup: avoid memory leak
Coverity CID 208314

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26 15:57:44 -08:00
Miika Turkia
b1b2638720 Move Cobalt and Divinglog DB parsing to parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
8be626d2c1 Move atoi_n to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
b3605de93e Move Shearwater DB parsing into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
568db03228 Move metric variable to parse.c
This is required when moving Shearwater DB parsing into parse-db.c

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
ddb9dba66c Move add_dive_site to parse.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
1c6e189c2b Move Suunto DB imports into parse-db.c
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
02c80a60b0 Refactore parse-xml.c into parse.c and parse-xml.c
This should help us to move parsing that is not XML related to other
files, hopefully making the code cleaner.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Stefan Fuchs
46004c39e2 Store and load the planner related depth info of a cylinder in logfile
Store cylinder.depth in XML files and in git storage.
This info is in fact the gas switch depth of a specific gas/cylinder
in the planner.
This change avoids the need of typing in a user specific depth value
again when replanning an existing planned dive.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 11:49:08 -08:00
Jan Mulder
f1437cfec7 Fix warning
Commit 9771255919 introduces a compiler warning due to mismatched
pointer types. Fixed here.

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-10 10:31:19 +01:00
Dirk Hohndel
27c49fe3ad Silence random warnings
None of these seem to point to actual issues, so let's quiet them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 17:25:18 -04:00
Miika Turkia
6573132307 Store RBT value on DivingLog import
Fixed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-10-07 22:38:49 -07:00
Linus Torvalds
d5a0184f71 Fix divinglog import temperature truncation
The code incorrectly divided the temperature by 10 as an integer,
causing unnecessary precision loss due to truncation.

Fix it, and update the test results for the now improved temperature
import.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 14:52:57 -07:00
Linus Torvalds
03b10383c9 Fix divinglog import limit checking
The divinglog import did horrible things with the strings returned from
the sqlite queries, and ended up using uninitialized values at the end
of the secondary profile data strings.

This rewrites the import logic to track the length of the strings
properly when importing the divinglog data.

We should run 'valgrind' a whole lot more than we do, I suspect.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 14:52:48 -07:00
Dirk Hohndel
21d78121ad Don't add separate country field, use taxonomy
The more I looked at the code that added the country to the dive site,
the more it seemed redundant given what we have with the taxonomy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Tomaz Canabrava
32e6ca4919 [Divesite] Save / Load the country from xml
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 09:52:33 -07:00
Seppo Takalo
a2a1dfdf9f Use dive ID instead of dive number when importing from Shearwater db
Dive IDs are unique but same dive number can appear multiple times within
the same database. This can happen for example when user changes the
"next log number" from his computer.

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-15 08:57:03 -07:00
Seppo Takalo
f7db0c705b Convert usage of atof() to strtod_flags()
The provided strod_flags(str, 0, 0) should work as a drop in replacement
for atof() but does not care about locales which may cause atof() to fail.

strtod_flags() would allow checking of conversion result, but I did not
change the existing logic. This was just regexp search&replace change
to get rid of atof(). I use flags 0 to get more relaxed conversion.

Fixes #574

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-15 08:57:03 -07:00
Miika Turkia
5afa5ed9f1 Detect dive mode on Shearwater DB import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-09-13 14:04:31 -07:00
Seppo Takalo
850917d41d Don't assume CCR mode when importing from Shearwater
Logic was assuming CCR mode if field "averagePPO2" was present.

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13 07:57:45 -07:00
Seppo Takalo
ba854a8cc5 Fix cylinder changes when importing from Shearwater database
Re-do the logic to use add_gas_switch_event() instead of creating event
manually.

Fix the SQL query to find the proper dive id from dive log number.

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13 07:57:45 -07:00
Seppo Takalo
83c9ad35a6 Fix Shearwater cylinder detection logic
Fix the SQL query to find proper dive id instead of assuming log number to
be the same as id.

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13 07:57:45 -07:00
Seppo Takalo
6509f2ed9f Ignore missing pressure values when importing from Shearwater
Shearwater seems to report missing AI sensors as a pressure reading
4092 (raw) which is 564 bar.

Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13 07:57:45 -07:00
Marc Arndt
48ff047086 adding comments as advised 2017-08-29 06:50:18 -07:00
Marc Arndt
90b9b61ba3 fixing indentation 2017-08-29 06:50:18 -07:00
Marc Arndt
ac7e60b456 Ignore Divesoft Button Press Events
Prevent button press events from showing on the profile
graph when we import divesoft DLF files.

Reported-by: Marc Arndt
Signed-off-by: Marc Arndt <marc@marcarndt.com>
2017-08-29 06:50:18 -07:00
Miika Turkia
fb151df883 Shearwater Perdix
Reportedly the case 2 corresponds to Perdix, so it might be that both
Petrel and Perdix use same model number (or the model is mistaken
before).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24 13:06:50 -07:00
Miika Turkia
a20aa850da Support for air pressure on Shearwater Desktop import
Fixes #548

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24 13:06:50 -07:00
Miika Turkia
7d22b52afc Grab correct dive number on Shearwater Desktop import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24 13:06:50 -07:00
Anton Lundin
9f290dcdb0 DLF: Parse more measurements, import GPS
This add support for parsing more measurements, and now imports GPS data
to.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10 09:09:53 -07:00
Anton Lundin
070c7e545b DLF: Parse Divesoft Liberty data better
There is something with ndl / tts / temp in the Liberty DLF files. If
that bit is set, the values are bogus. There is something more to it
here which I haven't figured out.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10 09:09:53 -07:00