Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 563:7bec4cf28cc7 bug_deco_clearing_missed_stops
BUGFIX bad CNS in decoplan when CF54 set.
author | JeanDo |
---|---|
date | Sat, 25 Feb 2012 19:41:43 +0100 |
parents | 56753ea6a791 |
children | 4e9e95d108d2 |
comparison
equal
deleted
inserted
replaced
562:56753ea6a791 | 563:7bec4cf28cc7 |
---|---|
2199 else //---- OC mode : have to follow all gas switches... ----------------- | 2199 else //---- OC mode : have to follow all gas switches... ----------------- |
2200 { | 2200 { |
2201 overlay unsigned char i = 0; // Decostop loop counter | 2201 overlay unsigned char i = 0; // Decostop loop counter |
2202 overlay float actual_ppO2; | 2202 overlay float actual_ppO2; |
2203 overlay unsigned char time, t; | 2203 overlay unsigned char time, t; |
2204 overlay unsigned char deepest_first = (read_custom_function(54) == 0); | |
2204 | 2205 |
2205 //---- Ascent to surface delay | 2206 //---- Ascent to surface delay |
2206 // NOTE: count as if time is spent with bottom pressure, | 2207 // NOTE: count as if time is spent with bottom pressure, |
2207 // AND the bottom gas | 2208 // AND the bottom gas |
2208 actual_ppO2 = (pres_surface + char_I_bottom_depth * METER_TO_BAR) | 2209 actual_ppO2 = (pres_surface + char_I_bottom_depth * METER_TO_BAR) |
2218 { | 2219 { |
2219 deco_calc_CNS_fraction(); | 2220 deco_calc_CNS_fraction(); |
2220 sim_dive_mins++; | 2221 sim_dive_mins++; |
2221 } | 2222 } |
2222 | 2223 |
2223 //---- Do all further stops | 2224 //---- Do all further stops ------------------------------------------ |
2224 for(i=0; i<NUM_STOPS; ++i) | 2225 for(i=0; i<NUM_STOPS; ++i) |
2225 { | 2226 { |
2226 //---- Get next stop | 2227 overlay unsigned char switch_gas; |
2227 time = char_O_deco_time[i]; | 2228 |
2228 temp_depth_limit = char_O_deco_depth[i] & 0x7F; | 2229 //---- Get next stop, possibly in reverse order ------------------ |
2229 if( time == 0 ) break; // End of table: done. | 2230 if( deepest_first ) |
2231 { | |
2232 time = char_O_deco_time[i]; | |
2233 temp_depth_limit = char_O_deco_depth[i]; | |
2234 } | |
2235 else | |
2236 { | |
2237 time = char_O_deco_time[(NUM_STOPS-1)-i]; | |
2238 temp_depth_limit = char_O_deco_depth[(NUM_STOPS-1)-i]; | |
2239 } | |
2240 if( time == 0 ) continue; | |
2230 | 2241 |
2231 //---- Gas Switch ? | 2242 //---- Gas Switch ? ---------------------------------------------- |
2232 if( char_O_deco_depth[i] & 0x80 ) | 2243 switch_gas = temp_depth_limit & 0x80; // Switch flag. |
2233 if( gas_switch_deepest() ) | 2244 temp_depth_limit &= 0x7F; // True stop depth. |
2234 gas_switch_set(); | 2245 |
2235 | 2246 if( switch_gas ) |
2236 //---- Convert Depth and N2_ratio to ppO2 | 2247 { |
2248 gas_switch_deepest(); | |
2249 gas_switch_set(); | |
2250 } | |
2251 | |
2252 //---- Convert Depth and N2_ratio to ppO2 ------------------------ | |
2237 actual_ppO2 = (pres_surface + temp_depth_limit * METER_TO_BAR) | 2253 actual_ppO2 = (pres_surface + temp_depth_limit * METER_TO_BAR) |
2238 * (1.0 - calc_N2_ratio - calc_He_ratio); | 2254 * (1.0 - calc_N2_ratio - calc_He_ratio); |
2239 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0; | 2255 if( actual_ppO2 < 0.0 ) actual_ppO2 = 0.0; |
2240 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55; | 2256 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55; |
2241 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5); | 2257 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5); |
2247 sim_dive_mins++; | 2263 sim_dive_mins++; |
2248 } | 2264 } |
2249 } | 2265 } |
2250 } | 2266 } |
2251 | 2267 |
2252 // Back to normal mode... | 2268 //---- Back to normal mode... -------------------------------------------- |
2253 char_I_step_is_1min = 0; | 2269 char_I_step_is_1min = 0; |
2254 sim_gas_last_depth = backup_gas_last_depth; | 2270 sim_gas_last_depth = backup_gas_last_depth; |
2255 sim_gas_last_used = backup_gas_last_used; | 2271 sim_gas_last_used = backup_gas_last_used; |
2256 sim_gas_delay = backup_gas_delay; | 2272 sim_gas_delay = backup_gas_delay; |
2257 sim_dive_mins = backup_dive_mins; | 2273 sim_dive_mins = backup_dive_mins; |