The parser used to append each parsed dive at the end of the log.
At the end the list was sorted. However, the divelist code depends
on the list being sorted. To avoid inconsistent states, add the
dives at the proper position.
Note that the reference data of TestDiveSeabearNewFormat had to
be adapted, because the CNS calculation now gives a different
value. This shouls be investigated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit 185b4678ff changed the parser-test to use sorted dive
lists. However, for the "new Seabear" data format test, the
sorting was done after comparison. Which is obviously silly.
Fix it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive list will be changed to an always-sorted list where one can
use binary search.
However, this makes some tests fail, because they only use parse_dive(),
which doesn't do any sorting.
To fix this future problem, sort the tables before performing the tests.
This provides a more realistic setup, as in the actual application,
the dive list will always be sorted on import.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As noted in a comment introduced in fe074ccad1, the profile test
should probably best be run using the default preferences. This
wasn't done back then, because the reference data assumes a (bogus)
setting of modO2 of 0.
This commit runs the test using the default preferences and updates
the reference data accordingly.
This is in preparation of changes to the preference system, where
the preference structure initializes itself to the default values.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The Divesoft Liberty has four O2 sensors. So far, we had a hard coded
limit of three sensors and crashed with a failed assert when we
encoutered more than three. This allows for up to
MAX_O2_SENSORS which is currently 6. The voting logic is adapted
accordingly: We sort the values and we keep deleting the values that
differ more than 20% by value from the closest. This follows what
Shearwater implements on their computers.
In some of the import/export functions the value is still hard
coded to 6 thanks to explicit field names.
Signed-off-by: Robert C. Helling <helling@lmu.de>
Fix how gases are marked as 'used' and kept from being deleted in the
equipment tab for CCR dives.
It does not make sense to treat the (arbitrary) first gas in the list
with a usage type of 'diluent' or 'oxygen' as 'used' and prevent the
user from deleting it. Dive computers report the initial diluent and
any other diluents used through a 'gaschange' event, so the actually
used diluents are already picked up as part of gaschange event based
logic.
Also clarify the selection of the first diluent used as a default if no
gaschange events exist.
Also fixed the test data - gases that have a pressure change should be
included in the profile if they do not have a gas change recorded
against them by other dive computers, even if they are oxygen.
A secondary problem shown by this is that the pressure change is not
applied to the profile - the pressure is currently shown as constant on
the start pressure. But this is for another pull request.
Signed-off-by: Michael Keller <github@ike.ch>
The conversion between mbar and depth sometimes uses DC's salinity, sometimes user's salinity. By other hand, it uses surface pressure given by user in calculation.
This fix try to standartize this values, using them from same source.
Signed-off-by: Rafael M. Salvioni <rafael.salvioni@gmail.com>
When collecting the data for the infobox, we have
already computed the current partial pressures of the
breathing gas taking into accoutn the divemode. Use
those rather than fractions (which for CCR mode are
those of diluent) to compute the gas density.
Reported-by: Pietro Tranquillini <p.tranquillini@gmail.com>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This dive contains logs from two dive computer, Garmin Descent MK2i and
Suunto Vyper Air. These dive computers each has a wireless pressure
transmitter connected to them, attached to different cylinders.
When downloading the dives, both of these pressure sensors get attached
to the first cylinder. This is correct for the Garmin sensor, but not
the Suunto sensor, which should be attached to the second cylinder. The
pressure graph doesn't reflect the measured SAC rate.
To fix this, make sure that the Suunto log is visible and then in the
Equipment tab ensure that the Sensors column is visible. In the field for
the 2nd cylinder it will say "Select one of these cylinders: 0", this
shows that there is a sensor attached to the first cylinder. Change this
text to "0" and press enter, now the sensor will be attached to the 2nd
cylinder and the pressure graph will now show the measured SAC rate for
this cylinder.
Signed-off-by: Michael Andreen <michael@andreen.dev>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>