Commit graph

230 commits

Author SHA1 Message Date
Robert C. Helling
dc55ee4a23 Update exif.cpp from upstream
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-19 15:29:40 -08:00
Linus Torvalds
4a550e4d7d Properly handle dive sites loaded from XML
We used to always create a new dive site structure when loading dive
site data from XML.

That is completely bogus, because it can (and does) create duplicate
dive sites with the same UUID.  Which makes the whole UUID pointless.

So instead, look up the existing dive site associated with the UUID
loaded from the XML, and try to merge the data properly if we already
had dive site information for that UUID.

Reported-by: Alessandro Volpi <volpial@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-19 15:23:46 -08:00
Linus Torvalds
fc55620d2d dive merging: merge water temperature too, not just air temperature
I have no idea why we only merged air temperatures.  But it was very
explicit (even the function doing the merging was named
"merge_airtemp()"), and water temperatures were left alone.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-19 15:23:46 -08:00
Linus Torvalds
0cf4104dc6 Handle negative dates (before the epoch) better
The Qt model sorting for the dive date was using a unsigned number,
which doesn't work for dates before 1970.

Also, the dive date parsing got the year 1900 wrong.  Not that we really
care, because other parts of date handling will screw up with any date
before the year 1904.  So if you claim to be diving before 1904, you get
basically random behavior.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-17 15:08:38 -08:00
Linus Torvalds
83aff9f777 Fix crash when merging dives with a missing dive computer model
The test for the dive being a planned dive was completely bogus:

 - it should use "same_string()" which correctly checks for NULL

 - the string it checks for is obviously spelled wrong anyway.

Reported-by: Alessandro Volpi <volpial@gmail.com>
Fixes: a031dbbbd ("When merging planned dives keep all cylinders")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-15 21:46:15 -08:00
Robert C. Helling
e31714d9b2 Set up gaslist only in the beginning of diveplan
In the beginning of the diveplan, divedatapoints of zero
duration indicate available gases with the depth giving
the suggested switch depth. Zero-duration datapoints in
the middle of the dive do not have this meaning and should
thus be ignored when composing the gaslist.

The tests should have these gas defining segments in the beginning.

This fixes a problem when replanning a dive that would change
to random gases during deco.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-11 08:31:42 -08:00
Robert C. Helling
057419fa85 Always show manually added gaschanges in notes
In the manually entered part, we dont wait until the next stop.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-11 08:31:42 -08:00
Robert C. Helling
032c3258ed Reset VPM-B state between repetitive dives
This resets the maximum crushing pressures and the maximal
ambient pressure between repetitive dives to prevent anomalies
that a dive produces a shorter deco when following another one
than without.

Reported-by: sfuchs@gmx.de
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-10 06:41:24 -08:00
Linus Torvalds
0e7d8993a2 Make cylinder merging a bit more careful
This makes some further updates to the new cylinder merging code:

 - avoid re-using the cylinder if the usage type (OC/diluent/O2) is
   different between the two dives, even if the gasmix might be the
   same.

 - avoid re-using a cylinder if the user has manually added pressure
   data for it (and the pressures don't match)

 - when deciding to reuse a cylinder, make sure that we merge as much of
   the type information as makes sense.

This will potentially result in more cylinders that might need manual
cleanup, but at least we won't be throwing out user data.  And in most
cases where merging happens, none of this is an issue (because the data
comes fresh from a dive computer, and won't have been manually edited to
trigger the new rules).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-09 21:30:49 -08:00
Linus Torvalds
e2bbd0ceec Rewrite cylinder merging code from scratch
The old cylinder merging code depended on the preferred dive having all
the cylinders, and the newly merged dive was just forced to pick from
that existing set of cylinders.

That worked ok if you have a "main" dive computer that you have all the
gases programmed for, and you download that first, and then you download
any secondary data later.

But it completely messed up if the second dive computer had gases that
the first one didn't know about, and just basically ended up doing
random things.

This rewrites the whole thing to actually try to create a union of the
two sets of cylinders when merging, with sane matching so that if the
cylinders match you won't get duplicates.

Miika Turkia hit this when he only used one gas, but had several gases
defined in his OSTC that he downloaded after his Vyper (with had just
the single gas defined).

This should fix that case (at least it does for my xml merging test-case
that showed the same problem after some munging).

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-09 21:30:49 -08:00
Dirk Hohndel
f6cd21ce5a Finish removal of informational_prefs
And make export-html build again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 12:44:11 -08:00
Joakim Bygdell
0277d5aacc Merge informational_prefs into git_prefs
There is no need to have two variables for the same purpose.

[Dirk Hohndel: changed to keep the two separate functions as otherwise
               we no longer parse existing repos successfully]

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 12:29:51 -08:00
Joakim Bygdell
11dcae436e MOBILE: Read profile settings from git
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
Joakim Bygdell
d4dbd0bee7 Save profile settings to git
In order to streamline the view between desktop and mobile we need to save
selected profile related settings to git.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
Robert C. Helling
6518b0db45 Treat gaschanges at 1s as inital gas use
When the first leg in the planner is not cylinder 0, a gaschange
event at t=1s is inserted. In the profile, we should treat that
as inital gas, so no pressure information is printed for cylinder 0
that is used nominally for one second.

This fixes a problem reported by Willem.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-04 07:09:35 -08:00
Stefan Fuchs
cd38cda186 Bugfix planner output formating (linebreaks)
Changed the markup with <div> and <br> tags of the planner output in
a way that is is a good compromise for both displaying in UI and
printing.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-04 07:06:29 -08:00
Robert C. Helling
855995191c Don't do strcmp on NIL pointer
This is what we have same_string() for...

This prevents a crash when saving a dive in the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 15:04:51 -08:00
Dirk Hohndel
db7290a915 Same typo, two more times
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 15:01:15 -08:00
Dirk Hohndel
a959e437a9 Fix typo
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 09:35:01 -08:00
Lubomir I. Ivanov
4a894e0713 Win32: add the --win32log option to log stdout and stderr to files
Adding --win32log as the first command line option on Windows
will now log all stdout and stderr output to the files
subsurface_err.log and subsurface_out.log in the working directory.

This change required a new argument 'bool logfile' to be added to:
subsurface_console_init() which is defined in all platform files
(linux.c, macos.c, etc.)

Example usage:
subsurface.exe --win32log -v -v -v

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-02-03 09:24:42 -08:00
Robert Helling
5aa9c6fa1b Do not count gas used in planned dives for statistics
This is important if in one dive we have the real dive and
a planned version of the dive as different computers using
different sets of cylinders.

[Dirk Hohndel: an early version of this was mistakenly pushed out
               by me; I reverted that and added this commit since
               fixing things up as I had done for the other two
               patches made things nearly unreadable]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:45:24 -08:00
Robert Helling
67de8f3a49 Correct: Handle more tanks than gasmixes
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).

