Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 514:3e9904d3c040
BUGFIX spurious CNS bound check.
author | JeanDo |
---|---|
date | Sun, 04 Dec 2011 17:46:13 +0100 |
parents | c9f19a546e64 |
children | 48bbb1a81027 |
comparison
equal
deleted
inserted
replaced
513:c9f19a546e64 | 514:3e9904d3c040 |
---|---|
2233 for(t=0; t<char_I_dive_interval; ++t) | 2233 for(t=0; t<char_I_dive_interval; ++t) |
2234 { | 2234 { |
2235 calc_tissue(2); // period = 10min. | 2235 calc_tissue(2); // period = 10min. |
2236 CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9) | 2236 CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9) |
2237 } | 2237 } |
2238 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); | 2238 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.56 ); |
2239 char_O_CNS_fraction = (unsigned char)(CNS_fraction * 100.0 + 0.5); | |
2239 | 2240 |
2240 //---- Restore model ----------------------------------------------------- | 2241 //---- Restore model ----------------------------------------------------- |
2241 char_I_deco_model = backup_model; | 2242 char_I_deco_model = backup_model; |
2242 } | 2243 } |
2243 | 2244 |
2401 else if (char_I_actual_ppO2 < 230) | 2402 else if (char_I_actual_ppO2 < 230) |
2402 CNS_fraction += time_factor*0.0209; | 2403 CNS_fraction += time_factor*0.0209; |
2403 else | 2404 else |
2404 CNS_fraction += time_factor*0.0482; // value for 2.5 | 2405 CNS_fraction += time_factor*0.0482; // value for 2.5 |
2405 | 2406 |
2406 if (CNS_fraction > 2.5) | 2407 if( CNS_fraction > 2.5 ) |
2407 CNS_fraction = 2.55; | 2408 CNS_fraction = 2.55; |
2408 if (CNS_fraction < 0.0) | 2409 if( CNS_fraction < 0.0 ) |
2409 CNS_fraction = 0.0; | 2410 CNS_fraction = 0.0; |
2410 | 2411 |
2411 char_O_CNS_fraction = (unsigned char)(100.0 * CNS_fraction + 0.5); | 2412 char_O_CNS_fraction = (unsigned char)(100.0 * CNS_fraction + 0.5); |
2412 } | 2413 } |
2413 | 2414 |
2528 // Uses and Updates: CNS_fraction | 2529 // Uses and Updates: CNS_fraction |
2529 // | 2530 // |
2530 void deco_calc_CNS_decrease_15min(void) | 2531 void deco_calc_CNS_decrease_15min(void) |
2531 { | 2532 { |
2532 RESET_C_STACK | 2533 RESET_C_STACK |
2533 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.5 ); | 2534 assert( 0.0 <= CNS_fraction && CNS_fraction <= 2.56 ); |
2534 | 2535 |
2535 CNS_fraction = 0.890899 * CNS_fraction; | 2536 CNS_fraction = 0.890899 * CNS_fraction; |
2536 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); | 2537 char_O_CNS_fraction = (unsigned char)(CNS_fraction * 100.0 + 0.5); |
2537 } | 2538 } |
2538 | 2539 |
2539 ////////////////////////////////////////////////////////////////////////////// | 2540 ////////////////////////////////////////////////////////////////////////////// |
2540 // deco_calc_percentage | 2541 // deco_calc_percentage |
2541 // | 2542 // |
2698 pres_tissue_He[x] = pres_tissue_He_vault[x]; | 2699 pres_tissue_He[x] = pres_tissue_He_vault[x]; |
2699 } | 2700 } |
2700 | 2701 |
2701 // Restore both CNS variable, too. | 2702 // Restore both CNS variable, too. |
2702 CNS_fraction = cns_vault; | 2703 CNS_fraction = cns_vault; |
2703 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); | 2704 char_O_CNS_fraction = (unsigned char)(CNS_fraction * 100.0 + 0.5); |
2704 } | 2705 } |
2705 | 2706 |
2706 ////////////////////////////////////////////////////////////////////////////// | 2707 ////////////////////////////////////////////////////////////////////////////// |
2707 // | 2708 // |
2708 #ifndef CROSS_COMPILE | 2709 #ifndef CROSS_COMPILE |