mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
456e2cec89
commit
e6545a7b0f
4 changed files with 40 additions and 19 deletions
|
@ -905,12 +905,15 @@ 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 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 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);
|
||||||
|
|
|
@ -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.
|
// 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_depth;
|
||||||
int bottom_gi;
|
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 first_stop_depth = 0;
|
||||||
int laststoptime = timestep;
|
int laststoptime = timestep;
|
||||||
bool o2breaking = false;
|
bool o2breaking = false;
|
||||||
|
int decostopcounter = 0;
|
||||||
|
|
||||||
set_gf(diveplan->gflow, diveplan->gfhigh, prefs.gf_low_at_maxdepth);
|
set_gf(diveplan->gflow, diveplan->gfhigh, prefs.gf_low_at_maxdepth);
|
||||||
set_vpmb_conservatism(diveplan->vpmb_conservatism);
|
set_vpmb_conservatism(diveplan->vpmb_conservatism);
|
||||||
|
@ -830,6 +840,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
|
||||||
|
|
||||||
//CVA
|
//CVA
|
||||||
do {
|
do {
|
||||||
|
decostopcounter = 0;
|
||||||
is_final_plan = (decoMode() == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
|
is_final_plan = (decoMode() == BUEHLMANN) || (previous_deco_time - deco_time < 10); // CVA time converges
|
||||||
if (deco_time != 10000000)
|
if (deco_time != 10000000)
|
||||||
vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0);
|
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);
|
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;
|
laststoptime = new_clock - clock;
|
||||||
|
decostoptable[decostopcounter].depth = depth;
|
||||||
|
decostoptable[decostopcounter].time = laststoptime;
|
||||||
|
++decostopcounter;
|
||||||
/* Finish infinite deco */
|
/* Finish infinite deco */
|
||||||
if (clock >= 48 * 3600 && depth >= 6000) {
|
if (clock >= 48 * 3600 && depth >= 6000) {
|
||||||
error = LONGDECO;
|
error = LONGDECO;
|
||||||
|
@ -1031,6 +1045,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec
|
||||||
|
|
||||||
deco_time = clock - bottom_time;
|
deco_time = clock - bottom_time;
|
||||||
} while (!is_final_plan);
|
} while (!is_final_plan);
|
||||||
|
decostoptable[decostopcounter].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);
|
||||||
if (decoMode() == VPMB) {
|
if (decoMode() == VPMB) {
|
||||||
|
|
|
@ -842,7 +842,8 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
dump_plan(&diveplan);
|
dump_plan(&diveplan);
|
||||||
#endif
|
#endif
|
||||||
if (recalcQ() && !diveplan_empty(&diveplan)) {
|
if (recalcQ() && !diveplan_empty(&diveplan)) {
|
||||||
plan(&diveplan, &displayed_dive, DECOTIMESTEP, &cache, isPlanner(), false);
|
struct decostop stoptable[60];
|
||||||
|
plan(&diveplan, &displayed_dive, DECOTIMESTEP, stoptable, &cache, isPlanner(), false);
|
||||||
emit calculatedPlanNotes();
|
emit calculatedPlanNotes();
|
||||||
}
|
}
|
||||||
// throw away the cache
|
// throw away the cache
|
||||||
|
@ -878,7 +879,8 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
|
||||||
setRecalc(oldRecalc);
|
setRecalc(oldRecalc);
|
||||||
|
|
||||||
//TODO: C-based function here?
|
//TODO: C-based function here?
|
||||||
plan(&diveplan, &displayed_dive, DECOTIMESTEP, &cache, isPlanner(), true);
|
struct decostop stoptable[60];
|
||||||
|
plan(&diveplan, &displayed_dive, DECOTIMESTEP, stoptable, &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,8 @@
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
|
||||||
// testing the dive plan algorithm
|
// testing the dive plan algorithm
|
||||||
extern bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct deco_state **cached_datap, bool is_planner, bool show_disclaimer);
|
struct decostop stoptable[60];
|
||||||
|
extern bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct decostop *decostoptable, 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 +365,7 @@ void TestPlan::testMetric()
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlan(&testPlan);
|
setupPlan(&testPlan);
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -404,7 +405,7 @@ void TestPlan::testImperial()
|
||||||
struct diveplan testPlan = {};
|
struct diveplan testPlan = {};
|
||||||
setupPlan(&testPlan);
|
setupPlan(&testPlan);
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -444,7 +445,7 @@ void TestPlan::testVpmbMetric45m30minTx()
|
||||||
setupPlanVpmb45m30mTx(&testPlan);
|
setupPlanVpmb45m30mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -474,7 +475,7 @@ void TestPlan::testVpmbMetric60m10minTx()
|
||||||
setupPlanVpmb60m10mTx(&testPlan);
|
setupPlanVpmb60m10mTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -504,7 +505,7 @@ void TestPlan::testVpmbMetric60m30minAir()
|
||||||
setupPlanVpmb60m30minAir(&testPlan);
|
setupPlanVpmb60m30minAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -534,7 +535,7 @@ void TestPlan::testVpmbMetric60m30minEan50()
|
||||||
setupPlanVpmb60m30minEan50(&testPlan);
|
setupPlanVpmb60m30minEan50(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -570,7 +571,7 @@ void TestPlan::testVpmbMetric60m30minTx()
|
||||||
setupPlanVpmb60m30minTx(&testPlan);
|
setupPlanVpmb60m30minTx(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -606,7 +607,7 @@ void TestPlan::testVpmbMetric100m60min()
|
||||||
setupPlanVpmb100m60min(&testPlan);
|
setupPlanVpmb100m60min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -648,7 +649,7 @@ void TestPlan::testVpmbMetricMultiLevelAir()
|
||||||
setupPlanVpmbMultiLevelAir(&testPlan);
|
setupPlanVpmbMultiLevelAir(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -678,7 +679,7 @@ void TestPlan::testVpmbMetric100m10min()
|
||||||
setupPlanVpmb100m10min(&testPlan);
|
setupPlanVpmb100m10min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -724,7 +725,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
setupPlanVpmb30m20min(&testPlan);
|
setupPlanVpmb30m20min(&testPlan);
|
||||||
setCurrentAppState("PlanDive");
|
setCurrentAppState("PlanDive");
|
||||||
|
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -744,7 +745,7 @@ void TestPlan::testVpmbMetricRepeat()
|
||||||
int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds;
|
||||||
|
|
||||||
setupPlanVpmb100mTo70m30min(&testPlan);
|
setupPlanVpmb100mTo70m30min(&testPlan);
|
||||||
plan(&testPlan, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
@ -780,7 +781,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, &displayed_dive, 60, &cache, 1, 0);
|
plan(&testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
|
|
Loading…
Add table
Reference in a new issue