[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
               commit, so this fixes things up to the final version]

Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:43:00 -08:00
Robert Helling
8a8315d6fe Correct "When merging planned dives keep all cylinders"
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.

Increase MAX_CYLINDERS to 20 to make room for this. We warn if we
exceed this number.

[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
               commit, so this fixes things up to the final version]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:41:35 -08:00
Dirk Hohndel
08c42813e5 Revert "In statistics, ignore gas use of planned dives"
This reverts commit 1d8662006c.

Mistakenly pushed to master

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 07:31:03 -08:00
Dirk Hohndel
414d7f2632 Deal with some of the whitespace issues in planner.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 03:10:57 -08:00
Stefan Fuchs
fbaeeec807 Print SAC values from prefs in diveplan
Print the SAC values from preferences into the diveplan.
These are the values used for calculation of gas consumption.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 02:45:58 -08:00
Stefan Fuchs
a1c51256b2 Add ATM pressure and altitude to diveplan
Print the ATM pressure and the altitude used for calculation into the resulting diveplan.
Moved this info together with the deco model info below the runtime table.
There is one drawback in this implementation: Altitude will be recalculated from surface pressure and therefore may differ slightly from altitude entered in the UI.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03 02:45:30 -08:00
Robert C. Helling
1d8662006c In statistics, ignore gas use of planned dives
When merged with real dives, those would double count otherwise.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-02 12:37:24 -08:00
Robert C. Helling
a031dbbbd8 When merging planned dives keep all cylinders
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.

Increase MAX_CYLINDERS to 20 to make room for this.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-02 12:36:08 -08:00
Robert C. Helling
99595542ec Handle more tanks than gasmixes
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).

Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-02 12:35:58 -08:00
Robert C. Helling
bb86d13546 Initialize the surface time
Otherwise we return garbage when there is no dive in the dive list.

Closes #184

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-01 14:43:27 -08:00
Robert C. Helling
c1dc0c9ce0 Allow user to disable a cylinder in planner
In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.

This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-23 22:11:51 -08:00
Dirk Hohndel
b15b3c195c QML UI: allow magic phrase for multiple buddies to be localized
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-22 18:20:03 -08:00
Linus Torvalds
e1ee577c4f Make event string translation when downloading from libdivecomputer more obvious
We had hardcoded the exact translation of the event numbers.  They
haven't changed (although we did have what appears to be a spurious
entry for "non stop time" at the end that libdivecomputer doesn't have
an enum for).

