Store a table of deco stops in planner

... in addition to struct diveplan which combines all kinds
of information

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-08-27 22:49:41 +02:00 committed by Dirk Hohndel
parent 456e2cec89
commit e6545a7b0f
4 changed files with 40 additions and 19 deletions

View file

@ -905,12 +905,15 @@ struct divedatapoint *create_dp(int time_incr, int depth, int cylinderid, int po
#if DEBUG_PLAN
void dump_plan(struct diveplan *diveplan);
#endif
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
struct decostop {
int depth;
int time;
};
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
void calc_crushing_pressure(double pressure);
void vpmb_start_gradient();
void clear_vpmb_state();
void delete_single_dive(int idx);
struct event *get_next_event(struct event *event, const char *name);

View file

@ -639,7 +639,16 @@ int wait_until(struct dive *dive, int clock, int min, int leap, int stepsize, in
// Work out the stops. Return value is if there were any mandatory stops.
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer)
void printdecotable(struct decostop *table)
{
while (table->depth) {
printf("depth=%d time=%d\n", table->depth, table->time);
++table;
}
}
bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer)
{
int bottom_depth;
int bottom_gi;
@ -674,6 +683,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
int first_stop_depth = 0;
int laststoptime = timestep;
bool o2breaking = false;
int decostopcounter = 0;
set_gf(diveplan->gflow, diveplan->gfhigh, prefs.gf_low_at_maxdepth);
set_vpmb_conservatism(diveplan->vpmb_conservatism);
@ -830,6 +840,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
//CVA
do {
decostopcounter = 0;
is_final_plan = (decoMode() == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
if (deco_time != 10000000)
vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0);
@ -975,6 +986,9 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
int new_clock = wait_until(dive, clock, clock, laststoptime * 2, timestep, depth, stoplevels[stopidx], avg_depth, bottom_time, &dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0);
laststoptime = new_clock - clock;
decostoptable[decostopcounter].depth = depth;
decostoptable[decostopcounter].time = laststoptime;
++decostopcounter;
/* Finish infinite deco */
if (clock >= 48 * 3600 && depth >= 6000) {
error = LONGDECO;
@ -1031,6 +1045,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
deco_time = clock - bottom_time;
} while (!is_final_plan);
decostoptable[decostopcounter].depth = 0;
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
if (decoMode() == VPMB) {