Commit graph

311 commits

Author SHA1 Message Date
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
Rick Walsh
17ef6774e0 Planner deco stops are at 10ft increments when measured in feet
When using feet as depth unit, deco stop levels should be at 10 ft rather
than 3 m increments.

For shallow stops, rounding means the difference is not apparent. However,
with stops deeper than 30 feet, using 3 m increments leads stops at 39ft,
49ft, ..., 98ft, etc.

Apart from making plans look messy, the old behaviour makes it harder to
benchmark the planner against published profiles in imperial units.

This revised patch uses the help macro M_OR_FT(6, 20) to set the last stop
at the correct depth.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 06:50:48 -07:00
Rick Walsh
8c4e1e6bfa Read planner preferences when we use them
Read and use the last_stop preference in the plan function.
Read the plan notes preferences and set variables (plan_verbatim,
plan_display_runtime, plan_display_duration, and plan_display_transitions)
in the add_plan_to_notes function. Don't read the preferences and set
variables otherwise. Both plan and add_plan_to_notes functions are called
on data change.

Previous behaviour was:
- Set variables on declaration
- Reset variables in plan function (even variables that only relate to
  planner notes output)
- Changing a preference triggered set_xxx function which sets variable,
  then plan function, which sets variable again.

Apart from being inefficient, the previous behaviour made it difficult to
track down where and when variables were set.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 06:37:01 -07:00
Jan Darowski
ddfd046c8d VPM-B: add CVA to the deco planner.
Added keeping bottom dive state and every deco's time, so we can
run multiple deco simulations with different gradients until they
converge to some optimal value.

Some improvements on the deco time calculation may be needed.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-04 00:13:34 +02:00
Jan Darowski
02f1339917 VPM-B: vpm without CVA working.
Add call of initial calculation of critical radius and start gradient,
so the VPM could work.
Currently without CVA, so the gradient isn't improved.
Only one iteration is run.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:54:57 +02:00
Jan Darowski
e7aa686f16 VPM-B: add vpm-b based deco checking.
Check during the trial_ascent() if existing pressure gradient is
smaller than previously calculated max gradient. If not, ascent
is impossible from the vpm-b's point of view.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:24:20 +02:00
Jan Darowski
500fbe4994 VPM-B: add deco choice to the ui.
Removed recreational mode from ui and pref and replaced it with
new deco_mode enum.
Added radio button ui selection.
Set default deco_mode to Buehlmann algorithm.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:07:58 +02:00
Rick Walsh
f763da66b3 Implement planner option to switch only at required stops
When option is enabled, if a stop is not otherwise required, a gas switch will be delayed until a stop is reached.  This option is ignored if the current gas is hypoxic.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 06:14:28 -07:00
Rick Walsh
cb1b6a3d30 Define gaschange_before and gaschange_after a few lines earlier
This is required so they work in the test for /* do we want to skip this leg as it is devoid of anything useful? */
We were already trying to use gaschange_after (and previously gaschange), but it was duplicating an existing condition (now removed).

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-26 06:10:34 -07:00
Rick Walsh
228eb6ce27 Fix gaschange_after definition
Previously gaschange_after was never being set back to false.  Now it will be.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-23 06:15:07 -07:00
Robert C. Helling
4094e6b233 Refactor to use gaschage_before and gaschange_after
... for better readability.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:39:17 -07:00
Robert C. Helling
d071ab4537 When displaying transitions show the gaschange at the stop if there is one
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:28:01 -07:00
Rick Walsh
26622e7e04 Planner notes - revise logic for gasmix output
The logic for when to output a gasmix in the notes table is more
complicated than it seems at first.
- On a descent leg, the gas is the gas used for descent
- At a stop (calculated or user defined), the gas is the gas used for that
  stop
- But on an ascent leg (if displayed), the gas is the gas that is ABOUT TO
  BE USED
- The gas should not be repeated if it's the same gas as used on the last
  row of the table
