Commit graph

36 commits

Author SHA1 Message Date
Robert C. Helling
69de9d8f98 Add planner infra structure for bailout
Add a divemode column to the planner model and a
corresponding field to struct divepoint and fill it
in the corresponding functions.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Robert C. Helling
8e21a65653 Localize global planner state
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-25 20:13:01 +01:00
Robert C. Helling
1f50485732 More VPMB state in special structure
... 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-10-01 23:58:55 +03:00
Robert C. Helling
e6545a7b0f Store a table of deco stops in planner
... in addition to struct diveplan which combines all kinds
of information

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
82aac4efff Make plan take dive and decotimestep as arguments
...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-08-29 06:49:44 -07:00
Robert C. Helling
7b18be2a50 Adopt planner state caching to new struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Dirk Hohndel
ee1bf18189 Add SPDX header to tests
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Stefan Fuchs
6f21d2749e Tests for minimum gas
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-19 17:11:52 -07:00
Robert C. Helling
bd89e33e76 Fix typo in saturation/desatureation rates
This patch eliminates the difference between the saturation and
desaturation rates. This was probably once meant as a conservative
measure but the desaturation rate was increased rather than the
saturation rate (which is probably a typo, as reported by Stefan).

Since there is no good basis for this anyway, this patch sets
both factors to 1.0 (and if accepted the whole factor business
should be removed).

This makes our deco times slightly longer. But in the past,
we had introduced a 1.2% fudge factor in the critical radius
calculation to add conservatism and match the benchmark better.

Removing this fudge factor brings us close to the benchmarks.
Expected test values updated.

Reported-by: Stefan <sjti@gmx.net>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-19 15:29:40 -08:00
Robert C. Helling
e31714d9b2 Set up gaslist only in the beginning of diveplan
In the beginning of the diveplan, divedatapoints of zero
duration indicate available gases with the depth giving
the suggested switch depth. Zero-duration datapoints in
the middle of the dive do not have this meaning and should
thus be ignored when composing the gaslist.

The tests should have these gas defining segments in the beginning.

