aboutsummaryrefslogtreecommitdiffstats
path: root/planner.c
AgeCommit message (Collapse)Author
2014-07-15Planner: Report CNS and OTUGravatar Gaetan Bisson
In add_plan_to_notes(), call update_cylinder_related_info() to compute CNS and OTU data for the planned dive. Report their values in the notes. Besides CNS and OTU, update_cylinder_related_info() also recomputes the SAC, which is harmless. Note that both dive->cns and dive->maxcns need to be zeroed out for the CNS value to actually be recomputed. Signed-off-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11planner: Correct pO2 comparisonGravatar Anton Lundin
Don't compare pO2 with a bool, compare it with the result of the ?: expression instead. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11Planner: fix calculation when it is safe to surfaceGravatar Dirk Hohndel
We were comparing with a negative depth which apparently confused the algorithm. Fixes #611 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Use user entered pO2 limits for high pO2 warnings.Gravatar Robert C. Helling
Furthermore, replaced gasmix accessors instead of .permille directly (think: air!) Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Limit the scope of gasidx in add_plan_to_notesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Remove unnecessary get_gasidx callGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-07Planner: Show gas consumption in pressure units as well and warn if not ↵Gravatar Robert C. Helling
enough reserve. Signed-off-by: Robert C. Helling <helling@atdotde.de> 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-04Remove unused labelGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04Clear out old events in create_dive_from_planGravatar Anton Lundin
Previous code where accumulating events from each iteration of the planning. This code clears the old ones before adding new ones. Fixes #595 [Dirk Hohndel: removed printf, updated comment, slightly moved the code, added parenthesis to silence warning] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03Remove non-existant variable from debug statementGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03Planner: Add backgas breaksGravatar Robert C. Helling
If the corresponding checkbox is checked the planner does interrupt pure O2 deco after 12min for 6min on cylinder 0. To make this work for air I removed the gasmix_is_null logic. I guess that makes the planner feature complete for the next release. [Dirk Hohndel: trivial merge into latest master] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03UI restructure: use displayed_dive for add dive and plan diveGravatar Dirk Hohndel
This gets rid of the stagingDive and stops the constant adding and removing of dives from the divelist (that was an INSANE design, seriously). When adding or planning a dive all work is now done in the dedicated displayed_dive. Add dive mostly works - when the user clicks save the dive is added to the dive list and selected. Plan dive is mostly untested. It passed trivial "start planner, save" testing so it's not entirely broken, but I'm sure there's more work to be done there. 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-01Use gas_mod helper instead of local versionGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> 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-27Close snprintf warningGravatar Anton Lundin
Gcc yells: warning: format not a string literal and no format arguments This closes that warning. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25Hook up UI elements for ascent rates to plannerGravatar Robert C. Helling
That provides some UI elements that were recently introduced with function of allowing the ascent rates of the planner to be configured by the user. I tried to make it work both with senisble as well as with imperial units. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23CSS and translation improvements to dive planGravatar Henrik Brautaset Aronsen
Use CSS styling to format the dive plan instead of deprecated HTML tags. Also make sure that we aren't sending HTML tags to translate() Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-11Have explicit "%s" format strings in printf style statementsGravatar Robert C. Helling
Not having a format string that explicitly references the arguments is considered a potential security issue in code. This gets rid of a compiler warning that turned into an error on Fedora 21. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11Deal with some uninitialized variable warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10Planner: use the actual setting for GF low at max depthGravatar Dirk Hohndel
Using the default_prefs value makes no sense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09planner.c: prevent an uninitialized warningGravatar Lubomir I. Ivanov
"warning: 'bottom_time' may be used uninitialized in this function" we set it to zero for now. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09planner.c: use implicit struct initializerGravatar Lubomir I. Ivanov
We should either use mplicit struct initializers (empty braces { } or double braced zero {{ 0 }}) or memset the struct. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> 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-08Planner: incease step size in deco ascends to 3 secondsGravatar Robert C. Helling
Triple time step in deco ascents to improve responsiveness of interactive deco calculation. [Dirk Hohndel: split commit into two] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05Switch to the new gasmix structure in dump_planGravatar Anton Lundin
dump_plan wasn't updated when the switch from he/o2 to gasmix was done in the planner code, this makes it compile again. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05Planner: Avoid bogus segments with 0 timeGravatar Robert C. Helling
Don't show a stop if we continue at this depth. This resolves a problem when there are more than two waypoints during deco at the same depth. This can happen at 6m when there is a gaschange to O2 and the last stop depth is 6m (which turns the 3m stop into another 6m stop). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05Planner: Change 'lasttime' only if we printed something in the plan.Gravatar Robert C. Helling
This makes the 'segment' durations equal the runtime differences even when we don't display transitions in deco. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04Disclaimer included in the printed diveplanGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> 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>
2014-06-03Planner: more accurately track assumed cylinder pressuresGravatar Dirk Hohndel
This makes things more consistent. The equipment view and the sample view of the beginning and end pressure for each cylinder correspond (and the beginning pressures of each cylinder segment are correctly reflected in the samples). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03CCR code: Change to sample structureGravatar Willem Ferguson
1) All the variables in the sample structures are strongly typed 2) Two additional types were declared in units.h: o2pressure_t bearing_t 3) The following variables were added: diluentpressure o2setpoint o2sensor[3] 4) Changes to a number of files were made to chanf sample->po2 to sample->po2.mbar bearing to bearring.degrees Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner: make the warnings visually stand out moreGravatar Dirk Hohndel
HTML is nice here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner: add a few more line breaks in the html notesGravatar Dirk Hohndel
This looks much better now. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner: Show gas changes at the correct depth.Gravatar Robert C. Helling
Gas changes (can) have a bogus waypoint following at the same depth with 0 time. Those were confusing the decision whether to show a waypoint. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner: Show waypoints for gas changes but no double depthsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Planner note logic and layout improvedGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Layout improvements to the dive planGravatar Robert C. Helling
Changed to html. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02Planner: fix typo that broke tank pressure trackingGravatar Dirk Hohndel
Oops, that's embarrassing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02Planner: warn about high pO2Gravatar Dirk Hohndel
If the user entered part of the plan exceeds a pO2 of 1.6, include a warning about that in the notes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02Optionally strip diveplan to bare minimumGravatar Robert C. Helling
There are new check-boxes to modify the look of the diveplan in the notes. The old behaviour appears with "verbatim display", others are shorter, runtimes, stoplengths and transitions being optional. Also round to full meters and minutes to remove optical clutter. To be done: Remember these setting in the config. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Remove is_air() and convert its users to gasmixGravatar Dirk Hohndel
Also make gasname() and get_gas_string() global functions (which allows us to delete code elsewhere). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Create simple non-thread-safe "gasname()" functionGravatar Linus Torvalds
Every single user of the get_gas_name() function wanted to just use the result to create a message or printout, and that made the interface a bit cumbersome. This adds a "gasname()" wrapper that returns a static buffer with the result in it, which is neither pretty nor thread-safe, but is a much simpler interface to work with. Our dive planning isn't multi-threaded, so nothing should care. [ This also converts a few open-coded gasname debug printouts to use the helper function, resulting in prettier printouts and less code ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01More cleanup for planner.cGravatar Dirk Hohndel
Remove unused variables and make the ifdef'ed out debug code work again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Change add_plan_to_notes() to operated on gasmixGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Switch verify_gas_exists to take gasmix argumentGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>