diff options
author | Patrick Valsecchi <patrick@thus.ch> | 2013-11-20 16:11:22 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-21 08:11:40 -0800 |
commit | fe2eabf3756c9883ee8e8c145e5cd12d8d336933 (patch) | |
tree | 2cde71531d087a96fa91ba1dc47d07f42ae98faa | |
parent | 4c4a7a6d968fa27de72f1510c55d327a7e919d7c (diff) | |
download | subsurface-fe2eabf3756c9883ee8e8c145e5cd12d8d336933.tar.gz |
Added a configuration option to have gf_low apply at max depth instead of at deepest ceiling.
Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | deco.c | 25 | ||||
-rw-r--r-- | dive.h | 2 | ||||
-rw-r--r-- | planner.c | 2 | ||||
-rw-r--r-- | pref.h | 3 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 10 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 4 | ||||
-rw-r--r-- | qt-ui/preferences.h | 1 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 7 | ||||
-rw-r--r-- | subsurfacestartup.c | 1 |
9 files changed, 34 insertions, 21 deletions
@@ -27,8 +27,9 @@ struct buehlmann_config { double gf_high; //! gradient factor high (at surface). double gf_low; //! gradient factor low (at bottom/start of deco calculation). double gf_low_position_min; //! gf_low_position below surface_min_shallow. + bool gf_low_at_maxdepth; //! if TRUE, gf_low applies at max depth instead of at deepest ceiling. }; -struct buehlmann_config buehlmann_config = { 1.0, 1.01, 0, 0.75, 0.35, 2.0 }; +struct buehlmann_config buehlmann_config = { 1.0, 1.01, 0, 0.75, 0.35, 2.0, FALSE }; const double buehlmann_N2_a[] = {1.1696, 1.0, 0.8618, 0.7562, 0.62, 0.5043, 0.441, 0.4, @@ -75,8 +76,6 @@ const double buehlmann_He_factor_expositon_one_second[] = { #define WV_PRESSURE 0.0627 // water vapor pressure in bar #define DECO_STOPS_MULTIPLIER_MM 3000.0 -#define GF_LOW_AT_MAXDEPTH 0 - double tissue_n2_sat[16]; double tissue_he_sat[16]; int ci_pointing_to_guiding_tissue; @@ -94,7 +93,6 @@ static double tissue_tolerance_calc(const struct dive *dive) double gf_high = buehlmann_config.gf_high; double gf_low = buehlmann_config.gf_low; double surface = get_surface_pressure_in_mbar(dive, TRUE) / 1000.0; - double lowest_ceiling; for (ci = 0; ci < 16; ci++) { @@ -106,12 +104,12 @@ static double tissue_tolerance_calc(const struct dive *dive) /* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */ -#if !GF_LOW_AT_MAXDEPTH - lowest_ceiling = (buehlmann_inertgas_b * tissue_inertgas_saturation - gf_low * buehlmann_inertgas_a * buehlmann_inertgas_b) / - ((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b); - if (lowest_ceiling > gf_low_pressure_this_dive) - gf_low_pressure_this_dive = lowest_ceiling; -#endif + if (!buehlmann_config.gf_low_at_maxdepth) { + double lowest_ceiling = (buehlmann_inertgas_b * tissue_inertgas_saturation - gf_low * buehlmann_inertgas_a * buehlmann_inertgas_b) / + ((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b); + if (lowest_ceiling > gf_low_pressure_this_dive) + gf_low_pressure_this_dive = lowest_ceiling; + } tolerated = (-buehlmann_inertgas_a * buehlmann_inertgas_b * (gf_high * gf_low_pressure_this_dive - gf_low * surface) - (1.0 - buehlmann_inertgas_b) * (gf_high - gf_low) * gf_low_pressure_this_dive * surface + @@ -139,10 +137,8 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s double ppn2 = (pressure - WV_PRESSURE) * (1000 - fo2 - fhe) / 1000.0; double pphe = (pressure - WV_PRESSURE) * fhe / 1000.0; -#if GF_LOW_AT_MAXDEPTH - if (pressure > gf_low_pressure_this_dive) + if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive) gf_low_pressure_this_dive = pressure; -#endif if (ccpo2) { /* CC */ double rel_o2_amb, f_dilutent; @@ -268,10 +264,11 @@ unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressur return depth; } -void set_gf(short gflow, short gfhigh) +void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth) { if (gflow != -1) buehlmann_config.gf_low = (double)gflow / 100.0; if (gfhigh != -1) buehlmann_config.gf_high = (double)gfhigh / 100.0; + buehlmann_config.gf_low_at_maxdepth = gf_low_at_maxdepth; } @@ -715,7 +715,7 @@ extern double add_segment(double pressure, const struct gasmix *gasmix, int peri extern void clear_deco(double surface_pressure); extern void dump_tissues(void); extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth); -extern void set_gf(short gflow, short gfhigh); +extern void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth); extern void cache_deco_state(double, char **datap); extern double restore_deco_state(char *data); @@ -574,7 +574,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b int gaschangenr; unsigned int *stoplevels = NULL; - set_gf(diveplan->gflow, diveplan->gfhigh); + set_gf(diveplan->gflow, diveplan->gfhigh, default_prefs.gf_low_at_maxdepth); if (!diveplan->surface_pressure) diveplan->surface_pressure = SURFACE_PRESSURE; if (*divep) @@ -31,9 +31,8 @@ struct preferences { short calc_ndl_tts; short gflow; short gfhigh; - int map_provider; + bool gf_low_at_maxdepth; short display_invalid_dives; - short show_invalid; short unit_system; struct units units; short show_sac; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 23c972741..1f3d7def9 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -564,6 +564,13 @@ bool MainWindow::askSaveChanges() else \ prefs.field = default_prefs.field +#define GET_TXT(name, field) \ + v = s.value(QString(name)); \ + if (v.isValid()) \ + prefs.field = strdup(v.toString().toUtf8().constData()); \ + else \ + prefs.field = default_prefs.field + void MainWindow::initialUiSetup() { @@ -623,7 +630,8 @@ void MainWindow::readSettings() GET_BOOL("calcalltissues", calc_all_tissues); GET_INT("gflow", gflow); GET_INT("gfhigh", gfhigh); - set_gf(prefs.gflow, prefs.gfhigh); + GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth); + set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth); GET_BOOL("show_sac", show_sac); s.endGroup(); diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index f638d9d7d..0249c894f 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -55,6 +55,7 @@ void PreferencesDialog::setUiFromPrefs() ui.gflow->setValue(prefs.gflow); ui.gfhigh->setValue(prefs.gfhigh); + ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth); // units if (prefs.unit_system == METRIC) @@ -111,7 +112,7 @@ void PreferencesDialog::syncSettings() s.setValue("pn2threshold", ui.pn2Threshold->value()); SB("ead", ui.ead_end_eadd); SB("mod", ui.mod); - s.setValue("modppo2", ui.maxppo2->value()); + s.setValue("modppO2", ui.maxppo2->value()); SB("dcceiling", ui.dc_reported_ceiling); SB("redceiling", ui.red_ceiling); SB("calcceiling", ui.calculated_ceiling); @@ -120,6 +121,7 @@ void PreferencesDialog::syncSettings() SB("calcalltissues", ui.all_tissues); s.setValue("gflow", ui.gflow->value()); s.setValue("gfhigh", ui.gfhigh->value()); + SB("gf_low_at_maxdepth", ui.gf_low_at_maxdepth); SB("show_sac", ui.show_sac); s.endGroup(); diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h index 1cd3d9096..fb0fcbc94 100644 --- a/qt-ui/preferences.h +++ b/qt-ui/preferences.h @@ -26,7 +26,6 @@ public slots: private: explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0); void setUiFromPrefs(); - void setUIFromSettings(); Ui::PreferencesDialog ui; struct preferences oldPrefs; }; diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 7e071face..581670c91 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -763,6 +763,13 @@ <item row="1" column="1"> <widget class="QSpinBox" name="gfhigh"/> </item> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="gf_low_at_maxdepth"> + <property name="text"> + <string>GFLow at max depth</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 8d5e609a9..39da8e47c 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -25,6 +25,7 @@ struct preferences default_prefs = { .calc_ndl_tts = FALSE, .gflow = 30, .gfhigh = 75, + .gf_low_at_maxdepth = FALSE, .font_size = 14.0, .display_invalid_dives = FALSE, .show_sac = FALSE, |