mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 01:43:23 +00:00
Merge branch 'for_dirkhh' of https://github.com/atdotde/subsurface
This commit is contained in:
commit
e1af20728e
1 changed files with 18 additions and 15 deletions
|
@ -925,10 +925,8 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru
|
||||||
{
|
{
|
||||||
int i, count_iteration = 0;
|
int i, count_iteration = 0;
|
||||||
double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0;
|
double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0;
|
||||||
int last_ndl_tts_calc_time = 0;
|
|
||||||
int first_ceiling = 0;
|
|
||||||
bool first_iteration = true;
|
bool first_iteration = true;
|
||||||
int final_tts = 0 , time_clear_ceiling = 0, time_deep_ceiling = 0, deco_time = 0, prev_deco_time = 10000000;
|
int deco_time = 0, prev_deco_time = 10000000;
|
||||||
char *cache_data_initial = NULL;
|
char *cache_data_initial = NULL;
|
||||||
/* For VPM-B outside the planner, cache the initial deco state for CVA iterations */
|
/* For VPM-B outside the planner, cache the initial deco state for CVA iterations */
|
||||||
if (prefs.deco_mode == VPMB && !in_planner())
|
if (prefs.deco_mode == VPMB && !in_planner())
|
||||||
|
@ -936,6 +934,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru
|
||||||
/* For VPM-B outside the planner, iterate until deco time converges (usually one or two iterations after the initial)
|
/* For VPM-B outside the planner, iterate until deco time converges (usually one or two iterations after the initial)
|
||||||
* Set maximum number of iterations to 10 just in case */
|
* Set maximum number of iterations to 10 just in case */
|
||||||
while ((abs(prev_deco_time - deco_time) >= 30) && (count_iteration < 10)) {
|
while ((abs(prev_deco_time - deco_time) >= 30) && (count_iteration < 10)) {
|
||||||
|
int last_ndl_tts_calc_time = 0, first_ceiling = 0, current_ceiling, final_tts = 0 , time_clear_ceiling = 0, time_deep_ceiling = 0;
|
||||||
for (i = 1; i < pi->nr; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
struct plot_data *entry = pi->entry + i;
|
struct plot_data *entry = pi->entry + i;
|
||||||
int j, t0 = (entry - 1)->sec, t1 = entry->sec;
|
int j, t0 = (entry - 1)->sec, t1 = entry->sec;
|
||||||
|
@ -973,22 +972,26 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru
|
||||||
vpmb_next_gradient(deco_time, surface_pressure / 1000.0);
|
vpmb_next_gradient(deco_time, surface_pressure / 1000.0);
|
||||||
}
|
}
|
||||||
entry->ceiling = deco_allowed_depth(tissue_tolerance_calc(dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, !prefs.calcceiling3m);
|
entry->ceiling = deco_allowed_depth(tissue_tolerance_calc(dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, !prefs.calcceiling3m);
|
||||||
|
if (prefs.calcceiling3m)
|
||||||
|
current_ceiling = deco_allowed_depth(tissue_tolerance_calc(dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, true);
|
||||||
|
else
|
||||||
|
current_ceiling = entry->ceiling;
|
||||||
/* If using VPM-B outside the planner, take first_ceiling_pressure as the deepest ceiling */
|
/* If using VPM-B outside the planner, take first_ceiling_pressure as the deepest ceiling */
|
||||||
if (prefs.deco_mode == VPMB && !in_planner()) {
|
if (prefs.deco_mode == VPMB && !in_planner()) {
|
||||||
if (entry->ceiling >= first_ceiling) {
|
if (current_ceiling > first_ceiling) {
|
||||||
time_deep_ceiling = t1;
|
time_deep_ceiling = t1;
|
||||||
first_ceiling = entry->ceiling;
|
first_ceiling = current_ceiling;
|
||||||
first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
|
first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
|
||||||
if (first_iteration) {
|
if (first_iteration) {
|
||||||
nuclear_regeneration(t1);
|
nuclear_regeneration(t1);
|
||||||
vpmb_start_gradient();
|
vpmb_start_gradient();
|
||||||
/* For CVA calculations, start by guessing deco time = dive time remaining */
|
/* For CVA calculations, start by guessing deco time = dive time remaining */
|
||||||
deco_time = pi->maxtime - t1;
|
deco_time = pi->maxtime - t1;
|
||||||
vpmb_next_gradient(deco_time, surface_pressure / 1000.0);
|
vpmb_next_gradient(deco_time, surface_pressure / 1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use the point where the ceiling clears as the end of deco phase for CVA calculations
|
// Use the point where the ceiling clears as the end of deco phase for CVA calculations
|
||||||
if (entry->ceiling > 0)
|
if (current_ceiling > 0)
|
||||||
time_clear_ceiling = 0;
|
time_clear_ceiling = 0;
|
||||||
else if (time_clear_ceiling == 0)
|
else if (time_clear_ceiling == 0)
|
||||||
time_clear_ceiling = t1;
|
time_clear_ceiling = t1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue