Mercurial > public > ostc4
comparison Discovery/Src/vpm.c @ 291:24ff72e627f4 div-fixes-6
Deco Models: limit NDL to 240 minutes
Limit the deco models to report up to 240 minutes of NDL. This was
triggered by commit 54d14bc2083c. The logbook uses a 8bit UINT, so
storing a value of 300 is impossible (which was taken care of in
that commit). But, as the small OSTCs also use 240 min. as maximum
NDL, we better do that here too (from a consistency point of view).
And while we are at it ... kick out some commented and useless code.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Thu, 02 May 2019 09:16:07 +0200 |
parents | 5e0bb91d4a12 |
children | bfcea6e2ab3f |
comparison
equal
deleted
inserted
replaced
290:5e0bb91d4a12 | 291:24ff72e627f4 |
---|---|
2276 | 2276 |
2277 /* =============================================================================== */ | 2277 /* =============================================================================== */ |
2278 // vpm_calc_nullzeit | 2278 // vpm_calc_nullzeit |
2279 // Purpose: This function calcs zero time (time where no decostops are needed) | 2279 // Purpose: This function calcs zero time (time where no decostops are needed) |
2280 //=============================================================================== | 2280 //=============================================================================== |
2281 #define MAX_NDL 240 | |
2282 | |
2281 static int vpm_calc_nullzeit(void) | 2283 static int vpm_calc_nullzeit(void) |
2282 { | 2284 { |
2283 static float future_helium_pressure[16]; | 2285 static float future_helium_pressure[16]; |
2284 static float future_nitrogen_pressure[16]; | 2286 static float future_nitrogen_pressure[16]; |
2285 static int temp_segment_time; | 2287 static int temp_segment_time; |
2293 float fraction_helium_begin; | 2295 float fraction_helium_begin; |
2294 float fraction_nitrogen_begin; | 2296 float fraction_nitrogen_begin; |
2295 int i = 0; | 2297 int i = 0; |
2296 int count = 0; | 2298 int count = 0; |
2297 int status = CALC_END; | 2299 int status = CALC_END; |
2298 //if(begin) | 2300 |
2299 //{ | |
2300 for(i = 0; i < 16;i++) | 2301 for(i = 0; i < 16;i++) |
2301 { | 2302 { |
2302 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10; | 2303 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10; |
2303 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10; | 2304 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10; |
2304 } | 2305 } |
2305 temp_segment_time = 0; | 2306 temp_segment_time = 0; |
2306 | 2307 |
2307 mix_number = 0; | 2308 mix_number = 0; |
2308 ambient_pressure = pInput->pressure_ambient_bar * 10; | 2309 ambient_pressure = pInput->pressure_ambient_bar * 10; |
2309 // fraction_helium_begin; | |
2310 // fraction_nitrogen_begin; | |
2311 decom_get_inert_gases( ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin ); | 2310 decom_get_inert_gases( ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin ); |
2312 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; | 2311 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; |
2313 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin; | 2312 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin; |
2314 | 2313 |
2315 //if(!nullzeit_unter60) | |
2316 //{ | |
2317 status = CALC_END; | 2314 status = CALC_END; |
2318 while (status == CALC_END) | 2315 while (status == CALC_END) |
2319 { | 2316 { |
2320 count++; | 2317 count++; |
2321 //if(count == 7) | |
2322 //return CALC_NULLZEIT2; | |
2323 temp_segment_time += 60; | 2318 temp_segment_time += 60; |
2324 if(temp_segment_time >= 300) | 2319 if(temp_segment_time >= MAX_NDL) |
2325 { | 2320 { |
2326 pDecoInfo->output_ndl_seconds = temp_segment_time * 60; | 2321 pDecoInfo->output_ndl_seconds = temp_segment_time * 60; |
2327 return CALC_NULLZEIT; | 2322 return CALC_NULLZEIT; |
2328 } | 2323 } |
2329 run_time += 60; | 2324 run_time += 60; |
2346 for (i = 1; i <= 16; ++i) | 2341 for (i = 1; i <= 16; ++i) |
2347 { | 2342 { |
2348 future_helium_pressure[i - 1] = previous_helium_pressure[i-1]; | 2343 future_helium_pressure[i - 1] = previous_helium_pressure[i-1]; |
2349 future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1]; | 2344 future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1]; |
2350 } | 2345 } |
2351 //} | |
2352 //} | |
2353 //if(!nullzeit_unter60 || begin || temp_segment_time > 10) | |
2354 //{ | |
2355 | 2346 |
2356 status = CALC_END; | 2347 status = CALC_END; |
2357 if(temp_segment_time < 60) | 2348 if(temp_segment_time < 60) |
2358 nullzeit_unter60 = true; | 2349 nullzeit_unter60 = true; |
2359 | 2350 |
2360 while (status == CALC_END) | 2351 while (status == CALC_END) |
2361 { | 2352 { |
2362 // count++; | |
2363 //if(count >= 5) | |
2364 //return CALC_NULLZEIT2; | |
2365 temp_segment_time += 5; | 2353 temp_segment_time += 5; |
2366 if(temp_segment_time >= 300) | 2354 if(temp_segment_time >= MAX_NDL) |
2367 { | 2355 { |
2368 pDecoInfo->output_ndl_seconds = temp_segment_time * 60; | 2356 pDecoInfo->output_ndl_seconds = temp_segment_time * 60; |
2369 return CALC_NULLZEIT; | 2357 return CALC_NULLZEIT; |
2370 } | 2358 } |
2371 if(nullzeit_unter60 && temp_segment_time > 60) | 2359 if(nullzeit_unter60 && temp_segment_time > 60) |
2372 { | 2360 { |
2373 nullzeit_unter60 = false; | 2361 nullzeit_unter60 = false; |
2374 //tts[NULLZEIT] = temp_segment_time * 60; | |
2375 return CALC_NULLZEIT; | 2362 return CALC_NULLZEIT; |
2376 } | 2363 } |
2377 run_time += 5; | 2364 run_time += 5; |
2378 //goto L700; | 2365 //goto L700; |
2379 for (i = 1; i <= 16; ++i) { | 2366 for (i = 1; i <= 16; ++i) { |
2392 for (i = 1; i <= 16; ++i) { | 2379 for (i = 1; i <= 16; ++i) { |
2393 future_helium_pressure[i - 1] = previous_helium_pressure[i-1]; | 2380 future_helium_pressure[i - 1] = previous_helium_pressure[i-1]; |
2394 future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1]; | 2381 future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1]; |
2395 } | 2382 } |
2396 status = CALC_END; | 2383 status = CALC_END; |
2397 //if(temp_segment_time < 5) | 2384 |
2398 //count = 2; | |
2399 //} | |
2400 //else | |
2401 //count = 1; | |
2402 if(temp_segment_time <= 20) | 2385 if(temp_segment_time <= 20) |
2403 { | 2386 { |
2404 while (status == CALC_END) | 2387 while (status == CALC_END) |
2405 { | 2388 { |
2406 //time_counter = temp_segment_time; | |
2407 //count++; | |
2408 //if(count > 2) | |
2409 //return CALC_NULLZEIT2; | |
2410 temp_segment_time += minimum_deco_stop_time; | 2389 temp_segment_time += minimum_deco_stop_time; |
2411 run_time += minimum_deco_stop_time; | 2390 run_time += minimum_deco_stop_time; |
2412 //goto L700; | 2391 //goto L700; |
2413 for (i = 1; i <= 16; ++i) { | 2392 for (i = 1; i <= 16; ++i) { |
2414 future_helium_pressure[i - 1] = future_helium_pressure[i - 1] + (inspired_helium_pressure - future_helium_pressure[i - 1]) * float_buehlmann_He_factor_expositon_one_minute[i-1]; | 2393 future_helium_pressure[i - 1] = future_helium_pressure[i - 1] + (inspired_helium_pressure - future_helium_pressure[i - 1]) * float_buehlmann_He_factor_expositon_one_minute[i-1]; |