Commit graph

526 commits

Author SHA1 Message Date
Robert C. Helling
e32896c2bc Introduce double depth_to_bar()
as it leads to significant cleanup.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:18:40 -07:00
Robert C. Helling
bd8126a709 Calculate ceiling only when it is needed
So far, add_segment() returned a tissue tolerance (i.e. ceiling)
computed just in its return statement. This tissue_tolerance
needed to be dragged around until it was needed or be dropped
if not needed at all.

As for VPM-B, this ceiling computation is a bit expensive, this patch
calls the computation function tissue_tolerance_calc() when the
value is actually needed and not before.

This changes the signature of some functions.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:17:39 -07:00
Robert C. Helling
d9306125d9 Do the Boyle compensation when the gradient is needed
and not some time before and store the result in a global variable.

This stores only the bottom gradients and computes the Boyle compensation
when computing the allowed ambient pressure.

As the Boyle compensation needs a reference ambient pressure, to find the ceiling,
we have to iterate this computation until the reference pressure is close enough to
the ceiling.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:15:19 -07:00
Miika Turkia
8e08fdcc85 Clean up CSV import parameters
Continuing the crusade against excessive number of parameters for some
functions. This should be the last of the import functions to be cleaned
up.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-27 08:59:44 -07:00
Miika Turkia
bde2e93f8f Seabear import: remove excessive amount of parameters
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:59:38 -07:00
Miika Turkia
5bda148020 Remove excessive amount of parameters
This removes the excessive amount of parameters on manual CSV import. We
just use appropriate string array than can be directly fed to XSLT
parsing.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:59:15 -07:00
Robert C. Helling
41349c29dd Prepare global state of VPM-B when starting to plan
Otherwise, the results of the calculations tend to be rather
random and irreproducible...

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-23 07:30:23 -07:00
Robert C. Helling
0bb65a17cb Use boyle_compensation in profile
otherwise VPM-B planned profiles seem to violate the ceiling. This needs
the first_stop_pressure to be available also in the profile, so I made
it global in planner.c

Important lesson: If you want to use deco_allowed_depth on a tissue_tolerance
that comes from a VPM-B planned dive, you have to call boyles_law() before
add_segment()!

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20 07:28:00 -07:00
Robert C. Helling
4e89a6020e Get rid of is_ok_vpmb
Since a8ce8, that made deco_allowed_depth work for VPM-B as well, this
function became obsolete but was reintroduced by one of Jan's latest patches.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-18 06:40:50 -07:00
Jan Darowski
499ec9af2f VPM-B: Add surface decompression time.
Now, we calculate the volume of free gas not only based on the deco
time but also time on the surface, needed for the full desaturation.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-08-15 14:32:36 +02:00
Jan Darowski
c0fde4f50f VPM-B: Add Boyles compensation to the planner.
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-08-15 14:21:18 +02:00
Salvador Cuñat
cfac25626b Add support for RBT reported sample value
RBT (Remaining Bottom Time) is a value calculated on the fly by some air
integrated divecomputers, for example Uwatec devices. This value is an
estimation based in some heuristic around time function pressure
gradients. This way, RBT would be the time a diver can spend at actual
depth without running out of gas (taking account of ascent, deco, if
required, and rock bottom gas reserve, if set).
Older Uwatec devices just made the calculus and only stored alarm events
if this time value reached zero, but modern devices store the value each
sample, in minutes.
It seems that Suunto Eon Steel is storing RBT values too, in seconds.

Libdivecomputer has supported RBT for a while, but Subsurface just
printed it to stdout and dropped it.

