comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 321:a99073445c18

Cleanup auto setpoint switch
author JeanDo
date Thu, 05 May 2011 22:18:24 +0200
parents 1de9eee3837b
children 676d18bce8d7
comparison
equal deleted inserted replaced
320:08a3f503e93e 321:a99073445c18
188 static float var_N2_e; // Exposition, for current N2 tissue. 188 static float var_N2_e; // Exposition, for current N2 tissue.
189 static float var_He_e; // Exposition, for current He tissue. 189 static float var_He_e; // Exposition, for current He tissue.
190 190
191 static float pres_diluent; // new in v.101 191 static float pres_diluent; // new in v.101
192 static float const_ppO2; // new in v.101 192 static float const_ppO2; // new in v.101
193 static float deco_ppO2_change; // new in v.101
194 static float deco_ppO2; // new in v.101
195 193
196 static unsigned char sim_gas_last_depth; // Depth of last used gas, to detected a gas switch. 194 static unsigned char sim_gas_last_depth; // Depth of last used gas, to detected a gas switch.
197 static unsigned char sim_gas_last_used; // Number of last used gas, to detected a gas switch. 195 static unsigned char sim_gas_last_used; // Number of last used gas, to detected a gas switch.
198 static unsigned short sim_gas_delay; // Time of gas-switch-stop ends [min on dive]. 196 static unsigned short sim_gas_delay; // Time of gas-switch-stop ends [min on dive].
199 static unsigned short sim_dive_mins; // Simulated dive time. 197 static unsigned short sim_dive_mins; // Simulated dive time.
237 static unsigned char DBG_deco_He_ratio; // new in v.108 235 static unsigned char DBG_deco_He_ratio; // new in v.108
238 static float DBG_pres_surface; // new in v.108 236 static float DBG_pres_surface; // new in v.108
239 static float DBG_GF_low; // new in v.108 237 static float DBG_GF_low; // new in v.108
240 static float DBG_GF_high; // new in v.108 238 static float DBG_GF_high; // new in v.108
241 static float DBG_const_ppO2; // new in v.108 239 static float DBG_const_ppO2; // new in v.108
242 static float DBG_deco_ppO2_change; // new in v.108
243 static float DBG_deco_ppO2; // new in v.108
244 static float DBG_float_saturation_multiplier; // new in v.108 240 static float DBG_float_saturation_multiplier; // new in v.108
245 static float DBG_float_desaturation_multiplier; // new in v.108 241 static float DBG_float_desaturation_multiplier; // new in v.108
246 static float DBG_float_deco_distance; // new in v.108 242 static float DBG_float_deco_distance; // new in v.108
247 static float DBG_N2_ratio; // new in v.108 243 static float DBG_N2_ratio; // new in v.108
248 static float DBG_He_ratio; // new in v.108 244 static float DBG_He_ratio; // new in v.108
318 DBG_char_I_depth_last_deco = char_I_depth_last_deco; 314 DBG_char_I_depth_last_deco = char_I_depth_last_deco;
319 DBG_pres_surface = pres_surface; 315 DBG_pres_surface = pres_surface;
320 DBG_GF_low = GF_low; 316 DBG_GF_low = GF_low;
321 DBG_GF_high = GF_high; 317 DBG_GF_high = GF_high;
322 DBG_const_ppO2 = const_ppO2; 318 DBG_const_ppO2 = const_ppO2;
323 DBG_deco_ppO2_change = deco_ppO2_change;
324 DBG_deco_ppO2 = deco_ppO2;
325 DBG_deco_N2_ratio = char_I_deco_N2_ratio[0]; 319 DBG_deco_N2_ratio = char_I_deco_N2_ratio[0];
326 DBG_deco_He_ratio = char_I_deco_He_ratio[0]; 320 DBG_deco_He_ratio = char_I_deco_He_ratio[0];
327 DBG_deco_gas_change = deco_gas_change[0]; 321 DBG_deco_gas_change = deco_gas_change[0];
328 DBG_float_saturation_multiplier = float_saturation_multiplier; 322 DBG_float_saturation_multiplier = float_saturation_multiplier;
329 DBG_float_desaturation_multiplier = float_desaturation_multiplier; 323 DBG_float_desaturation_multiplier = float_desaturation_multiplier;
335 if(const_ppO2) 329 if(const_ppO2)
336 int_O_DBS_bitfield |= DBS_ppO2; 330 int_O_DBS_bitfield |= DBS_ppO2;
337 for(i = 16; i < 32; i++) 331 for(i = 16; i < 32; i++)
338 if(pres_tissue[i]) 332 if(pres_tissue[i])
339 int_O_DBS_bitfield |= DBS_HE_sat; 333 int_O_DBS_bitfield |= DBS_HE_sat;
340 if(deco_ppO2_change)
341 int_O_DBS_bitfield |= DBS_ppO2chg;
342 if(float_saturation_multiplier < 0.99) 334 if(float_saturation_multiplier < 0.99)
343 int_O_DBS_bitfield |= DBS_SAT2l; 335 int_O_DBS_bitfield |= DBS_SAT2l;
344 if(float_saturation_multiplier > 1.3) 336 if(float_saturation_multiplier > 1.3)
345 int_O_DBS_bitfield |= DBS_SAT2h; 337 int_O_DBS_bitfield |= DBS_SAT2h;
346 if(GF_low < 0.19) 338 if(GF_low < 0.19)
427 if( !DBS_HE_sat && !He_ratio) 419 if( !DBS_HE_sat && !He_ratio)
428 for(i = 16; i < 32; i++) 420 for(i = 16; i < 32; i++)
429 if(pres_tissue[i]) 421 if(pres_tissue[i])
430 temp_DBS |= DBG_HEwoHE; 422 temp_DBS |= DBG_HEwoHE;
431 423
432 if(DBG_deco_ppO2 != deco_ppO2)
433 temp_DBS |= DBG_C_DPPO2;
434
435 if( DBG_deco_gas_change != deco_gas_change[0] 424 if( DBG_deco_gas_change != deco_gas_change[0]
436 || DBG_deco_N2_ratio != char_I_deco_N2_ratio[0] 425 || DBG_deco_N2_ratio != char_I_deco_N2_ratio[0]
437 || DBG_deco_He_ratio != char_I_deco_He_ratio[0] ) 426 || DBG_deco_He_ratio != char_I_deco_He_ratio[0] )
438 temp_DBS |= DBG_C_DGAS; 427 temp_DBS |= DBG_C_DGAS;
439 428
1144 if( char_I_const_ppO2 != 0 ) 1133 if( char_I_const_ppO2 != 0 )
1145 { 1134 {
1146 // In CCR mode, use calc_XX_ratio instead of XX_ratio. 1135 // In CCR mode, use calc_XX_ratio instead of XX_ratio.
1147 // Note: PPO2 and ratios are known outside the lumbs, so there is no 1136 // Note: PPO2 and ratios are known outside the lumbs, so there is no
1148 // ppWater in the equations below: 1137 // ppWater in the equations below:
1149 if( temp_deco > deco_ppO2_change ) 1138 deco_diluent -= const_ppO2;
1150 deco_diluent -= const_ppO2;
1151 else
1152 deco_diluent -= deco_ppO2;
1153 deco_diluent /= calc_N2_ratio + calc_He_ratio; 1139 deco_diluent /= calc_N2_ratio + calc_He_ratio;
1154 1140
1155 if (deco_diluent > temp_deco) 1141 if (deco_diluent > temp_deco)
1156 deco_diluent = temp_deco; 1142 deco_diluent = temp_deco;
1157 } 1143 }
1376 if( int_temp > 100 *(short)char_I_deco_gas_change[4] ) 1362 if( int_temp > 100 *(short)char_I_deco_gas_change[4] )
1377 deco_gas_change[4] = char_I_deco_gas_change[4]; 1363 deco_gas_change[4] = char_I_deco_gas_change[4];
1378 } 1364 }
1379 1365
1380 const_ppO2 = char_I_const_ppO2 * 0.01; 1366 const_ppO2 = char_I_const_ppO2 * 0.01;
1381 deco_ppO2_change = char_I_deco_ppO2_change * METER_TO_BAR
1382 + pres_surface
1383 + float_deco_distance;
1384 deco_ppO2 = char_I_deco_ppO2 * 0.01;
1385 float_desaturation_multiplier = char_I_desaturation_multiplier * 0.01; 1367 float_desaturation_multiplier = char_I_desaturation_multiplier * 0.01;
1386 float_saturation_multiplier = char_I_saturation_multiplier * 0.01; 1368 float_saturation_multiplier = char_I_saturation_multiplier * 0.01;
1387 GF_low = char_I_GF_Low_percentage * 0.01; 1369 GF_low = char_I_GF_Low_percentage * 0.01;
1388 GF_high = char_I_GF_High_percentage * 0.01; 1370 GF_high = char_I_GF_High_percentage * 0.01;
1389 GF_delta = GF_high - GF_low; 1371 GF_delta = GF_high - GF_low;
1402 pres_diluent = pres_respiration; 1384 pres_diluent = pres_respiration;
1403 if( char_I_const_ppO2 != 0 ) // new in v.101 1385 if( char_I_const_ppO2 != 0 ) // new in v.101
1404 { 1386 {
1405 pres_diluent -= const_ppO2; // new in v.101 1387 pres_diluent -= const_ppO2; // new in v.101
1406 pres_diluent /= N2_ratio + He_ratio; // new in v.101 1388 pres_diluent /= N2_ratio + He_ratio; // new in v.101
1389 if( pres_diluent < 0.0 )
1390 pres_diluent = 0.0;
1407 if( pres_diluent > pres_respiration ) // new in v.101 1391 if( pres_diluent > pres_respiration ) // new in v.101
1408 pres_diluent = pres_respiration; // new in v.101 1392 pres_diluent = pres_respiration; // new in v.101
1409 1393
1410 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0 + 0.5); 1394 char_O_diluent = (unsigned char)(pres_diluent/pres_respiration*100.0 + 0.5);
1411 char_O_diluent_ppO2 = (char)(pres_diluent * (1.0 - N2_ratio - He_ratio) * 100.0 + 0.5); 1395 char_O_diluent_ppO2 = (unsigned char)(pres_diluent * (1.0 - N2_ratio - He_ratio) * 100.0 + 0.5);
1412 } 1396 }
1413 1397
1414 if( pres_diluent > ppWater ) // new in v.101 1398 if( pres_diluent > ppWater ) // new in v.101
1415 { 1399 {
1416 overlay float EAD, END; 1400 overlay float EAD, END;