summaryrefslogtreecommitdiffstats
path: root/planner.c
AgeCommit message (Collapse)Author
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>
2014-04-29Show translated event names in tooltipGravatar Dirk Hohndel
In order for this to work we need to compare against the event type instead of the event name - which makes much more sense to do, anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18Remove unused variables and fix signed/unsigned mismatchGravatar Dirk Hohndel
The depth types are unsigned for dive plan datapoints. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18Comments added to plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Improvement for various bits of the plannerGravatar Robert Helling
Rewrite of the actual planner logic. Now ascend to the next potential stop depth. There the state is cached and we try to ascend to the next stop depth. If we hit the ceiling while doing that we go back to the cached state and wait there for a minute. Then we try again. Then loop. Converted all depth related variables from unsigned int to int. During planning, in a time step the current depth can temporarily be negative and comparisons of a negative int with an unsigned it have not the result I expected ( (int) -2 < (unsigned int) 3 turns out to be false). And we don’t really need the 32nd bit that unsigned buys us for depths. Deco stops are now shown in the same table as manually entered stops in boldface (I removed the second table to save screen estate). The gas shown in the table is still misleading as it means the gas used on the segment leading up to that event. The update of the profile only works partially upon changes in the list of available gases. Treatment of various gases is basically there but needs some more love. The ascent velocity is now provided by a function that takes the current depth as argument. Currently it always returns 10m/min but that will later be variable (and hopefully user configurable). The profile is not redrawn while deco is computed (avoiding an infinite recursion). The table got a new column for the duration of a segment while the old “duration” column was renamed “Runtime” to reflect what it actually shows. Currently, only the run time but not the duration are editable. All deco gases are used from the depth where their pO2 is 1.4bar. This should become more flexible. Calculation of the pressure drop in cylinders without configured volumes is suppressed. This solves a problem with the planner crashing when saving a dive where not all cylinders had been manually given a volume. [Short rant break: Treating 0/0 as air bites back at so many places. E.g. Cylinder data is initialized with memsetting the whole structures to 0. Then later suddenly this totally unconfigured cylinder is being treated as it would contain air. Maybe at some point this was a feature. But it lead to a naughty bug which took me over an hour to resolve. We should seriously reconsider this choice and better move to 209/0 being air if changing this everywhere is not too much trouble] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31Merge branch 'planner-mods'Gravatar Dirk Hohndel
Nothing exciting here, just a few independent changes close to each other. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31Distinguish between entered and calculated waypointsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15Only use a default cylinder if it is explicitly setGravatar Dirk Hohndel
We used to fall back to an AL80 default cylinder, but that meant that a user who doesn't want a default cylinder at all had no way to indicate that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14Convert other users of showError() to the new world orderGravatar Linus Torvalds
The "report_error()" interface is a lot simpler, although some of the C++ code uses QStrings which make them a bit annoying, especially for the varargs model. Still, even with the explicit conversion to UTF8 and "char *", the report_error() model is much nicer. This also just makes refreshDisplay() do the error reporting in the UI automatically, so a number of error paths don't even have to worry. And the multi-line model of error reporting means that it all automatically does the right thing, and reports errors for each file rather than just for the last file that failed to open. So this removes closer to a hundred lines of cruft, while being a simpler interface and doing better error reporting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03Don't use negative gas indexGravatar Dirk Hohndel
This shouldn't happen, but in case we run out of gases we shouldn't use the negative gas index (which is the error return of get_gas_idx()) for the array. Let's fall back to the (incorrect) first gas. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Convert the C code to using stdbool and true/falseGravatar Anton Lundin
Earlier we converted the C++ code to using true/false, and this converts the C code to using the same style. We already depended on stdbool.h in subsurfacestartup.[ch], and we build with -std=gnu99 so nobody could build subsurface without a c99 compiler. [Dirk Hohndel: small change suggested by Thiago Macieira: don't include stdbool.h for C++] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>