comparison Discovery/Src/vpm.c @ 877:a0900e4df15c Evo_2_23

DevBugfix: Exit condition deco_stop_depth deco_stop_depth is defined as float but handled like an integer. During code cleanup this was not considered for the break condition of the VPM calculation loop causing an endless loop condition. The legacy format has been restored in the updated version.
author Ideenmodellierer
date Tue, 20 Aug 2024 15:18:43 +0200
parents 0c89c6fa949c
children d4622533271d
comparison
equal deleted inserted replaced
876:5b325372db4b 877:a0900e4df15c
702 702
703 /* =============================================================================== */ 703 /* =============================================================================== */
704 /* ASSIGN VARIABLES FOR ASCENT FROM START OF DECO ZONE TO FIRST STOP. SAVE */ 704 /* ASSIGN VARIABLES FOR ASCENT FROM START OF DECO ZONE TO FIRST STOP. SAVE */
705 /* FIRST STOP DEPTH FOR LATER USE WHEN COMPUTING THE FINAL ASCENT PROFILE */ 705 /* FIRST STOP DEPTH FOR LATER USE WHEN COMPUTING THE FINAL ASCENT PROFILE */
706 /* =============================================================================== */ 706 /* =============================================================================== */
707 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0); 707 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
708 starting_depth = depth_start_of_deco_calc; 708 starting_depth = depth_start_of_deco_calc;
709 first_stop_depth = deco_stop_depth; 709 first_stop_depth = deco_stop_depth;
710 first_stop = true; 710 first_stop = true;
711 } 711 }
712 /* =============================================================================== */ 712 /* =============================================================================== */
753 BOYLES_LAW_COMPENSATION(&fist_stop_depth2, &deco_stop_depth, &step_size); 753 BOYLES_LAW_COMPENSATION(&fist_stop_depth2, &deco_stop_depth, &step_size);
754 } 754 }
755 decompression_stop(&deco_stop_depth, &step_size, false); 755 decompression_stop(&deco_stop_depth, &step_size, false);
756 starting_depth = deco_stop_depth; 756 starting_depth = deco_stop_depth;
757 757
758 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0) 758 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10)
759 deco_stop_depth = 0; 759 deco_stop_depth = 0;
760 else 760 else
761 { 761 {
762 deco_stop_depth = deco_stop_depth - step_size; 762 deco_stop_depth = deco_stop_depth - step_size;
763 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0); 763 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
764 } 764 }
765 765
766 count++; 766 count++;
767 //if(count > 14) 767 //if(count > 14)
768 //return CALC_CRITICAL2; 768 //return CALC_CRITICAL2;
895 //static int dp_max; 895 //static int dp_max;
896 //static float surfacetime; 896 //static float surfacetime;
897 // _Bool first_stop = false; 897 // _Bool first_stop = false;
898 float tissue_He_saturation[16]; 898 float tissue_He_saturation[16];
899 float tissue_N2_saturation[16]; 899 float tissue_N2_saturation[16];
900 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0); 900 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40);
901 //max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth); 901 //max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth);
902 902
903 /** CALC DECO Ceiling ******************************************************************/ 903 /** CALC DECO Ceiling ******************************************************************/
904 /** Not when Future stops */ 904 /** Not when Future stops */
905 if(vpm_calc_what == DECOSTOPS) 905 if(vpm_calc_what == DECOSTOPS)
1104 { 1104 {
1105 dp = 0; 1105 dp = 0;
1106 } 1106 }
1107 else 1107 else
1108 { 1108 {
1109 dp = 1 + (unsigned short)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size); 1109 dp = 1 + (short)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size);
1110 } 1110 }
1111 1111
1112 //dp_max = (int)fmaxf(dp_max,dp); 1112 //dp_max = (int)fmaxf(dp_max,dp);
1113 if(dp > dp_max) 1113 if(dp > dp_max)
1114 { 1114 {
1137 /* 0.2 msw and minimum stop time set at 0.1 minute (6 seconds), a near */ 1137 /* 0.2 msw and minimum stop time set at 0.1 minute (6 seconds), a near */
1138 /* continuous decompression schedule can be computed. */ 1138 /* continuous decompression schedule can be computed. */
1139 /* =============================================================================== */ 1139 /* =============================================================================== */
1140 1140
1141 starting_depth = deco_stop_depth; 1141 starting_depth = deco_stop_depth;
1142 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0) 1142 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10)
1143 deco_stop_depth = 0.0; 1143 deco_stop_depth = 0;
1144 else 1144 else
1145 { 1145 {
1146 deco_stop_depth = deco_stop_depth - step_size; 1146 deco_stop_depth = deco_stop_depth - step_size;
1147 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0); 1147 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
1148 } 1148 }
1149 1149
1150 last_run_time = run_time; 1150 last_run_time = run_time;
1151 count++; 1151 count++;
1152 //if(count > 14) 1152 //if(count > 14)
1989 float fraction_nitrogen_begin; 1989 float fraction_nitrogen_begin;
1990 int count = 0; 1990 int count = 0;
1991 _Bool buehlmann_wait = false; 1991 _Bool buehlmann_wait = false;
1992 float tissue_He_saturation[16]; 1992 float tissue_He_saturation[16];
1993 float tissue_N2_saturation[16]; 1993 float tissue_N2_saturation[16];
1994 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0); 1994 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40);
1995 /* loop */ 1995 /* loop */
1996 /* =============================================================================== */ 1996 /* =============================================================================== */
1997 /* CALCULATIONS */ 1997 /* CALCULATIONS */
1998 /* =============================================================================== */ 1998 /* =============================================================================== */
1999 1999
2001 // temp_segment_time = segment_time; 2001 // temp_segment_time = segment_time;
2002 ambient_pressure = *deco_stop_depth + barometric_pressure; 2002 ambient_pressure = *deco_stop_depth + barometric_pressure;
2003 //ending_ambient_pressure = ambient_pressure; 2003 //ending_ambient_pressure = ambient_pressure;
2004 decom_get_inert_gases(ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin ); 2004 decom_get_inert_gases(ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin );
2005 2005
2006 if(*deco_stop_depth == (pDiveSettings->last_stop_depth_bar * 10.0)) 2006 if(*deco_stop_depth == (float)(pDiveSettings->last_stop_depth_bar * 10))
2007 next_stop = 0; 2007 next_stop = 0;
2008 else 2008 else
2009 { 2009 {
2010 next_stop = *deco_stop_depth - *step_size; 2010 next_stop = *deco_stop_depth - *step_size;
2011 next_stop = fmaxf(next_stop, pDiveSettings->last_stop_depth_bar * 10.0); 2011 next_stop = fmaxf(next_stop,(float)pDiveSettings->last_stop_depth_bar * 10);
2012 } 2012 }
2013 2013
2014 inspired_helium_pressure = 2014 inspired_helium_pressure =
2015 (ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; 2015 (ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
2016 inspired_nitrogen_pressure = 2016 inspired_nitrogen_pressure =
2104 run_time += segment_time; 2104 run_time += segment_time;
2105 return; 2105 return;
2106 } 2106 }
2107 //goto L700; 2107 //goto L700;
2108 initial_CNS = gCNS_VPM; 2108 initial_CNS = gCNS_VPM;
2109 decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10.0, &gCNS_VPM); 2109 decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10,&gCNS_VPM);
2110 for (i = 0; i < 16; i++) 2110 for (i = 0; i < 16; i++)
2111 { 2111 {
2112 initial_helium_pressure[i] = helium_pressure[i]; 2112 initial_helium_pressure[i] = helium_pressure[i];
2113 initial_nitrogen_pressure[i] = nitrogen_pressure[i]; 2113 initial_nitrogen_pressure[i] = nitrogen_pressure[i];
2114 helium_pressure[i] += (inspired_helium_pressure - helium_pressure[i]) * float_buehlmann_He_factor_expositon_one_minute[i]; 2114 helium_pressure[i] += (inspired_helium_pressure - helium_pressure[i]) * float_buehlmann_He_factor_expositon_one_minute[i];
2312 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10.0; 2312 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10.0;
2313 } 2313 }
2314 temp_segment_time = 0; 2314 temp_segment_time = 0;
2315 2315
2316 mix_number = 0; 2316 mix_number = 0;
2317 ambient_pressure = pInput->pressure_ambient_bar * 10.0; 2317 ambient_pressure = pInput->pressure_ambient_bar * 10;
2318 decom_get_inert_gases( ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin ); 2318 decom_get_inert_gases( ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin );
2319 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; 2319 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
2320 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin; 2320 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin;
2321 2321
2322 status = CALC_END; 2322 status = CALC_END;
2323 while (status == CALC_END) 2323 while (status == CALC_END)