mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make plan take dive and decotimestep as arguments
...rather than use a global variable and a macro. This should be a no-op in preparation to allow planning several versions of a dive. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
58d7948871
commit
82aac4efff
4 changed files with 73 additions and 71 deletions
|
@ -835,6 +835,8 @@ extern void subsurface_command_line_exit(int *, char ***);
|
||||||
|
|
||||||
#define FRACTION(n, x) ((unsigned)(n) / (x)), ((unsigned)(n) % (x))
|
#define FRACTION(n, x) ((unsigned)(n) / (x)), ((unsigned)(n) % (x))
|
||||||
|
|
||||||
|
#define DECOTIMESTEP 60 /* seconds. Unit of deco stop times */
|
||||||
|
|
||||||
struct deco_state {
|
struct deco_state {
|
||||||
double tissue_n2_sat[16];
|
double tissue_n2_sat[16];
|
||||||
double tissue_he_sat[16];
|
double tissue_he_sat[16];
|
||||||
|
@ -903,11 +905,12 @@ struct divedatapoint *create_dp(int time_incr, int depth, int cylinderid, int po
|
||||||
#if DEBUG_PLAN
|
#if DEBUG_PLAN
|
||||||
void dump_plan(struct diveplan *diveplan);
|
void dump_plan(struct diveplan *diveplan);
|
||||||
#endif
|
#endif
|
||||||
bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
||||||
void calc_crushing_pressure(double pressure);
|
void calc_crushing_pressure(double pressure);
|
||||||
void vpmb_start_gradient();
|
void vpmb_start_gradient();
|
||||||
void clear_vpmb_state();
|
void clear_vpmb_state();
|
||||||
|
|
||||||
|
|
||||||
void delete_single_dive(int idx);
|
void delete_single_dive(int idx);
|
||||||
|
|
||||||
struct event *get_next_event(struct event *event, const char *name);
|
struct event *get_next_event(struct event *event, const char *name);
|
||||||
|
|
107
core/planner.c
107
core/planner.c
|
@ -19,7 +19,6 @@
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#define TIMESTEP 2 /* second */
|
#define TIMESTEP 2 /* second */
|
||||||
#define DECOTIMESTEP 60 /* seconds. Unit of deco stop times */
|
|
||||||
|
|
||||||
int decostoplevels_metric[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000,
|
int decostoplevels_metric[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000,
|
||||||
30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000,
|
30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000,
|
||||||
|
@ -616,7 +615,7 @@ bool enough_gas(int current_cylinder)
|
||||||
|
|
||||||
// Work out the stops. Return value is if there were any mandatory stops.
|
// Work out the stops. Return value is if there were any mandatory stops.
|
||||||
|
|
||||||
bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer)
|
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer)
|
||||||
{
|
{
|
||||||
int bottom_depth;
|
int bottom_depth;
|
||||||
int bottom_gi;
|
int bottom_gi;
|
||||||
|
@ -654,8 +653,8 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
set_vpmb_conservatism(diveplan->vpmb_conservatism);
|
set_vpmb_conservatism(diveplan->vpmb_conservatism);
|
||||||
if (!diveplan->surface_pressure)
|
if (!diveplan->surface_pressure)
|
||||||
diveplan->surface_pressure = SURFACE_PRESSURE;
|
diveplan->surface_pressure = SURFACE_PRESSURE;
|
||||||
displayed_dive.surface_pressure.mbar = diveplan->surface_pressure;
|
dive->surface_pressure.mbar = diveplan->surface_pressure;
|
||||||
clear_deco(displayed_dive.surface_pressure.mbar / 1000.0);
|
clear_deco(dive->surface_pressure.mbar / 1000.0);
|
||||||
max_bottom_ceiling_pressure.mbar = first_ceiling_pressure.mbar = 0;
|
max_bottom_ceiling_pressure.mbar = first_ceiling_pressure.mbar = 0;
|
||||||
create_dive_from_plan(diveplan, is_planner);
|
create_dive_from_plan(diveplan, is_planner);
|
||||||
|
|
||||||
|
@ -677,13 +676,13 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
*(decostoplevels + 1) = M_OR_FT(3,10);
|
*(decostoplevels + 1) = M_OR_FT(3,10);
|
||||||
|
|
||||||
/* Let's start at the last 'sample', i.e. the last manually entered waypoint. */
|
/* Let's start at the last 'sample', i.e. the last manually entered waypoint. */
|
||||||
sample = &displayed_dive.dc.sample[displayed_dive.dc.samples - 1];
|
sample = &dive->dc.sample[dive->dc.samples - 1];
|
||||||
|
|
||||||
current_cylinder = get_cylinderid_at_time(&displayed_dive, &displayed_dive.dc, sample->time);
|
current_cylinder = get_cylinderid_at_time(dive, &dive->dc, sample->time);
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
|
|
||||||
po2 = sample->setpoint.mbar;
|
po2 = sample->setpoint.mbar;
|
||||||
depth = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].depth.mm;
|
depth = dive->dc.sample[dive->dc.samples - 1].depth.mm;
|
||||||
average_max_depth(diveplan, &avg_depth, &max_depth);
|
average_max_depth(diveplan, &avg_depth, &max_depth);
|
||||||
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
||||||
|
|
||||||
|
@ -721,25 +720,25 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
stopidx += gaschangenr;
|
stopidx += gaschangenr;
|
||||||
|
|
||||||
/* Keep time during the ascend */
|
/* Keep time during the ascend */
|
||||||
bottom_time = clock = previous_point_time = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].time.seconds;
|
bottom_time = clock = previous_point_time = dive->dc.sample[dive->dc.samples - 1].time.seconds;
|
||||||
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->surface_interval = tissue_at_end(&displayed_dive, cached_datap);
|
diveplan->surface_interval = tissue_at_end(dive, cached_datap);
|
||||||
nuclear_regeneration(clock);
|
nuclear_regeneration(clock);
|
||||||
vpmb_start_gradient();
|
vpmb_start_gradient();
|
||||||
|
|
||||||
if (decoMode() == RECREATIONAL) {
|
if (decoMode() == RECREATIONAL) {
|
||||||
bool safety_stop = prefs.safetystop && max_depth >= 10000;
|
bool safety_stop = prefs.safetystop && max_depth >= 10000;
|
||||||
track_ascent_gas(depth, &displayed_dive.cylinder[current_cylinder], avg_depth, bottom_time, safety_stop);
|
track_ascent_gas(depth, &dive->cylinder[current_cylinder], avg_depth, bottom_time, safety_stop);
|
||||||
// How long can we stay at the current depth and still directly ascent to the surface?
|
// How long can we stay at the current depth and still directly ascent to the surface?
|
||||||
do {
|
do {
|
||||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
add_segment(depth_to_bar(depth, dive),
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&dive->cylinder[current_cylinder].gasmix,
|
||||||
DECOTIMESTEP, po2, &displayed_dive, prefs.bottomsac);
|
timestep, po2, dive, prefs.bottomsac);
|
||||||
update_cylinder_pressure(&displayed_dive, depth, depth, DECOTIMESTEP, prefs.bottomsac, &displayed_dive.cylinder[current_cylinder], false);
|
update_cylinder_pressure(dive, depth, depth, timestep, prefs.bottomsac, &dive->cylinder[current_cylinder], false);
|
||||||
clock += DECOTIMESTEP;
|
clock += timestep;
|
||||||
} while (trial_ascent(depth, 0, avg_depth, bottom_time, &displayed_dive.cylinder[current_cylinder].gasmix,
|
} while (trial_ascent(depth, 0, avg_depth, bottom_time, &dive->cylinder[current_cylinder].gasmix,
|
||||||
po2, diveplan->surface_pressure / 1000.0) &&
|
po2, diveplan->surface_pressure / 1000.0) &&
|
||||||
enough_gas(current_cylinder));
|
enough_gas(current_cylinder));
|
||||||
|
|
||||||
|
@ -747,8 +746,8 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
// In the best of all worlds, we would roll back also the last add_segment in terms of caching deco state, but
|
// In the best of all worlds, we would roll back also the last add_segment in terms of caching deco state, but
|
||||||
// let's ignore that since for the eventual ascent in recreational mode, nobody looks at the ceiling anymore,
|
// let's ignore that since for the eventual ascent in recreational mode, nobody looks at the ceiling anymore,
|
||||||
// so we don't really have to compute the deco state.
|
// so we don't really have to compute the deco state.
|
||||||
update_cylinder_pressure(&displayed_dive, depth, depth, -DECOTIMESTEP, prefs.bottomsac, &displayed_dive.cylinder[current_cylinder], false);
|
update_cylinder_pressure(dive, depth, depth, -timestep, prefs.bottomsac, &dive->cylinder[current_cylinder], false);
|
||||||
clock -= DECOTIMESTEP;
|
clock -= timestep;
|
||||||
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, true);
|
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, true);
|
||||||
previous_point_time = clock;
|
previous_point_time = clock;
|
||||||
do {
|
do {
|
||||||
|
@ -775,8 +774,8 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
} while (depth > 0);
|
} while (depth > 0);
|
||||||
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
|
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
|
||||||
create_dive_from_plan(diveplan, is_planner);
|
create_dive_from_plan(diveplan, is_planner);
|
||||||
add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer, error);
|
add_plan_to_notes(diveplan, dive, show_disclaimer, error);
|
||||||
fixup_dc_duration(&displayed_dive.dc);
|
fixup_dc_duration(&dive->dc);
|
||||||
|
|
||||||
free(stoplevels);
|
free(stoplevels);
|
||||||
free(gaschanges);
|
free(gaschanges);
|
||||||
|
@ -785,7 +784,7 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
|
|
||||||
if (best_first_ascend_cylinder != current_cylinder) {
|
if (best_first_ascend_cylinder != current_cylinder) {
|
||||||
current_cylinder = best_first_ascend_cylinder;
|
current_cylinder = best_first_ascend_cylinder;
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
|
|
||||||
#if DEBUG_PLAN & 16
|
#if DEBUG_PLAN & 16
|
||||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", best_first_ascend_cylinder,
|
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", best_first_ascend_cylinder,
|
||||||
|
@ -794,7 +793,7 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
}
|
}
|
||||||
|
|
||||||
// VPM-B or Buehlmann Deco
|
// VPM-B or Buehlmann Deco
|
||||||
tissue_at_end(&displayed_dive, cached_datap);
|
tissue_at_end(dive, cached_datap);
|
||||||
previous_deco_time = 100000000;
|
previous_deco_time = 100000000;
|
||||||
deco_time = 10000000;
|
deco_time = 10000000;
|
||||||
cache_deco_state(&bottom_cache); // Lets us make several iterations
|
cache_deco_state(&bottom_cache); // Lets us make several iterations
|
||||||
|
@ -823,17 +822,17 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
breaktime = -1;
|
breaktime = -1;
|
||||||
breakcylinder = 0;
|
breakcylinder = 0;
|
||||||
o2time = 0;
|
o2time = 0;
|
||||||
first_ceiling_pressure.mbar = depth_to_mbar(deco_allowed_depth(tissue_tolerance_calc(&displayed_dive,
|
first_ceiling_pressure.mbar = depth_to_mbar(deco_allowed_depth(tissue_tolerance_calc(dive,
|
||||||
depth_to_bar(depth, &displayed_dive)),
|
depth_to_bar(depth, dive)),
|
||||||
diveplan->surface_pressure / 1000.0,
|
diveplan->surface_pressure / 1000.0,
|
||||||
&displayed_dive,
|
dive,
|
||||||
1),
|
1),
|
||||||
&displayed_dive);
|
dive);
|
||||||
if (max_bottom_ceiling_pressure.mbar > first_ceiling_pressure.mbar)
|
if (max_bottom_ceiling_pressure.mbar > first_ceiling_pressure.mbar)
|
||||||
first_ceiling_pressure.mbar = max_bottom_ceiling_pressure.mbar;
|
first_ceiling_pressure.mbar = max_bottom_ceiling_pressure.mbar;
|
||||||
|
|
||||||
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time);
|
||||||
if ((current_cylinder = get_gasidx(&displayed_dive, &gas)) == -1) {
|
if ((current_cylinder = get_gasidx(dive, &gas)) == -1) {
|
||||||
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
|
||||||
current_cylinder = 0;
|
current_cylinder = 0;
|
||||||
}
|
}
|
||||||
|
@ -853,9 +852,9 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
if (depth - deltad < stoplevels[stopidx])
|
if (depth - deltad < stoplevels[stopidx])
|
||||||
deltad = depth - stoplevels[stopidx];
|
deltad = depth - stoplevels[stopidx];
|
||||||
|
|
||||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
add_segment(depth_to_bar(depth, dive),
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&dive->cylinder[current_cylinder].gasmix,
|
||||||
TIMESTEP, po2, &displayed_dive, prefs.decosac);
|
TIMESTEP, po2, dive, prefs.decosac);
|
||||||
clock += TIMESTEP;
|
clock += TIMESTEP;
|
||||||
depth -= deltad;
|
depth -= deltad;
|
||||||
/* Print VPM-Gradient as gradient factor, this has to be done from within deco.c */
|
/* Print VPM-Gradient as gradient factor, this has to be done from within deco.c */
|
||||||
|
@ -882,19 +881,19 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
if (current_cylinder != gaschanges[gi].gasidx) {
|
if (current_cylinder != gaschanges[gi].gasidx) {
|
||||||
if (!prefs.switch_at_req_stop ||
|
if (!prefs.switch_at_req_stop ||
|
||||||
!trial_ascent(depth, stoplevels[stopidx - 1], avg_depth, bottom_time,
|
!trial_ascent(depth, stoplevels[stopidx - 1], avg_depth, bottom_time,
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0) || get_o2(&displayed_dive.cylinder[current_cylinder].gasmix) < 160) {
|
&dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0) || get_o2(&dive->cylinder[current_cylinder].gasmix) < 160) {
|
||||||
current_cylinder = gaschanges[gi].gasidx;
|
current_cylinder = gaschanges[gi].gasidx;
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
#if DEBUG_PLAN & 16
|
#if DEBUG_PLAN & 16
|
||||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
|
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi].gasidx,
|
||||||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
|
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi].depth / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
/* Stop for the minimum duration to switch gas */
|
/* Stop for the minimum duration to switch gas */
|
||||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
add_segment(depth_to_bar(depth, dive),
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&dive->cylinder[current_cylinder].gasmix,
|
||||||
prefs.min_switch_duration, po2, &displayed_dive, prefs.decosac);
|
prefs.min_switch_duration, po2, dive, prefs.decosac);
|
||||||
clock += prefs.min_switch_duration;
|
clock += prefs.min_switch_duration;
|
||||||
if (prefs.doo2breaks && get_o2(&displayed_dive.cylinder[current_cylinder].gasmix) == 1000)
|
if (prefs.doo2breaks && get_o2(&dive->cylinder[current_cylinder].gasmix) == 1000)
|
||||||
o2time += prefs.min_switch_duration;
|
o2time += prefs.min_switch_duration;
|
||||||
} else {
|
} else {
|
||||||
/* The user has selected the option to switch gas only at required stops.
|
/* The user has selected the option to switch gas only at required stops.
|
||||||
|
@ -911,7 +910,7 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Check if ascending to next stop is clear, go back and wait if we hit the ceiling on the way */
|
/* Check if ascending to next stop is clear, go back and wait if we hit the ceiling on the way */
|
||||||
if (trial_ascent(depth, stoplevels[stopidx], avg_depth, bottom_time,
|
if (trial_ascent(depth, stoplevels[stopidx], avg_depth, bottom_time,
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0))
|
&dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0))
|
||||||
break; /* We did not hit the ceiling */
|
break; /* We did not hit the ceiling */
|
||||||
|
|
||||||
/* Add a minute of deco time and then try again */
|
/* Add a minute of deco time and then try again */
|
||||||
|
@ -933,28 +932,28 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
*/
|
*/
|
||||||
if (pendinggaschange) {
|
if (pendinggaschange) {
|
||||||
current_cylinder = gaschanges[gi + 1].gasidx;
|
current_cylinder = gaschanges[gi + 1].gasidx;
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
#if DEBUG_PLAN & 16
|
#if DEBUG_PLAN & 16
|
||||||
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi + 1].gasidx,
|
printf("switch to gas %d (%d/%d) @ %5.2lfm\n", gaschanges[gi + 1].gasidx,
|
||||||
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi + 1].depth / 1000.0);
|
(get_o2(&gas) + 5) / 10, (get_he(&gas) + 5) / 10, gaschanges[gi + 1].depth / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
/* Stop for the minimum duration to switch gas */
|
/* Stop for the minimum duration to switch gas */
|
||||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
add_segment(depth_to_bar(depth, dive),
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&dive->cylinder[current_cylinder].gasmix,
|
||||||
prefs.min_switch_duration, po2, &displayed_dive, prefs.decosac);
|
prefs.min_switch_duration, po2, dive, prefs.decosac);
|
||||||
clock += prefs.min_switch_duration;
|
clock += prefs.min_switch_duration;
|
||||||
if (prefs.doo2breaks && get_o2(&displayed_dive.cylinder[current_cylinder].gasmix) == 1000)
|
if (prefs.doo2breaks && get_o2(&dive->cylinder[current_cylinder].gasmix) == 1000)
|
||||||
o2time += prefs.min_switch_duration;
|
o2time += prefs.min_switch_duration;
|
||||||
pendinggaschange = false;
|
pendinggaschange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deco stop should end when runtime is at a whole minute */
|
/* Deco stop should end when runtime is at a whole minute */
|
||||||
int this_decotimestep;
|
int this_decotimestep;
|
||||||
this_decotimestep = DECOTIMESTEP - clock % DECOTIMESTEP;
|
this_decotimestep = timestep - clock % timestep;
|
||||||
|
|
||||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
add_segment(depth_to_bar(depth, dive),
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&dive->cylinder[current_cylinder].gasmix,
|
||||||
this_decotimestep, po2, &displayed_dive, prefs.decosac);
|
this_decotimestep, po2, dive, prefs.decosac);
|
||||||
clock += this_decotimestep;
|
clock += this_decotimestep;
|
||||||
/* Finish infinite deco */
|
/* Finish infinite deco */
|
||||||
if (clock >= 48 * 3600 && depth >= 6000) {
|
if (clock >= 48 * 3600 && depth >= 6000) {
|
||||||
|
@ -965,8 +964,8 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
/* The backgas breaks option limits time on oxygen to 12 minutes, followed by 6 minutes on
|
/* The backgas breaks option limits time on oxygen to 12 minutes, followed by 6 minutes on
|
||||||
* backgas (first defined gas). This could be customized if there were demand.
|
* backgas (first defined gas). This could be customized if there were demand.
|
||||||
*/
|
*/
|
||||||
if (get_o2(&displayed_dive.cylinder[current_cylinder].gasmix) == 1000) {
|
if (get_o2(&dive->cylinder[current_cylinder].gasmix) == 1000) {
|
||||||
o2time += DECOTIMESTEP;
|
o2time += timestep;
|
||||||
if (o2time >= 12 * 60) {
|
if (o2time >= 12 * 60) {
|
||||||
breaktime = 0;
|
breaktime = 0;
|
||||||
breakcylinder = current_cylinder;
|
breakcylinder = current_cylinder;
|
||||||
|
@ -974,18 +973,18 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
|
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
|
||||||
previous_point_time = clock;
|
previous_point_time = clock;
|
||||||
current_cylinder = 0;
|
current_cylinder = 0;
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (breaktime >= 0) {
|
if (breaktime >= 0) {
|
||||||
breaktime += DECOTIMESTEP;
|
breaktime += timestep;
|
||||||
if (breaktime >= 6 * 60) {
|
if (breaktime >= 6 * 60) {
|
||||||
o2time = 0;
|
o2time = 0;
|
||||||
if (is_final_plan)
|
if (is_final_plan)
|
||||||
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
|
plan_add_segment(diveplan, clock - previous_point_time, depth, current_cylinder, po2, false);
|
||||||
previous_point_time = clock;
|
previous_point_time = clock;
|
||||||
current_cylinder = breakcylinder;
|
current_cylinder = breakcylinder;
|
||||||
gas = displayed_dive.cylinder[current_cylinder].gasmix;
|
gas = dive->cylinder[current_cylinder].gasmix;
|
||||||
breaktime = -1;
|
breaktime = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1011,8 +1010,8 @@ bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_p
|
||||||
}
|
}
|
||||||
|
|
||||||
create_dive_from_plan(diveplan, is_planner);
|
create_dive_from_plan(diveplan, is_planner);
|
||||||
add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer, error);
|
add_plan_to_notes(diveplan, dive, show_disclaimer, error);
|
||||||
fixup_dc_duration(&displayed_dive.dc);
|
fixup_dc_duration(&dive->dc);
|
||||||
|
|
||||||
free(stoplevels);
|
free(stoplevels);
|
||||||
free(gaschanges);
|
free(gaschanges);
|
||||||
|
|
|
@ -842,7 +842,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
dump_plan(&diveplan);
|
dump_plan(&diveplan);
|
||||||
#endif
|
#endif
|
||||||
if (recalcQ() && !diveplan_empty(&diveplan)) {
|
if (recalcQ() && !diveplan_empty(&diveplan)) {
|
||||||
plan(&diveplan, &cache, isPlanner(), false);
|
plan(&diveplan, &displayed_dive, DECOTIMESTEP, &cache, isPlanner(), false);
|
||||||
emit calculatedPlanNotes();
|
emit calculatedPlanNotes();
|
||||||
}
|
}
|
||||||
// throw away the cache
|
// throw away the cache
|
||||||
|
@ -878,7 +878,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
|
||||||
setRecalc(oldRecalc);
|
setRecalc(oldRecalc);
|
||||||
|
|
||||||
//TODO: C-based function here?
|
//TODO: C-based function here?
|
||||||
plan(&diveplan, &cache, isPlanner(), true);
|
plan(&diveplan, &displayed_dive, DECOTIMESTEP, &cache, isPlanner(), true);
|
||||||
free(cache);
|
free(cache);
|
||||||
if (!current_dive || displayed_dive.id != current_dive->id) {
|
if (!current_dive || displayed_dive.id != current_dive->id) {
|
||||||
// we were planning a new dive, not re-planning an existing on
|
// we were planning a new dive, not re-planning an existing on
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
|
||||||
// testing the dive plan algorithm
|
// testing the dive plan algorithm
|
||||||
extern bool plan(struct diveplan *diveplan, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
extern bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
||||||
|
|
||||||
extern pressure_t first_ceiling_pressure;
|
extern pressure_t first_ceiling_pressure;
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ void TestPlan::testMetric()
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlan(&testPlan);
|
setupPlan(&testPlan);
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -404,7 +404,7 @@ void TestPlan::testImperial()
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlan(&testPlan);
|
setupPlan(&testPlan);
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -444,7 +444,7 @@ void TestPlan::testVpmbMetric45m30minTx()
|
||||||
setupPlanVpmb45m30mTx(&testPlan);
|
setupPlanVpmb45m30mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -474,7 +474,7 @@ void TestPlan::testVpmbMetric60m10minTx()
|
||||||
setupPlanVpmb60m10mTx(&testPlan);
|
setupPlanVpmb60m10mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -504,7 +504,7 @@ void TestPlan::testVpmbMetric60m30minAir()
|
||||||
setupPlanVpmb60m30minAir(&testPlan);
|
setupPlanVpmb60m30minAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -534,7 +534,7 @@ void TestPlan::testVpmbMetric60m30minEan50()
|
||||||
setupPlanVpmb60m30minEan50(&testPlan);
|
setupPlanVpmb60m30minEan50(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -570,7 +570,7 @@ void TestPlan::testVpmbMetric60m30minTx()
|
||||||
setupPlanVpmb60m30minTx(&testPlan);
|
setupPlanVpmb60m30minTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -606,7 +606,7 @@ void TestPlan::testVpmbMetric100m60min()
|
||||||
setupPlanVpmb100m60min(&testPlan);
|
setupPlanVpmb100m60min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -648,7 +648,7 @@ void TestPlan::testVpmbMetricMultiLevelAir()
|
||||||
setupPlanVpmbMultiLevelAir(&testPlan);
|
setupPlanVpmbMultiLevelAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -678,7 +678,7 @@ void TestPlan::testVpmbMetric100m10min()
|
||||||
setupPlanVpmb100m10min(&testPlan);
|
setupPlanVpmb100m10min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -724,7 +724,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
setupPlanVpmb30m20min(&testPlan);
|
setupPlanVpmb30m20min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -744,7 +744,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
||||||
|
|
||||||
setupPlanVpmb100mTo70m30min(&testPlan);
|
setupPlanVpmb100mTo70m30min(&testPlan);
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -780,7 +780,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 127u * 60u + 20u, 127u * 60u + 20u));
|
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 127u * 60u + 20u, 127u * 60u + 20u));
|
||||||
|
|
||||||
setupPlanVpmb30m20min(&testPlan);
|
setupPlanVpmb30m20min(&testPlan);
|
||||||
plan(&testPlan, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
|
Loading…
Add table
Reference in a new issue