Commit graph

13 commits

Author SHA1 Message Date
Dirk Hohndel
7a18edddbb Prevent time travel in planner dive edit
If the user enters an absolute time that is before the previous waypoint,
silently assume that this is a relative time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 16:22:38 -08:00
Dirk Hohndel
ae3886b987 Make Cancel work in dive planner dialog
With this a partially planned dive is indeed thrown away when hitting
Cancel.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 14:52:31 -08:00
Linus Torvalds
ab7aecf16e Simplify dive planning code
This simplifies the dive planning code by:

- allowing empty gas mixes (which means "pick previous gas")

- avoiding unnecessary strdup/free calls (this requires us to handle
  "const char *" in the parsers, but that was already true from a code
  standpoint, just not a type one)

- re-use the "plan()" function for a successful dive plan, rather than
  open-coding the dive plan segment handling.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 14:10:44 -08:00
Dirk Hohndel
e6afd055d8 Fix two bugs with the gas entry code in the dive planner
First, I forgot to pass in the idx into the gas callback function - this
way for the dynamically created dives we always used air for anything but
the first segment.

Second, when selecting a gas from the drop down (with the mouse or by
typing), the GtkEntry doesn't receive that text and therfore we never
picked up those gases.

We now also track the 'changed' event for the GtkComboBox, but never add
the text we get their to the completions (as by definition they are
already there).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 12:53:54 -08:00
Dirk Hohndel
d396f4afd8 Add simple debug function to planner
This allows you to dump the diveplan structure

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 12:49:07 -08:00
Dirk Hohndel
d3570508b1 Move planner UI into planner.c
There should be NO other changes in this commit - just moving the code and
adjusting the includes (and adding the entry point to display-gtk.h).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 11:23:14 -08:00
Dirk Hohndel
989cf37fcf Remove the now obsolete hard coded test_plan
This was just a crutch to get something out there for people to play with.
With the ability to input a plan in place this is now obsolete.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 08:51:26 -08:00
Dirk Hohndel
1b0ddfbbe2 Dive planner: add gas change events & start dive with the correct gas
When incrementally building dives with gas changes there are still some
serious issues and inconsistencies. But at least now the gases in the dive
we create appear to be correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 08:38:55 -08:00
Dirk Hohndel
85ed689dc0 Support relative times in diveplanner input "on the fly" mode
This had gotten lost when updating the profile on the fly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07 08:13:23 -08:00
Dirk Hohndel
be9be189f7 Display dive profile of the dive we plan, as we plan it
As the user enters data into the entry fields, that data is validated and
as soon as there is enough data we start constructing a dive profile,
including the final ascent to the surface, including required deco stops,
etc.

This commit still has some serious issues.

- when data is input that doesn't validate, we just print a warning to
  stdout - instead we need to change the backgroundcolor of the input
  field or something.
- when we switch to the last dive in order to show the profile we don't
  actually search for the last dive - we just show the first one in the
  tree. This works for the default sort order but is of course wrong
  otherwise

I'm sure there are many other bugs, but I want to push it out where it is
right now for others to be able to take a look.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06 22:15:03 -08:00
Dirk Hohndel
c8830ffe48 Add the ability to cache our deco state
We kept reduing all the deco calculations, including the previous dives
(if any) for each segment we add to the dive plan. This simply remembers
the last stage and then just adds to that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06 11:40:21 -08:00
Linus Torvalds
92a8fde9c2 Do a minimal hook-up of the dive plan tree view to the
actual planning

Yes, you can actually enter your segments now.

No, it's not wonderfully user-friendly.  If you don't enter enough
segments to create a dive plan, it will just silently fail, for example.
And the <tab> key that should get you to the next editable segment
doesn't.  And so on.  But it kind of works.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05 15:51:57 -08:00
Dirk Hohndel
cca847791a First stab at simplistic dive planning
This comes with absolutely no gui - so the plan literally needs to be
compiled into Subsurface. Not exactly a feature, but this allowed me to
focus on the planning part instead of spending time on tedious UI work.

A new menu "Planner" with entry "Test Planner" calls into the hard-coded
function in planner.c. There a simple dive plan can be constructed with
calls to plan_add_segment(&diveplan, duration, depth at the end, fO2, pO2)

Calling plan(&diveplan) does the deco calculations and creates deco stops
that keep us below the ceiling (with the GFlow/high values currently
configured). The stop levels used are defined at the top of planner.c in
the stoplevels array - there is no need to do the traditional multiples of
3m or anything like that.

The dive including the ascents and deco stops all the way to the surface
is completed and then added as simulated dive to the end of the divelist
(I guess we could automatically select it later) and can be viewed.

This is crude but shows the direction we can go with this. Envision a nice
UI that allows you to simply enter the segments and pick the desired
stops.

What is missing is the ability to give the algorithm additional gases that
it can use during the deco phase - right now it simply keeps using the
last gas used in the diveplan.

All that said, there are clear bugs here - and sadly they seem to be in
the deco calculations, as with the example given the ceiling that is
calculated makes no sense. When displayed in smooth mode it has very
strange jumps up and down that I wouldn't expect. For example with GF
35/75 (the default) the deco ceiling when looking at the simulated dive
jumps from 16m back up to 13m around 14:10 into the dive. That seems very
odd.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-04 23:56:55 -08:00