Mercurial > public > ostc4
comparison Discovery/Src/vpm.c @ 981:c6c781a2e85b default
Merge into default
| author | heinrichsweikamp |
|---|---|
| date | Tue, 11 Feb 2025 18:12:00 +0100 |
| parents | 79b522fbabe6 |
| children | 22d5b477c903 |
comparison
equal
deleted
inserted
replaced
| 871:f7318457df4d | 981:c6c781a2e85b |
|---|---|
| 130 static float rate_change[11]; | 130 static float rate_change[11]; |
| 131 static short mix_change[11]; | 131 static short mix_change[11]; |
| 132 | 132 |
| 133 static const _Bool vpm_b = true; | 133 static const _Bool vpm_b = true; |
| 134 | 134 |
| 135 static SvpmTableState vpmTableState = VPM_TABLE_INIT; | |
| 136 static SDecoinfo vpmTable; | |
| 137 | |
| 135 extern const float float_buehlmann_N2_factor_expositon_20_seconds[]; | 138 extern const float float_buehlmann_N2_factor_expositon_20_seconds[]; |
| 136 extern const float float_buehlmann_He_factor_expositon_20_seconds[]; | 139 extern const float float_buehlmann_He_factor_expositon_20_seconds[]; |
| 137 extern const float float_buehlmann_N2_factor_expositon_one_minute[]; | 140 extern const float float_buehlmann_N2_factor_expositon_one_minute[]; |
| 138 extern const float float_buehlmann_He_factor_expositon_one_minute[]; | 141 extern const float float_buehlmann_He_factor_expositon_one_minute[]; |
| 139 extern const float float_buehlmann_N2_factor_expositon_five_minutes[]; | 142 extern const float float_buehlmann_N2_factor_expositon_five_minutes[]; |
| 163 floorf(*x + 0.5f) : -floorf(0.5f - *x) ); | 166 floorf(*x + 0.5f) : -floorf(0.5f - *x) ); |
| 164 } | 167 } |
| 165 | 168 |
| 166 static float r_int(float *x) | 169 static float r_int(float *x) |
| 167 { | 170 { |
| 168 return( (*x>0) ? floorf(*x) : -floorf(- *x) ); | 171 return( (*x>0.0) ? floorf(*x) : -floorf(- *x) ); |
| 169 } | 172 } |
| 170 | 173 |
| 171 /** private functions | 174 /** private functions |
| 172 */ | 175 */ |
| 173 extern int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius); | 176 extern int radius_root_finder (float *a, float *b, float *c,float *low_bound, float *high_bound, float *ending_radius); |
| 189 static void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth,float * Deco_Stop_Depth,float* Step_Size); | 192 static void BOYLES_LAW_COMPENSATION (float* First_Stop_Depth,float * Deco_Stop_Depth,float* Step_Size); |
| 190 static int vpm_calc_ndl(void); | 193 static int vpm_calc_ndl(void); |
| 191 static void vpm_init_1(void); | 194 static void vpm_init_1(void); |
| 192 static void vpm_calc_deco_ceiling(void); | 195 static void vpm_calc_deco_ceiling(void); |
| 193 | 196 |
| 197 uint8_t vpm_get_decozone(void); | |
| 198 | |
| 194 static void vpm_init_1(void) | 199 static void vpm_init_1(void) |
| 195 { | 200 { |
| 196 units_equal_msw = true; | 201 units_equal_msw = true; |
| 197 units_equal_fsw = false; | 202 units_equal_fsw = false; |
| 198 altitude_dive_algorithm_off= true; //!Options: ON or OFF | 203 altitude_dive_algorithm_off= true; //!Options: ON or OFF |
| 217 float vpm_get_CNS(void) | 222 float vpm_get_CNS(void) |
| 218 { | 223 { |
| 219 return gCNS_VPM; | 224 return gCNS_VPM; |
| 220 } | 225 } |
| 221 | 226 |
| 227 | |
| 228 void vpm_maintainTable(SLifeData* pLifeData,SDecoinfo* pDecoInfo) | |
| 229 { | |
| 230 static uint32_t lastDiveSecond = 0; | |
| 231 uint8_t actual_deco_stop = 0; | |
| 232 int8_t index = 0; | |
| 233 uint8_t decreaseStopTime = 1; | |
| 234 | |
| 235 if(lastDiveSecond < pLifeData->dive_time_seconds) | |
| 236 { | |
| 237 lastDiveSecond = pLifeData->dive_time_seconds; | |
| 238 actual_deco_stop = decom_get_actual_deco_stop((SDiveState*)stateUsed); | |
| 239 | |
| 240 pDecoInfo->output_time_to_surface_seconds = 0; | |
| 241 for(index = DECOINFO_STRUCT_MAX_STOPS -1 ;index >= 0; index--) | |
| 242 { | |
| 243 if(pDecoInfo->output_stop_length_seconds[index] > 0) | |
| 244 { | |
| 245 if(decreaseStopTime) | |
| 246 { | |
| 247 if((pLifeData->depth_meter > (float)(actual_deco_stop - 1.5)) | |
| 248 && (pLifeData->depth_meter < (float)actual_deco_stop + 1.5)) | |
| 249 { | |
| 250 pDecoInfo->output_stop_length_seconds[index]--; | |
| 251 decreaseStopTime = 0; | |
| 252 } | |
| 253 else if (pLifeData->depth_meter < (float)(actual_deco_stop - 1.5)) /* missed deco stop */ | |
| 254 { | |
| 255 vpmTableState = VPM_TABLE_MISSED; | |
| 256 pDecoInfo->output_stop_length_seconds[index] = 0; | |
| 257 decreaseStopTime = 0; | |
| 258 } | |
| 259 } | |
| 260 pDecoInfo->output_time_to_surface_seconds += pDecoInfo->output_stop_length_seconds[index]; | |
| 261 } | |
| 262 } | |
| 263 pDecoInfo->output_time_to_surface_seconds += pLifeData->depth_meter / 10.0 * 60.0; | |
| 264 } | |
| 265 else if(lastDiveSecond > pLifeData->dive_time_seconds) | |
| 266 { | |
| 267 lastDiveSecond = pLifeData->dive_time_seconds; | |
| 268 } | |
| 269 } | |
| 270 | |
| 222 int vpm_calc(SLifeData* pINPUT, | 271 int vpm_calc(SLifeData* pINPUT, |
| 223 SDiveSettings* pSettings, | 272 SDiveSettings* pSettings, |
| 224 SVpm* pVPM, | 273 SVpm* pVPM, |
| 225 SDecoinfo* | 274 SDecoinfo* |
| 226 pDECOINFO, | 275 pDECOINFO, |
| 227 int calc_what) | 276 int calc_what) |
| 228 { | 277 { |
| 278 static uint8_t vpmTableActive = 0; | |
| 279 | |
| 229 vpm_init_1(); | 280 vpm_init_1(); |
| 230 //decom_CreateGasChangeList(pSettings, pINPUT); | 281 //decom_CreateGasChangeList(pSettings, pINPUT); |
| 231 vpm_calc_what = calc_what; | 282 vpm_calc_what = calc_what; |
| 232 /**clear decoInfo*/ | 283 /**clear decoInfo*/ |
| 284 | |
| 285 if((vpmTableActive) && (vpm_calc_what == DECOSTOPS)) | |
| 286 { | |
| 287 memcpy(&vpmTable, pDECOINFO, sizeof(SDecoinfo)); /* save changes done by e.g. the simulator */ | |
| 288 } | |
| 233 pDECOINFO->output_time_to_surface_seconds = 0; | 289 pDECOINFO->output_time_to_surface_seconds = 0; |
| 234 pDECOINFO->output_ndl_seconds = 0; | 290 pDECOINFO->output_ndl_seconds = 0; |
| 235 pDECOINFO->output_ceiling_meter = 0; | 291 pDECOINFO->output_ceiling_meter = 0; |
| 236 pDECOINFO->super_saturation = 0; | 292 pDECOINFO->super_saturation = 0; |
| 237 uint8_t tmp_calc_status; | 293 uint8_t tmp_calc_status; |
| 278 } | 334 } |
| 279 } | 335 } |
| 280 | 336 |
| 281 //Only Decostops not futute stops | 337 //Only Decostops not futute stops |
| 282 if(vpm_calc_what == DECOSTOPS) | 338 if(vpm_calc_what == DECOSTOPS) |
| 339 { | |
| 283 vpm_calc_status = tmp_calc_status; | 340 vpm_calc_status = tmp_calc_status; |
| 341 if(pSettings->vpm_tableMode) /* store the most conservative deco plan and stick to it. */ | |
| 342 { | |
| 343 if((int16_t)(pDECOINFO->output_time_to_surface_seconds - vpmTable.output_time_to_surface_seconds) > 60) | |
| 344 { | |
| 345 memcpy(&vpmTable, pDECOINFO, sizeof(SDecoinfo)); | |
| 346 vpmTableActive = 1; | |
| 347 if(pVpm->deco_zone_reached) /* table should not change after deco zone was entered */ | |
| 348 { | |
| 349 if(vpmTableState != VPM_TABLE_MISSED) | |
| 350 { | |
| 351 vpmTableState = VPM_TABLE_WARNING; | |
| 352 } | |
| 353 } | |
| 354 } | |
| 355 else | |
| 356 { | |
| 357 if(vpmTable.output_time_to_surface_seconds > 0) | |
| 358 { | |
| 359 vpm_maintainTable(pINPUT, &vpmTable); | |
| 360 vpmTable.output_ceiling_meter = pDECOINFO->output_ceiling_meter; | |
| 361 memcpy(pDECOINFO, &vpmTable, sizeof(SDecoinfo)); | |
| 362 } | |
| 363 } | |
| 364 } | |
| 365 } | |
| 284 return vpm_calc_status; | 366 return vpm_calc_status; |
| 285 } | 367 } |
| 286 | 368 |
| 287 void vpm_saturation_after_ascent(SLifeData* input) | 369 void vpm_saturation_after_ascent(SLifeData* input) |
| 288 { | 370 { |
| 458 } | 540 } |
| 459 j = 0; | 541 j = 0; |
| 460 | 542 |
| 461 for (i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) | 543 for (i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++) |
| 462 { | 544 { |
| 463 if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero >= depth_change[0] + 1) | 545 if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero >= depth_change[0] + 1) |
| 546 #ifdef ENABLE_DECOCALC_OPTION | |
| 547 && (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc) | |
| 548 #endif | |
| 549 ) | |
| 464 continue; | 550 continue; |
| 465 | 551 |
| 466 if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0) | 552 if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0) |
| 553 #ifdef ENABLE_DECOCALC_OPTION | |
| 554 || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) | |
| 555 #endif | |
| 556 ) | |
| 467 break; | 557 break; |
| 468 | 558 |
| 469 j++; | 559 j++; |
| 470 number_of_changes ++; | 560 number_of_changes ++; |
| 471 depth_change[j] = pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero ; | 561 depth_change[j] = pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero ; |
| 634 // buehlmann safety | 724 // buehlmann safety |
| 635 if(buehlmannSafety) | 725 if(buehlmannSafety) |
| 636 { | 726 { |
| 637 for (i = 0; i < 16; i++) | 727 for (i = 0; i < 16; i++) |
| 638 { | 728 { |
| 639 tissue_He_saturation[i] = helium_pressure[i] / 10; | 729 tissue_He_saturation[i] = helium_pressure[i] / 10.0; |
| 640 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; | 730 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0; |
| 641 } | 731 } |
| 642 | 732 |
| 643 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)) | 733 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)) |
| 644 { | 734 { |
| 645 | 735 |
| 646 vpm_violates_buehlmann = true; | 736 vpm_violates_buehlmann = true; |
| 647 do { | 737 do { |
| 648 deco_stop_depth += 3; | 738 deco_stop_depth += 3.0; |
| 649 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)); | 739 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar)); |
| 650 } | 740 } |
| 651 } | 741 } |
| 652 | 742 |
| 653 /* =============================================================================== */ | 743 /* =============================================================================== */ |
| 921 } | 1011 } |
| 922 if(buehlmannSafety) | 1012 if(buehlmannSafety) |
| 923 { | 1013 { |
| 924 for (i = 0; i < 16; i++) | 1014 for (i = 0; i < 16; i++) |
| 925 { | 1015 { |
| 926 tissue_He_saturation[i] = helium_pressure[i] / 10; | 1016 tissue_He_saturation[i] = helium_pressure[i] / 10.0; |
| 927 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; | 1017 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0; |
| 928 } | 1018 } |
| 929 | 1019 |
| 930 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)) | 1020 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)) |
| 931 { | 1021 { |
| 932 | |
| 933 vpm_violates_buehlmann = true; | 1022 vpm_violates_buehlmann = true; |
| 934 do { | 1023 do { |
| 935 deco_ceiling_depth += 0.1f; | 1024 deco_ceiling_depth += 0.1f; |
| 936 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)); | 1025 } 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 } | 1026 } |
| 959 // buehlmann safety | 1048 // buehlmann safety |
| 960 if(vpm_violates_buehlmann) | 1049 if(vpm_violates_buehlmann) |
| 961 { | 1050 { |
| 962 for (i = 0; i < 16; i++) | 1051 for (i = 0; i < 16; i++) |
| 963 { | 1052 { |
| 964 tissue_He_saturation[i] = helium_pressure[i] / 10; | 1053 tissue_He_saturation[i] = helium_pressure[i] / 10.0; |
| 965 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10; | 1054 tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0; |
| 966 } | 1055 } |
| 967 | 1056 |
| 968 if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)) | 1057 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 { | 1058 { |
| 970 | |
| 971 vpm_violates_buehlmann = true; | 1059 vpm_violates_buehlmann = true; |
| 972 do { | 1060 do { |
| 973 deco_ceiling_depth += 0.1f; | 1061 deco_ceiling_depth += 0.1f; |
| 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)); | 1062 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar)); |
| 975 } | 1063 } |
| 979 deco_ceiling_depth = first_stop_depth; | 1067 deco_ceiling_depth = first_stop_depth; |
| 980 pDecoInfo->output_ceiling_meter = deco_ceiling_depth ; | 1068 pDecoInfo->output_ceiling_meter = deco_ceiling_depth ; |
| 981 } | 1069 } |
| 982 else | 1070 else |
| 983 { | 1071 { |
| 984 pDecoInfo->output_ceiling_meter = 0; | 1072 pDecoInfo->output_ceiling_meter = 0.0; |
| 985 } | 1073 } |
| 986 | 1074 |
| 987 // fix hw 160627 | 1075 // fix hw 160627 |
| 988 if(pDecoInfo->output_ceiling_meter < 0) | 1076 if(pDecoInfo->output_ceiling_meter < 0.0) |
| 989 pDecoInfo->output_ceiling_meter = 0; | 1077 pDecoInfo->output_ceiling_meter = 0.0; |
| 990 | 1078 |
| 991 /*** End CALC ceiling ***************************************************/ | 1079 /*** End CALC ceiling ***************************************************/ |
| 992 } | 1080 } |
| 993 | 1081 |
| 994 | 1082 |
| 1003 float stop_time; | 1091 float stop_time; |
| 1004 int count = 0; | 1092 int count = 0; |
| 1005 static int dp_max; | 1093 static int dp_max; |
| 1006 static float surfacetime; | 1094 static float surfacetime; |
| 1007 _Bool first_stop = false; | 1095 _Bool first_stop = false; |
| 1096 float roundingValue = 0.0; | |
| 1097 | |
| 1098 uint16_t stop_time_seconds; | |
| 1099 | |
| 1008 max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth); | 1100 max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth); |
| 1009 if(begin) | 1101 if(begin) |
| 1010 { | 1102 { |
| 1011 gCNS_VPM = 0; | 1103 gCNS_VPM = 0; |
| 1012 dp_max = 0; | 1104 dp_max = 0; |
| 1101 { | 1193 { |
| 1102 dp = 0; | 1194 dp = 0; |
| 1103 } | 1195 } |
| 1104 else | 1196 else |
| 1105 { | 1197 { |
| 1106 dp = 1 + (int)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10)) / step_size); | 1198 roundingValue = (deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size; |
| 1107 } | 1199 dp = 1 + r_nint(&roundingValue); |
| 1108 dp_max = (int)fmaxf(dp_max,dp); | 1200 } |
| 1201 | |
| 1202 //dp_max = (int)fmaxf(dp_max,dp); | |
| 1203 if(dp > dp_max) | |
| 1204 { | |
| 1205 dp_max = dp; | |
| 1206 } | |
| 1109 if(dp < DECOINFO_STRUCT_MAX_STOPS) | 1207 if(dp < DECOINFO_STRUCT_MAX_STOPS) |
| 1110 { | 1208 { |
| 1111 int stop_time_seconds = fminf((999 * 60), (int)(stop_time *60)); | 1209 stop_time_seconds = (uint16_t)(fminf((999.9 * 60.0), (stop_time *60.0))); |
| 1112 // | 1210 // |
| 1113 | 1211 |
| 1114 //if(vpm_calc_what == DECOSTOPS) | 1212 //if(vpm_calc_what == DECOSTOPS) |
| 1115 pDecoInfo->output_stop_length_seconds[dp] = (unsigned short)stop_time_seconds; | 1213 pDecoInfo->output_stop_length_seconds[dp] = stop_time_seconds; |
| 1116 //else | 1214 //else |
| 1117 //decostop_bailout[dp] = (unsigned short)stop_time_seconds; | 1215 //decostop_bailout[dp] = (unsigned short)stop_time_seconds; |
| 1118 } | 1216 } |
| 1119 } | 1217 } |
| 1120 | 1218 |
| 1154 pDecoInfo->output_stop_length_seconds[dp] = 0; | 1252 pDecoInfo->output_stop_length_seconds[dp] = 0; |
| 1155 //else | 1253 //else |
| 1156 //decostop_bailout[dp] = 0; | 1254 //decostop_bailout[dp] = 0; |
| 1157 } | 1255 } |
| 1158 } | 1256 } |
| 1159 pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60); | 1257 pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60.0); |
| 1160 pDecoInfo->output_ndl_seconds = 0; | 1258 pDecoInfo->output_ndl_seconds = 0; |
| 1161 | 1259 |
| 1162 vpm_calc_deco_ceiling(); | 1260 vpm_calc_deco_ceiling(); |
| 1163 /* end of deco stop lo */ | 1261 /* end of deco stop lo */ |
| 1164 return CALC_END; | 1262 return CALC_END; |
| 1405 /* =============================================================================== */ | 1503 /* =============================================================================== */ |
| 1406 /* The tolerated ambient pressure cannot be less than zero absolute, i.e., */ | 1504 /* The tolerated ambient pressure cannot be less than zero absolute, i.e., */ |
| 1407 /* the vacuum of outer space! */ | 1505 /* the vacuum of outer space! */ |
| 1408 /* =============================================================================== */ | 1506 /* =============================================================================== */ |
| 1409 | 1507 |
| 1410 if (tolerated_ambient_pressure < 0) { | 1508 if (tolerated_ambient_pressure < 0.0) { |
| 1411 tolerated_ambient_pressure = 0; | 1509 tolerated_ambient_pressure = 0.0; |
| 1412 } | 1510 } |
| 1413 compartment_deco_ceiling[i - 1] = | 1511 compartment_deco_ceiling[i - 1] = |
| 1414 tolerated_ambient_pressure - barometric_pressure; | 1512 tolerated_ambient_pressure - barometric_pressure; |
| 1415 } | 1513 } |
| 1416 | 1514 |
| 1734 //>>>>>>>>>>>>>>>>>>>> | 1832 //>>>>>>>>>>>>>>>>>>>> |
| 1735 //Test depth to calculate helium_rate and nitrogen_rate | 1833 //Test depth to calculate helium_rate and nitrogen_rate |
| 1736 ending_ambient_pressure = starting_ambient_pressure/2; | 1834 ending_ambient_pressure = starting_ambient_pressure/2; |
| 1737 | 1835 |
| 1738 time_test = (ending_ambient_pressure - starting_ambient_pressure) / *rate; | 1836 time_test = (ending_ambient_pressure - starting_ambient_pressure) / *rate; |
| 1739 decom_get_inert_gases(starting_ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin ); | 1837 decom_get_inert_gases(starting_ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin ); |
| 1740 decom_get_inert_gases(ending_ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end ); | 1838 decom_get_inert_gases(ending_ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end ); |
| 1741 initial_inspired_he_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; | 1839 initial_inspired_he_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; |
| 1742 initial_inspired_n2_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin; | 1840 initial_inspired_n2_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin; |
| 1743 helium_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time_test; | 1841 helium_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time_test; |
| 1744 nitrogen_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/time_test; | 1842 nitrogen_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/time_test; |
| 1745 //>>>>>>>>>>>>>>>>>>>>> | 1843 //>>>>>>>>>>>>>>>>>>>>> |
| 1766 /* somewhere between these endpoints. The algorithm checks to make sure that */ | 1864 /* somewhere between these endpoints. The algorithm checks to make sure that */ |
| 1767 /* the solution lies in between these bounds by first computing the low bound */ | 1865 /* the solution lies in between these bounds by first computing the low bound */ |
| 1768 /* and high bound function values. */ | 1866 /* and high bound function values. */ |
| 1769 /* =============================================================================== */ | 1867 /* =============================================================================== */ |
| 1770 | 1868 |
| 1771 low_bound = 0.; | 1869 low_bound = 0.0; |
| 1772 high_bound = starting_ambient_pressure / *rate * -1.0f; | 1870 high_bound = starting_ambient_pressure / *rate * -1.0f; |
| 1773 for (i = 1; i <= 16; ++i) | 1871 for (i = 1; i <= 16; ++i) |
| 1774 { | 1872 { |
| 1775 initial_helium_pressure = helium_pressure[i - 1]; | 1873 initial_helium_pressure = helium_pressure[i - 1]; |
| 1776 initial_nitrogen_pressure = nitrogen_pressure[i - 1]; | 1874 initial_nitrogen_pressure = nitrogen_pressure[i - 1]; |
| 2018 { | 2116 { |
| 2019 calc_deco_ceiling(&deco_ceiling_depth, false); //weg, weil auf jeden Fall schleife für safety und so konservativer | 2117 calc_deco_ceiling(&deco_ceiling_depth, false); //weg, weil auf jeden Fall schleife für safety und so konservativer |
| 2020 } | 2118 } |
| 2021 else | 2119 else |
| 2022 { | 2120 { |
| 2023 deco_ceiling_depth = next_stop + 1; | 2121 deco_ceiling_depth = next_stop + 1.0; |
| 2024 } | 2122 } |
| 2025 if(deco_ceiling_depth > next_stop) | 2123 if(deco_ceiling_depth > next_stop) |
| 2026 { | 2124 { |
| 2027 while (deco_ceiling_depth > next_stop) | 2125 while (deco_ceiling_depth > next_stop) |
| 2028 { | 2126 { |
| 2029 | 2127 |
| 2030 segment_time += 60; | 2128 segment_time += 60.0; |
| 2031 if(segment_time >= 999 ) | 2129 if(segment_time >= 999.0 ) |
| 2032 { | 2130 { |
| 2033 segment_time = 999 ; | 2131 segment_time = 999.0 ; |
| 2034 run_time += segment_time; | 2132 run_time += segment_time; |
| 2035 return; | 2133 return; |
| 2036 } | 2134 } |
| 2037 //goto L700; | 2135 //goto L700; |
| 2038 initial_CNS = gCNS_VPM; | 2136 initial_CNS = gCNS_VPM; |
| 2046 } | 2144 } |
| 2047 calc_deco_ceiling(&deco_ceiling_depth, false); | 2145 calc_deco_ceiling(&deco_ceiling_depth, false); |
| 2048 } | 2146 } |
| 2049 if(deco_ceiling_depth < next_stop) | 2147 if(deco_ceiling_depth < next_stop) |
| 2050 { | 2148 { |
| 2051 segment_time -= 60; | 2149 segment_time -= 60.0; |
| 2052 gCNS_VPM = initial_CNS; | 2150 gCNS_VPM = initial_CNS; |
| 2053 for (i = 0; i < 16; i++) | 2151 for (i = 0; i < 16; i++) |
| 2054 { | 2152 { |
| 2055 helium_pressure[i] = initial_helium_pressure[i]; | 2153 helium_pressure[i] = initial_helium_pressure[i]; |
| 2056 nitrogen_pressure[i] = initial_nitrogen_pressure[i]; | 2154 nitrogen_pressure[i] = initial_nitrogen_pressure[i]; |
| 2086 } | 2184 } |
| 2087 buehlmann_wait = false; | 2185 buehlmann_wait = false; |
| 2088 while (buehlmann_wait || (deco_ceiling_depth > next_stop)) | 2186 while (buehlmann_wait || (deco_ceiling_depth > next_stop)) |
| 2089 { | 2187 { |
| 2090 //time_counter = temp_segment_time; | 2188 //time_counter = temp_segment_time; |
| 2091 segment_time += 1; | 2189 segment_time += 1.0; |
| 2092 | 2190 |
| 2093 if(segment_time >= 999 ) | 2191 if(segment_time >= 999.0 ) |
| 2094 { | 2192 { |
| 2095 segment_time = 999 ; | 2193 segment_time = 999.0 ; |
| 2096 run_time += segment_time; | 2194 run_time += segment_time; |
| 2097 return; | 2195 return; |
| 2098 } | 2196 } |
| 2099 //goto L700; | 2197 //goto L700; |
| 2100 initial_CNS = gCNS_VPM; | 2198 initial_CNS = gCNS_VPM; |
| 2298 int count = 0; | 2396 int count = 0; |
| 2299 int status = CALC_END; | 2397 int status = CALC_END; |
| 2300 | 2398 |
| 2301 for(i = 0; i < 16;i++) | 2399 for(i = 0; i < 16;i++) |
| 2302 { | 2400 { |
| 2303 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10; | 2401 future_helium_pressure[i] = pInput->tissue_helium_bar[i] * 10.0;//tissue_He_saturation[st_dive][i] * 10; |
| 2304 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10; | 2402 future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10.0; |
| 2305 } | 2403 } |
| 2306 temp_segment_time = 0; | 2404 temp_segment_time = 0; |
| 2307 | 2405 |
| 2308 mix_number = 0; | 2406 mix_number = 0; |
| 2309 ambient_pressure = pInput->pressure_ambient_bar * 10; | 2407 ambient_pressure = pInput->pressure_ambient_bar * 10; |
| 2407 if(temp_segment_time > 1) | 2505 if(temp_segment_time > 1) |
| 2408 return CALC_NDL; | 2506 return CALC_NDL; |
| 2409 else | 2507 else |
| 2410 return CALC_BEGIN; | 2508 return CALC_BEGIN; |
| 2411 } | 2509 } |
| 2510 | |
| 2511 void vpm_table_init() | |
| 2512 { | |
| 2513 vpmTable.output_time_to_surface_seconds = 0; | |
| 2514 vpmTableState = VPM_TABLE_INIT; | |
| 2515 } | |
| 2516 uint8_t vpm_get_decozone(void) | |
| 2517 { | |
| 2518 return((uint8_t)pVpm->depth_start_of_deco_zone_save); | |
| 2519 } | |
| 2520 SvpmTableState vpm_get_TableState(void) | |
| 2521 { | |
| 2522 return vpmTableState; | |
| 2523 } | |
| 2524 |
