comparison Discovery/Src/vpm.c @ 863:0c89c6fa949c Evo_2_23

Bugfix empty line in deco plan (VPM only): Floating numbers were used to calculate the target slot for the time entry of a deco stop. The float rounding caused a time to be written into one line above the intended one. In the next step the misplaced time was overwritten by the next shallower stop. To fix the problem the index calculation has been corrected and in addition digit numbers have generally been added to floating point operations to make the floating operation more visible.
author Ideenmodellierer
date Tue, 02 Jul 2024 20:05:08 +0200
parents b7d93ff6b3b2
children a0900e4df15c
comparison
equal deleted inserted replaced
862:974648b5ccfe 863:0c89c6fa949c
163 floorf(*x + 0.5f) : -floorf(0.5f - *x) ); 163 floorf(*x + 0.5f) : -floorf(0.5f - *x) );
164 } 164 }
165 165
166 static float r_int(float *x) 166 static float r_int(float *x)
167 { 167 {
168 return( (*x>0) ? floorf(*x) : -floorf(- *x) ); 168 return( (*x>0.0) ? floorf(*x) : -floorf(- *x) );
169 } 169 }
170 170
171 /** private functions 171 /** private functions
172 */ 172 */
173 extern int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius); 173 extern int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius);
636 // buehlmann safety 636 // buehlmann safety
637 if(buehlmannSafety) 637 if(buehlmannSafety)
638 { 638 {
639 for (i = 0; i < 16; i++) 639 for (i = 0; i < 16; i++)
640 { 640 {
641 tissue_He_saturation[i] = helium_pressure[i] / 10; 641 tissue_He_saturation[i] = helium_pressure[i] / 10.0;
642 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; 642 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
643 } 643 }
644 644
645 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)) 645 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar))
646 { 646 {
647 647
648 vpm_violates_buehlmann = true; 648 vpm_violates_buehlmann = true;
649 do { 649 do {
650 deco_stop_depth += 3; 650 deco_stop_depth += 3.0;
651 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)); 651 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar));
652 } 652 }
653 } 653 }
654 654
655 /* =============================================================================== */ 655 /* =============================================================================== */
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); 707 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
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) 758 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0)
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); 763 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
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); 900 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0);
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)
923 } 923 }
924 if(buehlmannSafety) 924 if(buehlmannSafety)
925 { 925 {
926 for (i = 0; i < 16; i++) 926 for (i = 0; i < 16; i++)
927 { 927 {
928 tissue_He_saturation[i] = helium_pressure[i] / 10; 928 tissue_He_saturation[i] = helium_pressure[i] / 10.0;
929 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; 929 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
930 } 930 }
931 931
932 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)) 932 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar))
933 { 933 {
934
935 vpm_violates_buehlmann = true; 934 vpm_violates_buehlmann = true;
936 do { 935 do {
937 deco_ceiling_depth += 0.1f; 936 deco_ceiling_depth += 0.1f;
938 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)); 937 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar));
939 } 938 }
961 // buehlmann safety 960 // buehlmann safety
962 if(vpm_violates_buehlmann) 961 if(vpm_violates_buehlmann)
963 { 962 {
964 for (i = 0; i < 16; i++) 963 for (i = 0; i < 16; i++)
965 { 964 {
966 tissue_He_saturation[i] = helium_pressure[i] / 10; 965 tissue_He_saturation[i] = helium_pressure[i] / 10.0;
967 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; 966 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
968 } 967 }
969 968
970 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)) 969 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar))
971 { 970 {
972
973 vpm_violates_buehlmann = true; 971 vpm_violates_buehlmann = true;
974 do { 972 do {
975 deco_ceiling_depth += 0.1f; 973 deco_ceiling_depth += 0.1f;
976 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)); 974 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar));
977 } 975 }
981 deco_ceiling_depth = first_stop_depth; 979 deco_ceiling_depth = first_stop_depth;
982 pDecoInfo->output_ceiling_meter = deco_ceiling_depth ; 980 pDecoInfo->output_ceiling_meter = deco_ceiling_depth ;
983 } 981 }
984 else 982 else
985 { 983 {
986 pDecoInfo->output_ceiling_meter = 0; 984 pDecoInfo->output_ceiling_meter = 0.0;
987 } 985 }
988 986
989 // fix hw 160627 987 // fix hw 160627
990 if(pDecoInfo->output_ceiling_meter < 0) 988 if(pDecoInfo->output_ceiling_meter < 0.0)
991 pDecoInfo->output_ceiling_meter = 0; 989 pDecoInfo->output_ceiling_meter = 0.0;
992 990
993 /*** End CALC ceiling ***************************************************/ 991 /*** End CALC ceiling ***************************************************/
994 } 992 }
995 993
996 994
1005 float stop_time; 1003 float stop_time;
1006 int count = 0; 1004 int count = 0;
1007 static int dp_max; 1005 static int dp_max;
1008 static float surfacetime; 1006 static float surfacetime;
1009 _Bool first_stop = false; 1007 _Bool first_stop = false;
1008
1009 short stop_time_seconds;
1010
1010 max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth); 1011 max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth);
1011 if(begin) 1012 if(begin)
1012 { 1013 {
1013 gCNS_VPM = 0; 1014 gCNS_VPM = 0;
1014 dp_max = 0; 1015 dp_max = 0;
1103 { 1104 {
1104 dp = 0; 1105 dp = 0;
1105 } 1106 }
1106 else 1107 else
1107 { 1108 {
1108 dp = 1 + (int)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10)) / step_size); 1109 dp = 1 + (unsigned short)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size);
1109 } 1110 }
1110 dp_max = (int)fmaxf(dp_max,dp); 1111
1112 //dp_max = (int)fmaxf(dp_max,dp);
1113 if(dp > dp_max)
1114 {
1115 dp_max = dp;
1116 }
1111 if(dp < DECOINFO_STRUCT_MAX_STOPS) 1117 if(dp < DECOINFO_STRUCT_MAX_STOPS)
1112 { 1118 {
1113 int stop_time_seconds = fminf((999 * 60), (int)(stop_time *60)); 1119 stop_time_seconds = (short) fminf((999.9 * 60.0), (stop_time *60.0));
1114 // 1120 //
1115 1121
1116 //if(vpm_calc_what == DECOSTOPS) 1122 //if(vpm_calc_what == DECOSTOPS)
1117 pDecoInfo->output_stop_length_seconds[dp] = (unsigned short)stop_time_seconds; 1123 pDecoInfo->output_stop_length_seconds[dp] = stop_time_seconds;
1118 //else 1124 //else
1119 //decostop_bailout[dp] = (unsigned short)stop_time_seconds; 1125 //decostop_bailout[dp] = (unsigned short)stop_time_seconds;
1120 } 1126 }
1121 } 1127 }
1122 1128
1131 /* 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 */
1132 /* continuous decompression schedule can be computed. */ 1138 /* continuous decompression schedule can be computed. */
1133 /* =============================================================================== */ 1139 /* =============================================================================== */
1134 1140
1135 starting_depth = deco_stop_depth; 1141 starting_depth = deco_stop_depth;
1136 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10) 1142 if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0)
1137 deco_stop_depth = 0; 1143 deco_stop_depth = 0.0;
1138 else 1144 else
1139 { 1145 {
1140 deco_stop_depth = deco_stop_depth - step_size; 1146 deco_stop_depth = deco_stop_depth - step_size;
1141 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10); 1147 deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
1142 } 1148 }
1143 1149
1144 last_run_time = run_time; 1150 last_run_time = run_time;
1145 count++; 1151 count++;
1146 //if(count > 14) 1152 //if(count > 14)
1156 pDecoInfo->output_stop_length_seconds[dp] = 0; 1162 pDecoInfo->output_stop_length_seconds[dp] = 0;
1157 //else 1163 //else
1158 //decostop_bailout[dp] = 0; 1164 //decostop_bailout[dp] = 0;
1159 } 1165 }
1160 } 1166 }
1161 pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60); 1167 pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60.0);
1162 pDecoInfo->output_ndl_seconds = 0; 1168 pDecoInfo->output_ndl_seconds = 0;
1163 1169
1164 vpm_calc_deco_ceiling(); 1170 vpm_calc_deco_ceiling();
1165 /* end of deco stop lo */ 1171 /* end of deco stop lo */
1166 return CALC_END; 1172 return CALC_END;
1407 /* =============================================================================== */ 1413 /* =============================================================================== */
1408 /* The tolerated ambient pressure cannot be less than zero absolute, i.e., */ 1414 /* The tolerated ambient pressure cannot be less than zero absolute, i.e., */
1409 /* the vacuum of outer space! */ 1415 /* the vacuum of outer space! */
1410 /* =============================================================================== */ 1416 /* =============================================================================== */
1411 1417
1412 if (tolerated_ambient_pressure < 0) { 1418 if (tolerated_ambient_pressure < 0.0) {
1413 tolerated_ambient_pressure = 0; 1419 tolerated_ambient_pressure = 0.0;
1414 } 1420 }
1415 compartment_deco_ceiling[i - 1] = 1421 compartment_deco_ceiling[i - 1] =
1416 tolerated_ambient_pressure - barometric_pressure; 1422 tolerated_ambient_pressure - barometric_pressure;
1417 } 1423 }
1418 1424
1736 //>>>>>>>>>>>>>>>>>>>> 1742 //>>>>>>>>>>>>>>>>>>>>
1737 //Test depth to calculate helium_rate and nitrogen_rate 1743 //Test depth to calculate helium_rate and nitrogen_rate
1738 ending_ambient_pressure = starting_ambient_pressure/2; 1744 ending_ambient_pressure = starting_ambient_pressure/2;
1739 1745
1740 time_test = (ending_ambient_pressure - starting_ambient_pressure) / *rate; 1746 time_test = (ending_ambient_pressure - starting_ambient_pressure) / *rate;
1741 decom_get_inert_gases(starting_ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin ); 1747 decom_get_inert_gases(starting_ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin );
1742 decom_get_inert_gases(ending_ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end ); 1748 decom_get_inert_gases(ending_ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end );
1743 initial_inspired_he_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; 1749 initial_inspired_he_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
1744 initial_inspired_n2_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin; 1750 initial_inspired_n2_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin;
1745 helium_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time_test; 1751 helium_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time_test;
1746 nitrogen_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/time_test; 1752 nitrogen_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/time_test;
1747 //>>>>>>>>>>>>>>>>>>>>> 1753 //>>>>>>>>>>>>>>>>>>>>>
1768 /* somewhere between these endpoints. The algorithm checks to make sure that */ 1774 /* somewhere between these endpoints. The algorithm checks to make sure that */
1769 /* the solution lies in between these bounds by first computing the low bound */ 1775 /* the solution lies in between these bounds by first computing the low bound */
1770 /* and high bound function values. */ 1776 /* and high bound function values. */
1771 /* =============================================================================== */ 1777 /* =============================================================================== */
1772 1778
1773 low_bound = 0.; 1779 low_bound = 0.0;
1774 high_bound = starting_ambient_pressure / *rate * -1.0f; 1780 high_bound = starting_ambient_pressure / *rate * -1.0f;
1775 for (i = 1; i <= 16; ++i) 1781 for (i = 1; i <= 16; ++i)
1776 { 1782 {
1777 initial_helium_pressure = helium_pressure[i - 1]; 1783 initial_helium_pressure = helium_pressure[i - 1];
1778 initial_nitrogen_pressure = nitrogen_pressure[i - 1]; 1784 initial_nitrogen_pressure = nitrogen_pressure[i - 1];
1983 float fraction_nitrogen_begin; 1989 float fraction_nitrogen_begin;
1984 int count = 0; 1990 int count = 0;
1985 _Bool buehlmann_wait = false; 1991 _Bool buehlmann_wait = false;
1986 float tissue_He_saturation[16]; 1992 float tissue_He_saturation[16];
1987 float tissue_N2_saturation[16]; 1993 float tissue_N2_saturation[16];
1988 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40); 1994 float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0);
1989 /* loop */ 1995 /* loop */
1990 /* =============================================================================== */ 1996 /* =============================================================================== */
1991 /* CALCULATIONS */ 1997 /* CALCULATIONS */
1992 /* =============================================================================== */ 1998 /* =============================================================================== */
1993 1999
1995 // temp_segment_time = segment_time; 2001 // temp_segment_time = segment_time;
1996 ambient_pressure = *deco_stop_depth + barometric_pressure; 2002 ambient_pressure = *deco_stop_depth + barometric_pressure;
1997 //ending_ambient_pressure = ambient_pressure; 2003 //ending_ambient_pressure = ambient_pressure;
1998 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 );
1999 2005
2000 if(*deco_stop_depth == (float)(pDiveSettings->last_stop_depth_bar * 10)) 2006 if(*deco_stop_depth == (pDiveSettings->last_stop_depth_bar * 10.0))
2001 next_stop = 0; 2007 next_stop = 0;
2002 else 2008 else
2003 { 2009 {
2004 next_stop = *deco_stop_depth - *step_size; 2010 next_stop = *deco_stop_depth - *step_size;
2005 next_stop = fmaxf(next_stop,(float)pDiveSettings->last_stop_depth_bar * 10); 2011 next_stop = fmaxf(next_stop, pDiveSettings->last_stop_depth_bar * 10.0);
2006 } 2012 }
2007 2013
2008 inspired_helium_pressure = 2014 inspired_helium_pressure =
2009 (ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; 2015 (ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
2010 inspired_nitrogen_pressure = 2016 inspired_nitrogen_pressure =
2020 { 2026 {
2021 calc_deco_ceiling(&deco_ceiling_depth, false); //weg, weil auf jeden Fall schleife für safety und so konservativer 2027 calc_deco_ceiling(&deco_ceiling_depth, false); //weg, weil auf jeden Fall schleife für safety und so konservativer
2022 } 2028 }
2023 else 2029 else
2024 { 2030 {
2025 deco_ceiling_depth = next_stop + 1; 2031 deco_ceiling_depth = next_stop + 1.0;
2026 } 2032 }
2027 if(deco_ceiling_depth > next_stop) 2033 if(deco_ceiling_depth > next_stop)
2028 { 2034 {
2029 while (deco_ceiling_depth > next_stop) 2035 while (deco_ceiling_depth > next_stop)
2030 { 2036 {
2031 2037
2032 segment_time += 60; 2038 segment_time += 60.0;
2033 if(segment_time >= 999 ) 2039 if(segment_time >= 999.0 )
2034 { 2040 {
2035 segment_time = 999 ; 2041 segment_time = 999.0 ;
2036 run_time += segment_time; 2042 run_time += segment_time;
2037 return; 2043 return;
2038 } 2044 }
2039 //goto L700; 2045 //goto L700;
2040 initial_CNS = gCNS_VPM; 2046 initial_CNS = gCNS_VPM;
2048 } 2054 }
2049 calc_deco_ceiling(&deco_ceiling_depth, false); 2055 calc_deco_ceiling(&deco_ceiling_depth, false);
2050 } 2056 }
2051 if(deco_ceiling_depth < next_stop) 2057 if(deco_ceiling_depth < next_stop)
2052 { 2058 {
2053 segment_time -= 60; 2059 segment_time -= 60.0;
2054 gCNS_VPM = initial_CNS; 2060 gCNS_VPM = initial_CNS;
2055 for (i = 0; i < 16; i++) 2061 for (i = 0; i < 16; i++)
2056 { 2062 {
2057 helium_pressure[i] = initial_helium_pressure[i]; 2063 helium_pressure[i] = initial_helium_pressure[i];
2058 nitrogen_pressure[i] = initial_nitrogen_pressure[i]; 2064 nitrogen_pressure[i] = initial_nitrogen_pressure[i];
2088 } 2094 }
2089 buehlmann_wait = false; 2095 buehlmann_wait = false;
2090 while (buehlmann_wait || (deco_ceiling_depth > next_stop)) 2096 while (buehlmann_wait || (deco_ceiling_depth > next_stop))
2091 { 2097 {
2092 //time_counter = temp_segment_time; 2098 //time_counter = temp_segment_time;
2093 segment_time += 1; 2099 segment_time += 1.0;
2094 2100
2095 if(segment_time >= 999 ) 2101 if(segment_time >= 999.0 )
2096 { 2102 {
2097 segment_time = 999 ; 2103 segment_time = 999.0 ;
2098 run_time += segment_time; 2104 run_time += segment_time;
2099 return; 2105 return;
2100 } 2106 }
2101 //goto L700; 2107 //goto L700;
2102 initial_CNS = gCNS_VPM; 2108 initial_CNS = gCNS_VPM;
2103 decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10,&gCNS_VPM); 2109 decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10.0, &gCNS_VPM);
2104 for (i = 0; i < 16; i++) 2110 for (i = 0; i < 16; i++)
2105 { 2111 {
2106 initial_helium_pressure[i] = helium_pressure[i]; 2112 initial_helium_pressure[i] = helium_pressure[i];
2107 initial_nitrogen_pressure[i] = nitrogen_pressure[i]; 2113 initial_nitrogen_pressure[i] = nitrogen_pressure[i];
2108 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];
2300 int count = 0; 2306 int count = 0;
2301 int status = CALC_END; 2307 int status = CALC_END;
2302 2308
2303 for(i = 0; i < 16;i++) 2309 for(i = 0; i < 16;i++)
2304 { 2310 {
2305 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10; 2311 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10.0;//tissue_He_saturation[st_dive][i] * 10;
2306 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10; 2312 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10.0;
2307 } 2313 }
2308 temp_segment_time = 0; 2314 temp_segment_time = 0;
2309 2315
2310 mix_number = 0; 2316 mix_number = 0;
2311 ambient_pressure = pInput->pressure_ambient_bar * 10; 2317 ambient_pressure = pInput->pressure_ambient_bar * 10.0;
2312 decom_get_inert_gases( ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin ); 2318 decom_get_inert_gases( ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin );
2313 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; 2319 inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
2314 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin; 2320 inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin;
2315 2321
2316 status = CALC_END; 2322 status = CALC_END;
2317 while (status == CALC_END) 2323 while (status == CALC_END)