Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 443:4c7f304de294
BUGFIX: infinite loop for Decoplaner's CNS in CCR mode.
author | JeanDo |
---|---|
date | Wed, 10 Aug 2011 21:53:17 +0200 |
parents | 4826dd98514b |
children | 274689f46b1a |
comparison
equal
deleted
inserted
replaced
442:9cec10e64077 | 443:4c7f304de294 |
---|---|
2369 if (CNS_fraction > 2.5) | 2369 if (CNS_fraction > 2.5) |
2370 CNS_fraction = 2.55; | 2370 CNS_fraction = 2.55; |
2371 if (CNS_fraction < 0.0) | 2371 if (CNS_fraction < 0.0) |
2372 CNS_fraction = 0.0; | 2372 CNS_fraction = 0.0; |
2373 | 2373 |
2374 char_O_CNS_fraction = (unsigned char)(100.0f * CNS_fraction + 0.5f ); | 2374 char_O_CNS_fraction = (unsigned char)(100.0 * CNS_fraction + 0.5); |
2375 } | 2375 } |
2376 | 2376 |
2377 ////////////////////////////////////////////////////////////////////////////// | 2377 ////////////////////////////////////////////////////////////////////////////// |
2378 // deco_calc_CNS_planning | 2378 // deco_calc_CNS_planning |
2379 // | 2379 // |
2386 // Uses 1min CNS period: | 2386 // Uses 1min CNS period: |
2387 char_I_step_is_1min = 1; | 2387 char_I_step_is_1min = 1; |
2388 | 2388 |
2389 //---- Retrieve bottom Gas used, and set variables. | 2389 //---- Retrieve bottom Gas used, and set variables. |
2390 sim_gas_last_used = char_I_first_gas; | 2390 sim_gas_last_used = char_I_first_gas; |
2391 sim_gas_last_depth = 0; // Surface gas marker. | 2391 sim_gas_last_depth = 0; // Surface gas marker. |
2392 gas_switch_set(); // Sets initial calc_N2/He_ratio | 2392 gas_switch_set(); // Sets initial calc_N2/He_ratio |
2393 | 2393 |
2394 //---- CCR mode : do the full TTS at once -------------------------------- | 2394 //---- CCR mode : do the full TTS at once -------------------------------- |
2395 if( char_I_const_ppO2 != 0 ) | 2395 if( char_I_const_ppO2 != 0 ) |
2396 { | 2396 { |
2397 overlay unsigned char t; | 2397 overlay unsigned short t; // Needs 16bits here ! |
2398 char_I_actual_ppO2 = char_I_const_ppO2; | 2398 char_I_actual_ppO2 = char_I_const_ppO2; |
2399 for(t=0; t<int_O_ascenttime; ++t) | 2399 for(t=0; t<int_O_ascenttime; ++t) |
2400 deco_calc_CNS_fraction(); | 2400 deco_calc_CNS_fraction(); |
2401 } | 2401 } |
2402 else //---- OC mode : have to follow all gas switches... ----------------- | 2402 else //---- OC mode : have to follow all gas switches... ----------------- |
2403 { | 2403 { |
2404 overlay unsigned char i = 0; // Decostop loop counter | 2404 overlay unsigned char i = 0; // Decostop loop counter |
2405 overlay float actual_ppO2; | 2405 overlay float actual_ppO2; |
2406 overlay unsigned char time, t; | 2406 overlay unsigned char time, t; |
2407 | 2407 |
2408 //---- Ascent to surface delay | 2408 //---- Ascent to surface delay |
2409 // NOTE: count as if time is spent with bottom pressure, | 2409 // NOTE: count as if time is spent with bottom pressure, |
2424 for(i=0; i<NUM_STOPS; ++i) | 2424 for(i=0; i<NUM_STOPS; ++i) |
2425 { | 2425 { |
2426 //---- Get next stop | 2426 //---- Get next stop |
2427 time = char_O_deco_time[i]; | 2427 time = char_O_deco_time[i]; |
2428 temp_depth_limit = char_O_deco_depth[i] & 0x7F; | 2428 temp_depth_limit = char_O_deco_depth[i] & 0x7F; |
2429 if( time == 0 ) break; // End of table: done. | 2429 if( time == 0 ) break; // End of table: done. |
2430 | 2430 |
2431 //---- Gas Switch ? | 2431 //---- Gas Switch ? |
2432 if( char_O_deco_depth[i] & 0x80 ) | 2432 if( char_O_deco_depth[i] & 0x80 ) |
2433 gas_switch_deepest(); | 2433 gas_switch_deepest(); |
2434 | 2434 |