aboutsummaryrefslogtreecommitdiffstats
path: root/dive.h
AgeCommit message (Collapse)Author
2015-10-01Add support to "split" a dive with surface time in the middleGravatar Linus Torvalds
Right now this requires that (a) the dive have only one divecomputer associated with it. Trying to split a dive with multiple dive computers would be *much* harder to do, since you'd have to try to line up the surface interval between computers etc. So just don't do it after downloading multiple dive computers for the same dive. (b) there must be at least one minute between the sample that came up to the surface and the sample that goes down again. If you just peeked your head above the surface, don't try to split things into two dives. Maybe we can relax this for freediving or something. also note that the split dive will only get new numbering if the dive that was split was the very last dive in the divelist. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-26Cloud storage: try to work around weird Windows rename issueGravatar Dirk Hohndel
In some cases the rename of the cache directory would fail in my testing. Based on code that Lubomir provided, this tries a Windows specific implementation of folder rename if the QDir based one fails for some reason - but obviously only if we are running on Windows. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-22Be much more careful about merging divesGravatar Linus Torvalds
This patch changes the dive merging to be much more careful about things, because it turns out that we had several small oddities that caused big merge issues. The oddities are: - the dive "duration" is actually how long we spend under water. But that means that when we do "dive->when + dive.duration.seconds" to calculate the end of the dive, that is nonsensical if you came up to the surface in the middle of a dive. Now, normally you don't see profiles like that, but once you start merging dives together, it can go from "small detail" to "dominant factor". - We have two different cases of merging: the automatic "merge new dive computer download if it looks like the same dive" (which always has a merge offset of 0, since we merge it as a new dive computer) and the "merge two different dives into one longer dive. The code assumed that it could look at the "downloaded" flag for the dive to check one or the other, but that doesn't really work. Reading a dive from an XML file isn't any different from downloading it. So we need to change the logic to determine what kind of merge it is to actually check the passed-in time offset. With this, Stuart Vernon's test-case of eight dives with short surface intervals in between end up merging correctly into one dive. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Reported-by: Stuart Vernon <stuartv@force2.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-19Uemis downloader: start downloading using the correct dive IDGravatar Linus Torvalds
The logic to pick the initial dive ID for the uemis downloader was very confused, and did not work at all when restarting a download when the Uemis filled up, and the "Force download all dives" flag was set. It also required a rather odd Uemis-specific callback from the download UI because of how it picked the initial ID. This changes the logic to just look at the list of downloaded dives when restarting, which simplifies the logic a lot, gets rid of the odd special callback, and also means that the whole "Force download" issue just goes away. It seems to work now. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-11Add checkbox to force images to match divesGravatar Robert C. Helling
Give the user the possibility to attach images to a dive even when the times do not match Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-05Uemis downloader: fix and move helper functionGravatar Guido Lerch
This function is only used in the Uemis downloader, and it got broken when we switched to using a separate table for the downloaded dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31Introduce double depth_to_bar()Gravatar Robert C. Helling
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-31Calculate ceiling only when it is neededGravatar Robert C. Helling
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-31Do the Boyle compensation when the gradient is neededGravatar Robert C. Helling
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-27Clean up CSV import parametersGravatar Miika Turkia
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-25Seabear import: remove excessive amount of parametersGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25Remove excessive amount of parametersGravatar Miika Turkia
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-23Prepare global state of VPM-B when starting to planGravatar Robert C. Helling
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-20Use boyle_compensation in profileGravatar Robert C. Helling
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-18Get rid of is_ok_vpmbGravatar Robert C. Helling
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-15VPM-B: Add surface decompression time.Gravatar Jan Darowski
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-15VPM-B: Add Boyles compensation to the planner.Gravatar Jan Darowski
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-30Add support for RBT reported sample valueGravatar Salvador Cuñat
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-27CSV import: add support for DC hw infoGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-27Add hw info to Seabear importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-21Add setpoint support for CSV importGravatar Miika Turkia
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-12Divinglog import: basic dive info for DB importGravatar Miika Turkia
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-05Round MOD of gas rather than truncateGravatar Robert C. Helling
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-05Add simple test for the dive plannerGravatar Dirk Hohndel
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-03VPM-B: add next gradient calculation.Gravatar Jan Darowski
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-03VPM-B: add vpm-b based deco checking.Gravatar Jan Darowski
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-03VPM-B: add initial gradient calculation.Gravatar Jan Darowski
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-03VPM-B: add nuclei size calculation and nuclear regeneration.Gravatar Jan Darowski
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-06-27Add support for importing O2 sensors from CSV fileGravatar Anton Lundin
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-27Teach copy_string to return NULL on empty stringGravatar Anton Lundin
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-24Rewrite GPS fix matching code for imports from our webserviceGravatar Dirk Hohndel
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-17Store the user's unit preferences in git storageGravatar Dirk Hohndel
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-16Remove all the no longer necessary code that aborts read of first V2 fileGravatar Dirk Hohndel
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-13Move git related declarations into their own header fileGravatar Dirk Hohndel
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-12Cloud storage: sync the remote after saveGravatar Dirk Hohndel
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-07Temporary dive + temporary site = crashGravatar Tomaz Canabrava
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-05-11Only add disclaimer and runtime table if we added deco to replanne diveGravatar Robert C. Helling
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-02Tag list handling: add two new helpersGravatar Dirk Hohndel
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-04-28Rename helper function and make it globalGravatar Dirk Hohndel
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-24Allow images to be added via the webGravatar Robert C. Helling
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-24Don't load images too oftenGravatar Robert C. Helling
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-24Cleaning up variable names in image loadingGravatar Robert C. Helling
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-24Add suit field for CSV importGravatar Miika Turkia
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-23When deleting a cylinder, adapt gas changesGravatar Dirk Hohndel
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-22Handle XSLT based imports correctlyGravatar Dirk Hohndel
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-02Only do safety stop of dive has at least max depth of 10mGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23Import support for new Seabear formatGravatar Miika Turkia
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-15Refactored image timestamp checking.Gravatar Jan Darowski
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-11Event name should be a const char *Gravatar Dirk Hohndel
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-02-27Add hashes to imagesGravatar Robert C. Helling
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>