The dive will start with gas 0. If things change during the planned part
of the dive, this will be represented by an event. Use the last gas for
the ascent.
Obviously this still doesn't handle deco gases, but at least we now no
longer switch back to the first gas after the planned part of the dive.
This also adds quite a bit of debugging code to be able to trace what's
happening in the planner.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Stupid Gtk. Seriously. So in order to get a notification if the user
selects the drop down for the gas with the mouse I need to connect to the
"changed" signal for the combobox. But that also fires whenever the user
types something into the GtkEntry. Which means we once again get called
for all kinds of silly partial names.
Instead we want to handle the manual entry in the "focus-out" callback
(the user has hit tab or something else to move away from the GtkEntry -
let's assume that this is the text he wants us to use) and only respond to
the changed signal on the combobox if the user selected something from the
dropdown.
The easiest way to do that (I think) is to check the text with the strings
stored in the model. If this indeed matches a string stored in the model
then most likely this is something the user selected from the dropdown.
But more importantly if it isn't in the model, then we KNOW that this is
just a partial string that was typed in. And we can ignore that one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>