comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 265:ab8ce7de2b46

BUGFIX zero gas rate (bug bb28).
author JeanDo
date Tue, 12 Apr 2011 01:19:33 +0200
parents d9593e0f1eea
children fda90f19486a
comparison
equal deleted inserted replaced
264:d9593e0f1eea 265:ab8ce7de2b46
2290 // Output: int_O_gas_volumes[0..4] in litters * 0.1 2290 // Output: int_O_gas_volumes[0..4] in litters * 0.1
2291 // 2291 //
2292 void deco_gas_volumes(void) 2292 void deco_gas_volumes(void)
2293 { 2293 {
2294 overlay float volumes[5]; 2294 overlay float volumes[5];
2295 overlay float ascent_usage; 2295 overlay float bottom_usage, ascent_usage;
2296 overlay unsigned char i, deepest_first; 2296 overlay unsigned char i, deepest_first;
2297 overlay unsigned char gas; 2297 overlay unsigned char gas;
2298 RESET_C_STACK 2298 RESET_C_STACK
2299 2299
2300 //---- initialize with bottom consumption -------------------------------- 2300 //---- initialize with bottom consumption --------------------------------
2302 volumes[i] = 0.0; 2302 volumes[i] = 0.0;
2303 2303
2304 assert(1 <= char_I_first_gas && char_I_first_gas <= 5); 2304 assert(1 <= char_I_first_gas && char_I_first_gas <= 5);
2305 gas = char_I_first_gas - 1; 2305 gas = char_I_first_gas - 1;
2306 2306
2307 volumes[gas] 2307 bottom_usage = read_custom_function(56) * 0.1;
2308 = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar. 2308 if( bottom_usage > 0.0 )
2309 * char_I_bottom_time // in minutes. 2309 volumes[gas]
2310 * read_custom_function(56) // In deci-liter/minutes. 2310 = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar.
2311 * 0.1; // deci-liters --> liters. 2311 * char_I_bottom_time // in minutes.
2312 * bottom_usage; // In liter/minutes.
2313 else
2314 volumes[gas] = 65535.0;
2312 2315
2313 //---- Ascent usage ------------------------------------------------------ 2316 //---- Ascent usage ------------------------------------------------------
2314 2317
2315 deepest_first = read_custom_function(54) == 0; 2318 deepest_first = read_custom_function(54) == 0;
2316 ascent_usage = read_custom_function(57) * 0.1; // In liter/minutes. 2319 ascent_usage = read_custom_function(57) * 0.1; // In liter/minutes.
2318 // Usage up to the first stop: 2321 // Usage up to the first stop:
2319 // - computed at MAX depth (easier, safer), 2322 // - computed at MAX depth (easier, safer),
2320 // - with an ascent speed of 10m/min. 2323 // - with an ascent speed of 10m/min.
2321 // - with ascent litter / minutes. 2324 // - with ascent litter / minutes.
2322 // - still using bottom gas: 2325 // - still using bottom gas:
2323 volumes[gas] 2326 if( ascent_usage > 0.0 )
2324 += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar 2327 volumes[gas]
2325 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min) 2328 += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar
2326 * ascent_usage; // Consumption ( xxx / min @ 1 bar) 2329 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min)
2330 * ascent_usage; // Consumption ( xxx / min @ 1 bar)
2331 else
2332 volumes[gas] = 65535.0;
2327 2333
2328 for(i=0; i<32; ++i) 2334 for(i=0; i<32; ++i)
2329 { 2335 {
2330 overlay unsigned char j; 2336 overlay unsigned char j;
2331 overlay unsigned char depth, time, ascent; 2337 overlay unsigned char depth, time, ascent;
2358 gas = j; 2364 gas = j;
2359 } 2365 }
2360 2366
2361 // usage during stop: 2367 // usage during stop:
2362 // Note: because first gas is not in there, increment gas+1 2368 // Note: because first gas is not in there, increment gas+1
2363 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar. 2369 if( ascent_usage > 0.0 )
2364 * time // in minutes. 2370 volumes[gas] += (depth*0.1 + 1.0) // depth --> bar.
2365 * ascent_usage // in xxx / min @ 1bar. 2371 * time // in minutes.
2366 // Plus usage during ascent to the next stop, at 10m/min. 2372 * ascent_usage // in xxx / min @ 1bar.
2367 + (depth*0.1 + 1.0) 2373 // Plus usage during ascent to the next stop, at 10m/min.
2368 * ascent*0.1 // meter --> min 2374 + (depth*0.1 + 1.0)
2369 * ascent_usage; 2375 * ascent*0.1 // meter --> min
2376 * ascent_usage;
2377 else
2378 volumes[gas] = 65535.0;
2370 } 2379 }
2371 2380
2372 //---- convert results for the ASM interface ----------------------------- 2381 //---- convert results for the ASM interface -----------------------------
2373 for(i=0; i<5; ++i) 2382 for(i=0; i<5; ++i)
2374 if( volumes[i] > 6553.4 ) 2383 if( volumes[i] > 6553.4 )