Commit graph

116 commits

Author SHA1 Message Date
Robert C. Helling
9fd531dcc5 Round gas depth properly
The D in MOD, EAD, END, and EADD stands for "depth" and
as such these should be mm in int rather than double.

The intermediate fn2 and fhe2, however, as intermediate
value should not be rounded to an integer.

The upshot of this is a litle more numerical stability.
It should lead to more stable values in TestProfile
when run on architectures with different floating
point precision.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-12-06 22:29:04 +01:00
Robert C. Helling
07745893e5 Don't attempt to compute SAC for CCR dives
CCRs are different. It does not make sense to compute
a depth dependent SAC. You could compute the rate of O2
consumption but even that is likely wrong (as O2 in the
diluent would enter that as well), so simply don't attempt
it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-11-24 11:03:51 -08:00
Robert C. Helling
41258647d2 Don't access gasmix.o2.fraction
Air is a special gas that does not contain oxygen according
to gasmix.o2.fraction. If you want to use the fo2, you
need to use get_o2() to treat this special case correctly.

This fixes a bug when setting the MND of a gas containing
21% oxygen when o2 is considered not narcotic.

Reported-by: Christoph Gruen <gruen.christoph@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-10-01 08:50:36 -07:00
Robert C. Helling
2126ac7c25 Adopt tests to updated CNS and OTU calculations
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-08-19 10:58:08 -07:00
Linus Torvalds
6c4e890960 Clean up divecomputer 'device' handling
We have this odd legacy notion of a divecomputer 'device', that was
originally just basically the libdivecomputer 'EVENT_DEVINFO' report
that was associated with each dive.  So it had firmware version,
deviceid, and serial number.

It had also gotten extended to do 'nickname' handling, and it was all
confusing, ugly and bad.  It was particularly bad because it wasn't
actually a 'per device' thing at all: due to the firmware field, a dive
computer that got a firmware update forced a new 'device'.

To make matters worse, the 'deviceid' was also almost random, because
we've calculated it a couple of different ways, and libdivecomputer
itself has changed how the legacy 32-bit 'serial number' is expressed.

Finally, because of all these issues, we didn't even try to make the
thing unique, so it really ended up being a random snapshot of the state
of the dive computer at the time of a dive, and sometimes we'd pick one,
and sometimes another, since they weren't really well-defined.

So get rid of all this confusion.

The new rules:

 - the actual random dive computer state at the time of a dive is kept
   in the dive data. So if you want to know the firmware version, it
   should be in the 'extra data'

 - the only serial number that matters is the string one in the extra
   data, because that's the one that actually matches what the dive
   computer reports, and isn't some random 32-bit integer with ambiguous
   formatting.

 - the 'device id' - the thing we match with (together with the model
   name, eg "Suunto EON Steel") is purely a hash of the real serial
   number.

   The device ID that libdivecomputer reports in EVENT_DEVINFO is
   ignored, as is the device ID we've saved in the XML or git files. If
   we have a serial number, the device ID will be uniquely associated
   with that serial number, and if we don't have one, the device ID will
   be zero (for 'match anything').

   So now 'deviceid' is literally just a shorthand for the serial number
   string, and the two are joined at the hip.

 - the 'device' managament is _only_ used to track devices that have
   serial numbers _and_ nicknames. So no more different device
   structures just because one had a nickname and the other didn't etc.

   Without a serial number, the device is 'anonymous' and fundamentally
   cannot be distinguished from other devices of the same model, so a
   nickname is meaningless. And without a nickname, there is no point in
   creating a device data structure, since all the data is in the dive
   itself and the device structure wouldn't add any value..

These rules mean that we no longer have ambiguous 'device' structures,
and we can never have duplicates that can confuse us.

This does mean that you can't give a nickname to a device that cannot be
uniquely identified with a serial number, but those are happily fairly
rare (and mostly older ones).  Dirk said he'd look at what it takes to
give more dive computers proper serial numbers, and I already did it for
the Garmin Descent family yesterday.

(Honesty in advertizing: right now you can't add a nickname to a dive
computer that doesn't already have one, because such a dive computer
will not have a device structure.  But that's a UI issue, and I'll sort
that out separately)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-08-18 13:22:02 -07:00
Berthold Stoeger
846e1ba53e core: always create a fake profile if there are no samples
Before making the cylinder-table dynamic, dives always
had at least one cylinger. When such a dive is displayed,
the TabDiveInformation class calls per_cylinder_mean_depth().
If there are no samples, this function generates a "fake
profile" with fake_dc(). Thus, effectively dives always
had samples once the user was displaying them.

