Mercurial > public > ostc4
comparison Discovery/Src/buehlmann.c @ 258:0087d6251f59 bm-3
Buehlmann: factor out another global gDecotable
And strip out another useless global.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Fri, 12 Apr 2019 22:00:07 +0200 |
parents | 21387d7e786f |
children | cc2406b835ff |
comparison
equal
deleted
inserted
replaced
257:21387d7e786f | 258:0087d6251f59 |
---|---|
41 static float next_stop_depth_input_is_actual_stop_id(SDiveSettings *pDiveSettings, int actual_id); | 41 static float next_stop_depth_input_is_actual_stop_id(SDiveSettings *pDiveSettings, int actual_id); |
42 static float get_gf_at_pressure(SDiveSettings *pDiveSettings, float pressure); | 42 static float get_gf_at_pressure(SDiveSettings *pDiveSettings, float pressure); |
43 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings); | 43 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings); |
44 static _Bool dive1_check_deco(SDiveSettings *pDiveSettings); | 44 static _Bool dive1_check_deco(SDiveSettings *pDiveSettings); |
45 | 45 |
46 static SDecoinfo gDecotable; | |
47 static float gSurface_pressure_bar; | 46 static float gSurface_pressure_bar; |
48 static float gPressure; | 47 static float gPressure; |
49 static int gGas_id; | 48 static int gGas_id; |
50 static float gTissue_nitrogen_bar[16]; | 49 static float gTissue_nitrogen_bar[16]; |
51 static float gTissue_helium_bar[16]; | 50 static float gTissue_helium_bar[16]; |
120 gGas_id = 0; | 119 gGas_id = 0; |
121 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16)); | 120 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16)); |
122 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16)); | 121 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16)); |
123 gGF_value = ((float)pDiveSettings->gf_low) / 100.0f; | 122 gGF_value = ((float)pDiveSettings->gf_low) / 100.0f; |
124 | 123 |
125 // | 124 stoplist = pDecoInfo->output_stop_length_seconds; |
126 memcpy(&gDecotable, pDecoInfo, sizeof(SDecoinfo)); | |
127 stoplist = gDecotable.output_stop_length_seconds; | |
128 | 125 |
129 if(pLifeData->dive_time_seconds < 60) | 126 if(pLifeData->dive_time_seconds < 60) |
130 return; | 127 return; |
131 | 128 |
132 // clean stop list | 129 // clean stop list |
238 gGF_value = get_gf_at_pressure(pDiveSettings, next_depth + gSurface_pressure_bar); | 235 gGF_value = get_gf_at_pressure(pDiveSettings, next_depth + gSurface_pressure_bar); |
239 buehlmann_backup_and_restore(true); | 236 buehlmann_backup_and_restore(true); |
240 ascend_time = ascend_with_all_gaschanges(pDiveSettings, gStop.depth - next_depth); | 237 ascend_time = ascend_with_all_gaschanges(pDiveSettings, gStop.depth - next_depth); |
241 ceiling = tissue_tolerance(); | 238 ceiling = tissue_tolerance(); |
242 /* pre check actual limit */ | 239 /* pre check actual limit */ |
243 if(gDecotable.output_stop_length_seconds[gStop.id] >= 999*60) | 240 if(pDecoInfo->output_stop_length_seconds[gStop.id] >= 999*60) |
244 { | 241 { |
245 tts_seconds -= 999*60 - gDecotable.output_stop_length_seconds[gStop.id]; | 242 tts_seconds -= 999*60 - pDecoInfo->output_stop_length_seconds[gStop.id]; |
246 gDecotable.output_stop_length_seconds[gStop.id] = 999*60; | 243 pDecoInfo->output_stop_length_seconds[gStop.id] = 999*60; |
247 } | 244 } |
248 else | 245 else |
249 /* more deco on the actual depth */ | 246 /* more deco on the actual depth */ |
250 if(ceiling > next_depth + gSurface_pressure_bar) | 247 if(ceiling > next_depth + gSurface_pressure_bar) |
251 { | 248 { |
252 next_depth = -1; | 249 next_depth = -1; |
253 buehlmann_backup_and_restore(false); | 250 buehlmann_backup_and_restore(false); |
254 decom_tissues_exposure2(10, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar); // some seconds at least at each stop | 251 decom_tissues_exposure2(10, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar); // some seconds at least at each stop |
255 decom_oxygen_calculate_cns_exposure(10, &pDiveSettings->decogaslist[gGas_id], gPressure, &gCNS); | 252 decom_oxygen_calculate_cns_exposure(10, &pDiveSettings->decogaslist[gGas_id], gPressure, &gCNS); |
256 gDecotable.output_stop_length_seconds[gStop.id] += 10; | 253 pDecoInfo->output_stop_length_seconds[gStop.id] += 10; |
257 tts_seconds += 10; | 254 tts_seconds += 10; |
258 } | 255 } |
259 } while(next_depth == -1); | 256 } while(next_depth == -1); |
260 tts_seconds += ascend_time; | 257 tts_seconds += ascend_time; |
261 gStop.depth = next_depth; | 258 gStop.depth = next_depth; |
274 } | 271 } |
275 } | 272 } |
276 gStop.id--; | 273 gStop.id--; |
277 } | 274 } |
278 | 275 |
279 gDecotable.output_time_to_surface_seconds = tts_seconds; | 276 pDecoInfo->output_time_to_surface_seconds = tts_seconds; |
280 memcpy(pDecoInfo, &gDecotable, sizeof(SDecoinfo)); | |
281 } | 277 } |
282 | 278 |
283 | 279 |
284 static float tissue_tolerance(void) | 280 static float tissue_tolerance(void) |
285 { | 281 { |