Instead, use an explicit array index initializer array, so that it's
obvious that the two match up (and if the sample event numbers ever
change, we should cope with it gracefully).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-17 09:15:50 -08:00
Linus Torvalds
fe5f15bdc5 Add support for libdivecomputer using DC_SAMPLE_GASMIX
New libdivecomputer versions use DC_SAMPLE_GASMIX to indicate a gas
change (which contains the cylinder index we're changing to) rather than
SAMPLE_EVENT_GASCHANGE*.

Unlike the old GASCHANGE model, and despite the name, DC_SAMPLE_GASMIX
does not actually say what the mix is, it only specifies a cylinder
index.  We had already extended SAMPLE_EVENT_GASCHANGE2 to have the
cylinder index in the otherwise unused "flags" field, so this is not all
that different from what we used to do.

And subsurface internally already had the logic that "if we know what
the cylinder index is, take the gas mix from the cylinder data", so
we've already been able to transparently use _either_ the actual gas mix
or the cylinder index to show the event.

But we do want to make it an event rather than some sample data, because
we want to show it as such in the profile.  But because we are happy
with just the cylinder index, we'll just translate the DC_SAMPLE_GASMIX
thing to the SAMPLE_EVENT_GASCHANGE2 event, and nothing really changes
for subsurface.

libdivecomputer has made other changes, like indicating the initial
cylinder index with an early DC_SAMPLE_GASMIX report, but we've seen
that before too (in the form of early SAMPLE_EVENT_GASCHANGE events), so
that doesn't really end up changing anything for us either.

HOWEVER, one thing that is worth noticing: do *not* apply this patch and
then use an old libdivecomputer library that sends both the
DC_SAMPLE_GASMIX samples _and_ the deprecated SAMPLE_EVENT_GASCHANGE
events.  It will all *work*, but since subsurface will take either,
you'll then get duplicate gas mix events.

It's not like that is in any way fatal, but it might be a bit confusing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-16 17:45:00 -08:00
Robert C. Helling
7725842383 Use real gas compressibility in planner
Modify formluas for gas use to take into account the
compressibility correction for real gases. This introduces
also the inverse formula to compute the pressure for a given
amount of gas.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-16 03:17:40 -08:00
Dirk Hohndel
1ab6e7fc8a Prevent crash on Mac when typing comma in GPS coordinates field
Our attempt to skip any white space after the comma causes an ASSERT (strangely
only on Macs).

This closes #158

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-14 09:09:58 -08:00
Linus Torvalds
638e7fb28f Add cylinder equipment tooltips with gas volume
This adds tooltips for the equipment tab for each cylinder, showing the
amount of gas used.

When you mouse over the size and working pressure fields, the tooltip will
show the amount of gas used (along with start and end gas volumes). And
when you mouse over the start and end pressures, it will show the start
and end gas volumes, and the Z factor used.

I started doing this because of the gas volume questions in the last day
or two (and a few from a few weeks ago). When even Robert Helling starts
wondering about the effects of compressibility on the SAC calculation, our
numbers are clearly too opaque.

With these tooltips, at least you can see what went into the used gas
calculations, instead of having to add debugging options to print out Z
factors.

[ This patch also adds a "rint()" to get the rounding right in the
  gas_volume() function.  Although rounding to the nearst milliliter
  really doesn't matter, it's the right thing to do after doing FP
  calculations ;^]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-12 14:17:09 -08:00
Anton Lundin
48b2b3d0b3 ostctools: Add support for profile version 0x24
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
983561b353 ostctools_import: Switch to using dc_parser_new2
Instead of creating the individual parsers, and keeping track of their
arguments, this just uses the "new" dc_parser_new2 function ment for
buffer parsing.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
70e2404492 Stop accessing the internals of dc_descriptor_t
This removes our own declaration of dc_descriptor_t and all our accesses
to its internals, and switches to use the libdivecomputer functions to
access those instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Anton Lundin
d11dfd2f45 ostctools: Correct argument order to get_descriptor
This corrects the argument order, which was changed back in
00629c861c, but not on this place. Whups.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-01-12 14:15:53 -08:00
Miika Turkia
aaa46c2465 Add some additional parameters to help text
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-06 20:44:02 -08:00
Robert C. Helling
935734100f Rename prefs.deco_mode to prefs.planner_deco_mode
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
bb4bf639c3 Fix deco_mode confusion
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB
vs RECREATIONAL): One for the planner (deco_mode) and one for
displaying dives (display_deco_mode). The former is set in the planner
settings while the latter is set in the preferences.

This patch clears up a confusion which of the two to use by introducing
a helper function that selects the correct variable.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Robert C. Helling
43599742a3 Display surface interval in diveplan
...instead of just stating "repetitive dive". As requested by
a user.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-03 22:28:18 -08:00
Miika Turkia
8766054581 Hooking up av1.xslt for log import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2016-12-31 09:56:08 +02:00
Robert C. Helling
10b8bda662 Fix picture hashing logic for pictures on the web.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2016-12-30 19:43:00 +01:00
Anton Lundin
38474f2d47 android: Add a subsurface_user_is_root for android
This is to compile the desktop ui for android

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00
Anton Lundin
3b884c2e7c Use get_descriptor instead of hard-coded switch's
This starts using the newly lifted out get_descriptor in configure dive
computer, instead of previously hard-coded out of date
switch-statements.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-12-28 22:40:18 -08:00