Commit graph

190 commits

Author SHA1 Message Date
Anton Lundin
86d66d3c9d Limit the scope of gasidx in add_plan_to_notes
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 13:37:27 -07:00
Anton Lundin
94e66dbdd6 Remove unnecessary get_gasidx call
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 13:26:48 -07:00
Robert C. Helling
f79c659b10 Planner: Show gas consumption in pressure units as well and warn if not enough reserve.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-07 13:59:52 -07:00
Robert C. Helling
79cd5ce835 Remove gasmix_is_null
The semantic of fo2==fhe==0 to mean "same gasmix as before" apparently
is not used anywhere and gets in the way of the semantic "this is air".

If there is really need for mix meaning "same as before", please use another
value, e.g. one with a specific negative percentage.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-05 07:43:10 -07:00
Dirk Hohndel
cc86d68c86 Planner: don't set cylinder start and end pressure when adding dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 11:40:02 -07:00
Dirk Hohndel
d4e3745370 Planner: only track gas when planning a dive
When adding a dive we don't have SAC data so we should simply have the
user manually enter their gas consumption. That still doesn't work, but
this is one required step to get it to work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 11:26:31 -07:00
Dirk Hohndel
c728b4b7bb Remove unused label
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 06:39:38 -07:00
Anton Lundin
9c6513b11d Clear out old events in create_dive_from_plan
Previous code where accumulating events from each iteration of the
planning. This code clears the old ones before adding new ones.

Fixes #595

[Dirk Hohndel: removed printf, updated comment, slightly moved the code,
               added parenthesis to silence warning]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 06:28:21 -07:00
Dirk Hohndel
5fb947681e Remove non-existant variable from debug statement
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 21:02:39 -07:00
Robert C. Helling
5db706d291 Planner: Add backgas breaks
If the corresponding checkbox is checked the planner does interrupt
pure O2 deco after 12min for 6min on cylinder 0.

To make this work for air I removed the gasmix_is_null logic.

I guess that makes the planner feature complete for the next release.

[Dirk Hohndel: trivial merge into latest master]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 16:33:19 -07:00
Dirk Hohndel
611bae3441 UI restructure: use displayed_dive for add dive and plan dive
This gets rid of the stagingDive and stops the constant adding and
removing of dives from the divelist (that was an INSANE design,
seriously).

When adding or planning a dive all work is now done in the dedicated
displayed_dive.

Add dive mostly works - when the user clicks save the dive is added to the
dive list and selected.

Plan dive is mostly untested. It passed trivial "start planner, save"
testing so it's not entirely broken, but I'm sure there's more work to be
done there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 14:45:01 -07:00
Dirk Hohndel
117b212cdd UI restructure: make planner act on displayed_dive
Instead of constantly creating and deleting dives and messing with the
dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 13:39:06 -07:00
Anton Lundin
b1869c619a Use gas_mod helper instead of local version
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01 09:38:15 -07:00
Robert C. Helling
1b7abab9b9 Show ascent gas consumption separately in planner
In the worst gase you have to provide gas for your buddy during all the
ascent. So you should have the amount of gas used in ascent as a reserve.
This patch makes the planner notes display that value separately.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01 07:05:01 -07:00
Anton Lundin
707b9f0666 Close snprintf warning
Gcc yells:
warning: format not a string literal and no format arguments

This closes that warning.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 06:54:44 -07:00
Robert C. Helling
772727fc7f Hook up UI elements for ascent rates to planner
That provides some UI elements that were recently introduced with function
of allowing the ascent rates of the planner to be configured by the user.

I tried to make it work both with senisble as well as with imperial units.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 13:48:44 +08:00
Henrik Brautaset Aronsen
9f7c79557e CSS and translation improvements to dive plan
Use CSS styling to format the dive plan instead of deprecated HTML tags.
Also make sure that we aren't sending HTML tags to translate()

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:50:05 +08:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Robert C. Helling
2d7b02726e Have explicit "%s" format strings in printf style statements
Not having a format string that explicitly references the arguments is
considered a potential security issue in code.
This gets rid of a compiler warning that turned into an error on Fedora 21.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 13:58:20 -07:00
Dirk Hohndel
b70c877b3c Deal with some uninitialized variable warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 09:37:12 -07:00
Dirk Hohndel
ecb5f4c792 Planner: use the actual setting for GF low at max depth
Using the default_prefs value makes no sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:08:51 -07:00
Lubomir I. Ivanov
32e89123a2 planner.c: prevent an uninitialized warning
"warning: 'bottom_time' may be used uninitialized in this
function"

