Commit graph

18 commits

Author SHA1 Message Date
Dirk Hohndel
22c94a3e65 Don't try to force depth to be unsigned
Trying to clean up the signed vs. unsigned issues it becomes clear that
forcing depth to be unsigned causes way too many problems in the code.

So this commit goes the opposite direction; since we clearly aren't
limited INT_MAX vs UINT_MAX, simply make more of the depth related
variables signed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 09:53:44 -07:00
Robert C. Helling
8a59d78faa When handing off a picture to a worker thread, copy it first
as otherwise we crash when the picture is freed before the
worker thread (to load from the net or to compute hashes)
is finished

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-16 07:46:28 -07:00
Dirk Hohndel
f2c40907c5 Clean up signedness confusion in dive.c
This started out as cleaning up warnings - but it actually turned into a
matter of semantics and correctness. Which lead to changes in .h files
which will have a ton of ripple effects.

A lot more of this to come.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:46:58 -08:00
Linus Torvalds
3f30832471 gas model: split up gas compressibility into a file of its own
The gas compressibility is such a specialized thing that I really prefer
having it separate.

This keeps Robert's Redlich-Kwong equation as-is, but let's experiment
with other models soon...

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02 18:08:18 -08:00
Robert C. Helling
84769dc2f6 This computes the compressibility of the gas depending on the mixture.
As it turns out, the van der Waals equation gives results that are
numerically not really useful, so we use the Redlich Kwong equation
which is, according to Wikipedia, much more accurate, which can be confirmed
given the empirical values for air.

As opposed to the previous approach with a look-up table, this takes
into account the actual gasmix. This always assumes the gas to be at
20 degrees Centigrade.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-29 08:58:16 -08:00
Robert C. Helling
26779a9af5 If salinity is not density, add density of fresh water
There was a reported case of an import of a dive that gave a salinity of
35g/l. This is an actual salinity (an amount of salt in the water) but
for subsurface the salinity is actually the density of the water. So for
too small values of the salinity add the density of fresh water.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-28 15:39:52 +01:00
Linus Torvalds
45ed0ec757 gas pressures: use an actual compressibility table for air
We could in theory make this dependent on the gasmix, but for now let's
just assume (incorrectly) that everything we breathe acts like air.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25 01:22:32 +01:00
Linus Torvalds
7ebc31c1ec gas pressures: do not use gas compressibility for cylinder naming
This actually didn't make a difference for the common case, since our
simplified gas compressibility model had a compressibility factor of 1.0
up to 200 bar, and increased smoothly from there.  As a result, the
common 2400 and 3000 psi workpressures didn't really see an effect from
this.

Not taking compressibility into account does kind of make sense for
cylinder naming, since the cylinder may be used for different gases with
very different compressibility characteristics.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25 00:45:38 +01:00
Linus Torvalds
82c003c914 gas pressures: do some initial cleanup
This marks "surface_volume_multiplier()" static in preparation for
changing it to use an actual honest-to-goodness compressibility
estimation.  Without that, it wasn't obvious that the function wasn't
used in other random places.

Also, remove the "wet_volume()" function.  It was unused, but more
importantly, it was wrong.  Yes, it was the inverse of "gas_volume()",
but when you calculate wet volumes from the imperial sizes, you don't
actually use the "real" gas volume, you use the idealized one.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25 00:45:35 +01:00
Dirk Hohndel
38ab11a6c0 Add option to allocate the samples in fake_dc()
We (ab)use fake_dc() to create a pleasing profile for a manually added
dive. Based on it's intended use, fake_dc() simply handed back a dc
structure that pointed at staticly allocated samples - that's obviously
(now that I think about it) going to blow up in my face if I edit a
manually added dive more than once.

So now we have an option for fake_dc() to actually allocate the samples -
this way the rest of the code can treat these samples as we would treat
samples created any other way. We can free them and replace them with a
new set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20 09:36:14 -08:00
Miika Turkia
24e2f83d67 Allow merging of dives with zero depth/duration
Fixes #1003

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-04 12:38:48 -08:00
Salvador Cuñat
ce3a78efca Assign lower number to a merged dive instead of higher one
At the moment, if we have, say, dives ... 100, 101 and 102 and we merge 101 and
102, we get a list numbered ... 99, 100, 102. This is, probably, an
undesired behavior. The patch simple chooses lower of both dive numbers instead
of higher one.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07 18:40:20 -08:00
Stephen Hemminger
7a42215067 dive: paren error in set point handling
This probably is a serious bug, found by cppcheck.
Original code had paren's in probably the wrong place!

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 21:31:13 -08:00
K. \"pestophagous\" Heller
2778470b97 Prevent gaschange tank icons from using garbage coords.
Tank icons were shown at incorrect spots on the profile
when the DiveEventItem object held a pointer to a struct
event even after the struct event at that address had
been freed.  When internalEvent is a pointer to freed
memory, internalEvent->time.seconds could have all kinds
of crazy values, which get used in member function
DiveEventItem::recalculatePos to place the tank at bad
x coordinates.

The DiveEventItem(s) no longer store a pointer to memory
that they do not own.  This way, no matter how the path of
execution arrives into slot recalculatePos, we never need
fear that the DiveEventItem will dereference a garbage
pointer to a struct event.

Fixes #968

Signed-off-by: K. Heller <pestophagous@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-03 22:56:23 -08:00
Lubomir I. Ivanov
1efb747338 dive.c: fix a couple of comment typos
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16 09:26:08 -08:00
Stephen Hemminger
6cb30ba1b6 simple spelling changes
Fix obvious spelling mistakes in comments (and one error message).

Yes, this is trivial but I saw one while reviewing some of the code
and after that decided to run code through some tools.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-15 12:10:37 -08:00
Lubomir I. Ivanov
e31b6c0ed3 dive.c: remove unused variable
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-11-07 22:26:33 -08:00
Tomaz Canabrava
4c0156e3d5 Move all core-functionality to subsurface-core
And adapt a new CMakeLists.txt file for it. On the way I've also
found out that we where double-compilling a few files. I've also
set the subsurface-core as a include_path but that was just to
reduce the noise on this commit, since I plan to remove it from
the include path to make it obligatory to specify something like

 include "subsurface-core/dive.h"

for the header files. Since the app is growing quite a bit we ended
up having a few different files with almost same name that did
similar things, I want to kill that (for instance Dive.h, dive.h,
PrintDive.h and such).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30 10:36:48 -07:00
Renamed from dive.c (Browse further)