aboutsummaryrefslogtreecommitdiffstats
path: root/core/planner.c
AgeCommit message (Collapse)Author
2017-12-01Actually compute variations in backgroundGravatar Robert C. Helling
This reenables the computation of plan variations but now in a separate thread. Once finieshed, a signal is sent to update the notes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01Cut off excessive deco timesGravatar Robert C. Helling
before we run out of memory. Diving deep with air and small GFhigh can cause those (try GF 30/70 at 75m with 25+min bottom time) Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25In planner.c remove unused variable o2break_doneGravatar Stefan Fuchs
Reported-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25Localize global planner stateGravatar Robert C. Helling
For UI responsiveness, we need to be able to run the planner in the background. This needs the planner state to be localized (and we need to pass a pointer around). In order to not let too many lines overrun (and to save typing in the future) I have renamed instances of struct deco_state to ds. Yes this should have gone to a separate commit but I accidentally commit --amend'ed it. Computing of planner variations is temporarily disabled. Unlock the planner when returning early So we don't deadlock in add dive and recreational mode (which use the planner without actually planning). Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25Run variations calculation in backgroundGravatar Robert C. Helling
but there are still side effects and thus it crashes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-09Planner don't add minimum gas switch time more than onceGravatar Stefan Fuchs
Avoid adding the minimum gas switch time more than once even if we skip some available deco gas. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-08VPMB: calculate time of final ascent properlyGravatar Rick Walsh
Commit d15779a calculates final stop based on stoplevels[2], but if final stop is 6m/20ft, we should use stoplevels[3]. This fixes it. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08VPMB profile: use deco_time rather bottom_time from plannerGravatar Rick Walsh
This makes the calculations in profile.c a little simpler, especially now we adopt consistent final ascent rate to determine deco_time since d15779a27 Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08VPMB: calculate deco_time assuming final ascent always takes the same timeGravatar Rick Walsh
If we consider the actual time to ascend from the final stop when calculating deco_time, then slowing the final ascent can lead to the final stop being extended, which is completely nonsensical. For consistency with the original VPMB implementation, we can't ignore the final ascent time completely, but if we assume it is always the same (take default ascent rate of 9m/min) then slower the final ascent won't lead to a longer final stop. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-08VPM-B: move bottom_time into deco_stateGravatar Rick Walsh
Removing ext variable from profile.c should facilitate future performance gains Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-11-04Disable o2 break option if last stop is not at 6m/20ftGravatar Stefan Fuchs
Disable the possibility to plan o2 breaks of option "last stop at 6m/20ft" is not set. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04O2 breaks code enhancements and cleanupGravatar Stefan Fuchs
Remove unused variables o2time and breaktime or convert into boolean. Never consider minimum gas switch time when switching to o2. Reflect this behavior also in the UI. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-31When O2 breaking, add segment with current mix not with nextGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-31Don't do the minimal gaschanging stops during O2 breaktingGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-31Correct time bookkeeping when doing O2 breaksGravatar Robert C. Helling
These got mangled with previous changes to stop length determination. Fixes #662 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-30whitespace (planner.c)Gravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-10-30VPMB profile: use bottom_time to calculate deco_time in plannerGravatar Rick Walsh
This corrects the issue where the displayed ceiling in the profile was "broken" by the planner, especially for shorter and shallower dives. Also fixes issue outside of planner where the deepest VPM-B ceiling was shown too early, messing up the deco_time calculation. VPM-B plans respond to change in O2% in gas as expected (in my testing) Fixes: #630 Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-10-18init_deco correctly identify previous dives and report overlapping divesGravatar Stefan Fuchs
When changing the date/time of a dive in the planner the dive may end up in a totaly new position in respect to date/time of other dives in dive list table. It can be moved to the past or the future before or after other existing dives. It also could overlap with an existing dive. This change enables identification of a new "virtual" dive list position and based on this starts looking for previous dives. Then it (as before the change) does init the deco calculation with any applicable previous dive and surface interval. If some of these applicable dives overlap it returns a neg. surface time which is then used in the planner notes to prohibit display of results. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Tidy up code in planner.c - create_dive_from_plan()Gravatar Stefan Fuchs
Tidy up the code which creates the first sample for time = 0 to make clear that the info for this does NOT come from the first planner point (dp). No functional change. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Fix dump_plan debug codeGravatar Stefan Fuchs
This fixes some debug code to dump the diveplan which is usually not compiled and used. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Planner creating dive from plan: No pressure for 1st sample with new gasGravatar Stefan Fuchs
In the planner when a dive is created from the diveplan every first sample with a new gas shouldn't have a pressure value added. Otherwise the interpolation code for the pressure graph in the profile will draw the pressure graph incorrectly. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16In planner prefer best_first_ascend_cylinder for gas breaksGravatar Stefan Fuchs
Up to now the cylinder for gas breaks was hardcoded to first cylinder. With this change the best_first_ascend_cylinder is used if its O2 is <=32%. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16Don't confuse cyl with same gasmix with best_first_ascend_gasGravatar Stefan Fuchs
When calculating the dive plan in the planner don't accidently use another gas with same gasmix instead of the gas stored as "best_first_ascend_gas". This is important if you have e.g. a bottom stage and back gas with same gas mix because then you always want to start your ascent with the gas you used in last entered dive planner point. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-01More VPMB state in special structureGravatar Robert C. Helling
... and reset deco information in profile ceiling computation. The planner test then needs to know about the struct holding the deco state. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20Remove option to apply GFlow at maxdepthGravatar Robert C. Helling
This option should have never been there. This is not how gradient factors are supposed to work. It would only trick users to use the wrong value.. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Compute variations of plansGravatar Robert C. Helling
Print out partial derivatives of stop times with respect to variation of depth and duratin of last manual segment. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Store a table of deco stops in plannerGravatar Robert C. Helling
... in addition to struct diveplan which combines all kinds of information Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Cache all Buehlmann factorsGravatar Robert C. Helling
not just the last one. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Allow for o2 breaks in binary search stop time finderGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Find deco stop time by binary search instead of iterationGravatar Robert C. Helling
This allows to go to much smaller granularity without severe performance penalty. It should also increase performance for long decompression times. Currently this leads to missing cached tissue factors, the caching has to be adopted to this. Also, for the time being this breaks the bottom gas breaks feature. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Make plan take dive and decotimestep as argumentsGravatar Robert C. Helling
...rather than use a global variable and a macro. This should be a no-op in preparation to allow planning several versions of a dive. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-07-20Unify sample pressure and o2pressure as pressure[2] arrayGravatar Linus Torvalds
We currently carry two pressures around for all the samples and plot info, but the second pressure is reserved for CCR dives as the O2 cylinder pressure. That's kind of annoying when we *could* use it for regular sidemount dives as the secondary pressure. So start prepping for that instead: don't make it "pressure" and "o2pressure", make it just be an array of two pressure values. NOTE! This is purely mindless prepwork. It literally just does a search-and-replace, keeping the exact same semantics, so "pressure[1]" is still just O2 pressure. But at some future date, we can now start using it for a second sensor value for sidemount instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-26Adopt planner state caching to new structGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26Move planner notes to separate fileGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-04-29Add SPDX header to core C filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-20Identify user provided notes in plain text in replanGravatar Robert C. Helling
This is another attept at the problem if identifying a potentially user supplied text in the dive notes upon replannig a dive. It gets rid of the user visable position markers (*!* and ***) and cirumvents problems with mark-up by first converting the old notes to plan text (assuming that user only enters plain text in the notes field as we do in other places as well). Then the automatically added part is identified by locating the disclaimer in the text (if the user edited/delted the disclaimer or changed langue in between it is her problem to manually delete the old plan). Everything from the disclaimer on is deleted and replaced by the new plan. If the disclaimer is not found, the new plan is appended to the old notes. This way we make sure no information gets automatically deleted. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-04-20Show % after Büllmanns GFsGravatar Jan Mulder
2 strings in the planner output showed based on "Bühlmann ZHL-16B with GFLow = " gradient factors without % after the factor. While this is fine for an abbreviated form like GF 40/80, this looks strange for a verbose sentence like the 2 corrected ones. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-16Handle notes from plannerGravatar Stefan Fuchs
New strategy to identify old planner output in notes when replanning a dive: Text anchors ("*!*" and "***") added for planner output For backwards compatibility: If there is no anchor but an old table delete everything. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-06Move version and date around notes to save spaceGravatar Robert C. Helling
This prints this information in the header near "Subsurface" where I guess at least the version information belongs. Plus it saves a line. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-04-06Add creation date and Subsurface version to planner outputGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-28Always show notes when replanningGravatar Robert C. Helling
... as per popular request. Plus adding const keyword to constant strings. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-28Fix missing slash in markupGravatar Robert C. Helling
Reported-by: Stefan Fuchs Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-28Handle notes in replanGravatar Robert C. Helling
Upon replanning a dive, we want to delete the old dive plan in the notes and replace it with the actual. This fixes a problem when we failed to detect the old plan due to the deco model name appearing in the disclaimer that was used as a marker for the notes. This patch also adds translation markers for the deco model name strings.. Fixes #285 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-19Tests for minimum gasGravatar Stefan Fuchs
Add automatic tests in TestPlan for minimum gas: - Copy minimum gas result (pressure) to diveplan. - Add cylinder size and working pressure for bottom gas to every dive in TestPlan Hint: Unrealistic cylinder sizes (100l, 200l) have to be used for the very long and deep dives in TestPlan - Add minimum gas check for every dive - Add two additional test dives in TestPlan which produce sane minimum gas results with 24l tank Hint: Deco check for these new dives is commented out at the moment Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-19Prevent overflow in minimum gas calculationGravatar Stefan Fuchs
For the "crazy" long and deep dives in "TestPlan" an overflow happened here. Rearranged the calculation to have more margin. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-13Use GFLow, GFHigh (not GFlow, GF Low, GF low).Gravatar Martin Měřinský
2017-03-12planner.c: fix a couple of float -> int cast warningsGravatar Lubomir I. Ivanov
Use lrint() to fix both: 1) core\planner.c:902:23: warning: conversion to 'int' from 'doub le' may alter its value [-Wfloat-conversion] 2) core\planner.c:907:21: warning: conversion to 'int32_t' from ' double' may alter its value [-Wfloat-conversion] Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-11Merge branch 'master' of https://github.com/dje29/subsurfaceGravatar Dirk Hohndel
2017-03-11Fix build after mergesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-11Change type of divedatepoint.depth to depth_tGravatar Robert C. Helling
... for consistency, while we are at it. There are still some internal depth variables which are ints somebody might take a go at those. Signed-off-by: Robert C. Helling <helling@atdotde.de>