we set it to zero for now.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 16:55:53 -07:00
Lubomir I. Ivanov
7451790660 planner.c: use implicit struct initializer
We should either use mplicit struct initializers (empty braces { }
or double braced zero {{ 0 }}) or memset the struct.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 16:55:09 -07:00
Dirk Hohndel
a3ce3221fd Fix incorrect argument order for %.*f
Strangely, *prinf() on Linux appears to do the right thing in either
order (my guess is based on the type of the two values?), but on Windows
things go badly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 11:23:05 -07:00
Robert C. Helling
e6fc5d2370 Planner: incease step size in deco ascends to 3 seconds
Triple time step in deco ascents to improve responsiveness of interactive
deco calculation.

[Dirk Hohndel: split commit into two]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 20:25:39 -07:00
Anton Lundin
58952b15b4 Switch to the new gasmix structure in dump_plan
dump_plan wasn't updated when the switch from he/o2 to gasmix was done
in the planner code, this makes it compile again.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 08:46:24 -07:00
Robert C. Helling
9c7284b403 Planner: Avoid bogus segments with 0 time
Don't show a stop if we continue at this depth.

This resolves a problem when there are more than two waypoints during deco
at the same depth. This can happen at 6m when there is a gaschange to O2
and the last stop depth is 6m (which turns the 3m stop into another 6m
stop).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 07:10:41 -07:00
Robert C. Helling
14eb0e23af Planner: Change 'lasttime' only if we printed something in the plan.
This makes the 'segment' durations equal the runtime differences even when
we don't display transitions in deco.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 07:09:58 -07:00
Robert C. Helling
40dd6f4c39 Disclaimer included in the printed diveplan
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 14:45:54 -07:00
Dirk Hohndel
5bc5cae6dc Planner: only copy cylinders that were used in the template dive
This was only semi-implemented the first time around. Now we really only
copy the ones that are indeed used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 23:09:12 -07:00
Dirk Hohndel
9df3751c04 Planner: more accurately track assumed cylinder pressures
This makes things more consistent. The equipment view and the sample view
of the beginning and end pressure for each cylinder correspond (and the
beginning pressures of each cylinder segment are correctly reflected in
the samples).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 21:53:33 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Dirk Hohndel
1bcb38dc49 Planner: make the warnings visually stand out more
HTML is nice here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:39:53 -07:00
Dirk Hohndel
d89cf361a0 Planner: add a few more line breaks in the html notes
This looks much better now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:39:53 -07:00
Robert C. Helling
5a62eeffea Planner: Show gas changes at the correct depth.
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-03 11:39:49 -07:00
Robert C. Helling
1f1dcecc02 Planner: Show waypoints for gas changes but no double depths
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:54:01 -07:00
Robert C. Helling
575a092e7e Planner note logic and layout improved
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:38:28 -07:00
Robert C. Helling
2785d7bc3e Layout improvements to the dive plan
Changed to html.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:23:37 -07:00
Dirk Hohndel
db4a003ef5 Planner: fix typo that broke tank pressure tracking
Oops, that's embarrassing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 13:14:59 -07:00
Dirk Hohndel
9cae50acab Planner: warn about high pO2
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-02 12:58:27 -07:00
Robert C. Helling
90885bfb8e Optionally strip diveplan to bare minimum
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-02 12:40:36 -07:00
Dirk Hohndel
28093ae957 Remove is_air() and convert its users to gasmix
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-01 20:57:11 -07:00
Linus Torvalds
ee36bf8bf3 Create simple non-thread-safe "gasname()" function
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-01 20:40:03 -07:00
Dirk Hohndel
cfb93cb92c More cleanup for planner.c
Remove unused variables and make the ifdef'ed out debug code work again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 17:45:00 -07:00
Dirk Hohndel
0d7ce2704d Change add_plan_to_notes() to operated on gasmix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 17:34:40 -07:00
Dirk Hohndel
bd142bbee2 Switch verify_gas_exists to take gasmix argument
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 16:27:19 -07:00
Dirk Hohndel
fece3f321f Switch more functions to use gasmix type
This time it's get_gas_string().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 16:12:01 -07:00
Dirk Hohndel
fe773241ee Next step to using gasmix instead of o2/he
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-01 15:40:46 -07:00
Dirk Hohndel
2bf46381a8 Use proper types
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-01 14:19:19 -07:00
Dirk Hohndel
1a04013453 Encapsulate the horrid gas encoding in gas change events
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-01 12:07:29 -07:00