From 449468f3445c5523ee7c4d4a46c6162db60a7095 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 23 Aug 2015 15:58:50 +0200 Subject: [PATCH 1/5] Show tissue ceilings in tenth of m/ft
Signed-off-by: Robert C. Helling <[email protected]> --- profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile.c b/profile.c index 6716854..0722151 100644 --- a/profile.c +++ b/profile.c @@ -1209,7 +1209,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me for (k = 0; k < 16; k++) { if (entry->ceilings[k]) { depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit); - put_format(b, translate("gettextFromC", "Tissue %.0fmin: %.0f%s\n"), buehlmann_N2_t_halflife[k], depthvalue, depth_unit); + put_format(b, translate("gettextFromC", "Tissue %.0fmin: %.1f%s\n"), buehlmann_N2_t_halflife[k], depthvalue, depth_unit); } } } -- 1.9.5 (Apple Git-50.3)
From 9a9ad26a4b05faae92d6ee1e62838446bb224b55 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 23 Aug 2015 16:00:02 +0200 Subject: [PATCH 2/5] Comment meaning of preference variables Signed-off-by: Robert C. Helling <[email protected]> --- pref.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pref.h b/pref.h index e471add..6ad54b4 100644 --- a/pref.h +++ b/pref.h @@ -75,7 +75,7 @@ struct preferences { short tankbar; short save_userid_local; char *userid; - int ascrate75; + int ascrate75; // All rates in mm / sec int ascrate50; int ascratestops; int ascratelast6m; @@ -90,7 +90,7 @@ struct preferences { char *proxy_pass; bool doo2breaks; bool drop_stone_mode; - bool last_stop; + bool last_stop; // At 6m? bool verbatim_plan; bool display_runtime; bool display_duration; -- 1.9.5 (Apple Git-50.3)
From 5cad75449d2438916d56bc0d8fa0b4fb5c71b660 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 23 Aug 2015 16:00:55 +0200 Subject: [PATCH 3/5] dump_tissues() should be available regardless of macro settings this does not increas binary size increadably but is usefull when trying to figure out what the planner is doing. Signed-off-by: Robert C. Helling <[email protected]> --- deco.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/deco.c b/deco.c index 198ffe8..8bff4c2 100644 --- a/deco.c +++ b/deco.c @@ -488,7 +488,6 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s return tissue_tolerance_calc(dive); } -#ifdef DECO_CALC_DEBUG void dump_tissues() { int ci; @@ -500,7 +499,6 @@ void dump_tissues() printf(" %6.3e", tissue_he_sat[ci]); printf("\n"); } -#endif void clear_deco(double surface_pressure) { -- 1.9.5 (Apple Git-50.3)
From 05fc7ab2c5f354744ac4f4c738ee507808710ef1 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 23 Aug 2015 16:04:59 +0200 Subject: [PATCH 4/5] Prepare global state of VPM-B when starting to plan Otherwise, the results of the calculations tend to be rather random and irreproducible... Signed-off-by: Robert C. Helling <[email protected]> --- deco.c | 2 ++ dive.h | 3 +++ planner.c | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/deco.c b/deco.c index 8bff4c2..20d8b04 100644 --- a/deco.c +++ b/deco.c @@ -508,6 +508,8 @@ void clear_deco(double surface_pressure) tissue_he_sat[ci] = 0.0; max_n2_crushing_pressure[ci] = 0.0; max_he_crushing_pressure[ci] = 0.0; + n2_regen_radius[ci] = get_crit_radius_N2(); + he_regen_radius[ci] = get_crit_radius_He(); } gf_low_pressure_this_dive = surface_pressure; if (!buehlmann_config.gf_low_at_maxdepth) diff --git a/dive.h b/dive.h index 0125b76..ed9e025 100644 --- a/dive.h +++ b/dive.h @@ -830,6 +830,9 @@ struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix, void dump_plan(struct diveplan *diveplan); #endif bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer); +void calc_crushing_pressure(double pressure); +void vpmb_start_gradient(); + void delete_single_dive(int idx); struct event *get_next_event(struct event *event, const char *name); diff --git a/planner.c b/planner.c index aca5a05..6011dd9 100644 --- a/planner.c +++ b/planner.c @@ -996,6 +996,13 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool create_dive_from_plan(diveplan, is_planner); return(false); } + calc_crushing_pressure(depth_to_mbar(depth, &displayed_dive) / 1000.0); + nuclear_regeneration(clock); + clear_deco(displayed_dive.surface_pressure.mbar / 1000.0); + vpmb_start_gradient(); + previous_deco_time = 100000000; + deco_time = 10000000; + tissue_tolerance = tissue_at_end(&displayed_dive, cached_datap); displayed_dive.surface_pressure.mbar = diveplan->surface_pressure; @@ -1107,7 +1114,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool vpmb_next_gradient(deco_time, diveplan->surface_pressure / 1000.0); previous_deco_time = deco_time; - restore_deco_state(bottom_cache); + tissue_tolerance = restore_deco_state(bottom_cache); depth = bottom_depth; gi = bottom_gi; -- 1.9.5 (Apple Git-50.3)
From a42708389a51b23454ca2769b5900c22308c7949 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 23 Aug 2015 16:08:04 +0200 Subject: [PATCH 5/5] Add a test for the VPM-B mode of the planner Signed-off-by: Robert C. Helling <[email protected]> --- tests/testplan.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testplan.h | 1 + 2 files changed, 76 insertions(+) diff --git a/tests/testplan.cpp b/tests/testplan.cpp index 88f1366..b506779 100644 --- a/tests/testplan.cpp +++ b/tests/testplan.cpp @@ -2,6 +2,7 @@ #include "testplan.h" #include "planner.h" #include "units.h" +#include "qthelper.h" #include <QDebug> #define DEBUG 1 @@ -19,6 +20,18 @@ void setupPrefs() prefs.last_stop = true; } +void setupPrefsVpmb() +{ + prefs = default_prefs; + prefs.ascrate50 = 10000 / 60; + prefs.ascrate75 = prefs.ascrate50; + prefs.ascratestops = prefs.ascrate50; + prefs.ascratelast6m = prefs.ascrate50; + prefs.descrate = 99000 / 60; + prefs.last_stop = false; + prefs.deco_mode = VPMB; +} + void setupPlan(struct diveplan *dp) { dp->salinity = 10300; @@ -45,6 +58,31 @@ void setupPlan(struct diveplan *dp) plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, oxygen, 0, 1); } +void setupPlanVpmb(struct diveplan *dp) +{ + dp->salinity = 10300; + dp->surface_pressure = 1013; + dp->bottomsac = 0; + dp->decosac = 0; + + struct gasmix bottomgas = { {180}, {450} }; + struct gasmix ean50 = { {500}, {0} }; + struct gasmix oxygen = { {1000}, {0} }; + pressure_t po2 = { 1600 }; + displayed_dive.cylinder[0].gasmix = bottomgas; + displayed_dive.cylinder[1].gasmix = ean50; + displayed_dive.cylinder[2].gasmix = oxygen; + displayed_dive.surface_pressure.mbar = 1013; + reset_cylinders(&displayed_dive, true); + free_dps(dp); + + int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330); + plan_add_segment(dp, droptime, M_OR_FT(100, 330), bottomgas, 0, 1); + plan_add_segment(dp, 60*60 - droptime, M_OR_FT(100, 330), bottomgas, 0, 1); + plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, ean50, 0, 1); + plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, oxygen, 0, 1); +} + void TestPlan::testMetric() { char *cache = NULL; @@ -117,4 +155,41 @@ void TestPlan::testImperial() QCOMPARE(displayed_dive.dc.duration.seconds, 110u * 60u - 2u); } +void TestPlan::testVpmbMetric() +{ + char *cache = NULL; + + setupPrefsVpmb(); + prefs.unit_system = METRIC; + prefs.units.length = units::METERS; + + struct diveplan testPlan = { 0 }; + setupPlanVpmb(&testPlan); + setCurrentAppState("PlanDive"); + + plan(&testPlan, &cache, 1, 0); + +#if DEBUG + free(displayed_dive.notes); + displayed_dive.notes = NULL; + save_dive(stdout, &displayed_dive); +#endif + + // check first gas change to EAN50 at 21m + struct event *ev = displayed_dive.dc.events; + QVERIFY(ev != NULL); + QCOMPARE(ev->gas.index, 1); + QCOMPARE(ev->value, 50); + QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000); + // check second gas change to Oxygen at 6m + ev = ev->next; + QVERIFY(ev != NULL); + QCOMPARE(ev->gas.index, 2); + QCOMPARE(ev->value, 100); + QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6000); + // check expected run time of 105 minutes + QCOMPARE(displayed_dive.dc.duration.seconds, 18980u); +} + + QTEST_MAIN(TestPlan) diff --git a/tests/testplan.h b/tests/testplan.h index b35cd75..7822129 100644 --- a/tests/testplan.h +++ b/tests/testplan.h @@ -8,6 +8,7 @@ class TestPlan : public QObject { private slots: void testImperial(); void testMetric(); + void testVpmbMetric(); }; #endif // TESTPLAN_H -- 1.9.5 (Apple Git-50.3)
as requested by Dirk, here is a test that tests the behaviour of VPM-B dive planning. The actual test is patch 5, the previous ones were created in the process of making the test pass (i.e. get the same dive plan as the full program). The test is supposed to pass after Rick’s first_stop_pressure patch is applied. This is a result of a multi-hour debugger session. Puh! Best Robert
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
