comparison src/p2_deco.c @ 587:e81cf407261a

V2.97 SP1
author heinrichsweikamp
date Sat, 10 Mar 2018 15:34:47 +0100
parents 00ad4ffd915b
children 146e50d2672f
comparison
equal deleted inserted replaced
586:06642f6ffe59 587:e81cf407261a
1 // *************************************************************************** 1 // ***************************************************************************
2 // p2_deco.c REFACTORED VERSION V2.98+ 2 // p2_deco.c REFACTORED VERSION V2.97 SP1
3 // 3 //
4 // Created on: 12.05.2009 4 // Created on: 12.05.2009
5 // Author: heinrichs weikamp, contributions by Ralph Lembcke and others 5 // Author: heinrichs weikamp, contributions by Ralph Lembcke and others
6 // 6 //
7 // *************************************************************************** 7 // ***************************************************************************
1019 } 1019 }
1020 1020
1021 // After the first deco stop, gas changes are only done at deco stops now! 1021 // After the first deco stop, gas changes are only done at deco stops now!
1022 1022
1023 // check if a stop is found and there is a better gas to switch to 1023 // check if a stop is found and there is a better gas to switch to
1024 if( need_stop && gas_find_better() ) 1024 if( need_stop )
1025 if( gas_find_better() )
1025 { 1026 {
1026 // set the new calculation ratios for N2, He and O2 1027 // set the new calculation ratios for N2, He and O2
1027 gas_set_ratios(); 1028 gas_set_ratios();
1028 1029
1029 // prime the deco stop with the gas change time 1030 // prime the deco stop with the gas change time
1163 if( sim_gas_last_depth && (char_I_deco_gas_change[j] > sim_gas_last_depth) ) continue; 1164 if( sim_gas_last_depth && (char_I_deco_gas_change[j] > sim_gas_last_depth) ) continue;
1164 1165
1165 // Is the change depth of the gas shallower or equal to the change depth 1166 // Is the change depth of the gas shallower or equal to the change depth
1166 // of the best gas found so far, or is it the first better gas found? 1167 // of the best gas found so far, or is it the first better gas found?
1167 // If yes, we have a better gas 1168 // If yes, we have a better gas
1168 if( char_I_deco_gas_change[j] <= switch_depth ) 1169 if( char_I_deco_gas_change[j] < switch_depth )
1169 { 1170 {
1170 switch_gas = j+1; // remember this gas (1..5) 1171 switch_gas = j+1; // remember this gas (1..5)
1171 switch_depth = char_I_deco_gas_change[j]; // remember its change depth 1172 switch_depth = char_I_deco_gas_change[j]; // remember its change depth
1172 } 1173 }
1173 } // continue looping through all gases to eventually find an even better gas 1174 } // continue looping through all gases to eventually find an even better gas
1969 } 1970 }
1970 else 1971 else
1971 { 1972 {
1972 //---- no stop required -------------------------------------- 1973 //---- no stop required --------------------------------------
1973 1974
1974 // ascend by float_ascent_speed for 1 minute 1975 // convert next depth (without stop requirement) to absolute pressure
1975 sim_pres_respiration -= float_ascent_speed * METER_TO_BAR; 1976 sim_pres_respiration = sim_depth_limit * METER_TO_BAR + pres_surface;
1976 1977
1977 // finish deco calculation if surface is reached 1978 // finish deco calculation if surface is reached
1978 if( sim_pres_respiration <= pres_surface ) 1979 if( sim_pres_respiration <= pres_surface )
1979 { 1980 {
1980 Surface: 1981 Surface:
2056 // depth in meters where we are now (no round-up) 2057 // depth in meters where we are now (no round-up)
2057 sim_depth_limit = (unsigned char)((sim_pres_respiration - pres_surface) * BAR_TO_METER); 2058 sim_depth_limit = (unsigned char)((sim_pres_respiration - pres_surface) * BAR_TO_METER);
2058 2059
2059 // Check if there is a better gas to switch to, but only in alternative plan mode 2060 // Check if there is a better gas to switch to, but only in alternative plan mode
2060 // or if override is set. If yes, introduce a stop for the gas change. 2061 // or if override is set. If yes, introduce a stop for the gas change.
2061 if( ((char_O_deco_status & DECO_PLAN_ALTERNATE) || (char_O_main_status & DECO_GASCHANGE_OVRD)) 2062 if( (char_O_deco_status & DECO_PLAN_ALTERNATE) || (char_O_main_status & DECO_GASCHANGE_OVRD) )
2062 && gas_find_better() ) 2063 if( gas_find_better() )
2063 { 2064 {
2064 // depth in meters we came from 2065 // depth in meters we came from
2065 overlay unsigned char old_depth_limit = (unsigned char)((old_deco - pres_surface) * BAR_TO_METER); 2066 overlay unsigned char old_depth_limit = (unsigned char)((old_deco - pres_surface) * BAR_TO_METER);
2066 2067
2067 // adjust sim_depth_limit to the gas change depth, but not deeper than the depth we came from 2068 // adjust sim_depth_limit to the gas change depth, but not deeper than the depth we came from