aboutsummaryrefslogtreecommitdiffstats
path: root/dive.h
AgeCommit message (Collapse)Author
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>
2015-02-25Display slowness warning before opening a V2 fileGravatar Dirk Hohndel
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-13Allow editing of dive sitesGravatar Dirk Hohndel
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-13Finally remove location, latitude and longitude from struct diveGravatar Dirk Hohndel
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-13Adapt GPS coordinate download from our companion app to dive sitesGravatar Dirk Hohndel
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-12Make special backup when switching XML versionsGravatar Dirk Hohndel
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-12Switch components for cut/paste dive to dive site logicGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Get trip location from dive's dive siteGravatar Dirk Hohndel
This adds another useful helper function as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Show dive coordinates on map based on dive siteGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Save and parse dive site structures to XMLGravatar Dirk Hohndel
Read and write divesite sections in the XML file. Read divelogs of version 2 and create dive site structures on the fly. Read version 3 files that have divesiteid instead of location / gps. Saves version 3 files where dives no longer have location and gps but instead refer to a divesiteid The commit contains quite a few fprintf(stderr,...) in order to allow better monitoring of the parsing / transforming of locations and gps to dive sites. This will need to be removed later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Add dive site data structureGravatar Dirk Hohndel
This leaves location and gps coordinates in the struct dive to allow a step by step migration. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11Remove redundant functionGravatar Dirk Hohndel
We had two functions doing exactly the same thing. Let's drop the one with the highly confusing name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10Only update tags in the selected dives if they were changedGravatar Dirk Hohndel
If current_dive and displayed_dive still have the same tags then we shouldn't touch the tags of other selected dives. Fixes #826 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-20Use SAC from preferences for PSCR oxygen dropGravatar Robert C. Helling
The ratio between SAC and oxygen metabolism rate can be assumed constant but not the metabolism rate. So we better base our calculation on the ratio that uses the SAC from the preferences as that pairs well with the O2 consumption from the preferences. Hence we ran remove the sac parameter from fill_pressures(). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17Save predefined SACGravatar Robert C. Helling
When planning a dive, the gas consumption is based on a user configured SAC. Thus we should use that SAC and not try to recompute it from samples. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... and repair a failed rebase (sorry). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Maintab combobox to set dive typeGravatar Robert C. Helling
still needs some work Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09Add more infrastructure for a separate dive tableGravatar Dirk Hohndel
This will allow us to download the dives from the dive computer into a separate table just for that purpose and not into the main dive_table. I really dislike the code that's in place that dates back to the very earliest code written for Subsurface. Dumping the dives straight into the main dive_table seems really stupid to me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06Add missing divemaster field to the manual importGravatar Dirk Hohndel
No idea why I didn't notice earlier that this was missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31Use unit selection for XSL transformation on CSV exportGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31Add duration format to XSLT callGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>