mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:23:25 +00:00
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>
This commit is contained in:
parent
c477f56029
commit
63d98138b4
3 changed files with 21 additions and 6 deletions
2
dive.h
2
dive.h
|
@ -711,7 +711,7 @@ struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix,
|
|||
#if DEBUG_PLAN
|
||||
void dump_plan(struct diveplan *diveplan);
|
||||
#endif
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
|
||||
int plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
|
||||
void delete_single_dive(int idx);
|
||||
|
||||
struct event *get_next_event(struct event *event, char *name);
|
||||
|
|
24
planner.c
24
planner.c
|
@ -517,7 +517,7 @@ static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops,
|
|||
return stoplevels;
|
||||
}
|
||||
|
||||
static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer)
|
||||
static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer, int error)
|
||||
{
|
||||
char buffer[20000], temp[1000];
|
||||
int len, lastdepth = 0, lasttime = 0;
|
||||
|
@ -533,6 +533,15 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
|
|||
if (!dp)
|
||||
return;
|
||||
|
||||
if (error) {
|
||||
snprintf(temp, sizeof(temp),
|
||||
translate("gettextFromC", "Decompression calculation aborted due to excessive time"));
|
||||
snprintf(buffer, sizeof(buffer), "<span style='color: red;'>%s </span> %s<br>",
|
||||
translate("gettextFromC", "Warning:"), temp);
|
||||
dive->notes = strdup(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
len = show_disclaimer ? snprintf(buffer, sizeof(buffer), "<div><b>%s<b></div><br>", disclaimer) : 0;
|
||||
snprintf(temp, sizeof(temp), translate("gettextFromC", "based on GFlow = %d and GFhigh = %d"),
|
||||
diveplan->gflow, diveplan->gfhigh);
|
||||
|
@ -724,7 +733,7 @@ int ascend_velocity(int depth, int avg_depth, int bottom_time)
|
|||
}
|
||||
}
|
||||
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer)
|
||||
int plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer)
|
||||
{
|
||||
struct sample *sample;
|
||||
int po2;
|
||||
|
@ -747,6 +756,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
int o2time = 0;
|
||||
int breaktime = -1;
|
||||
int breakcylinder;
|
||||
int error = 0;
|
||||
|
||||
set_gf(diveplan->gflow, diveplan->gfhigh, prefs.gf_low_at_maxdepth);
|
||||
if (!diveplan->surface_pressure)
|
||||
|
@ -772,9 +782,8 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
transitiontime = depth / 75; /* this still needs to be made configurable */
|
||||
plan_add_segment(diveplan, transitiontime, 0, gas, po2, false);
|
||||
create_dive_from_plan(diveplan, is_planner);
|
||||
return;
|
||||
return(error);
|
||||
}
|
||||
|
||||
tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap);
|
||||
|
||||
#if DEBUG_PLAN & 4
|
||||
|
@ -889,6 +898,11 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
DECOTIMESTEP, po2, &displayed_dive);
|
||||
cache_deco_state(tissue_tolerance, &trial_cache);
|
||||
clock += DECOTIMESTEP;
|
||||
/* Finish infinite deco */
|
||||
if(clock >= 48 * 3600 && depth >= 6000) {
|
||||
error = LONGDECO;
|
||||
break;
|
||||
}
|
||||
if (prefs.doo2breaks) {
|
||||
if (get_o2(&displayed_dive.cylinder[current_cylinder].gasmix) == 1000) {
|
||||
o2time += DECOTIMESTEP;
|
||||
|
@ -929,7 +943,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
* data that we need to be there when plotting the dive */
|
||||
plan_add_segment(diveplan, clock - previous_point_time, 0, gas, po2, false);
|
||||
create_dive_from_plan(diveplan, is_planner);
|
||||
add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer);
|
||||
add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer, error);
|
||||
fixup_dc_duration(&displayed_dive.dc);
|
||||
|
||||
free(stoplevels);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef PLANNER_H
|
||||
#define PLANNER_H
|
||||
|
||||
#define LONGDECO 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Loading…
Add table
Reference in a new issue