comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 490:68aa097f0062

BUGFIX (minor) deco_calc_CNS_planning should save ppO2 and gas switch history.
author JeanDo
date Sat, 29 Oct 2011 15:53:21 +0200
parents 7c48692dd17c
children 560764da0629
comparison
equal deleted inserted replaced
489:b8edb7362870 490:68aa097f0062
2394 // Note: Needs a call to deco_push_tissues_to_vault(), 2394 // Note: Needs a call to deco_push_tissues_to_vault(),
2395 // deco_pull_tissues_from_vault() to avoid trashing everything... 2395 // deco_pull_tissues_from_vault() to avoid trashing everything...
2396 // 2396 //
2397 // Input: CNS_fraction, char_O_deco_time[], char_O_deco_depth[] 2397 // Input: CNS_fraction, char_O_deco_time[], char_O_deco_depth[]
2398 // Output: CNS_fraction, char_O_CNS_fraction 2398 // Output: CNS_fraction, char_O_CNS_fraction
2399 // Trashed: char_I_actual_ppO2
2400 // 2399 //
2401 void deco_calc_CNS_planning(void) 2400 void deco_calc_CNS_planning(void)
2402 { 2401 {
2402 overlay unsigned char backup_gas_last_depth;
2403 overlay unsigned char backup_gas_last_used;
2404 overlay unsigned short backup_gas_delay;
2405 overlay unsigned short backup_dive_mins;
2406 overlay unsigned char backup_actual_ppO2;
2407
2403 RESET_C_STACK 2408 RESET_C_STACK
2404 2409
2410 // Backup state machine
2411 backup_gas_last_depth = sim_gas_last_depth;
2412 backup_gas_last_used = sim_gas_last_used;
2413 backup_gas_delay = sim_gas_delay;
2414 backup_dive_mins = sim_dive_mins;
2415 backup_actual_ppO2 = char_I_actual_ppO2;
2416
2405 // Uses 1min CNS period: 2417 // Uses 1min CNS period:
2406 char_I_step_is_1min = 1; 2418 char_I_step_is_1min = 1;
2407 2419
2408 //---- Retrieve bottom Gas used, and set variables. 2420 //---- Retrieve bottom Gas used, and set variables.
2409 sim_gas_last_used = char_I_first_gas; 2421 sim_gas_last_used = char_I_first_gas;
2435 2447
2436 // Ascent time (rounded up): 2448 // Ascent time (rounded up):
2437 time = (unsigned char)(0.1 * char_I_bottom_depth + 0.5); 2449 time = (unsigned char)(0.1 * char_I_bottom_depth + 0.5);
2438 2450
2439 for(t=0; t<time; ++t) 2451 for(t=0; t<time; ++t)
2452 {
2440 deco_calc_CNS_fraction(); 2453 deco_calc_CNS_fraction();
2454 sim_dive_mins++;
2455 }
2441 2456
2442 //---- Do all further stops 2457 //---- Do all further stops
2443 for(i=0; i<NUM_STOPS; ++i) 2458 for(i=0; i<NUM_STOPS; ++i)
2444 { 2459 {
2445 //---- Get next stop 2460 //---- Get next stop
2458 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55; 2473 if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55;
2459 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5); 2474 char_I_actual_ppO2 = (unsigned char)(100.0 * actual_ppO2 + 0.5);
2460 2475
2461 //---- Apply the stop 2476 //---- Apply the stop
2462 for(t=0; t<time; ++t) 2477 for(t=0; t<time; ++t)
2478 {
2463 deco_calc_CNS_fraction(); 2479 deco_calc_CNS_fraction();
2480 sim_dive_mins++;
2481 }
2464 } 2482 }
2465 } 2483 }
2466 2484
2467 // Back to normal mode... 2485 // Back to normal mode...
2468 char_I_step_is_1min = 0; 2486 char_I_step_is_1min = 0;
2487 sim_gas_last_depth = backup_gas_last_depth;
2488 sim_gas_last_used = backup_gas_last_used;
2489 sim_gas_delay = backup_gas_delay;
2490 sim_dive_mins = backup_dive_mins;
2491 char_I_actual_ppO2 = backup_actual_ppO2;
2469 } 2492 }
2470 2493
2471 ////////////////////////////////////////////////////////////////////////////// 2494 //////////////////////////////////////////////////////////////////////////////
2472 // deco_calc_CNS_decrease_15min 2495 // deco_calc_CNS_decrease_15min
2473 // 2496 //