aboutsummaryrefslogtreecommitdiffstats
path: root/dive.h
AgeCommit message (Collapse)Author
2014-10-28Improve tank handling for CobaltGravatar Dirk Hohndel
This isn't Cobalt specific, this is specific to dive computers that indicate the first tank that's in use with a gaschange event that coincides with the first sample. We need to make sure that we suppress showing that gas change event (regardless which cylinder it goes to) and instead set the correct cylinder index from the very start of the dive. This works with the test data I have and doesn't seem to break thing with any of the files that I tried... but I'm worried that this is not the right way to do things. Fixes #742 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28dive.h: add a variant of FOR_EACH_PICTUREGravatar Lubomir I. Ivanov
This prevents a warning caused by -Waddress, that the address of 'displayed_dive' will always be defined. Exact macro variant suggested by Dirk. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28Parse meta information from Seaber logGravatar Miika Turkia
This will parse date information from Seabear log file and skips the "header" data to allow parsing of the CSV content. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-26Support for importing Poseidon MK6 logsGravatar Miika Turkia
This patch adds support for importing the logs from a Poseidon MK6 rebreather. This DC produces logs that contain of a .txt file that has all the meta data and a .csv file that contains the sample readings. The CSV file is different from the others in that it has a line per each sample reading at given time. Thus we have to merge all the lines from one point in time into one sample reading of ours. [Dirk Hohndel: addressed some compiler warnings] Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19Make planner work again for CCR divesGravatar Robert C. Helling
The latest CCR patches had rendered the planner not usable for CCR dives. This patch corrects this (and reenables the CCR set point column for segments). The problem was that a new member setpoint of struct divepoint had been introduced, but there was already po2 which had the same meaning. This patch merges the two and renames them setpoint to prevent future confusion. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-13CCR patch: Reorganise the oxygen partial pressure calculationsGravatar willem ferguson
This patch responds to the side effects that the CCR code has had with respect to ceilings in OC dives and dive plans. Dive ceilings are now calculated correctly again. The following were performed: 1) remove the oxygen sensor and setpoint fields from the gas_pressures structure. 2) Re-insert setpoint and oxygen sensor fields in the plot_data structure. 3) Remove the algorithm that reads the o2 sensor data and calculates the pressures.po2 value from function fill_pressures() in dive.c and save it as a separate function calc_ccr_po2() in profile.c. 4) Activate calc_ccr_po2 from function fill_pressures() in profile.c. 5) Move the relative position of the call to fill_pressures() within the function create_polt_info_new() in profile.c. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12CCR patch: Calculate the correct partial gas pressures for CCR divesGravatar willem ferguson
This patch adds code to the function fillpressures() in dive.c to allow calculating o2 pressures, based on the data from the po2 sensors in the system. The following changes were made: 1) add code to perform po2 calculations for CCR with 1, 2 or 3 oxygen sesnors. 2) Add four fields to the gas_pressures structure in dive.h. This allows communication of data between the function that calls get_pressures() and the return of partail pressure values to the calling function. 3) Delete the fields for setpoint and gas partial pressures from the structure plot_info. All partial pressures (from instruments as well as calculated) now reside in the pressures structure that forms part of plot_info. 4) Perform changes in several parts of profile.c to make use of the pressures structure in plot_info. [Dirk Hohndel: yet again massive whitespace cleanup] Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12CCR patch: Oxygen partial pressuresGravatar willem ferguson
This patch does three things: 1) A new function fill_o2_values() is added to profile.c. This fills all oxygen sesnsor and setpoint values that have been zeroed before in order to save space in the dive log. This recreates the full set of sensor values obtained from the original CCR xml log file. 2) Function fill_o2_values() is activated in function create_ plot_info_new() in profile.c 3) The calling parameters to function fill_pressures() in dive.c are changed. The last parameter is now a pointer to a structure of divecomputer. This will be needed in the last patch of the present series of three patches. [Dirk Hohndel: minor whitespace cleanup] Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12Start sanitizing gaschange event informationGravatar Linus Torvalds
Decode the gasmix data into a sane format when creating the event, and add the (currently unused) ability to specify a gas change to a particular cylinder rather than (or in addition to) the gasmix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-18Helper function for partial pressure calculationGravatar Robert C. Helling
This patch introduces a new structure holding partial pressures (doubles in bar) for all three gases and a helper function to compute them from gasmix (which holds fractions) and ambient pressure. Currentlty this works for OC and CCR, to be extended later to PSCR. Currently the dive_comp_type argument is unused. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-17Fix compilation with C99Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25CCR code: Split profile.c into two files, with gas caluclations separate.Gravatar Willem Ferguson
This patch implements a separation of the code for gas pressure calculations from the rest of the code in profile.c. The latter file is now split into: profile.c and gaspressures.c. The details of the transferred functions is given at the top of gaspressures.c. The following chnages were made: 1) dive.h: The function types of calculate_depth_to_mbar and depth_to_mbar were made non-static in order to make them available within gaspressures.c. 2) profile.c: Prototypes for the functions in gaspressures.c were inserted at the top of profile. Ten functions were transferred from profile.c to gaspressures.c 3) gaspressures.c as well as a short header, gaspressures.h were created. For the gas pressure calculations for CCR dives, gaspressures.c forms the immediate basis for further code development. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19Mark manually entered waypoints as suchGravatar Dirk Hohndel
With this information, when we re-plan a dive we can bring the user right back to the point where they ended - they have the waypoints in the dive pointes table and handles are shown on the right points in the profile - and the rest of the dive is once again calculated by the planning algorithm. For now this state is lost when saving the dive file as we don't add this flag in the sample to our saved files. So if we don't find any samples marked as manually added we add ALL of the samples as way points on the diveplan and the user has to manually remove the ones that were calculated. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19Planner: bring sanity to the SAC rate handlingGravatar Dirk Hohndel
The old implementation was... let's call it creative. This tries to actually get things right instead of using magic. Don't pretend that double values are ints. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16Don't always clear the dive before selectively copyingGravatar Dirk Hohndel
This will be needed when pasting the data back into a (set of) dive(s). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16Cut'n'paste for dive data: implement some infrastructureGravatar Dirk Hohndel
This commit doesn't do anything, yet. It just puts in place helper infrastructure that will later allow us to cut and paste parts of the data of one dive into another dive (or set of dives). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-13Make SAC values in planner settings respect unit settingsGravatar Robert C. Helling
So far, the fields for the two SAC rates did not show a unit and were implictly l/min. Now they respect the settings for volume units. This was harder than I thought for two reasons: 1) Imperial units for SAC are cuft/min but a typical value would be .70. So I made the point the field prefix and what is entered is actually hundreth of cuft per minute. 2) I had to get the rounding right in order not to get effects like 20l/min become .70 cuft/min (19800 ml/min internally) which would then become 19l/min when switching back. While being at it, I gave the gradient factors '%'-signs as units. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Picture handling: cleaning up the messGravatar Dirk Hohndel
We had pointers to data structures on the stack which we frequently reallocated. These data structure contain basically a filename and an offset. We then create a hash of the pointers to those datastructures with the filename being the key. And then we passed those pointers around through a Qt model(!!!) only in order to then later look up by filename what the offset might be. I am at a loss for words for the lunacy behind this design. How about we just remember the offsets and pass the integers around? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Bail out of deco calculation after 48h or dive timeGravatar Robert C. Helling
With very low values of GFhigh and setting the last stop depth to 6m it is possible to create dives that need infintie decompression time. This ends deco after 48h and replaces the dive plan with an error message. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-04Planner: show mean depthGravatar Dirk Hohndel
Almost invisible, mostly looking like an odd bug in the profile code, there was a tiny red line at depth 0 in the planned profile. Turns out that was the missing mean depth. We didn't populate enough data in the dive computer of the dive we generated from the plan (and the length of the depth line was incorrectly determined by the duration of the dive instead of the duration stored in the dive computer). Fixes #570 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03Use Qt date localization instead of translated stringsGravatar Dirk Hohndel
This gets us consistent date format everywhere. The reordering of month name and day of the month didn't work correctly on Windows, anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-30Implement the functionality of remove_picture.Gravatar Tomaz Canabrava
Added the remove_picture functionality, with code shamelessy stolen from remove_event, and hoock it up with the interface. Fixes #650 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-17Replace cylinder_is_used with is_cylinder_usedGravatar Anton Lundin
is_cylinder_used uses get_cylinder_index as underlaying function that does the right thing with with respect on how to find the closest matching cylinder, and handles both types of gaschange events correctly. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Suppress XML preamble in CSV exportGravatar Sergey Starosek
To obey <xsl:output omit-xml-declaration="yes"/> element one should rely on libxslt to do its job instead of writing document himself. Discussion on this subject can be found at http://comments.gmane.org/gmane.comp.gnome.lib.xslt/3839 Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Change in logic while aplying gps fixes to divesGravatar Salvador Cuñat
We were actually searching dives which match the dowloaded position fixes. So we're also trying to take into account if the fix is automatic or no based on a limited amount of predefined strings (bad idea, as the user can change in companion app settings the predefined string). This way, in actual implementation, if program concludes that a fix has been manually got or, simply, the user is unlucky enough to have all the position fixes out of the dive time, find_dive_n_near() function will pair fix and dive in an ordered way (1st fix -> 1st dive; 2nd fix -> 2nd dive ...) which is probably erroneous, except for manual position fixes. BTW actual implementation can't pair the same gps position with more than one dive, which would be the case, e.g. in repetitive dives while at anchor in the same point. The patch changes the logic: - Search positions for defined dives (instead of dives for defined positions) without care if position has manually or automatically been set. - Only take care of those dives that don't have a position yet. - It makes two assumptions: a.- If the position fix has been taken during the dive time, is correct. If there are more than one inside the dive time, takes the first one (closest to the DC's reported time). b.- If not during diving time, the correct one is the nearest fix before the dive begins (also the usual case if manually fixed from the smartphone just before jump into the water). But will work too if there is only one fix *in SAME_GROUP range* after the dive (another usual case). - Finally, as copy_gps_location() in dive.h is used only here, let it take care of naming the dive if user hasn't named it yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12Rename event: correctly replace event with new oneGravatar Dirk Hohndel
I don't like that the event structure includes the variable length array. That really makes it a pain to change the name of an event (on the flip side, freeing events is easier I guess). Anyway, to correctly rename an event we need to actually remove the event from the correct dc and then add a new event with the new name. The previous code was insane (it only worked if the new name was of smaller or equal length, otherwise it had a beautiful buffer overflow). And of course we need to do this both for the current_dive and the displayed_dive. Fixes #616 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Add support for importing pressure from CSV filesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Add helper functions to ensure we have sane tag listsGravatar Dirk Hohndel
There should never be empty or duplicate tags on those lists. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Add support for importing TTS from CSV filesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Add support for importing NDL from CSV filesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Add support divecomputer based TTSGravatar Anton Lundin
Since earlier have we had support for our own calculated TTS. This adds support for holding TTS values reported by a dive computer. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-08Fix picture loadingGravatar Dirk Hohndel
Signed vs unsigned comparisons are such a pain. Since we want offsets to be +/- 30 minutes around the dive we need to allow negative offsets - but duration_t was defined as uint32_t. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-05Remove gasmix_is_nullGravatar Robert C. Helling
The semantic of fo2==fhe==0 to mean "same gasmix as before" apparently is not used anywhere and gets in the way of the semantic "this is air". If there is really need for mix meaning "same as before", please use another value, e.g. one with a specific negative percentage. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04Planner: don't set cylinder start and end pressure when adding diveGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04Planner: only track gas when planning a diveGravatar Dirk Hohndel
When adding a dive we don't have SAC data so we should simply have the user manually enter their gas consumption. That still doesn't work, but this is one required step to get it to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: make planner act on displayed_diveGravatar Dirk Hohndel
Instead of constantly creating and deleting dives and messing with the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: add clone_dive helperGravatar Dirk Hohndel
This is kind of the inverse to copy_dive(). Instead of duplicating all the data that the dive points to, it moves it to a new struct dive and zeroes out the old one so there are no two sets of pointers to these data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03Add a "smart strdup" helper named copy_string()Gravatar Dirk Hohndel
If the string is non-NULL, copy it, otherwise return NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: add helper function to copy and clear a diveGravatar Dirk Hohndel
This way we can safely copy around dives (specifically, copy the dive to be displayed / edited into the displayed_dive). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-02UI restructure: use a global variable to hold the dive we show / editGravatar Dirk Hohndel
There is massive confusion about what we display when and where and which dive structure (or pointer to a dive structure) contains which information at which stage. This is the first step towards restructuring all of this. This creates a global variable displayed_dive which at any point in time should be what is displayed on screen (both in the profile and in the maintab). It removes the editedDive concept from MainTab. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01Show ascent gas consumption separately in plannerGravatar Robert C. Helling
In the worst gase you have to provide gas for your buddy during all the ascent. So you should have the amount of gas used in ascent as a reserve. This patch makes the planner notes display that value separately. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25Make pO2 settings functional in plannerGravatar Robert C. Helling
Spin boxes for pO2 are now hooked up to preference values. Adding new cylinders (or changing their fo2) computes the MOD accordin to the current value of decopo2. Note that chaning the limits for deco pO2 does _not_ automatically update the switch depth of all cylinders as those might have been manually entered. Furthermore, MOD has now to option of rounding to multiples of a given depth. That is used for the automatic switch depth which are now always multiples of 3m (so that EAN50 is switched to at 21m rather than 22m). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-18Use __typeof__ instead of typeof in the headerGravatar Thiago Macieira
This allows us to compile Subsurface with strict C or C++ mode. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-14User survey: force running the survey from command lineGravatar Dirk Hohndel
This way people can test the dialog much easier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11Provide for a dive_computer_type variable within dc structureGravatar Willem Ferguson
This patch lays the foundation for differentiating between open-circuit(OC)dives and rebreather dives (CCR). The following were done: 1) In dive.h add an enum type dive_computer_type 2) In dive.h add two more fields to the dc structure: a) dctype (an enum field indicating dc type) b) no_o2sensor (indicating number of o2 sensors for this dc) 3) In parse-xml.c add a function trimspace that strips any whitespace from a string. This is used by two functions: utf8_string as well as by get_dc_type, described below. The pointer to buffer is not changed in order to ensure consistency when the buffer is freed. 4) In parse-xml.c add a function get_dc_type. This parses the dc_type string from xml and assigns an enum value which will later be returned to the function that parses the dc variables. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11Allow the user to delete a dive computer from a diveGravatar Dirk Hohndel
This can't be the only dive computer, of course. Goes nicely with the ability to reprder them. Fixes #551 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09Picture handling: switch to stronger typed offsetGravatar Dirk Hohndel
Also change the on file XML to be even easier to read by making it a duration as well (which gets us '32:34 min' instead of un-typed seconds). This is backwards compatible, it will happily read what was written with the previous commit). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08Picture handling: change data structure to store offset instead timestampGravatar Dirk Hohndel
It makes no sense to store a 64bit time stamp with every picture. Even the 32bit offset (in seconds) from the dive start is WAY overkill. But switching to that makes the code much more simple in a number of spots. And makes what is saved to the XML file easier to read, too. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08Picture handling: keep picture list sortedGravatar Dirk Hohndel
And simplify the list handling algorithm. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner: only copy cylinders that were used in the template diveGravatar Dirk Hohndel
This was only semi-implemented the first time around. Now we really only copy the ones that are indeed used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>