diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-04-07 15:06:44 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2016-04-11 21:23:35 +0200 |
commit | a260dc2f8ac3123b85a9f5bd0a3fd3186db67055 (patch) | |
tree | 8f3fbc2bad10aef5baaaa87d71cde37798976bb3 | |
parent | ccff22759612455ba5b4eb7232b6b8d50177ba4a (diff) | |
download | subsurface-a260dc2f8ac3123b85a9f5bd0a3fd3186db67055.tar.gz |
Fix time of first ceiling calculation
In our verision of VPM-B for real dives, we take as the deco time the
difference between the time of the deepest ceiling and the time when the
ceiling clears.
When the display of ceilings was set to multiples of 3m this was confused, as
the maximum finder had issues: First of all, it updated the time when the ceiling
was the same (which was almost always the case for stepped ceilings) but changing
>= to > was not enough, since then the first time a deepest stepped ceiling was
reached was used.
This patch uses the actual ceiling (not rounded to the next integer multiple of 3m)
for this calculation to get rid of this problem.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
-rw-r--r-- | core/profile.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/core/profile.c b/core/profile.c index 72c5e0298..c0042ed3d 100644 --- a/core/profile.c +++ b/core/profile.c @@ -926,7 +926,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru 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; int last_ndl_tts_calc_time = 0; - int first_ceiling = 0; + int first_ceiling = 0, current_ceiling; bool first_iteration = true; int final_tts = 0 , time_clear_ceiling = 0, time_deep_ceiling = 0, deco_time = 0, prev_deco_time = 10000000; char *cache_data_initial = NULL; @@ -973,22 +973,26 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru 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); + 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 (prefs.deco_mode == VPMB && !in_planner()) { - if (entry->ceiling >= first_ceiling) { - time_deep_ceiling = t1; - first_ceiling = entry->ceiling; - first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive); - if (first_iteration) { - nuclear_regeneration(t1); - vpmb_start_gradient(); - /* For CVA calculations, start by guessing deco time = dive time remaining */ - deco_time = pi->maxtime - t1; - vpmb_next_gradient(deco_time, surface_pressure / 1000.0); - } + if (current_ceiling > first_ceiling) { + time_deep_ceiling = t1; + first_ceiling = current_ceiling; + first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive); + if (first_iteration) { + nuclear_regeneration(t1); + vpmb_start_gradient(); + /* For CVA calculations, start by guessing deco time = dive time remaining */ + deco_time = pi->maxtime - t1; + 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 - if (entry->ceiling > 0) + if (current_ceiling > 0) time_clear_ceiling = 0; else if (time_clear_ceiling == 0) time_clear_ceiling = t1; |