aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
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-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-06-22Prevent potential division by zeroGravatar Dirk Hohndel
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-01-25More descriptive variable in calls to get_dive_gasGravatar Anton Lundin
In a previous patch, 37830bdb ("Always show deco gas as dive gas") the semantic of the last variable was changed. This updates other calls to this function. This is nothing but documenting changes. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-24Correcly look at all relevant dive computer structuresGravatar Dirk Hohndel
When calculating maxima for a dive, we need to take data from all existing dive computer structures plus potentially also a fake dive computer structure that is just passed in in order to create a meaningful profile. Commit 86c961614bfa ("Actually walk all dive computers, don't just claim to do so") missed that second case and no longer took the fake_dc into account, breaking the display of dives that don't have samples. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-20Fix build problemGravatar Dirk Hohndel
In commit 86c961614bfa ("Actually walk all dive computers, don't just claim to do so") I somehow managed to forget one hunk of the patch (I was editing out debug messages). And I clearly forgot to test compile the final patch as pushed. Apologies. 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-19Actually walk all dive computers, don't just claim to do soGravatar Dirk Hohndel
If the first dive computer had pressure samples, but the second one (and no higher one) did, then we would draw a flat horizontal line for the tank pressure graph (but lable it with the correct pressures). This routine that is hunting for the actual maxima and minima does have to really go through all dive computers, not just "this one and up". 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-05Display CCR setpoint values on the po2 graphGravatar Willem Ferguson
When a CCR dive is viewed and the toolbar button for PO2 is activated, both the PO2 (green line) and the O2 setpoint (red line) are shown. This allows evaluation of the PO2 in the CCR loop with respect to the pre-configured O2 setpoint. The setpoint graph can be disabled from the Preferences/Graphs tab by checking the appropriate checkbox. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-03Interpolate running depth when necessaryGravatar Miika Turkia
The running depth must be interpolated when sample interval is more than 10 seconds. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01Fix mean depth on info boxGravatar Miika Turkia
The running depth must be divided by current time to get the average depth. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31Information overlay: include the moving mean depthGravatar Dirk Hohndel
Apparently this is useful for some tech divers. We urgently need an option to turn off the graph and this text, though, as I am guessing that this is just distracting and annoying to 90+% of our users. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28Whitespace cleanupGravatar Dirk Hohndel
Plus removal of a few qDebug() calls I introduced earlier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28Populate the plot info with tts informationGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18Free event list names on clear_events()Gravatar Anton Lundin
clear_events() just reset the start point of our event list, but didn't actually free the event names that got "cleared". Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-17Recording average depth dataGravatar Robert C. Helling
This is the calculation that is needed to display a running average in the profile. It adds a new member plot_data.running_sum which can be turned into the running average by dividing by plot_data.time. Right now this isn't used by the UI. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-04Don't interpolate pressure while dragging waypointsGravatar Robert C. Helling
A profiler session in the planner shows that for deep long dives a significant amount of CPU time is spent in populate_pressure_information() which interpolates the cylinder pressure graphs. This patch introduces a "fast" flag for the replot of the profile which is active while the mouse button is still pressed and that suppresses this calculation. In the future, this flag could be used for other responsiveness tunings of the plot. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-01Context menu entry to change setpointGravatar Robert C. Helling
This patch adds a context menu entry to add a setpoint change event. In particular, this can be used to turn a logged dive into a CCR dive. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20Correctly computer O2 partial pressureGravatar Robert C. Helling
I had forgotten a / 1000.0 in the conversion of partial pressures from (double) bar to (int32) mbar. Fixes #763 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19Fix warnings in debug_print_profiledataGravatar Anton Lundin
Use the right format, now when those variables are integers and not doubles. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18Cleaning up pressuresGravatar Robert C. Helling
Added comment about meaning of o2pressure in struct plot_info. Turned some pressures from double (in bar) to pressure_t (in mbar) [Dirk Hohndel: picked parts of this patch and dropped others] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18Fix issues in CCR handlingGravatar willem ferguson
In commit 0d7c192e6edc ("For CCR dives, the diluent cylinder is the current cylinder") a few things got broken. This tries to undo those changes and adds expanded XML output. 1) Calculate correct partial pressure of oxygen to be plotted on dive profile, taking into account the oxygen sensor data. Currently, erroneously, OC PO2 values are shown, due to an erroneous calling parameter to fill_pressures(). 2) Read start and end cylinder pressured correctly. some wrong assignments were done in file.c. This is now corrected and the correct cylinder pressures are shown in the equipment tab. 3) Write correct cylinder pressures to XML. Currently the data for the two cylinders are written to XML the wrong way round (diluent pressures = oxygen and vice versa). 4) Expand XML output: a) Write oxygen sensor data to XML b) Write no_of_02sensors to XML Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17For CCR dives, show plot for diluent and O2 cylinder pressuresGravatar Robert C. Helling
Also fixes a bug in the diluent pressure interpolation Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17For CCR dives, the diluent cylinder is the current cylinderGravatar Robert C. Helling
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the diluent cylinder (rather than the O2 cylinder). This eliminates special cases. Now, for CCR, we have to handle the O2 cylinder in addition (rather than the diluent in addition). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17More CCR code cleanupGravatar Dirk Hohndel
Random constants are bad. Let's use the indices that we already calculated (and true and false if we mean boolean values). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12profile.c: fix a bug in calculate_gas_information_new()Gravatar Lubomir I. Ivanov
In a test case loading dives/test35.xml results in a infinite(-like) loop (Note: possibly requires the partial pressure plots enabled). calculate_gas_information_new() has an 'if' branch to update the cylinderindex to a dive's diluent_cylinder_index, but it does not consider that said index can be set previously to -1. This results in a random neighbour memory assigned as &dive->cylinder[-1].gasmix and passed to fill_pressures(..). Following the calculations in the function the He gas, can receive a bad value (e.g. for the test case in the E+6 ranges). Said value is then used in DivePlotDataModel()::pheMax() (defined by MAX_PPGAS_FUNC()) resulting in one of the loops (the 3rd one) in DiveCartesianAxis::updateTicks() to loop indefinitely. Fixes #759 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08Remove leftover last_setpointGravatar Anton Lundin
Back in 24c491053cd9 ("Don't overwrite zero setpoints") the filling of last_setpoint logic was removed. This clears out the last bits left over. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07The po2 argument of addS_segment is the setpoint, not the pO2 at that timeGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07Don't overwrite zero setpointsGravatar Robert C. Helling
As we agreed, in memory we don't zero repeated setpoints and thus zero setpoints don't have to be overwritten by the last setpoint value. This corrects the deco ceiling with CCR dives that bailout to OC. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04Use the CCR corrected gases for EAD and END calculationsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04Prepare for PSCR calculationsGravatar Robert C. Helling
Calculations for passive semi-closed rebreathers are pretty much like OC except the pO2 is lower bey a certain (SAC dependent) factor. This patch introduces the corresponding calculations in case dctype == PSCR which is so far never set and there is currently no UI for these calculations. As pO2 is SAC dependent it takes a certain attempt at getting it and drops to defaults from the prefs otherwise. As there is no UI at this point and I also don't have any dives, this has not received much testing, yet, but it compiles. At least. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-03Calculate nitrogen and helium gas pressures for CCR after import from CSVGravatar willem ferguson
Currently the gas pressures stored in structures of pressure are calculated using the gasmix composition of the currently selected cylinder. But with CCR dives the default cylinder is the oxygen cylinder (here, index 0). However, the gas pressures need to be calculated using gasmix data from cylinder 1 (the diluent cylinder). This patch allows setting the appropriate cylinder for calculating the values in the structures of pressure. It also allows for correctly calculating gas pressures for any open circuit cylinders (e.g. bailout) that a CCR diver may use. This is performed as follows: 1) In dive.h create an enum variable {oxygen, diluent, bailout} 2) Within the definition of cylinder_t, add a member: cylinder_use_type This stores an enum variable, one of the above. 3) In file.c where the Poseidon CSV data are read in, assign the appropriate enum values to each of the cylinders. 4) Within the definition of structure dive, add two members: int oxygen_cylinder_index int diluent_cylinder_index This will keep the indices of the two main CCR cylinders. 5) In dive.c create a function get_cylinder_use(). This scans the cylinders for that dive, looking for a cylinder that has a particular cylinder_use_type and returns that cylinder index. 6) In dive.c create a function fixup_cylinder_use() that stores the indices of the oxygen and diluent cylinders in the variables dive->oxygen_cylinder_index and dive->diluent_cylinder_index, making use of the function in 4) above. 7) In profile.c, modify function calculate_gas_information_new() to use the above functions for CCR dives to find the oxygen and diluent cylinders and to calculate partail gas pressures based on the diluent cylinder gas mix. This results in the correct calculation of gas partial pressures in the case of CCR dives, displaying the correct partial pressure graphs in the dive profile widget. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-01Remove code that zeroes out duplicate oxygen sensor and temperature valuesGravatar willem ferguson
Remove the code that changes all duplicate oxygen sensor, setpoint and temperature values from a dive log to zero. One of the motivations is that a zero setpoint value indicates an Open Circuit dive segment, not Closed Circuit Rebreather. The code in dive.c is removed and the comments for the corresponding restoration code that restores the last known values into sensor or temperature with zero values is [fill_o2_values() in profile.c] is changed to apply to the present situation. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-27profile.c: remove a variable which is set but not usedGravatar Lubomir I. Ivanov
fill_o2_values(): struct gas_pressures *pressures; Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27profile.c: remove unused variables in calculate_ccr_po2()Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@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-14CCR patch: Correction of inconsistency in profile.cGravatar willem ferguson
fill_o2_values() in profile.c: Robert identified the inconsistency of po2 assignmemts when using OC dives as opposed to CCR dives. This is corrected here. OC dives still need to be processed in this function because the po2 values have not been initialised anywhere else before thos code executes. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-14Reshuffle CCR voting logic and minor clean upsGravatar Robert C. Helling
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-12Remove unused variablesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> 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-10-11Keeping up the fight for whitespace consistencyGravatar Dirk Hohndel
Sadly, some of the code being fixed is my own... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-11CCR patch: Import and store oxygen sensor dataGravatar willem ferguson
This patch allows the importing of oxygen sensor and setpoint data from Poseidon CCR dive logs. 1) Change parse-xml.c to read up to three oxygen sensor values from xml. and to store the information in sample structures 2) Change parse-xml.c to read o2 setpoint values fro xml and to store it in sample structures 3) Change dive.c to delete all sensor and setpoint values where subsequent samples have sensor/setpoint values that are the same. 4) Change profile.c to store the sensor/setpoint values from the samples into plotinfo. 5) Change the sample Poseidon xml log in the dives directory to ensure the correct order and hierarchy of the dive and divecomputer nodes. [Dirk Hohndel: minor cleanup, removed debug code, whitespace] Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-19Add tissue saturation plot to tooltipGravatar Robert C. Helling
This adds a graphical representation of tissue loadings at the current moment during the dive to the tooltip box. The layout is inspired by the Sherwater Petrel.Add tissue saturation plot to tooltip Signed-off-by: Dirk Hohndel <dirk@hohndel.org>