changeset 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
files Discovery/Src/buehlmann.c Discovery/Src/vpm.c
diffstat 2 files changed, 10 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/buehlmann.c	Thu May 02 08:43:07 2019 +0200
+++ b/Discovery/Src/buehlmann.c	Thu May 02 09:16:07 2019 +0200
@@ -517,7 +517,7 @@
 	return (pDiveSettings->gf_high - gfSteigung * (pressure - gSurface_pressure_bar) )/ 100.0f;
 }
 
-
+#define MAX_NDL 240
 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings)
 {
 	float local_tissue_nitrogen_bar[16];
@@ -528,7 +528,7 @@
 	//Check ndl always use gHigh
 	gGF_value = ((float)pDiveSettings->gf_high) / 100.0f;
 	//10 minutes steps
-	while(ndl < (300 * 60))
+	while(ndl < (MAX_NDL * 60))
 	{
 		memcpy(local_tissue_nitrogen_bar, gTissue_nitrogen_bar, (4*16));
 		memcpy(local_tissue_helium_bar, gTissue_helium_bar, (4*16));
@@ -545,10 +545,10 @@
 		buehlmann_backup_and_restore(false);
 	}
 
-	if(ndl < (300 * 60))
+	if(ndl < (MAX_NDL * 60))
 		ndl -= 600;
 
-	if(ndl > (150 * 60))
+	if(ndl > (MAX_NDL/2 * 60))
 		return ndl;
 
 	// refine
@@ -559,7 +559,6 @@
 	for(i = 0; i < 10; i++)
 	{
 		ndl += 60;
-		//tissues_exposure_at_gPressure_seconds(60);
 		decom_tissues_exposure2(60, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar);
 		decom_oxygen_calculate_cns_exposure(60,&pDiveSettings->decogaslist[gGas_id],gPressure,&gCNS);
 		buehlmann_backup_and_restore(true);
--- a/Discovery/Src/vpm.c	Thu May 02 08:43:07 2019 +0200
+++ b/Discovery/Src/vpm.c	Thu May 02 09:16:07 2019 +0200
@@ -2278,6 +2278,8 @@
 //	vpm_calc_nullzeit
 //     Purpose: This function calcs zero time (time where no decostops are needed)
 //===============================================================================
+#define MAX_NDL	240
+
 static int vpm_calc_nullzeit(void)
 {
     static float future_helium_pressure[16];
@@ -2295,8 +2297,7 @@
     int i = 0;
     int count = 0;
     int status = CALC_END;
-    //if(begin)
-    //{
+
         for(i = 0; i < 16;i++)
         {
             future_helium_pressure[i] =  pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10;
@@ -2306,22 +2307,16 @@
 
         mix_number = 0;
         ambient_pressure = pInput->pressure_ambient_bar  * 10;
-//		 fraction_helium_begin;
-//		 fraction_nitrogen_begin;
         decom_get_inert_gases( ambient_pressure / 10,  (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin );
         inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
         inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin;
 
-        //if(!nullzeit_unter60)
-        //{
             status = CALC_END;
             while (status == CALC_END)
             {
                 count++;
-                //if(count == 7)
-                    //return CALC_NULLZEIT2;
                 temp_segment_time  +=  60;
-                if(temp_segment_time >= 300)
+                if(temp_segment_time >= MAX_NDL)
                 {
                     pDecoInfo->output_ndl_seconds = temp_segment_time * 60;
                     return CALC_NULLZEIT;
@@ -2348,10 +2343,6 @@
                 future_helium_pressure[i - 1] = previous_helium_pressure[i-1];
                 future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1];
             }
-        //}
-    //}
-    //if(!nullzeit_unter60 || begin ||  temp_segment_time > 10)
-    //{
 
         status = CALC_END;
         if(temp_segment_time < 60)
@@ -2359,11 +2350,8 @@
 
         while (status == CALC_END)
         {
-        //	count++;
-            //if(count >= 5)
-                //return CALC_NULLZEIT2;
             temp_segment_time  +=  5;
-            if(temp_segment_time >= 300)
+            if(temp_segment_time >= MAX_NDL)
             {
                 pDecoInfo->output_ndl_seconds = temp_segment_time * 60;
                 return CALC_NULLZEIT;
@@ -2371,7 +2359,6 @@
             if(nullzeit_unter60 && temp_segment_time > 60)
             {
                 nullzeit_unter60 = false;
-                //tts[NULLZEIT] = temp_segment_time * 60;
                 return CALC_NULLZEIT;
             }
             run_time += 5;
@@ -2394,19 +2381,11 @@
             future_nitrogen_pressure[i - 1] = previous_nitrogen_pressure[i - 1];
         }
         status = CALC_END;
-        //if(temp_segment_time < 5)
-            //count = 2;
-    //}
-    //else
-        //count = 1;
+
     if(temp_segment_time <= 20)
     {
         while (status == CALC_END)
         {
-            //time_counter = temp_segment_time;
-            //count++;
-            //if(count > 2)
-                //return CALC_NULLZEIT2;
             temp_segment_time  +=  minimum_deco_stop_time;
             run_time += minimum_deco_stop_time;
             //goto L700;