This fixes a problem when replanning a dive that would change
to random gases during deco.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-11 08:31:42 -08:00
Anton Lundin
c2ea3c2616 Our tests are actually GUILESS
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-05 14:45:25 -08:00
Robert C. Helling
935734100f Rename prefs.deco_mode to prefs.planner_deco_mode
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Rick Walsh
7b891904e7 Rename conservatism_level to vpmb_conservatism
Make the variable purpose less ambiguous

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:29:56 -07:00
Rick Walsh
b827107619 Update TestPlan for divedatapoint storing cylinder id instead of gasmix
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:07:55 -07:00
Tomaz Canabrava
21e8b1e363 Fix compilation with the new folder architecture
A few more fixes for things that broke in commit 7be962bfc2 ("Move
subsurface-core to core and qt-mobile to mobile-widgets").

[Dirk Hohndel: slightly edited and overlap with Linus' patch removed]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 12:32:36 -07:00
Dirk Hohndel
4ceb65938a Silence warnings in testplan.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:50:37 -08:00
Rick Walsh
cd0963c26f TestPlan: update known Subsurface runtimes
The purpose of testing against known Subsurface runtimes is to warn (when test
is run in verbose mode) if the runtime has altered. Before the next release, we
should update the known Subsurface runtimes to match current behaviour, so we
are alerted when we change something during the next release cycle.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 15:18:48 +01:00
Rick Walsh
117d13485c TestPlan: include subsurfacestartup.h
Commit 9d8b0ad introduces the copy_prefs function, and uses it to replace prefs
= default_prefs. We need to include subsurfacestartup.h for it to work in
testplan.cpp, otherwise TestPlan_build fails.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 15:16:49 +01:00
Dirk Hohndel
9d8b0addf9 Correctly copy preferences
When just assigning one structure to the other we copy the string
pointers. If we then modify those strings in the copy, we happily free
the strings of the original. And then resetting the preferences equally
happily reused those strings, pointing to long since freed memory.

I think what I did now is excessive for the current use case in that it
copies a ton of strings that are unset in the default_prefs. But I figured
this is a rarely used function and I might as well do it correctly.

Also, once we implement multi user support with per user preferences we
will be copying completely populated preferences around (at least that's
my guess).

Fixes #940

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06 10:19:43 +01:00
Rick Walsh
fe9958380e TestPlan: Set VPM-B conservatism to zero
The VPM-B benchmark results are all based on nominal/zero conservatism, so we
should make sure we use zero conservatism in the tests.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-27 12:53:46 -04:00
Rick Walsh
084b4152e4 TestPlan: Add test for repeating dive
If variables were accidentally carried through from a previous calculated plan,
subsequent plan could be affected.  This test aims to detect if this happens.
Commit 8994270 corrected such a bug.  If it were reverted, this test would fail
(as it should).

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-22 07:36:37 -07:00
Robert C. Helling
10d8a625d0 Adopt expected times in TestPlan
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:19:10 -07:00
Robert C. Helling
3a7109e44e Changed qInfo() to qDebug()
... as the former was introduced only in Qt 5.5 in order to make the
test build also with 5.4

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 15:13:43 -07:00
Rick Walsh
d15a1db428 TestPlan: Do not re-declare bool result
Fixing this error makes TestPlan pass again.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-30 09:14:58 -07:00
Rick Walsh
954c30c4cf VPM-B Tests: Compare against known Subsurface runtime
We should compare the calculated runtime against the runtime previously
calculated by Subsurface, expecting them to match exactly, in order to detect if
a change has been made.  We still compare against a benchmark, allowing some
difference.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-29 20:06:56 -07:00
Rick Walsh
1e7dd49234 Update expected runtime of VPM-B test to match benchmark
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-29 20:06:32 -07:00
Rick Walsh
961c218c06 VPM-B Tests: Output first ceiling
This is useful for determining why we calculate a difference profile

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-29 20:06:28 -07:00
Rick Walsh
6c43685eda Dive planner tests: pass dives that are close to expected duration
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 17:55:59 -07:00
Rick Walsh
e47f62f869 VPM-B: Add more planner tests
Add more VPM-B planner tests.  The "expected" total run time is taken as the
total run time produced by the Fortran VPM-B program.  For all these tests, the
results are within two minutes, which is a good result, but most are classified
as a "fail".

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:57:26 -07:00
Rick Walsh
e25404c9f2 Test VPM-B Correct expected dive time in comment
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:57:09 -07:00
Rick Walsh
3ea7ee1934 Test another VPM-B dive plan
This adds a test for 100 m for 60 min dive on trimix using VPM-B

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:57:06 -07:00
Robert C. Helling
fbce8a0378 Add a test for the VPM-B mode of the planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-23 07:30:33 -07:00
Robert C. Helling
56913191af Fix typo in test and some numbers
With these values I reproduce the runtimes from the UI.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:56:48 -07:00
Dirk Hohndel
5766d1894c Adapt the test to the API change
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 22:30:02 -07:00
Dirk Hohndel
35dc814105 Add simple test for the dive planner
This sets up a standard dive scenario (30 minutes at 260ft/79m, EAN36 and
Oxygen as deco gases, last stop at 20ft/6m) and calls the planner to set
up a dive plan given certain standard gases.

Instead of trying to verify the complete plans it checks that we switch to
the deco gases at the right depth and the complete duration of the dive
matches our expectation.

The test intentionally fails right now for imperial as we have the wrong
switch depth for Oxygen. See how useful tests are?

On the downside, the test does NOT produce the same plan as Subsurface
when I try to create a consistent setup for both - and I have not been
able to figure out why. There must be some other parameters that I'm not
setting, but I haven't identified them, yet. It's very small differences,
for example in the metric case the stops at 21m, 9m, and 6m are each one
minute shorter in the test than it what Subsurface calculates.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 09:42:38 -07:00