Mercurial > public > ostc4
comparison Discovery/Src/test_vpm.c @ 38:5f11787b4f42
include in ostc4 repository
author | heinrichsweikamp |
---|---|
date | Sat, 28 Apr 2018 11:52:34 +0200 |
parents | |
children | f9b17e898a7a |
comparison
equal
deleted
inserted
replaced
37:ccc45c0e1ea2 | 38:5f11787b4f42 |
---|---|
1 /////////////////////////////////////////////////////////////////////////////// | |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/test_vpm.c | |
5 /// \brief test 101 | |
6 /// \author Heinrichs Weikamp | |
7 /// \date 26-Oct-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 #include <stdio.h> | |
30 #include <stdint.h> | |
31 //#include "LED.h" | |
32 //#include "Keyboard.h" | |
33 //#include "stm32f4xx_hal.h" | |
34 #include "buehlmann.h" | |
35 #include "calc_crush.h" | |
36 #include "vpm.h" | |
37 #include "display.h" | |
38 #include "test_vpm.h" | |
39 #include "math.h" | |
40 #include "data_central.h" | |
41 #include "decom.h" | |
42 #include "logbook.h" | |
43 #include "tInfoLog.h" | |
44 | |
45 #define true 1 | |
46 #define false 0 | |
47 //#define uint8_t unsigned char | |
48 | |
49 extern SSettings Settings; | |
50 | |
51 _Bool simulate_descent(SDiveState* pInput, float ending_depth_meter, float rate_meter_per_minutes); | |
52 void init_buehlmann(SDiveState* pInput); | |
53 | |
54 _Bool test1(void); | |
55 uint8_t test2_unapproved(void); | |
56 uint8_t test3_unapproved(void); | |
57 | |
58 _Bool simulate_descent(SDiveState* pInput, | |
59 float ending_depth_meter, | |
60 float rate_meter_per_minutes) | |
61 { | |
62 int i =0; | |
63 static float initial_helium_pressure[16]; | |
64 static float initial_nitrogen_pressure[16]; | |
65 static float initial_inspired_he_pressure; | |
66 static float initial_inspired_n2_pressure; | |
67 static float fraction_nitrogen_begin; | |
68 static float fraction_nitrogen_end; | |
69 static float fraction_helium_begin; | |
70 static float fraction_helium_end; | |
71 static float nitrogen_rate; | |
72 static float helium_rate; | |
73 static float time; | |
74 | |
75 extern const float WATER_VAPOR_PRESSURE; | |
76 extern const float HELIUM_TIME_CONSTANT[]; | |
77 extern const float NITROGEN_TIME_CONSTANT[]; | |
78 | |
79 float starting_ambient_pressure = pInput->lifeData.pressure_ambient_bar * 10; | |
80 float ending_ambient_pressure = ending_depth_meter + pInput->lifeData.pressure_surface_bar * 10; | |
81 | |
82 if((rate_meter_per_minutes <= 0) || (starting_ambient_pressure >= ending_ambient_pressure)) | |
83 return 0; | |
84 | |
85 for(i=0; i<16; i++) | |
86 { | |
87 initial_helium_pressure[i] = pInput->lifeData.tissue_helium_bar[i] * 10.0f; | |
88 initial_nitrogen_pressure[i] = pInput->lifeData.tissue_nitrogen_bar[i] * 10.0f; | |
89 } | |
90 | |
91 //New | |
92 time = (ending_ambient_pressure - starting_ambient_pressure) / rate_meter_per_minutes; | |
93 decom_get_inert_gases(starting_ambient_pressure / 10, &pInput->lifeData.actualGas, &fraction_nitrogen_begin, &fraction_helium_begin ); | |
94 decom_get_inert_gases(ending_ambient_pressure / 10, &pInput->lifeData.actualGas, &fraction_nitrogen_end, &fraction_helium_end ); | |
95 initial_inspired_he_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin; | |
96 initial_inspired_n2_pressure = (starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin; | |
97 helium_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time; | |
98 nitrogen_rate = ((ending_ambient_pressure - WATER_VAPOR_PRESSURE)* fraction_nitrogen_end - initial_inspired_n2_pressure)/time; | |
99 pInput->lifeData.pressure_ambient_bar = ending_ambient_pressure/10; | |
100 | |
101 for( i = 0; i < 16; i++) | |
102 { | |
103 pInput->lifeData.tissue_helium_bar[i] = schreiner_equation__2(&initial_inspired_he_pressure, | |
104 &helium_rate, | |
105 &time, | |
106 &HELIUM_TIME_CONSTANT[i], | |
107 &initial_helium_pressure[i])/10.0f; | |
108 | |
109 pInput->lifeData.tissue_nitrogen_bar[i] = schreiner_equation__2(&initial_inspired_n2_pressure, | |
110 &nitrogen_rate, | |
111 &time, | |
112 &NITROGEN_TIME_CONSTANT[i], | |
113 &initial_nitrogen_pressure[i]) / 10.0f; | |
114 } | |
115 | |
116 | |
117 calc_crushing_pressure(&pInput->lifeData, &pInput->vpm,initial_helium_pressure,initial_nitrogen_pressure,starting_ambient_pressure, rate_meter_per_minutes); | |
118 | |
119 pInput->lifeData.dive_time_seconds += ((ending_ambient_pressure - starting_ambient_pressure)/rate_meter_per_minutes) * 60; | |
120 return 1; | |
121 } | |
122 void init_buehlmann(SDiveState* pInput) | |
123 { | |
124 pInput->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; | |
125 pInput->lifeData.dive_time_seconds = 0; | |
126 for(int i=0;i<BUEHLMANN_STRUCT_MAX_GASES;i++) | |
127 { | |
128 pInput->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero = 0; | |
129 pInput->diveSettings.decogaslist[i].nitrogen_percentage = 79 - i; | |
130 pInput->diveSettings.decogaslist[i].helium_percentage = i; | |
131 pInput->diveSettings.decogaslist[i].setPoint_cbar = 0; | |
132 } | |
133 pInput->lifeData.actualGas = pInput->diveSettings.decogaslist[0]; | |
134 pInput->diveSettings.last_stop_depth_bar = 0.3f; | |
135 pInput->diveSettings.input_next_stop_increment_depth_bar = 0.3f; | |
136 | |
137 pInput->decolistVPM.output_time_to_surface_seconds = 0; | |
138 pInput->decolistFutureVPM.output_time_to_surface_seconds = 0; | |
139 pInput->decolistBuehlmann.output_time_to_surface_seconds = 0; | |
140 pInput->decolistFutureBuehlmann.output_time_to_surface_seconds = 0; | |
141 for(int i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
142 { | |
143 pInput->decolistVPM.output_stop_length_seconds[i] = 0; | |
144 pInput->decolistFutureVPM.output_stop_length_seconds[i] = 0; | |
145 | |
146 pInput->decolistBuehlmann.output_stop_length_seconds[i] = 0; | |
147 pInput->decolistFutureBuehlmann.output_stop_length_seconds[i] = 0; | |
148 } | |
149 for(int i=0;i<16;i++) | |
150 { | |
151 pInput->lifeData.tissue_nitrogen_bar[i] = 0.750927f; | |
152 pInput->lifeData.tissue_helium_bar[i] = 0; | |
153 } | |
154 pInput->diveSettings.gf_high = 80; | |
155 pInput->diveSettings.gf_low = 20; | |
156 pInput->diveSettings.vpm_conservatism = 2; | |
157 | |
158 pInput->lifeData.pressure_surface_bar = 1.0f; | |
159 pInput->lifeData.pressure_ambient_bar = 1.0f; | |
160 | |
161 pInput->warnings.decoMissed = 0; | |
162 pInput->events.gasChange = 0; | |
163 pInput->events.info_GasChange = 0; | |
164 pInput->events.info_manuelGasSetO2 = 0; | |
165 pInput->events.info_manuelGasSetHe = 0; | |
166 pInput->events.manuelGasSet = 0; | |
167 pInput->warnings.ppO2High = 0; | |
168 pInput->warnings.ppO2Low = 0; | |
169 pInput->warnings.slowWarning = 0; | |
170 | |
171 | |
172 //pInput->decolistVPM.UNUSED_input_necessary_stop_length_seconds_otherwise_zero[i] = 0; | |
173 /*for(i=0;i<BUEHLMANN_STRUCT_MAX_ASCENDRATES;i++) | |
174 { | |
175 pInput->lifeData.ascentrate[i].rate_bar_per_minute = 1.2f; | |
176 pInput->lifeData.ascentrate[i].use_from_depth_bar = 0; // only one ascendrate at the moment | |
177 }*/ | |
178 //pInput->diveSettings.input_second_stop_depth_bar = 0.6f; | |
179 //pInput->lifeData.actual_gas_id = 0; | |
180 //pInput->lifeData.actual_setpoint_bar_if_rebreather_otherwise_zero = 0; | |
181 //pInput->lifeData.distance_used_below_stop_levels_bar = 0; | |
182 // pInput->lifeData.pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; | |
183 | |
184 } | |
185 | |
186 | |
187 void init_buehlmann2(SDiveState* pInput) | |
188 { | |
189 pInput->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; | |
190 pInput->lifeData.dive_time_seconds = 0; | |
191 int i=0; | |
192 for(i=0;i<BUEHLMANN_STRUCT_MAX_GASES;i++) | |
193 { | |
194 pInput->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero = 0; | |
195 pInput->diveSettings.decogaslist[i].nitrogen_percentage = 20; | |
196 pInput->diveSettings.decogaslist[i].helium_percentage = 70; | |
197 pInput->diveSettings.decogaslist[i].setPoint_cbar = 0; | |
198 } | |
199 pInput->lifeData.actualGas = pInput->diveSettings.decogaslist[0]; | |
200 /*for(i=0;i<BUEHLMANN_STRUCT_MAX_ASCENDRATES;i++) | |
201 { | |
202 pInput->lifeData.ascentrate[i].rate_bar_per_minute = 1.2f; | |
203 pInput->lifeData.ascentrate[i].use_from_depth_bar = 0; // only one ascendrate at the moment | |
204 }*/ | |
205 pInput->diveSettings.last_stop_depth_bar = 0.3f; | |
206 //pInput->diveSettings.input_second_stop_depth_bar = 0.6f; | |
207 pInput->diveSettings.input_next_stop_increment_depth_bar = 0.3f; | |
208 pInput->decolistVPM.output_time_to_surface_seconds = 0; | |
209 pInput->decolistFutureVPM.output_time_to_surface_seconds = 0; | |
210 pInput->decolistBuehlmann.output_time_to_surface_seconds = 0; | |
211 pInput->decolistFutureBuehlmann.output_time_to_surface_seconds = 0; | |
212 for(int i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
213 { | |
214 pInput->decolistVPM.output_stop_length_seconds[i] = 0; | |
215 pInput->decolistFutureVPM.output_stop_length_seconds[i] = 0; | |
216 | |
217 pInput->decolistBuehlmann.output_stop_length_seconds[i] = 0; | |
218 pInput->decolistFutureBuehlmann.output_stop_length_seconds[i] = 0; | |
219 } | |
220 for(i=0;i<16;i++) | |
221 { | |
222 pInput->lifeData.tissue_nitrogen_bar[i] = 0.750927f; | |
223 pInput->lifeData.tissue_helium_bar[i] = 0; | |
224 } | |
225 | |
226 // pInput->lifeData.distance_used_below_stop_levels_bar = 0; | |
227 pInput->diveSettings.gf_high = 80; | |
228 pInput->diveSettings.gf_low = 20; | |
229 pInput->diveSettings.vpm_conservatism = 2; | |
230 // pInput->lifeData.pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; | |
231 pInput->lifeData.pressure_surface_bar = 1.0f; | |
232 pInput->lifeData.pressure_ambient_bar = 1.0f; | |
233 } | |
234 | |
235 | |
236 _Bool test1() | |
237 { | |
238 /* debug code with watch */ | |
239 static int32_t output_time_to_surface_minutes; | |
240 static int32_t counter = 0; | |
241 //static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
242 | |
243 /* all the rest */ | |
244 SDiveState input; | |
245 | |
246 init_buehlmann(&input); | |
247 //vpm conservatism = 0, repetitive = false, | |
248 vpm_init(&input.vpm,0,false,0); | |
249 | |
250 //runter auf 70 meter mit 26 meter/minute | |
251 simulate_descent(&input, 70.0f, 26.0f); | |
252 //10 minuten settigung | |
253 //buehlmann__test__saturate_tissues(&input, 10 * 60); | |
254 decom_tissues_exposure(10 * 60, &input.lifeData); | |
255 //buehlmann_calc_deco(&input); | |
256 | |
257 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
258 | |
259 //Check time to surface 46 min +- 0.6 | |
260 // MultiDeco hw: 42 min | |
261 | |
262 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
263 if (output_time_to_surface_minutes != 46) | |
264 counter = 0; | |
265 else | |
266 counter++; | |
267 | |
268 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
269 return false; | |
270 /* for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
271 { | |
272 | |
273 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
274 { | |
275 counter2++; | |
276 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
277 } | |
278 } | |
279 i = i;*/ | |
280 | |
281 vpm_saturation_after_ascent(&input.lifeData); | |
282 input.vpm.decomode_vpm_plus_conservatism_last_dive = input.diveSettings.vpm_conservatism; | |
283 | |
284 //Pause 60 min | |
285 decom_tissues_exposure(60 * 60, &input.lifeData ); | |
286 //buehlmann__test__saturate_tissues(&input, 60 * 60); | |
287 vpm_init(&input.vpm,0,true, 60 * 60); | |
288 //runter auf 70 meter mit 26 meter/minute | |
289 simulate_descent(&input, 70.0f, 26.0f); | |
290 //10 minuten settigung | |
291 //buehlmann__test__saturate_tissues(&input, 10 * 60); | |
292 decom_tissues_exposure(10 * 60, &input.lifeData); | |
293 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
294 //Check time to surface 46 min +- 0.6 | |
295 // MultiDeco hw: 42 min | |
296 | |
297 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
298 | |
299 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 57.0f) >= 0.6f) | |
300 return false; | |
301 | |
302 return true; | |
303 } | |
304 | |
305 | |
306 uint8_t test2_unapproved(void) | |
307 { | |
308 /* debug code with watch */ | |
309 static int32_t output_time_to_surface_minutes; | |
310 static int32_t counter = 0; | |
311 static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
312 static int32_t counter2 = 0; | |
313 | |
314 /* all the rest */ | |
315 SDiveState input; | |
316 int i; | |
317 | |
318 init_buehlmann(&input); | |
319 //vpm conservatism = 3, repetitive = false, | |
320 vpm_init(&(input.vpm),3,false,0); | |
321 | |
322 //runter auf 70 meter mit 26 meter/minute | |
323 simulate_descent(&input, 70.0f, 26.0f); | |
324 //30 minuten saetigung | |
325 //buehlmann__test__saturate_tissues(&input, 30 * 60); | |
326 decom_tissues_exposure(30 * 60, &input.lifeData ); | |
327 //buehlmann_calc_deco(&input); | |
328 | |
329 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
330 //Check time to surface 179.833 min (Peter Version 140415) +- 0.6, MultiDeco is 195 min | |
331 | |
332 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
333 if (output_time_to_surface_minutes != 180) | |
334 counter = 0; | |
335 else | |
336 counter++; | |
337 | |
338 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 180.0f) >= 0.6f) | |
339 return false; | |
340 for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
341 { | |
342 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
343 { | |
344 counter2++; | |
345 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
346 } | |
347 } | |
348 i = i; | |
349 return true; | |
350 } | |
351 | |
352 /** | |
353 ****************************************************************************** | |
354 * @brief test 3 | |
355 * Trimix 10/70 | |
356 * everything else identical to test1 by Peter Ryser | |
357 * @version V0.0.1 | |
358 * @date 19-April-2014 | |
359 * @retval 1 for result is similar to DRx code, 0 otherwise | |
360 ****************************************************************************** | |
361 */ | |
362 uint8_t test3_unapproved(void) | |
363 { | |
364 | |
365 /* debug code with watch */ | |
366 static int32_t output_time_to_surface_minutes; | |
367 static int32_t counter = 0; | |
368 static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
369 static int32_t counter2 = 0; | |
370 | |
371 /* all the rest */ | |
372 SDiveState input; | |
373 int i; | |
374 | |
375 init_buehlmann2(&input); | |
376 //vpm conservatism = 0, repetitive = false, | |
377 vpm_init(&(input.vpm),0,false,0); | |
378 | |
379 //runter auf 70 meter mit 26 meter/minute | |
380 simulate_descent(&input, 70.0f, 26.0f); | |
381 //10 minuten settigung | |
382 decom_tissues_exposure(10 * 60, &input.lifeData); | |
383 //buehlmann__test__saturate_tissues(&input, 10 * 60); | |
384 //buehlmann_calc_deco(&input); | |
385 | |
386 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
387 | |
388 //Check time to surface 46 min +- 0.6 | |
389 | |
390 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
391 if (output_time_to_surface_minutes != 46) | |
392 counter = 0; | |
393 else | |
394 counter++; | |
395 | |
396 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
397 return false; | |
398 for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
399 { | |
400 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
401 { | |
402 counter2++; | |
403 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
404 } | |
405 } | |
406 i = i; | |
407 return true; | |
408 } | |
409 | |
410 /** | |
411 ****************************************************************************** | |
412 * @brief test 4 - find the limit | |
413 * Trimix 10/70 | |
414 * 200 Meter, 30 Minuten | |
415 * @version V0.0.1 | |
416 * @date 19-April-2014 | |
417 * @retval 1 for result is similar to DRx code, 0 otherwise | |
418 ****************************************************************************** | |
419 */ | |
420 uint8_t test4_unapproved(void) | |
421 { | |
422 | |
423 /* debug code with watch */ | |
424 static int32_t output_time_to_surface_minutes; | |
425 static int32_t counter = 0; | |
426 static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
427 static int32_t counter2 = 0; | |
428 | |
429 /* all the rest */ | |
430 SDiveState input; | |
431 int i; | |
432 | |
433 init_buehlmann2(&input); | |
434 //vpm conservatism = 0, repetitive = false, | |
435 vpm_init(&input.vpm,0,false,0); | |
436 | |
437 //runter auf 70 meter mit 26 meter/minute | |
438 simulate_descent(&input, 200.0f, 26.0f); | |
439 //10 minuten settigung | |
440 decom_tissues_exposure(10 * 60, &input.lifeData ); | |
441 //buehlmann__test__saturate_tissues(&input, 30 * 60); | |
442 //buehlmann_calc_deco(&input); | |
443 | |
444 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
445 | |
446 //Check time to surface 1270 min | |
447 // Multi Deco 1270 Minuten | |
448 | |
449 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
450 if (output_time_to_surface_minutes != 1270) | |
451 counter = 0; | |
452 else | |
453 counter++; | |
454 | |
455 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 1270.0f) >= 0.6f) | |
456 return false; | |
457 for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
458 { | |
459 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
460 { | |
461 counter2++; | |
462 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
463 } | |
464 } | |
465 i = i; | |
466 return true; | |
467 } | |
468 | |
469 /*uint8_t test5_unapproved(uint32_t frame1, uint32_t frame2, uint32_t frame3, uint32_t frame4)*/ | |
470 uint8_t test5_unapproved(void) | |
471 { | |
472 /* debug code with watch */ | |
473 static int32_t output_time_to_surface_minutes; | |
474 static int32_t counter = 0; | |
475 | |
476 // static int32_t counter2 = 0; | |
477 /* all the rest */ | |
478 SDiveState input; | |
479 | |
480 //uint32_t frame[5]; | |
481 | |
482 uint8_t vpm_count; | |
483 | |
484 /* | |
485 frame[0] = frame1; | |
486 frame[1] = frame2; | |
487 frame[2] = frame3; | |
488 frame[3] = frame4; | |
489 frame[4] = frame[0]; | |
490 */ | |
491 init_buehlmann(&input); | |
492 vpm_init(&input.vpm,0,false,0); | |
493 logbook_initNewdiveProfile(&input,&Settings); | |
494 setSimulationValues(12, 26 , 70, 30); | |
495 | |
496 long time = 60 * 70 / 26 + 10 *60; | |
497 | |
498 vpm_count = 0; | |
499 while(input.lifeData.dive_time_seconds < time ) | |
500 { | |
501 /* frame[4] = frame[0]; | |
502 frame[0] = frame[1]; | |
503 frame[1] = frame[2]; | |
504 frame[2] = frame[3]; | |
505 frame[3] = frame[4];*/ | |
506 UpdateLifeDataTest(&input); | |
507 | |
508 vpm_count++; | |
509 if(vpm_count > 20) | |
510 { | |
511 vpm_calc(&input.lifeData, &(input.diveSettings),&input.vpm, &input.decolistVPM, DECOSTOPS); | |
512 vpm_count = 0; | |
513 } | |
514 | |
515 /* | |
516 #ifdef VGAOUT | |
517 tVGA_refresh(frame[1], &input); | |
518 GFX_VGA_transform(frame[1],frame[0]); | |
519 GFX_SetFrameBuffer(frame[0], TOP_LAYER); | |
520 GFX_clear_buffer(frame[3]); // frame[3] is the previous frame[0] | |
521 #endif | |
522 */ | |
523 if(input.lifeData.dive_time_seconds == 60 *5) | |
524 { | |
525 input.events.gasChange = 1; | |
526 input.events.info_GasChange = 2; | |
527 } | |
528 else | |
529 { | |
530 input.events.gasChange = 0; | |
531 input.events.info_GasChange = 0; | |
532 } | |
533 logbook_writeSample(input); | |
534 } | |
535 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
536 | |
537 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
538 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
539 logbook_EndDive(); | |
540 | |
541 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
542 if (output_time_to_surface_minutes != 46) | |
543 counter = 0; | |
544 else | |
545 counter++; | |
546 | |
547 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
548 return false; | |
549 | |
550 return true; | |
551 } | |
552 | |
553 | |
554 uint8_t test6_unapproved(void) | |
555 { | |
556 /* debug code with watch */ | |
557 static int32_t output_time_to_surface_minutes; | |
558 static int32_t counter = 0; | |
559 | |
560 // static int32_t counter2 = 0; | |
561 /* all the rest */ | |
562 SDiveState input; | |
563 | |
564 //uint32_t frame[5]; | |
565 | |
566 uint8_t vpm_count; | |
567 | |
568 init_buehlmann(&input); | |
569 vpm_init(&input.vpm,0,false,0); | |
570 logbook_initNewdiveProfile(&input,&Settings); | |
571 setSimulationValues(12, 26 , 65, 15); | |
572 | |
573 long time = 60 * 70 / 26 + 10 *60; | |
574 | |
575 vpm_count = 0; | |
576 while(input.lifeData.dive_time_seconds < time ) | |
577 { | |
578 UpdateLifeDataTest(&input); | |
579 | |
580 vpm_count++; | |
581 if(vpm_count > 20) | |
582 { | |
583 vpm_calc(&input.lifeData, &(input.diveSettings),&input.vpm, &input.decolistVPM, DECOSTOPS); | |
584 vpm_count = 0; | |
585 } | |
586 if(input.lifeData.dive_time_seconds == 60 *5) | |
587 { | |
588 input.events.gasChange = 1; | |
589 input.events.info_GasChange = 2; | |
590 } | |
591 else | |
592 { | |
593 input.events.gasChange = 0; | |
594 input.events.info_GasChange = 0; | |
595 } | |
596 logbook_writeSample(input); | |
597 } | |
598 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
599 | |
600 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
601 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
602 logbook_EndDive(); | |
603 | |
604 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
605 if (output_time_to_surface_minutes != 46) | |
606 counter = 0; | |
607 else | |
608 counter++; | |
609 | |
610 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
611 return false; | |
612 | |
613 return true; | |
614 } | |
615 | |
616 uint8_t test7_unapproved(void) | |
617 { | |
618 /* debug code with watch */ | |
619 static int32_t output_time_to_surface_minutes; | |
620 static int32_t counter = 0; | |
621 | |
622 // static int32_t counter2 = 0; | |
623 /* all the rest */ | |
624 SDiveState input; | |
625 | |
626 //uint32_t frame[5]; | |
627 | |
628 uint8_t vpm_count; | |
629 | |
630 init_buehlmann(&input); | |
631 vpm_init(&input.vpm,0,false,0); | |
632 logbook_initNewdiveProfile(&input,&Settings); | |
633 setSimulationValues(12, 26 , 40, 45); | |
634 | |
635 long time = 60 * 70 / 26 + 10 *60; | |
636 | |
637 vpm_count = 0; | |
638 while(input.lifeData.dive_time_seconds < time ) | |
639 { | |
640 UpdateLifeDataTest(&input); | |
641 | |
642 vpm_count++; | |
643 if(vpm_count > 20) | |
644 { | |
645 vpm_calc(&input.lifeData,&input.diveSettings, &input.vpm, &input.decolistVPM, DECOSTOPS); | |
646 vpm_count = 0; | |
647 } | |
648 if(input.lifeData.dive_time_seconds == 60 *5) | |
649 { | |
650 input.events.gasChange = 1; | |
651 input.events.info_GasChange = 2; | |
652 } | |
653 else | |
654 { | |
655 input.events.gasChange = 0; | |
656 input.events.info_GasChange = 0; | |
657 } | |
658 logbook_writeSample(input); | |
659 } | |
660 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
661 | |
662 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
663 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
664 logbook_EndDive(); | |
665 | |
666 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
667 if (output_time_to_surface_minutes != 46) | |
668 counter = 0; | |
669 else | |
670 counter++; | |
671 | |
672 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
673 return false; | |
674 | |
675 return true; | |
676 } | |
677 | |
678 void test_log_only(uint8_t max_depth_meter, uint16_t divetime_minutes) | |
679 { | |
680 SDiveState input; | |
681 float ascendrate_seconds; | |
682 float descendrate_seconds; | |
683 uint32_t divetime_seconds; | |
684 uint32_t divetime_start_ascend; | |
685 | |
686 init_buehlmann(&input); | |
687 input.lifeData.max_depth_meter = 0.0; | |
688 input.lifeData.depth_meter = 0.0; | |
689 input.lifeData.temperature_celsius = 22.7; | |
690 | |
691 ascendrate_seconds = 12.0 / 60.0; | |
692 descendrate_seconds = 20.0 / 60.0; | |
693 divetime_seconds = divetime_minutes * 60; | |
694 divetime_start_ascend = divetime_seconds - (uint32_t)(max_depth_meter / ascendrate_seconds); | |
695 | |
696 logbook_initNewdiveProfile(&input,&Settings); | |
697 | |
698 while(input.lifeData.dive_time_seconds < divetime_seconds ) | |
699 { | |
700 input.lifeData.dive_time_seconds += 1; | |
701 | |
702 if(input.lifeData.max_depth_meter < (float)max_depth_meter) | |
703 { | |
704 input.lifeData.depth_meter += descendrate_seconds; | |
705 input.lifeData.max_depth_meter = input.lifeData.depth_meter; | |
706 } | |
707 else if((input.lifeData.dive_time_seconds >= divetime_start_ascend) && (input.lifeData.depth_meter > 0)) | |
708 { | |
709 input.lifeData.depth_meter -= ascendrate_seconds; | |
710 if(input.lifeData.depth_meter < 0) | |
711 input.lifeData.depth_meter = 0; | |
712 } | |
713 | |
714 logbook_writeSample(input); | |
715 } | |
716 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
717 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
718 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
719 logbook_EndDive(); | |
720 } | |
721 | |
722 | |
723 /** | |
724 ****************************************************************************** | |
725 * @brief test 101 | |
726 * a) for air | |
727 * b) air + oxygen | |
728 * c) Trimix 10/70 + oxygen | |
729 * 65 Meter, 42 Minuten with descent | |
730 * @version V0.0.1 | |
731 * @date 26-Oct-2014 | |
732 * @retval ToDo: 1 for result is similar to MultiDeco | |
733 ****************************************************************************** | |
734 */ | |
735 | |
736 uint8_t test101_buehlmann_unapproved(void) | |
737 { | |
738 /* all the rest */ | |
739 SDiveState input; | |
740 | |
741 init_buehlmann(&input); | |
742 | |
743 //Gas Change at 6 meter to oxygin | |
744 //input.diveSettings.decogaslist[1].change_during_ascent_depth_bar_otherwise_zero = 0.6f; | |
745 //input.diveSettings.decogaslist[1].nitrogen_percentage = 0; | |
746 //input.diveSettings.decogaslist[1].helium_percentage = 0; | |
747 input.diveSettings.gf_high = 100; | |
748 input.diveSettings.gf_low = 100; | |
749 input.diveSettings.ascentRate_meterperminute = 10.0f; | |
750 input.diveSettings.last_stop_depth_bar = 0.3f; // input.diveSettings.last_stop_depth_bar = 0.6f; /* ist egal bei oxygen */ | |
751 | |
752 //runter auf 65 meter mit 20 meter/minute | |
753 simulate_descent(&input, 65.0f, 20.0f); | |
754 //38min 45sec saettigung == 2325 sec | |
755 decom_tissues_exposure(30*60, &input.lifeData ); | |
756 // decom_tissues_exposure(2325, &input.lifeData ); | |
757 | |
758 //vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM)); | |
759 buehlmann_calc_deco(&input.lifeData,&input.diveSettings,&input.decolistBuehlmann); | |
760 | |
761 | |
762 //Check time to surface MultiDeco 4.04 | |
763 // 308 min with Air | |
764 // 190,5 min with Air + 6m last stop with oxygen | |
765 // 538 min with Trimix 10/70 and oxygen at 6m | |
766 | |
767 // ... | |
768 | |
769 return true; | |
770 } |