When the cylinder-table was made dynamic, dives without
cylinders were supported. This can notably happen, when
importing from CSV (this could actually be a bug).
per_cylinder_mean_depth() exits early in that case and
doesn't create a fake profile. This lead to crashes
of the profile-widget, which were fixed in 6b2e56e513.
Non-sample dives were now shown with the Subsurface-logo.

To restore the previous behavior, genarate a fake profile
for sample-less dives in fixup_dive(), which is called
anytime  a dive is loaded or imported. This seems to
have been the intention anyway and this worked only
"by chance". This will make a few fake_dc() calls obsolete,
but so be it.

Since fake profiles are now generated on loading,
the parse-tests need to be fixed to account for that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-23 11:30:17 -07:00
Robert C. Helling
1c8c6f9551 Add test for profile in VPMB mode
For some reason, this test seems not to run effectively, at least
locally, I had to update the reference file.

Added a check that indeed the file to be compared was
successfully opened.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-03-24 10:30:22 -07:00
Robert C. Helling
2064ce06cc Fix pO2 for CCR at shallow depths
Even when diving a CCR, the pO2 cannot exceed ambient
pressure. This only makes a difference at shallow depths.

Fix this in the calculation of OTUs and CNS.

This affects some tests that now have slightly different CNS and OTU values.

Suggested-by: Justin Ashworth
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-02-26 08:42:30 -08:00
James Wobser
4f3b26f9b6 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>
2020-09-04 15:54:08 +03:00
Linus Torvalds
62e95fdc86 Save SAC, OTU and CNS in the XML export
We do _not_ read them back, since they are calculated values, although I
guess we could aim to do that too at some point in case we have an
import from somewhere else that has these values but not the profile (or
gas use) to actually calculate them.

Fix test-cases that are checked by TestParse (but nothing else) to match.

Requested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-14 13:27:07 -07:00
Robert C. Helling
b3270222fd Add test for profile data
There was a TestProfile but that was a stub that did not test anything.

We have an export function that serialises the profile data
(including lots of derived data like deco information and
cylinder pressure interpolation). So here is now a simple
tests that can detect regressions in the profle.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-04 13:39:18 -07:00
Berthold Stoeger
17526ded58 cleanup: move clearing of device nodes to clear_dive_file_data()
It makes no sense to keep the device nodes if all the other data
is cleared. Let's do this automatically and not explicitly.
This ensures that the function is also called on mobile.
Currently it was only called on desktop.

Weirdly, the parser-tests were expecting that the device nodes
were not reset by clear_dive_file_data() and therefore divecomputers
were accumulating in the test results. Thus, the additional
computers had to be removed from the expected test results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Jason Bramwell
ac0914e509 Correct celcius/celsius typo in test dives
Corrected typos in three files:
dives/Test.csv
dives/TestComma.csv
dives/APDLogViewer.csv

Simply replaced the word celcius with celsius.

Signed-off-by: Jason Bramwell <jb2cool@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-09 14:41:43 -08:00
willemferguson
ef9bce9233 Desktop: Import gps coordinates: test files
These are test files enabling a test of the import of dive
coordinates from GPS

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-01-24 09:51:51 -08:00
willemferguson
1bdf00b2b4 Convert the atmospheric pressure in the Information Tab to an editable field
The Information tab shows the atmospheric pressure. Make this value editable
and also ensure that changes to it are undo-able.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-05-15 07:37:14 -07:00
Berthold Stoeger
858d3e2eed Dive site: fix merging tests
The handling of dive site merging changed and therefore the tests
have to be adapted.

1) Dive sites are recognized as identical based on their name.
   Therefore, give the dive sites that should be merged the same name.
2) The dive site id of the first imported dive is kept. Thus,
   merge and reverse merge produce two different output files.
   Create a second file reflecting that fact.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
