comparison Discovery/Src/buehlmann.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 cc2406b835ff
children 305f251cc981
comparison
equal deleted inserted replaced
290:5e0bb91d4a12 291:24ff72e627f4
515 return ((float)pDiveSettings->gf_low) / 100.0f; 515 return ((float)pDiveSettings->gf_low) / 100.0f;
516 516
517 return (pDiveSettings->gf_high - gfSteigung * (pressure - gSurface_pressure_bar) )/ 100.0f; 517 return (pDiveSettings->gf_high - gfSteigung * (pressure - gSurface_pressure_bar) )/ 100.0f;
518 } 518 }
519 519
520 520 #define MAX_NDL 240
521 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings) 521 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings)
522 { 522 {
523 float local_tissue_nitrogen_bar[16]; 523 float local_tissue_nitrogen_bar[16];
524 float local_tissue_helium_bar[16]; 524 float local_tissue_helium_bar[16];
525 int i; 525 int i;
526 int ndl = 0; 526 int ndl = 0;
527 527
528 //Check ndl always use gHigh 528 //Check ndl always use gHigh
529 gGF_value = ((float)pDiveSettings->gf_high) / 100.0f; 529 gGF_value = ((float)pDiveSettings->gf_high) / 100.0f;
530 //10 minutes steps 530 //10 minutes steps
531 while(ndl < (300 * 60)) 531 while(ndl < (MAX_NDL * 60))
532 { 532 {
533 memcpy(local_tissue_nitrogen_bar, gTissue_nitrogen_bar, (4*16)); 533 memcpy(local_tissue_nitrogen_bar, gTissue_nitrogen_bar, (4*16));
534 memcpy(local_tissue_helium_bar, gTissue_helium_bar, (4*16)); 534 memcpy(local_tissue_helium_bar, gTissue_helium_bar, (4*16));
535 // 535 //
536 ndl += 600; 536 ndl += 600;
543 break; 543 break;
544 } 544 }
545 buehlmann_backup_and_restore(false); 545 buehlmann_backup_and_restore(false);
546 } 546 }
547 547
548 if(ndl < (300 * 60)) 548 if(ndl < (MAX_NDL * 60))
549 ndl -= 600; 549 ndl -= 600;
550 550
551 if(ndl > (150 * 60)) 551 if(ndl > (MAX_NDL/2 * 60))
552 return ndl; 552 return ndl;
553 553
554 // refine 554 // refine
555 memcpy(gTissue_nitrogen_bar, local_tissue_nitrogen_bar, (4*16)); 555 memcpy(gTissue_nitrogen_bar, local_tissue_nitrogen_bar, (4*16));
556 memcpy(gTissue_helium_bar, local_tissue_helium_bar, (4*16)); 556 memcpy(gTissue_helium_bar, local_tissue_helium_bar, (4*16));
557 557
558 //One minutes step 558 //One minutes step
559 for(i = 0; i < 10; i++) 559 for(i = 0; i < 10; i++)
560 { 560 {
561 ndl += 60; 561 ndl += 60;
562 //tissues_exposure_at_gPressure_seconds(60);
563 decom_tissues_exposure2(60, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar); 562 decom_tissues_exposure2(60, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar);
564 decom_oxygen_calculate_cns_exposure(60,&pDiveSettings->decogaslist[gGas_id],gPressure,&gCNS); 563 decom_oxygen_calculate_cns_exposure(60,&pDiveSettings->decogaslist[gGas_id],gPressure,&gCNS);
565 buehlmann_backup_and_restore(true); 564 buehlmann_backup_and_restore(true);
566 if(dive1_check_deco(pDiveSettings)) 565 if(dive1_check_deco(pDiveSettings))
567 break; 566 break;