This adds support for RBT value on subsurface sample structure and shows
it in the profile's info box, right under TTS(calc), if selected, where
these two values can be easily compared by humans.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30 07:43:16 -07:00
Miika Turkia
6953824bd6 CSV import: add support for DC hw info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27 06:34:43 -07:00
Miika Turkia
3ef5dbaacb Add hw info to Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27 06:34:18 -07:00
Miika Turkia
b28517b9b0 Add setpoint support for CSV import
The import of setpoint values is tested with Seabear data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-21 07:34:24 -07:00
Miika Turkia
e98cbdf020 Divinglog import: basic dive info for DB import
This parses the basic metadata of a dive when importing Divinglog
database. (Discarding deleted dives is my best guess as I do not have
that in my sample dive.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-12 13:58:16 -07:00
Robert C. Helling
a7d18a9fa6 Round MOD of gas rather than truncate
For the proper calculation, we need to take salinity and surface pressure
into account (rather than depth = bar * 10 - 10)

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 15:53:49 -07:00
Dirk Hohndel
35dc814105 Add simple test for the dive planner
This sets up a standard dive scenario (30 minutes at 260ft/79m, EAN36 and
Oxygen as deco gases, last stop at 20ft/6m) and calls the planner to set
up a dive plan given certain standard gases.

Instead of trying to verify the complete plans it checks that we switch to
the deco gases at the right depth and the complete duration of the dive
matches our expectation.

The test intentionally fails right now for imperial as we have the wrong
switch depth for Oxygen. See how useful tests are?

On the downside, the test does NOT produce the same plan as Subsurface
when I try to create a consistent setup for both - and I have not been
able to figure out why. There must be some other parameters that I'm not
setting, but I haven't identified them, yet. It's very small differences,
for example in the metric case the stops at 21m, 9m, and 6m are each one
minute shorter in the test than it what Subsurface calculates.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 09:42:38 -07:00
Jan Darowski
bfb9f19080 VPM-B: add next gradient calculation.
It improves (increases) gradients for all the compartments,
so more free gas can be created in the divers body. Next gradients
will converge, so the volume won't exceed the safe limit, indicated
by the crit_volume_lambda parameter.

Function takes time of the last deco in seconds.
Requires vpmb_start_gradient() to be run before.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:59:22 +02:00
Jan Darowski
e7aa686f16 VPM-B: add vpm-b based deco checking.
Check during the trial_ascent() if existing pressure gradient is
smaller than previously calculated max gradient. If not, ascent
is impossible from the vpm-b's point of view.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:24:20 +02:00
Jan Darowski
fad592e43a VPM-B: add initial gradient calculation.
Calculate the max difference between tissue saturation and ambient
pressure that can be accepted during the ascent.
Partial results are kept for later improving in next CVA iterations

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:19:57 +02:00
Jan Darowski
2435d79c0e VPM-B: add nuclei size calculation and nuclear regeneration.
This function calculates the size of nuclei at the end of deco,
then simulates their regeneration, to the moment before the deco.
This is redundant as nuclear regeneration is a very slow process.

Function should be called with time in seconds, just before the ascent.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 22:45:29 +02:00
Anton Lundin
f04b3bc166 Add support for importing O2 sensors from CSV file
This adds support for importing individual O2 sensors from a CSV file,
e.g. an APD log viewer file.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 14:42:05 -07:00
Anton Lundin
5a61c81cc2 Teach copy_string to return NULL on empty string
In subsurface we store no value as a NULL pointer everywhere, but
sometimes some structures returns a empty field as a empty string.

This teaches our helper copy_string to return NULL if you try to copy a
empty string.

This fixes a bug where we store buddy and divemaster in git as empty
strings if they passed via MainTab::saveTaggedStrings().

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-27 05:57:52 -07:00
Dirk Hohndel
e5f4697f91 Rewrite GPS fix matching code for imports from our webservice
The longer I stared at the existing code the less it made sense.
So instead I rewrote it in a way that seems logical to me. And added a
boatload of debugging output (which needs to be removed, of course).

I tested this against more than a hundred dives and it seemed to always
pick the right fix.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-24 22:38:44 -07:00
Dirk Hohndel
ff4b5478b5 Store the user's unit preferences in git storage
Save and load a usually unused copy of the preferences with the units that
were active the last time the dive list was saved to git storage (this
isn't used in XML files); storing the unit preferences in the data file is
usually pointless (that's a setting of the software, not a property of the
data), but it's a great hint of what the user might expect to see when
creating a backend service that visualizes the dive list without
Subsurface running - so this is basically a functionality for the core
library that Subsurface itself doesn't use but that another consumer of
the library (like an HTML exporter) will need.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17 09:48:10 -07:00
Dirk Hohndel
ccc9d80015 Remove all the no longer necessary code that aborts read of first V2 file
This was a poorly implemented hack when we executed the reverse geo lookup
in the main thread and opening a V2 file could take a very long time. We
need to do the "Welcome" message quite differently.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 14:41:56 -07:00
Dirk Hohndel
9a22efb97b Move git related declarations into their own header file
Also change the name of the enum and make sure all the inner functions get
passed the remote transport information.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13 09:14:48 -07:00
Dirk Hohndel
e21cae2d46 Cloud storage: sync the remote after save
This change once again tests if the remote can be reached. Even with a
fairly big data file and a medium speed internet connection the remote
sync is fast enough to call it nearly instantaneous. Maybe a couple of
seconds.

We may need more checks / different heuristics / warnings if the sync
didn't happen, etc. But for now this should allow more reasonable testing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12 13:56:23 -07:00
Tomaz Canabrava
dd5e221388 Temporary dive + temporary site = crash
We always thought that a dive had a dive site
and that a dive really exists. but if we go
to add dive and then go to add dive site,
none of those exist yet and then we got a crash.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-07 08:04:37 -07:00
Robert C. Helling
698b2b133f Only add disclaimer and runtime table if we added deco to replanne dive
As a side effect this changes the signature of plan(): Before it
returned an int that was supposed to be possibly an error but
we never bothered to check it. So now it's bool indicating if the
planner did add stops.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-11 07:57:09 -07:00
Dirk Hohndel
51183f4ee7 Tag list handling: add two new helpers
taglist_added() simply figures out the tags that are in the new list but
not in the original list.

taglist_dump() makes debugging things easier.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-02 12:16:03 -07:00
Dirk Hohndel
f4677d7604 Rename helper function and make it global
save_one_dive_to_mb() is very useful (but there was a namespace collision
with another helper in save_git.c)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-28 11:27:36 -07:00
Robert C. Helling
757c4aab20 Allow images to be added via the web
This adds a new divelist context menu entry which asks for a URL. The file
is retrieved and if it is an image it is added to the cache and the url
is associated to dives as with local files.

NB this currently only works with URLs pointing directly to images. But it
should not be too hard to add the possibility to add a direction via an html
file and its image tags.

To test: open dives/test43.xml and delete the image and then add the URL
http://euve10195.vserver.de/~robert/wreck.jpg

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24 09:36:21 -07:00
Robert C. Helling
98ae7b1f86 Don't load images too often
Factor out image load to find timestamp from loop over dives.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24 09:35:51 -07:00
Robert C. Helling
a0a3c6ec15 Cleaning up variable names in image loading
Use more explicit variabel names and make the get timestamp function actually
return the timestamp rather than getting a pointer argument

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24 09:35:35 -07:00
Miika Turkia
c80d1879b7 Add suit field for CSV import
Fixes #853

[Dirk Hohndel: fixed test compile]

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24 06:50:50 -07:00
Dirk Hohndel
415abeea66 When deleting a cylinder, adapt gas changes
When we delete a cylinder the gas changes in that dive may have to be
adjusted. We didn't do this at all in the past. With this commit we should
be doing this right for a single dive that is being edited.

This does NOT handle multiple dives being edited at the same time (or more
specifically - if you have multiple dives selected and delete a cylinder,
the dives that had the same set of cylinders (other than the displayed
dive) will get that particular cylinder deleted, but won't have their gas
change events (and sensor data in the samples) adapted.

Possibly we should simply prohibit deleting cylinders when more than one
dive are selected.

See #834

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-23 15:27:21 -07:00
Dirk Hohndel
6f7e3d04cb Handle XSLT based imports correctly
XSLT conversions create V2 XML files, but we shouldn't abort when we parse
those without having the user informed about the potential slowness - all
XSLT based imports are slow, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-22 13:20:27 -07:00
Robert C. Helling
61ff7c5f8b Only do safety stop of dive has at least max depth of 10m
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02 09:46:10 -07:00
Miika Turkia
86ac7fdf47 Import support for new Seabear format
This add support for Seabear's new import format that is used by H3 and
T1. In the future also the Hudc  should switch to the new format. The
main difference to the old one is that time stamps are no longer
recorded in the samples, but intervali is specified in the header.

The header contains other useful information as well that we should
build support for. E.g. surface pressure, gas mixes, GF, and mode might
be useful additions later on.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23 05:44:06 -07:00
Jan Darowski
7d37a3f5a6 Refactored image timestamp checking.
Seperated getting image timestamp from picture_load_exif_data() and
ShiftImageTimesDialog::syncCameraClicked() into picture_get_timestamp()
and seperated checking timestamp from dive_create_picture() to
dive_check_picture_time().

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-15 15:47:23 -07:00
Dirk Hohndel
ddff93f096 Event name should be a const char *
This avoids a possible warning when calling this function with a string
literal as second argument.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-11 11:15:03 -07:00
Robert C. Helling
b02bf002a6 Add hashes to images
Upon successfull reading an image file, this computes a SHA1 hash of the
image and saves it with the picture tag in the log file. When a file is
not successfully loaded (for example because the log was created on a
different computer) we look up the hash in a dictionary that maps hashes
to local file names.

That dictionary (actually two for both directions), is loaded on startup
and saved upon destruction of the main window.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27 06:29:44 +01:00
Dirk Hohndel
0ed4356fc2 Display slowness warning before opening a V2 file
This is somewhat invasive as aborting the XML file read requires us to
report things up the recursive parsing chain.

What we really need to do here is to ask the user how they want to use the
data from reverse geo lookup. But for now we only warn about the fact that
this can take a while.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-25 10:05:37 +01:00
Dirk Hohndel
32ad046f56 Allow editing of dive sites
And hook things up when double clicking the globe.

The user experience isn't consistent with what we do on the main tab
(i.e., no coloring of fields that are changed), but it seems to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:35 -08:00
Dirk Hohndel
06e578424e Finally remove location, latitude and longitude from struct dive
With this all references to these members should be gone and all the code
should be switched over to the dive site infrastructure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
6708e06872 Adapt GPS coordinate download from our companion app to dive sites
This is a bit awkward now. We are downloading what looks like fake dives
in the v2 format. So we create a dive site for every single fix.

After we merge those new dive sites into the existing dives we need to
throw away all the dive sites that weren't used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13 14:27:34 -08:00
Dirk Hohndel
d4f2b72148 Make special backup when switching XML versions
Since the last few dozen commits change the format in irreversible ways
and could therefore be destructive and lose data for testers of the
development version, let's try to be extra careful and create "special"
backup files that aren't overwritten by subsequent backups. At least this
way people can go back to the previous state.

Of course people using the git backend don't have to worry about this as
they always can go back to any earlier save.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 23:35:52 -08:00
Dirk Hohndel
32da12664d Switch components for cut/paste dive to dive site logic
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12 21:11:51 -08:00