b024ca101e Dive site: make UUID generation deterministic
Instead of using a random UUID, use an SHA1 hash of name, description
and notes (if defined). This is necessary for testing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Robert C. Helling
d9f2b537af Fixed get_gas_at_time for equal times
This fixes a subtle bug introduced in 5c4569247a which
unified two functions finding the gasmix at a given time
during the dive. There was a slight difference, though:
Does a gaschange exactly at that time count or not? For
the planner to work, the answer has to be in the affirmative.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-10-30 15:33:43 +01:00
Miika Turkia
68ef735bde Update DM5 test data
Now that we read the temperatures properly, the test comparison must
also include them.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Miika Turkia
947065d995 Add water temperature to test dive
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
a4c2eb5b70 Update latests changes to test dive
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
4a5b40c144 Update DL7 tests to current import
As we now parse dives without profile, we get 2 more dives from the
sample log import (3 in total). And naturally also the resulting XML to
compare against needs to be updated.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
35778d9bbc Add converted DL7 file for test validation
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
87bab637fa Add two dive headers to DL7 sample
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
62779fa453 DL7/zxu sample dive
Manually crafted sample dive demonstrating parts of the DL7 format.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Miika Turkia
0c564a4579 Fix test parsing as new DC appears in the XML files
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
63f1c84e38 Add imported version of DM5 test dive
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08:00
Miika Turkia
25afbdaa89 Test dives in DM5 database format
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27 13:42:10 -08: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
Miika Turkia
c69a56b53b Fix TestParse to handle CCR import properly
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24 10:03:07 +09:00
Miika Turkia
405f27eb2a Fix comparison data for TestParse
It appears that we used to get additional tts=0:00min tags on Seabear
parsing. I would assume these to be incorrect as there other values
right before these that look more sensible. Also the resent change to
streamline the feature of not storing repeating values causes the test
to fail. Anyway, just grabbing the new result to compare with as it
seems sensible.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-23 04:11:00 +09:00
Miika Turkia
ccf916344b Include some extradata info on Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 21:36:50 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Miika Turkia
21cdc64712 Update Seabear test data to use proper times
Now that we parse them...

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:32:32 +03:00
Stefan Fuchs
67fbf6009a Test for adding a picture with data after JFIF EOI to a dive
Add one more picture to the already existing test.
This new picture is a JPEG and has data after JFIF EOI tag.

Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-06 10:31:09 -07:00
Jeremie Guichard
2b06a0b223 Fix potential double/float to int rounding errors
Not using lrint(f) when converting double/float to int
creates rounding errors.
This error was detected by TestParse::testParseDM4 failure
on Windows. It was creating rounding inconsistencies
on Linux too, see change in TestDiveDM4.xml.

Enable -Wfloat-conversion for gcc version greater than 4.9.0

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-09 23:07:30 +07:00
Dirk Hohndel
3fef6ec31d Simple test case for merging dives
We do some merging in a couple of the other tests as well, but the idea
is to have specific test cases that exercise our merge logic.

This one starts simple. Merge a dive with some valid info with a second
one that has less data filled. And then try it in both possible orders.

It shows a few potential problems.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-21 18:22:56 -08:00
Robert C. Helling
c4976b505a Test for basic image handling
This tests adding image files to dives including hashing and evaluating
exif data.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-21 13:14:56 -08:00
Dirk Hohndel
ec20d36f3c Add test for merging multiple cylinders
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-09 22:22:12 -08:00
Dirk Hohndel
4c74b15e2f TestParse: adjust reference output
Things have changed a bit in how we store data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 16:12:10 -08:00
Linus Torvalds
56ed3f1c61 Fix Qt date interfaces for times before 1970
This seems to work around the crazy QDateTime::fromTime_t() problem in Qt.

It is *very* lightly tested. In fact, the only test is that "test0.xml"
change that is part of this patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29 09:07:41 -07:00
Salvador Cuñat
19fffba327 SmartTrak import - Add example divelog file
This is the example divelog shipped with Subgear products (OEMs for
Scubapro/Uwatec), just changed the name to be meaningful for the reader
of the dives directory.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-12 07:39:21 -08:00
Dirk Hohndel
4e4cd280c4 Add missing XML files for TestRenumber
Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 14:40:33 +01:00
Dirk Hohndel
3f900885df Adjust expected output for TestParse
With commit b26e516e2a ("Dive_sites-Notes shouldn't be stored as
attribute") our output format changed slightly. Adjust the expected output
to match that change to ensure that TestParse passes again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-04 13:53:29 +01:00
Miika Turkia
261c11de28 Test case: fix Seabear test data to proper dive length
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-01 07:56:21 -04:00
Miika Turkia
1153f81856 Test case: control log for DLD import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-13 15:27:59 -07:00
Dirk Hohndel
1b37e0f1a4 Add test for dive site duplication bug
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-30 10:32:38 -07:00
Miika Turkia
bd5fbce64b Test dives for Seabear new format import comparison
This file contains imported dives from Seabear H3 and T1 dive computers.
It is used for validating Seaber import from new file format.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-28 08:46:55 -07:00
Miika Turkia
5868fc46aa Test dives for Seabear new format
These are test dives for Seabear H3 and T1 dive computers received from
Seabear Diving Technology.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-28 08:46:51 -07:00
Miika Turkia
ffa45b9d24 Test dive for Seabear HUDC import comparison
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27 06:35:10 -07:00