summaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
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>
2014-09-19Tissue saturation plot a la Sherwater PretelGravatar Robert C. Helling
This adds a toolbox icon to turn on a tissue plot inspired by the bar graph of the Sherwater Petrel, It shows the inert gas partial pressures for individual compartments. If they are below the ambient pressure (grey line) they are shown in units of the ambient pressure, if they are above, the excess is shown as a percentage of the allowed overpressure for plain Buehlmann. So it has the same units as a gradient factor. Thus also the a gradient factor line (for the current depth) is shown. The different tissues get different colors, greener for the faster ones and bluer for the slower ones. Positioning and on/off icon action still need some tender loving care. Signed-off-by: Robert C. Helling <helling@atdotde.de> 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-11CCR patch: adapt code for diluent cylinder pressures (3)Gravatar willem ferguson
This patch implements the cylinder pressure calculations for diluent gas in CCR dive computers. This is the third patch for achieving this. The following were performed: 1) Add two lines to try_to_fill_sample() in parse-xml so that diluent cylinder pressures are stored from XML dive log file into structures of sample. 2) Add one line to populate_plot_entries() in profile.c so that the diluent cylinder pressures are copied from structures of sample to structures of plot_info. 3) add three constant #defines in profile.h 4) change populate_pressure_information() in gaspressures.c in order to take into account pressure calculations for the diluent cylinder, calling subordinate functions in the appropriate way. 5) change create_plot_info_new() in profile.c in order to initiate the pressure calculations for the diluent cylinder. 6) Implement two debugging functions (one in profile.c, another in gaspressures.c). These debugging functions are activated by means of #defines. Two function calls dealing with oxygen pressure are currently commented out. They will be activated in the following patch that attends to CCR oxygen partial pressure calculation. [Dirk Hohndel: rather massive whitespace cleanup] Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> 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-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-06-29Only calculate deco stops, TTS and NDL every 30sGravatar Anton Lundin
This introduces a limiter that we only calculate deco stop, TTS and NDL with a minimum of 30s intervall and just reused the values from the previous sample in other cases. I run my OSTC3 at 2s sample intervall so this is a 15x speedup in that case. Signed-off-by: Anton Lundin <glance@acc.umu.se> 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-23Be more consistent in partial pressure namingGravatar Henrik Brautaset Aronsen
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂. They all mean the same, but it's better to be consistent Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09Fix incorrect argument order for %.*fGravatar Dirk Hohndel
Strangely, *prinf() on Linux appears to do the right thing in either order (my guess is based on the type of the two values?), but on Windows things go badly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08Change character for liter in SAC values as wellGravatar Dirk Hohndel
And fix the bug that in the info overlay SAC was always given in metric values. And try to reduce the number of places in which we calculate the unit conversions... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>