Mercurial > public > ostc4
annotate Discovery/Src/test_vpm.c @ 369:210bffc496a3 MotionDetection
Added a function to count the active custom views.
author | ideenmodellierer |
---|---|
date | Tue, 13 Aug 2019 21:12:17 +0200 |
parents | 54d14bc2083c |
children | aa6006975e76 |
rev | line source |
---|---|
38 | 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; | |
281 | 164 pInput->events.info_manualGasSetO2 = 0; |
165 pInput->events.info_manualGasSetHe = 0; | |
166 pInput->events.manualGasSet = 0; | |
38 | 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 return true; | |
349 } | |
350 | |
351 /** | |
352 ****************************************************************************** | |
353 * @brief test 3 | |
354 * Trimix 10/70 | |
355 * everything else identical to test1 by Peter Ryser | |
356 * @version V0.0.1 | |
357 * @date 19-April-2014 | |
358 * @retval 1 for result is similar to DRx code, 0 otherwise | |
359 ****************************************************************************** | |
360 */ | |
361 uint8_t test3_unapproved(void) | |
362 { | |
363 | |
364 /* debug code with watch */ | |
365 static int32_t output_time_to_surface_minutes; | |
366 static int32_t counter = 0; | |
367 static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
368 static int32_t counter2 = 0; | |
369 | |
370 /* all the rest */ | |
371 SDiveState input; | |
372 int i; | |
373 | |
374 init_buehlmann2(&input); | |
375 //vpm conservatism = 0, repetitive = false, | |
376 vpm_init(&(input.vpm),0,false,0); | |
377 | |
378 //runter auf 70 meter mit 26 meter/minute | |
379 simulate_descent(&input, 70.0f, 26.0f); | |
380 //10 minuten settigung | |
381 decom_tissues_exposure(10 * 60, &input.lifeData); | |
382 //buehlmann__test__saturate_tissues(&input, 10 * 60); | |
383 //buehlmann_calc_deco(&input); | |
384 | |
385 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
386 | |
387 //Check time to surface 46 min +- 0.6 | |
388 | |
389 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
390 if (output_time_to_surface_minutes != 46) | |
391 counter = 0; | |
392 else | |
393 counter++; | |
394 | |
395 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
396 return false; | |
397 for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
398 { | |
399 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
400 { | |
401 counter2++; | |
402 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
403 } | |
404 } | |
405 return true; | |
406 } | |
407 | |
408 /** | |
409 ****************************************************************************** | |
410 * @brief test 4 - find the limit | |
411 * Trimix 10/70 | |
412 * 200 Meter, 30 Minuten | |
413 * @version V0.0.1 | |
414 * @date 19-April-2014 | |
415 * @retval 1 for result is similar to DRx code, 0 otherwise | |
416 ****************************************************************************** | |
417 */ | |
418 uint8_t test4_unapproved(void) | |
419 { | |
420 | |
421 /* debug code with watch */ | |
422 static int32_t output_time_to_surface_minutes; | |
423 static int32_t counter = 0; | |
424 static float decotable_minutes[DECOINFO_STRUCT_MAX_STOPS]; | |
425 static int32_t counter2 = 0; | |
426 | |
427 /* all the rest */ | |
428 SDiveState input; | |
429 int i; | |
430 | |
431 init_buehlmann2(&input); | |
432 //vpm conservatism = 0, repetitive = false, | |
433 vpm_init(&input.vpm,0,false,0); | |
434 | |
435 //runter auf 70 meter mit 26 meter/minute | |
436 simulate_descent(&input, 200.0f, 26.0f); | |
437 //10 minuten settigung | |
438 decom_tissues_exposure(10 * 60, &input.lifeData ); | |
439 //buehlmann__test__saturate_tissues(&input, 30 * 60); | |
440 //buehlmann_calc_deco(&input); | |
441 | |
442 vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM), DECOSTOPS); | |
443 | |
444 //Check time to surface 1270 min | |
445 // Multi Deco 1270 Minuten | |
446 | |
447 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
448 if (output_time_to_surface_minutes != 1270) | |
449 counter = 0; | |
450 else | |
451 counter++; | |
452 | |
453 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 1270.0f) >= 0.6f) | |
454 return false; | |
455 for(i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++) | |
456 { | |
457 if(decotable_minutes[i] != ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f) | |
458 { | |
459 counter2++; | |
460 decotable_minutes[i] = ((float)input.decolistVPM.output_stop_length_seconds[i]) / 60.0f; | |
461 } | |
462 } | |
463 return true; | |
464 } | |
465 | |
466 /*uint8_t test5_unapproved(uint32_t frame1, uint32_t frame2, uint32_t frame3, uint32_t frame4)*/ | |
467 uint8_t test5_unapproved(void) | |
468 { | |
469 /* debug code with watch */ | |
470 static int32_t output_time_to_surface_minutes; | |
471 static int32_t counter = 0; | |
472 | |
473 // static int32_t counter2 = 0; | |
474 /* all the rest */ | |
475 SDiveState input; | |
476 | |
477 //uint32_t frame[5]; | |
478 | |
479 uint8_t vpm_count; | |
480 | |
481 /* | |
482 frame[0] = frame1; | |
483 frame[1] = frame2; | |
484 frame[2] = frame3; | |
485 frame[3] = frame4; | |
486 frame[4] = frame[0]; | |
487 */ | |
488 init_buehlmann(&input); | |
489 vpm_init(&input.vpm,0,false,0); | |
490 logbook_initNewdiveProfile(&input,&Settings); | |
491 setSimulationValues(12, 26 , 70, 30); | |
492 | |
493 long time = 60 * 70 / 26 + 10 *60; | |
494 | |
495 vpm_count = 0; | |
496 while(input.lifeData.dive_time_seconds < time ) | |
497 { | |
498 /* frame[4] = frame[0]; | |
499 frame[0] = frame[1]; | |
500 frame[1] = frame[2]; | |
501 frame[2] = frame[3]; | |
502 frame[3] = frame[4];*/ | |
503 UpdateLifeDataTest(&input); | |
504 | |
505 vpm_count++; | |
506 if(vpm_count > 20) | |
507 { | |
508 vpm_calc(&input.lifeData, &(input.diveSettings),&input.vpm, &input.decolistVPM, DECOSTOPS); | |
509 vpm_count = 0; | |
510 } | |
511 | |
512 /* | |
513 #ifdef VGAOUT | |
514 tVGA_refresh(frame[1], &input); | |
515 GFX_VGA_transform(frame[1],frame[0]); | |
516 GFX_SetFrameBuffer(frame[0], TOP_LAYER); | |
517 GFX_clear_buffer(frame[3]); // frame[3] is the previous frame[0] | |
518 #endif | |
519 */ | |
520 if(input.lifeData.dive_time_seconds == 60 *5) | |
521 { | |
522 input.events.gasChange = 1; | |
523 input.events.info_GasChange = 2; | |
524 } | |
525 else | |
526 { | |
527 input.events.gasChange = 0; | |
528 input.events.info_GasChange = 0; | |
529 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
219
diff
changeset
|
530 logbook_writeSample(&input); |
38 | 531 } |
532 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
533 | |
534 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
535 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
536 logbook_EndDive(); | |
537 | |
538 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
539 if (output_time_to_surface_minutes != 46) | |
540 counter = 0; | |
541 else | |
542 counter++; | |
543 | |
544 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
545 return false; | |
546 | |
547 return true; | |
548 } | |
549 | |
550 | |
551 uint8_t test6_unapproved(void) | |
552 { | |
553 /* debug code with watch */ | |
554 static int32_t output_time_to_surface_minutes; | |
555 static int32_t counter = 0; | |
556 | |
557 // static int32_t counter2 = 0; | |
558 /* all the rest */ | |
559 SDiveState input; | |
560 | |
561 //uint32_t frame[5]; | |
562 | |
563 uint8_t vpm_count; | |
564 | |
565 init_buehlmann(&input); | |
566 vpm_init(&input.vpm,0,false,0); | |
567 logbook_initNewdiveProfile(&input,&Settings); | |
568 setSimulationValues(12, 26 , 65, 15); | |
569 | |
570 long time = 60 * 70 / 26 + 10 *60; | |
571 | |
572 vpm_count = 0; | |
573 while(input.lifeData.dive_time_seconds < time ) | |
574 { | |
575 UpdateLifeDataTest(&input); | |
576 | |
577 vpm_count++; | |
578 if(vpm_count > 20) | |
579 { | |
580 vpm_calc(&input.lifeData, &(input.diveSettings),&input.vpm, &input.decolistVPM, DECOSTOPS); | |
581 vpm_count = 0; | |
582 } | |
583 if(input.lifeData.dive_time_seconds == 60 *5) | |
584 { | |
585 input.events.gasChange = 1; | |
586 input.events.info_GasChange = 2; | |
587 } | |
588 else | |
589 { | |
590 input.events.gasChange = 0; | |
591 input.events.info_GasChange = 0; | |
592 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
219
diff
changeset
|
593 logbook_writeSample(&input); |
38 | 594 } |
595 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
596 | |
597 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
598 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
599 logbook_EndDive(); | |
600 | |
601 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
602 if (output_time_to_surface_minutes != 46) | |
603 counter = 0; | |
604 else | |
605 counter++; | |
606 | |
607 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
608 return false; | |
609 | |
610 return true; | |
611 } | |
612 | |
613 uint8_t test7_unapproved(void) | |
614 { | |
615 /* debug code with watch */ | |
616 static int32_t output_time_to_surface_minutes; | |
617 static int32_t counter = 0; | |
618 | |
619 // static int32_t counter2 = 0; | |
620 /* all the rest */ | |
621 SDiveState input; | |
622 | |
623 //uint32_t frame[5]; | |
624 | |
625 uint8_t vpm_count; | |
626 | |
627 init_buehlmann(&input); | |
628 vpm_init(&input.vpm,0,false,0); | |
629 logbook_initNewdiveProfile(&input,&Settings); | |
630 setSimulationValues(12, 26 , 40, 45); | |
631 | |
632 long time = 60 * 70 / 26 + 10 *60; | |
633 | |
634 vpm_count = 0; | |
635 while(input.lifeData.dive_time_seconds < time ) | |
636 { | |
637 UpdateLifeDataTest(&input); | |
638 | |
639 vpm_count++; | |
640 if(vpm_count > 20) | |
641 { | |
642 vpm_calc(&input.lifeData,&input.diveSettings, &input.vpm, &input.decolistVPM, DECOSTOPS); | |
643 vpm_count = 0; | |
644 } | |
645 if(input.lifeData.dive_time_seconds == 60 *5) | |
646 { | |
647 input.events.gasChange = 1; | |
648 input.events.info_GasChange = 2; | |
649 } | |
650 else | |
651 { | |
652 input.events.gasChange = 0; | |
653 input.events.info_GasChange = 0; | |
654 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
219
diff
changeset
|
655 logbook_writeSample(&input); |
38 | 656 } |
657 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
658 | |
659 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
660 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
661 logbook_EndDive(); | |
662 | |
663 output_time_to_surface_minutes = input.decolistVPM.output_time_to_surface_seconds / 60; | |
664 if (output_time_to_surface_minutes != 46) | |
665 counter = 0; | |
666 else | |
667 counter++; | |
668 | |
669 if(fabsf( ((float)input.decolistVPM.output_time_to_surface_seconds / 60.0f) - 46.0f) >= 0.6f) | |
670 return false; | |
671 | |
672 return true; | |
673 } | |
674 | |
675 void test_log_only(uint8_t max_depth_meter, uint16_t divetime_minutes) | |
676 { | |
677 SDiveState input; | |
678 float ascendrate_seconds; | |
679 float descendrate_seconds; | |
680 uint32_t divetime_seconds; | |
681 uint32_t divetime_start_ascend; | |
682 | |
683 init_buehlmann(&input); | |
684 input.lifeData.max_depth_meter = 0.0; | |
685 input.lifeData.depth_meter = 0.0; | |
686 input.lifeData.temperature_celsius = 22.7; | |
687 | |
688 ascendrate_seconds = 12.0 / 60.0; | |
689 descendrate_seconds = 20.0 / 60.0; | |
690 divetime_seconds = divetime_minutes * 60; | |
691 divetime_start_ascend = divetime_seconds - (uint32_t)(max_depth_meter / ascendrate_seconds); | |
692 | |
693 logbook_initNewdiveProfile(&input,&Settings); | |
694 | |
695 while(input.lifeData.dive_time_seconds < divetime_seconds ) | |
696 { | |
697 input.lifeData.dive_time_seconds += 1; | |
698 | |
699 if(input.lifeData.max_depth_meter < (float)max_depth_meter) | |
700 { | |
701 input.lifeData.depth_meter += descendrate_seconds; | |
702 input.lifeData.max_depth_meter = input.lifeData.depth_meter; | |
703 } | |
704 else if((input.lifeData.dive_time_seconds >= divetime_start_ascend) && (input.lifeData.depth_meter > 0)) | |
705 { | |
706 input.lifeData.depth_meter -= ascendrate_seconds; | |
707 if(input.lifeData.depth_meter < 0) | |
708 input.lifeData.depth_meter = 0; | |
709 } | |
710 | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
219
diff
changeset
|
711 logbook_writeSample(&input); |
38 | 712 } |
713 volatile SLogbookHeader* logbookHeader = logbook_getCurrentHeader(); | |
714 logbookHeader->total_diveTime_seconds = input.lifeData.dive_time_seconds; | |
715 logbookHeader->maxDepth = input.lifeData.max_depth_meter * 100; | |
716 logbook_EndDive(); | |
717 } | |
718 | |
719 | |
720 /** | |
721 ****************************************************************************** | |
722 * @brief test 101 | |
723 * a) for air | |
724 * b) air + oxygen | |
725 * c) Trimix 10/70 + oxygen | |
726 * 65 Meter, 42 Minuten with descent | |
727 * @version V0.0.1 | |
728 * @date 26-Oct-2014 | |
729 * @retval ToDo: 1 for result is similar to MultiDeco | |
730 ****************************************************************************** | |
731 */ | |
732 | |
733 uint8_t test101_buehlmann_unapproved(void) | |
734 { | |
735 /* all the rest */ | |
736 SDiveState input; | |
737 | |
738 init_buehlmann(&input); | |
739 | |
740 //Gas Change at 6 meter to oxygin | |
741 //input.diveSettings.decogaslist[1].change_during_ascent_depth_bar_otherwise_zero = 0.6f; | |
742 //input.diveSettings.decogaslist[1].nitrogen_percentage = 0; | |
743 //input.diveSettings.decogaslist[1].helium_percentage = 0; | |
744 input.diveSettings.gf_high = 100; | |
745 input.diveSettings.gf_low = 100; | |
746 input.diveSettings.ascentRate_meterperminute = 10.0f; | |
747 input.diveSettings.last_stop_depth_bar = 0.3f; // input.diveSettings.last_stop_depth_bar = 0.6f; /* ist egal bei oxygen */ | |
748 | |
749 //runter auf 65 meter mit 20 meter/minute | |
750 simulate_descent(&input, 65.0f, 20.0f); | |
751 //38min 45sec saettigung == 2325 sec | |
752 decom_tissues_exposure(30*60, &input.lifeData ); | |
753 // decom_tissues_exposure(2325, &input.lifeData ); | |
754 | |
755 //vpm_calc(&(input.lifeData),&(input.diveSettings),&(input.vpm),&(input.decolistVPM)); | |
756 buehlmann_calc_deco(&input.lifeData,&input.diveSettings,&input.decolistBuehlmann); | |
757 | |
758 | |
759 //Check time to surface MultiDeco 4.04 | |
760 // 308 min with Air | |
761 // 190,5 min with Air + 6m last stop with oxygen | |
762 // 538 min with Trimix 10/70 and oxygen at 6m | |
763 | |
764 // ... | |
765 | |
766 return true; | |
767 } |