aboutsummaryrefslogtreecommitdiffstats
path: root/planner.c
AgeCommit message (Collapse)Author
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>
2014-06-01Switch more functions to use gasmix typeGravatar Dirk Hohndel
This time it's get_gas_string(). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Next step to using gasmix instead of o2/heGravatar Dirk Hohndel
This changes the divedatapoints and functions that deal with them. It changes plan_add_segment(), create_dp(), gasToStr(), and tankInUse() to consume gasmix instead of o2/he. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Use proper typesGravatar Dirk Hohndel
This is step one of many to use gasmix instead of int o2/he. Right now some of these changes look ridiculous because after changing a few lines we immediately go back to o2 = get_o2(gas). The reason is that I wanted to convert a hand full of functions at a time. So in this commit I only change validate_gas(), get_gas_from_events() and get_gasidx() to use a struct gasmix instead of int o2, int he. This state builds and survived some mild testing. Let's continue on top of that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Encapsulate the horrid gas encoding in gas change eventsGravatar Dirk Hohndel
We should never pass permille values around as integers. And we shouldn't have to decode the stupid value in more than one place. This doesn't tackle all the places where we access O2 and He "too early" and should instead keep passing around a gaxmix. But it's a first step. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Planner: correctly track gas usedGravatar Dirk Hohndel
This part of the algorithm was off as part of it (but not all of it - crazy, I know) assumed the old semantic for gas changes where the new gas was introduced at the end of the segment and not at the beginning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Planner: track gas used even if we don't have a real cylinderGravatar Dirk Hohndel
We tracked gas used by simulating a dive with a cylinder - but for that we need a cylinder size and working pressure. If the user just enters a gas but no cylinder data (likely in order to figure out how much gas is used so that she then can pick a big enough cylinder), we didn't show any gas consumption. It kinda sucks to add another member to the cylinder structure, but this seemed far more reasonable then some other, global structure that independently tracks gas usage. This just seemed to make sense. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Planner: more fixes for gas trackingGravatar Dirk Hohndel
Gas switches are now for the current segment, not for the next. We can only track gas for cylinders for which we have size / working pressure information. Print a warning for others. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01Planner: add warning if the plan consumes more gas than providedGravatar Dirk Hohndel
If we have size information including working pressure for a cylinder, we already track the expected pressure at each way point - this way we can also alert the user if more gas is consumed than is available in the cylinder. This does not include sound planning strategies like "rule of thirds". It simply assumes that you won't be able to breathe down the cylinder past about 10bar (using 0 as cutoff seemed silly). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31Planner: don't include the disclaimer in the dive plan detail widgetGravatar Dirk Hohndel
We want the disclaimer in the final dive that can be printed, but it's distracting when shown while planning the dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31Planner: look harder to find the right gasGravatar Dirk Hohndel
Silly bug - while we normally fill the cylinders in a tight group with no "null" cylinders in the middle, since we copy from an existing dive and since that may end up with an odd sequence of cylinders, we need to continue looking at ALL cylinders and not stop with the first one that's empty. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30Planner: don't do unnecessary work on empty dive plansGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30Planner: start the ascend with the strongest allowed deco mix.Gravatar Robert C. Helling
In analyze_gaslist() we were only keeping gases that had their .depth above the current depth, i.e. where we could switch to in the future. Now we take note as well of the strongest gas that we could have already switched to and switch to it before we attempt to ascend. [Dirk Hohndel: minor whitespace and code cleanup] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29Planner: clean up the function that tracks our gasesGravatar Dirk Hohndel
This doesn't add gases. It just makes sure they are there. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29Planner: track gas consumption in cylinders and samplesGravatar Dirk Hohndel
This commit is a little bigger than I usually prefer, but it's all somewhat interconnected. - we pass around the cylinders throughout the planning process and as we create the plan we calculate the gas consumption in every segment and track this both in the end pressure of the cylinder and over time in the samples - because of that we no longer try to calculate the gas consumption after being done planning; we just use what we calculated along the way - we also no longer add gases during the planning process - all gases have to come from the list of cylinders passed in (which makes sense as we should only use those gases that the user added in the UI or inherited from a the selected dive (when starting to plan with a dive already selected) With this patch I think we are close do being able to move all of the planning logic back into the planner.c code where it belongs. The one issue that still bothers me is that we are juggling so many dive structures and then keep copying content around. It seems like we should be able to reduce that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Planner: record the new dive at the correct timeGravatar Dirk Hohndel
We don't want to do this when calling plan() from createTemporaryPlan() - we only want to record the dive at the end of createPlan(). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28Planner: add missing disclaimerGravatar Dirk Hohndel
This may not be the best way to do it, but it's better than just printing "(null)". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Paint the dive red if the user is breaking ceiling on the planner.Gravatar Tomaz Canabrava
This patch paints the dive red if the user is breaking ceiling on the planner - it's quite fast, it analizes the depth over the max(tissue_1 .. tissue_16) and changes the color of the profile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Fix warningGravatar Dirk Hohndel
When converting from assert to if I forgot to invert the comparison... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Merge branch 'Planner'Gravatar Dirk Hohndel
2014-05-26Planner: convert assert into warningGravatar Dirk Hohndel
We need to make sure we let the user know about this in a more user friendly way... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Reenabled copying the diveplan to dive notes.Gravatar Robert C. Helling
Gas consumption calculation fixed. Pressure difference still needs cylinder size to be set. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26Use get_o2() and get_he() instead of accessing permilles directlyGravatar Robert C. Helling
This gets rid of problems with air. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Add waipoints when changing ascend rate in plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Implement ascend rate according to GUE standard proceduresGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Fix bug in handling of fake SAMPLE_EVENT_PO2 eventsGravatar Dirk Hohndel
In commit bcdd6192fe45 ("Show translated event names in tooltip") I was too aggressive in replacing the checking for event names with checking for event types. It turns out that we are abusing an existing event type in the planner (and use a different event name to mark the difference). By just checking for the type this now caused incorrect information to be displayed in the info box (a simply "PO2 warning" on a Suunto D9 could turn into a "Bailing out to OC" notice). The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from libdivecomputer. Once we have those, we can do this the right way. For now we just fall back to also checking the event name (which is what I wanted to get away from so translated names don't trip us up). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>