aboutsummaryrefslogtreecommitdiffstats
path: root/planner.c
AgeCommit message (Collapse)Author
2015-04-05Read stored planner prefs when starting.Gravatar Joakim Bygdell
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-04Spelling correctedGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04Take gas consumption into account for recreational modeGravatar Robert C. Helling
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-02Only do safety stop of dive has at least max depth of 10mGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02Checkbox and preference for safety stopGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02Add 3min safety stopGravatar Joakim Bygdell
Fixes #839 Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02Introduce recreational planner modeGravatar Robert C. Helling
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-03-09Improve gas accounting in the pannerGravatar Joakim Bygdell
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-08Add explicit setpoint change at t=0 when planning CCR divesGravatar Robert C. Helling
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-02-03Show stops in verbatim diveplanGravatar Robert C. Helling
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-01-20Adopt planner gas calculation to PSCR mode and include low pO2 warningGravatar Robert C. Helling
[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-17Save predefined SACGravatar Robert C. Helling
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-10Refactor dctype -> divemodeGravatar Robert C. Helling
... 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-10Rebreather type selector UIGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-12Set sample setpoint correctlyGravatar Robert C. Helling
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-07In diveplan differentiate between last printed depth and last depthGravatar Robert C. Helling
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-11-25Assign setpoint to correct sample in plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21Print gas changes at the correct lines in diveplanGravatar Robert C. Helling
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-21Show the setpoint in the diveplanGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21Don't plan gas switches when in CCR modeGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12Support different salinity in plannerGravatar Anton Lundin
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-04Prepare for PSCR calculationsGravatar Robert C. Helling
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-04Don't track gas consuption on CCR legsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19Make planner work again for CCR divesGravatar Robert C. Helling
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-09-18TyposGravatar Salvo Tomaselli
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-08-19Mark manually entered waypoints as suchGravatar Dirk Hohndel
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-19Remove unused functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19Planner: correctly free divedatapointsGravatar Dirk Hohndel
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-06Fix uninitialized variable warningGravatar Dirk Hohndel
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-06Fix compile warningGravatar Miika Turkia
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-05Planner: actually return the errorGravatar Dirk Hohndel
Just setting it up is only half of the solution... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Bail out of deco calculation after 48h or dive timeGravatar Robert C. Helling
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-04Planner: show mean depthGravatar Dirk Hohndel
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-07-24Planner: fix start time handlingGravatar Dirk Hohndel
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-18get_gas_at_time needs to always give us a valid gasv4.1.91Gravatar Dirk Hohndel
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-18Use our types in interpolate_transitionGravatar Henrik Brautaset Aronsen
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Convert get_gas_from_events to get_gas_at_timeGravatar Anton Lundin
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-18Use more of our propper types in the plannerGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Planner: don't track cylinder pressure if working pressure is 0Gravatar Dirk Hohndel
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-15Planner: Report CNS and OTUGravatar Gaetan Bisson
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-11planner: Correct pO2 comparisonGravatar Anton Lundin
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-11Planner: fix calculation when it is safe to surfaceGravatar Dirk Hohndel
We were comparing with a negative depth which apparently confused the algorithm. Fixes #611 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Use user entered pO2 limits for high pO2 warnings.Gravatar Robert C. Helling
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-10Limit the scope of gasidx in add_plan_to_notesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Remove unnecessary get_gasidx callGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-07Planner: Show gas consumption in pressure units as well and warn if not ↵Gravatar Robert C. Helling
enough reserve. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-05Remove gasmix_is_nullGravatar Robert C. Helling
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-04Planner: don't set cylinder start and end pressure when adding diveGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04Planner: only track gas when planning a diveGravatar Dirk Hohndel
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-04Remove unused labelGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>