- Ascent legs should only be displayed if the display transitions option
  is selected, OR if there is a gas change without a stop (the user can
  now set a minimum duration for a gaschange, but zero is still allowed).

The existing code tries to track what gas is being used/switched to at
each waypoint, and whether the gas should be printed or postponed to the
next leg.  It works sometimes but not always.

This patch replaces the postponed gas logic with:
- Is this an ascent leg? (determines whether the applicable gas is the
  preceding or following leg, and whether the leg should be displayed at
  all if the transitions option isn't selected)
- Is it an ascent with a gaschange without a stop?
- Has the gas actually changed from the last output?
- Will the next leg be at the same level and same gas (in which case merge
  them)?

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:24:56 -07:00
Dirk Hohndel
86b8d796c8 Prevent null pointer dereference
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:56 -07:00
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Rick Walsh
48aa0bdfd0 Planner: change timestep to 2 seconds
Change the timestep used to calculate tissue pressures and ascents from 3
seconds to 2 seconds. But whats wrong with using 3 seconds?

Deco stops are at 3 m (10') intervals, and our ascent rate is usually
9 m/min (30'/min), or at least multiples of 3 m/min (10'/min).  Hence time
to ascend from one stop to the next stop is 20s (or any factor of 60).
Using 3s increments, we round our ascent interval up to 21 s, which leads
to messy durations and runtimes.

But what about me?  I like SI units and whole decimals.  Don't worry, 2s
timesteps fit nicely when using 10 m/min ascent rate (18 s between stops).

[Dirk Hohndel: edited the commit message to fix minute/second confusion]

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 15:29:22 -07:00
Rick Walsh
e5a4b5a618 Planner - end deco stops at whole minutes of runtime
--20cf303ddd3893b1500518e9204e
Content-Type: text/plain; charset=UTF-8

Use an adjusted timestep to calculate length of deco stops, so that they
always end at whole minutes of runtime.  This makes for a cleaner ascent
profile.

<div dir="ltr">Use an adjusted timestep to calculate length of deco stops, so that they always end at whole minutes of runtime.  This makes for a cleaner ascent profile.<br></div>

From 15e08450252f304fc7d46931e2aca5c991c2f3de Mon Sep 17 00:00:00 2001
From: Rick Walsh <rickmwalsh@gmail.com>
Date: Sat, 20 Jun 2015 11:36:07 +1000
Subject: [PATCH 2/2] Planner - end deco stops at whole minutes of runtime

Use an adjusted timestep to calculate length of deco stops, so that they always end at whole minutes of runtime.  This makes for a cleaner ascent profile.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 18:20:18 -07:00
Rick Walsh
845030a8ad Enforce planner minimum gas switch duration
Enforce a minimum duration for gas switching in the planner.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-19 09:15:51 -07:00
Rick Walsh
f66ea4cbb0 Show duration before runtime on planner notes table
Switch the column order of the planner notes table so that duration is displayed before runtime.  This is consistent with:
- the verbatim output order, e.g. "Stay at 12.0 m for 3:00 min - runtime 32:48 on EAN50"
- MultiDeco, e.g. http://www.hhssoftware.com/multideco/view_multideco.html
- Planner on the Shearwater Petrel
- How I have been taught to write out my dive plan in my wetnotes

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16 20:32:40 -07:00
Jan Darowski
a524c01c3f Don't compare signed and unsigned values
This fixes a "reproducable hang when using "edit dive in planner" on
non-planned dive".
Comparing unsigned and signed integers isn't a great idea.

Fixes #880

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-14 21:20:55 -07:00
Robert C. Helling
22bfc4936f Add explicit casts to silence compiler warnings
clang complais when converting (char *) to (unsigned char *), so tell
it it's fine.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28 08:16:37 -07:00
Joakim Bygdell
9ca033c550 Be more precise about the safety-stop.
There is no point in doing a stop at 5m if the last manual waypoint is shallower.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-21 13:26:49 -07:00
Robert C. Helling
907ccb0b71 Allow "oxygen" as a gas name
...as this what comes in when the user selects this gas in the
add dive/dive planner contet menu.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-17 15:07:02 -07:00
Robert C. Helling
698b2b133f Only add disclaimer and runtime table if we added deco to replanne dive
As a side effect this changes the signature of plan(): Before it
returned an int that was supposed to be possibly an error but
we never bothered to check it. So now it's bool indicating if the
planner did add stops.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-11 07:57:09 -07:00
Robert C. Helling
9d8eb10421 Only warn when trying to replan a logged dive
If there are more than 100 samples, average some of them so we end up with no more than 100.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-08 10:02:45 -07:00
Joakim Bygdell
68ec73f1b0 Recmode: Fix ascent gas consumption.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-09 14:36:33 -07:00
Joakim Bygdell
afea30fd8a Recmode: Allow the user to specify gas reserve.
Since most regulators have an intermediate pressure of 10bar
the minimum value is 10 while the max is 99.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-09 14:36:17 -07:00
Joakim Bygdell
695637dcff Recmode: Take safety stop into account when calculating ascent gas consumption.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-09 14:35:46 -07:00
Joakim Bygdell
352433723d Read stored planner prefs when starting.
Back in 5bf23381e we started storing planner settings in prefs.
We need to read those settings back when we start the planner.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-05 07:40:54 -07:00
Robert C. Helling
004fa9a26b Spelling corrected
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:25:02 -07:00
Robert C. Helling
e03c5ce8e9 Take gas consumption into account for recreational mode
If there is valid gas information (cylinder size and starting pressure),
also ascent before gas runs out (taking a 40bar reserve into account).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:21:40 -07:00
Robert C. Helling
61ff7c5f8b Only do safety stop of dive has at least max depth of 10m
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02 09:46:10 -07:00
Robert C. Helling
cc8d601422 Checkbox and preference for safety stop
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02 09:46:10 -07:00
Joakim Bygdell
cd34fea1db Add 3min safety stop
Fixes #839

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02 09:46:08 -07:00
Robert C. Helling
8571dcf967 Introduce recreational planner mode
This adopts the planner to the needs of the recreational diver. Rather than immediately
starting to ascent doing deco stops this mode, this mode stays at the last manually
entered depth for the maximal time before mandantory stops appear (NDL). It does not
change gas but keeps using the last used cylinder.

TODO: * Grey out unused UI elements of the planner in this mode
      * Start ascent before gas runs out (or into reserve)
      * Do a 3min @ 5m safety stop.

Fixes #840

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02 09:45:50 -07:00
Joakim Bygdell
20a82e2b21 Improve gas accounting in the panner
When using gasmixes where the difference is less than 2% the planner can't
caclulate casconsumptions correctly. This sets the minimum gasdifference
to 1%.

Fixes #795

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-09 10:39:50 -07:00
Robert C. Helling
c67812acc3 Add explicit setpoint change at t=0 when planning CCR dives
As we now have the logic that there is always an explicit setpoint at
t=0sec for CCR dives, also the planner should honor that.

This fixes a bug that when planning a CCR dive we later add a
setpoint change this influenced the ceiling _before_ the
setpoint change.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-08 12:54:39 -07:00
Robert C. Helling
f913ed5b9d Show stops in verbatim diveplan
The position of one curly brace was wrong. Bummer.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-03 11:43:16 -08:00
Robert C. Helling
39b528d6da Adopt planner gas calculation to PSCR mode and include low pO2 warning
[Dirk Hohndel: fixed obvious compile problem]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-20 06:47:28 +12:00
Robert C. Helling
881803441e Save predefined SAC
When planning a dive, the gas consumption is based on a user configured SAC.
Thus we should use that SAC and not try to recompute it from samples.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:18:08 +13:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Robert C. Helling
d01c6c824b Rebreather type selector UI
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:24 -08:00
Robert C. Helling
f22a708e27 Set sample setpoint correctly
Forward the sample set-point setting as otherwise all ascents are
planned on OC.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-12 07:15:22 -08:00
Robert C. Helling
8cd5d08ba9 In diveplan differentiate between last printed depth and last depth
In the decision if a dive segment should lead to a line in the
diveplan, we need to differentiate between the lastdepth (the
depth of the last dp to tell if we are currently stopping) and
the last depth that we printed a line for (needed for gaschange
lines). Without this patch, no stops without gas changes were
listed anymore in the diveplan.

Like the last patch for the diveplan: I hope this time I got this
logic right.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-07 09:45:25 -06:00
Robert C. Helling
81fce5ad19 Assign setpoint to correct sample in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:30:23 -08:00
Robert C. Helling
61961b11ad Print gas changes at the correct lines in diveplan
This is a pain. We plan with segments but the plan shows waypoints.
If after a constant depth segment the gaschange (or setpoint chenge
for that matter) appears, the _next_ line should get the info
about the new gas (i.e. change _after_ the constant depth segment).

If, however, the gas is changed after a transition, the final waypoint
of the transition gets the gas printed.

And all is different for a verbatim plan, where the gas change is
an event rather than part of a segment.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 07:42:49 -08:00
Robert C. Helling
3f0159b734 Show the setpoint in the diveplan
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 07:42:21 -08:00
Robert C. Helling
1dfebe7c10 Don't plan gas switches when in CCR mode
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 07:42:09 -08:00
Anton Lundin
a06befc007 Support different salinity in planner
Depth is often mentioned in a length unit, but what we care about is
pressure. When diving in fresh water the pressure is lower than the same
depth in salt water. This adds support for using different salinities in
planning.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12 14:42:15 -08:00
Robert C. Helling
06ddfc0122 Prepare for PSCR calculations
Calculations for passive semi-closed rebreathers are pretty much like OC
except the pO2 is lower bey a certain (SAC dependent) factor. This patch
introduces the corresponding calculations in case dctype == PSCR which is
so far never set and there is currently no UI for these calculations. As
pO2 is SAC dependent it takes a certain attempt at getting it and drops to
defaults from the prefs otherwise.

As there is no UI at this point and I also don't have any dives, this has
not received much testing, yet, but it compiles. At least.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 07:13:04 -08:00
Robert C. Helling
f31d34adfd Don't track gas consuption on CCR legs
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 07:05:23 -08:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Salvo Tomaselli
bff471f98d Typos
This fixes two typos found by lintian.
I guess a bunch of translations will need to be updated or something, I am not
sure how they work so I didn't touch them. I presume in the worst case they
will need to be re-translated at the next iteration

--
Salvo Tomaselli

"Io non mi sento obbligato a credere che lo stesso Dio che ci ha dotato di
senso, ragione ed intelletto intendesse che noi ne facessimo a meno."
                -- Galileo Galilei

http://ltworf.github.io/ltworf/
From a0e5f48349557fcccd82ba8c7555043de140835c Mon Sep 17 00:00:00 2001
From: Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>
Signed-off-by: Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>
Date: Fri, 12 Sep 2014 18:25:20 +0200
Subject: [PATCH] Fix typos reported by lintian

Fixes two typos reported by lintian.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-18 06:24:05 -07:00
Dirk Hohndel
5b0f4e79c4 Mark manually entered waypoints as such
With this information, when we re-plan a dive we can bring the user right
back to the point where they ended - they have the waypoints in the dive
pointes table and handles are shown on the right points in the profile -
and the rest of the dive is once again calculated by the planning
algorithm.

For now this state is lost when saving the dive file as we don't add this
flag in the sample to our saved files. So if we don't find any samples
marked as manually added we add ALL of the samples as way points on the
diveplan and the user has to manually remove the ones that were
calculated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
c463087ab0 Remove unused function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:48 -05:00
Dirk Hohndel
77f9bf06fd Planner: correctly free divedatapoints
Simply setting the pointer to NULL leaks memory.
And that C++ recursive two function implementation... oh boy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:39 -05:00
Dirk Hohndel
66bb17e602 Fix uninitialized variable warning
Reading the code we should never be able to access breakcylinder without
having initialized it first, but this seems like a really cheap fix.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 10:51:53 -07:00
Miika Turkia
4b9b19cec6 Fix compile warning
warning: format not a string literal and no format arguments

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 06:03:33 -07:00
Dirk Hohndel
db2292c772 Planner: actually return the error
Just setting it up is only half of the solution...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05 10:56:18 -07:00
Robert C. Helling
63d98138b4 Bail out of deco calculation after 48h or dive time
With very low values of GFhigh and setting the last stop depth to 6m it
is possible to create dives that need infintie decompression time.

This ends deco after 48h and replaces the dive plan with an error message.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05 06:58:35 -07:00
Dirk Hohndel
825eb019ab Planner: show mean depth
Almost invisible, mostly looking like an odd bug in the profile code,
there was a tiny red line at depth 0 in the planned profile. Turns out
that was the missing mean depth. We didn't populate enough data in the
dive computer of the dive we generated from the plan (and the length of
the depth line was incorrectly determined by the duration of the dive
instead of the duration stored in the dive computer).

Fixes #570

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-04 07:36:07 -07:00
Dirk Hohndel
f29f41ae9e Planner: fix start time handling
We setup the startTime for the dive plan in too many places... but never
actually copied it into the planned dive.

Fixes #640

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24 09:03:56 -07:00
Dirk Hohndel
17bcd1bc60 get_gas_at_time needs to always give us a valid gas
Before this function was changed it was really supposed to just change a
gas that was passed in in case there was an event that changed the mix -
but with the new name the caller will assume that they get a valid gasmix.
And promptly we had one caller that didn't initialize gas to be based on
the first cylinder before calling get_gas_at_time().

Instead of adding yet one more spot that knows about the oddity of the old
API I simply changed get_gas_at_time() to do what it name appears to imply
and fixed the other callers not to bother to initialize the gasmix.

Fixes #647

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 18:46:51 -07:00
Henrik Brautaset Aronsen
93f63466d6 Use our types in interpolate_transition
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 17:55:10 -07:00
Anton Lundin
7806dbbd9e Convert get_gas_from_events to get_gas_at_time
This converts the get_gas_from_events to a get_gas_at_time function that
actually maps our events to what cylinder and thus gas we are breathing
at that time.

[Dirk Hohndel: fixed to actually use the gas that was looked up
               (and make things compile)]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 10:13:52 -07:00
Anton Lundin
9eeeba468a Use more of our propper types in the planner
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 10:02:11 -07:00
Dirk Hohndel
912560f928 Planner: don't track cylinder pressure if working pressure is 0
The pressure graph will go from 0 to negative - one could make a weak
argument that this would at least tell you how much pressure you'd need in
the cylinder to start with, but that's kinda lame.

Fixes #615

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 23:04:30 -07:00
Gaetan Bisson
d652268655 Planner: Report CNS and OTU
In add_plan_to_notes(), call update_cylinder_related_info() to compute
CNS and OTU data for the planned dive. Report their values in the notes.

Besides CNS and OTU, update_cylinder_related_info() also recomputes the
SAC, which is harmless. Note that both dive->cns and dive->maxcns need
to be zeroed out for the CNS value to actually be recomputed.

Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 04:05:53 -07:00
Anton Lundin
3dbc5bfeaa planner: Correct pO2 comparison
Don't compare pO2 with a bool, compare it with the result of the ?:
expression instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 16:58:24 -07:00
Dirk Hohndel
6c9aaf406a Planner: fix calculation when it is safe to surface
We were comparing with a negative depth which apparently confused the
algorithm.

Fixes #611

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 10:10:15 -07:00
Robert C. Helling
6fa996a883 Use user entered pO2 limits for high pO2 warnings.
Furthermore, replaced gasmix accessors instead of .permille directly (think: air!)

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 13:43:24 -07:00
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