comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 478:fd8266b511cc

New SAC (CF56/CF57) in 5..50 l/min range (no more decimal).
author JeanDo
date Wed, 12 Oct 2011 19:02:38 +0200
parents 5546da23afab
children 7c48692dd17c
comparison
equal deleted inserted replaced
477:1b09cead63a8 478:fd8266b511cc
2506 // Input: char_I_bottom_depth, char_I_bottom_time for planned dive. 2506 // Input: char_I_bottom_depth, char_I_bottom_time for planned dive.
2507 // Gas list. 2507 // Gas list.
2508 // char_I_first_gas is the bottom gas. 2508 // char_I_first_gas is the bottom gas.
2509 // decoplan (char_O_deco_depth, char_O_deco_time). 2509 // decoplan (char_O_deco_depth, char_O_deco_time).
2510 // CF#54 == TRUE if shallowest stop first. 2510 // CF#54 == TRUE if shallowest stop first.
2511 // CF#56 == bottom deci-liters/minutes (0.5 .. 50.0) or bar/min. 2511 // CF#56 == bottom liters/minutes (5 .. 50) or bar/min.
2512 // CF#57 == deco deci-liters/minutes (0.5 .. 50.0) or bar/min. 2512 // CF#57 == deco liters/minutes (5 .. 50) or bar/min.
2513 // Output: int_O_gas_volumes[0..4] in litters * 0.1 2513 // Output: int_O_gas_volumes[0..4] in litters * 0.1
2514 // 2514 //
2515 void deco_gas_volumes(void) 2515 void deco_gas_volumes(void)
2516 { 2516 {
2517 overlay float volumes[NUM_GAS]; 2517 overlay float volumes[NUM_GAS];
2518 overlay float bottom_usage, ascent_usage; 2518 overlay float bottom_usage, deco_usage;
2519 overlay unsigned char i, deepest_first; 2519 overlay unsigned char i, deepest_first;
2520 overlay unsigned char gas; 2520 overlay unsigned char gas;
2521 RESET_C_STACK 2521 RESET_C_STACK
2522 2522
2523 //---- initialize with bottom consumption -------------------------------- 2523 //---- initialize with bottom consumption --------------------------------
2525 volumes[i] = 0.0; 2525 volumes[i] = 0.0;
2526 2526
2527 assert(1 <= char_I_first_gas && char_I_first_gas <= NUM_GAS); 2527 assert(1 <= char_I_first_gas && char_I_first_gas <= NUM_GAS);
2528 gas = char_I_first_gas - 1; 2528 gas = char_I_first_gas - 1;
2529 2529
2530 bottom_usage = read_custom_function(56) * 0.1; 2530 bottom_usage = (float) read_custom_function(56);
2531 if( bottom_usage > 0.0 ) 2531 if( bottom_usage > 0.0 )
2532 volumes[gas] 2532 volumes[gas]
2533 = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar. 2533 = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar.
2534 * char_I_bottom_time // in minutes. 2534 * char_I_bottom_time // in minutes.
2535 * bottom_usage; // In liter/minutes. 2535 * bottom_usage; // In liter/minutes.
2537 volumes[gas] = 65535.0; 2537 volumes[gas] = 65535.0;
2538 2538
2539 //---- Ascent usage ------------------------------------------------------ 2539 //---- Ascent usage ------------------------------------------------------
2540 2540
2541 deepest_first = read_custom_function(54) == 0; 2541 deepest_first = read_custom_function(54) == 0;
2542 ascent_usage = read_custom_function(57) * 0.1; // In liter/minutes. 2542 deco_usage = (float) read_custom_function(57); // In liter/minutes.
2543 2543
2544 // Usage up to the first stop: 2544 // Usage up to the first stop:
2545 // - computed at MAX depth (easier, safer), 2545 // - computed at MAX depth (easier, safer),
2546 // - with an ascent speed of 10m/min. 2546 // - with an ascent speed of 10m/min.
2547 // - with ascent litter / minutes. 2547 // - with ascent litter / minutes.
2548 // - still using bottom gas: 2548 // - still using bottom gas:
2549 if( ascent_usage > 0.0 ) 2549 if( deco_usage > 0.0 )
2550 volumes[gas] 2550 volumes[gas]
2551 += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar 2551 += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar
2552 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min) 2552 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min)
2553 * ascent_usage; // Consumption ( xxx / min @ 1 bar) 2553 * deco_usage; // Consumption ( xxx / min @ 1 bar)
2554 else 2554 else
2555 volumes[gas] = 65535.0; 2555 volumes[gas] = 65535.0;
2556 2556
2557 for(i=0; i<NUM_STOPS; ++i) 2557 for(i=0; i<NUM_STOPS; ++i)
2558 { 2558 {
2587 gas = j; 2587 gas = j;
2588 } 2588 }
2589 2589
2590 // usage during stop: 2590 // usage during stop:
2591 // Note: because first gas is not in there, increment gas+1 2591 // Note: because first gas is not in there, increment gas+1
2592 if( ascent_usage > 0.0 ) 2592 if( deco_usage > 0.0 )
2593 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar. 2593 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar.
2594 * time // in minutes. 2594 * time // in minutes.
2595 * ascent_usage // in xxx / min @ 1bar. 2595 * deco_usage // in xxx / min @ 1bar.
2596 // Plus usage during ascent to the next stop, at 10m/min. 2596 // Plus usage during ascent to the next stop, at 10m/min.
2597 + (depth*0.1 + 1.0) 2597 + (depth*0.1 + 1.0)
2598 * ascent*0.1 // metre --> min 2598 * ascent*0.1 // metre --> min
2599 * ascent_usage; 2599 * deco_usage;
2600 else 2600 else
2601 volumes[gas] = 65535.0; 2601 volumes[gas] = 65535.0;
2602 } 2602 }
2603 2603
2604 //---- convert results for the ASM interface ----------------------------- 2604 //---- convert results for the ASM interface -----------------------------