Display surface interval in diveplan

...instead of just stating "repetitive dive". As requested by
a user.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-01-03 15:14:42 +01:00 committed by Subsurface
parent 72bcb6481f
commit 43599742a3
4 changed files with 21 additions and 15 deletions

View file

@ -860,7 +860,7 @@ struct diveplan {
short vpmb_conservatism; short vpmb_conservatism;
struct divedatapoint *dp; struct divedatapoint *dp;
int eff_gflow, eff_gfhigh; int eff_gflow, eff_gfhigh;
bool repetitive; unsigned int surface_interval;
}; };
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered); struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered);

View file

@ -361,7 +361,7 @@ static struct gasmix air = { .o2.permille = O2_IN_AIR, .he.permille = 0 };
/* take into account previous dives until there is a 48h gap between dives */ /* take into account previous dives until there is a 48h gap between dives */
/* return true if this is a repetitive dive */ /* return true if this is a repetitive dive */
bool init_decompression(struct dive *dive) unsigned int init_decompression(struct dive *dive)
{ {
int i, divenr = -1; int i, divenr = -1;
unsigned int surface_time; unsigned int surface_time;
@ -448,7 +448,7 @@ bool init_decompression(struct dive *dive)
} }
// I do not dare to remove this call. We don't need the result but it might have side effects. Bummer. // I do not dare to remove this call. We don't need the result but it might have side effects. Bummer.
tissue_tolerance_calc(dive, surface_pressure); tissue_tolerance_calc(dive, surface_pressure);
return deco_init; return surface_time;
} }
void update_cylinder_related_info(struct dive *dive) void update_cylinder_related_info(struct dive *dive)

View file

@ -14,7 +14,7 @@ extern void update_cylinder_related_info(struct dive *);
extern void mark_divelist_changed(int); extern void mark_divelist_changed(int);
extern int unsaved_changes(void); extern int unsaved_changes(void);
extern void remove_autogen_trips(void); extern void remove_autogen_trips(void);
extern bool init_decompression(struct dive *dive); extern unsigned int init_decompression(struct dive *dive);
/* divelist core logic functions */ /* divelist core logic functions */
extern void process_dives(bool imported, bool prefer_imported); extern void process_dives(bool imported, bool prefer_imported);

View file

@ -128,7 +128,7 @@ void interpolate_transition(struct dive *dive, duration_t t0, duration_t t1, dep
} }
/* returns the tissue tolerance at the end of this (partial) dive */ /* returns the tissue tolerance at the end of this (partial) dive */
bool tissue_at_end(struct dive *dive, char **cached_datap) unsigned int tissue_at_end(struct dive *dive, char **cached_datap)
{ {
struct divecomputer *dc; struct divecomputer *dc;
struct sample *sample, *psample; struct sample *sample, *psample;
@ -136,19 +136,19 @@ bool tissue_at_end(struct dive *dive, char **cached_datap)
depth_t lastdepth = {}; depth_t lastdepth = {};
duration_t t0 = {}, t1 = {}; duration_t t0 = {}, t1 = {};
struct gasmix gas; struct gasmix gas;
bool repetitive = false; unsigned int surface_interval = 0;
if (!dive) if (!dive)
return false; return 0;
if (*cached_datap) { if (*cached_datap) {
restore_deco_state(*cached_datap); restore_deco_state(*cached_datap);
} else { } else {
repetitive = init_decompression(dive); surface_interval = init_decompression(dive);
cache_deco_state(cached_datap); cache_deco_state(cached_datap);
} }
dc = &dive->dc; dc = &dive->dc;
if (!dc->samples) if (!dc->samples)
return false; return 0;
psample = sample = dc->sample; psample = sample = dc->sample;
for (i = 0; i < dc->samples; i++, sample++) { for (i = 0; i < dc->samples; i++, sample++) {
@ -191,7 +191,7 @@ bool tissue_at_end(struct dive *dive, char **cached_datap)
psample = sample; psample = sample;
t0 = t1; t0 = t1;
} }
return repetitive; return surface_interval;
} }
@ -596,10 +596,16 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
snprintf(temp, sz_temp, translate("gettextFromC", "recreational mode based on Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"), snprintf(temp, sz_temp, translate("gettextFromC", "recreational mode based on Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"),
diveplan->gflow, diveplan->gfhigh); diveplan->gflow, diveplan->gfhigh);
} }
len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s%s</b><br>%s</div>", if (diveplan->surface_interval > 60) {
translate("gettextFromC", "Subsurface dive plan"), len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s %d:%02d)</b><br>%s</div>",
diveplan->repetitive ? translate("gettextFromC", " (repetitive)") : "", translate("gettextFromC", "Subsurface dive plan (surface interval "),
FRACTION(diveplan->surface_interval / 60, 60),
temp); temp);
} else {
len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b><br>%s</div>",
translate("gettextFromC", "Subsurface dive plan"),
temp);
}
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"), len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"),
diveplan_duration(diveplan)); diveplan_duration(diveplan));
@ -1086,7 +1092,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
gi = gaschangenr - 1; gi = gaschangenr - 1;
/* Set tissue tolerance and initial vpmb gradient at start of ascent phase */ /* Set tissue tolerance and initial vpmb gradient at start of ascent phase */
diveplan->repetitive = tissue_at_end(&displayed_dive, cached_datap); diveplan->surface_interval = tissue_at_end(&displayed_dive, cached_datap);
nuclear_regeneration(clock); nuclear_regeneration(clock);
vpmb_start_gradient(); vpmb_start_gradient();