annotate Discovery/Src/buehlmann.c @ 923:6fc0e3d230e4 Evo_2_23

UART6 DMA handling: Make sure that RX transmission uses DMA stream 2
author Ideenmodellierer
date Mon, 04 Nov 2024 20:21:02 +0100
parents 974648b5ccfe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
1 /* getrennte Gase f�r die verschiedenen Modi
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
2 um Gaswechsel Eintr�ge zu vereinfachen
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 das heisst:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 oc == bailout in cc mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /* Konvention:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 float extExample_variable_can_be_used_with_extern;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 #include <string.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 #include <math.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 #include <stdbool.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 #include "buehlmann.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 extern const float buehlmann_N2_a[];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 extern const float buehlmann_N2_b[];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 extern const float buehlmann_He_a[];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 extern const float buehlmann_He_b[];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 float depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 int id;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 } SStop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 #define DECO_STOPS_MAX_TTS_CALCULATON_IN_SECONDS 59940 // 999 minuten; before: 18000 // 5(h) * 60(min) * 60 sec = 18000 sec
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 #define DECO_STOPS_MAX_TTS_FOR_EVERY_SECOND_CALC_IN_SECONDS 7200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #define NINETY_NINE_MINUTES_IN_SECONDS 59940
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 # define PRESSURE_TEN_METER 1.0f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 # define PRESSURE_THREE_METER 0.333334f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 # define PRESSURE_150_CM 0.15f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 # define PRESSURE_HALF_METER 0.05f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
37 static void buehlmann_backup_and_restore(_Bool backup_restore_otherwise);
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
38 static float tissue_tolerance(void);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
39 static void ambient_bar_to_deco_stop_depth_bar(SDiveSettings *pDiveSettings, float ceiling);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
40 static int ascend_with_all_gaschanges(SDiveSettings *pDiveSettings, float pressure_decrease);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
41 static float next_stop_depth_input_is_actual_stop_id(SDiveSettings *pDiveSettings, int actual_id);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
42 static float get_gf_at_pressure(SDiveSettings *pDiveSettings, float pressure);
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
43 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
44 static _Bool dive1_check_deco(SDiveSettings *pDiveSettings);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
46 static float gSurface_pressure_bar;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
47 static float gPressure;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
48 static int gGas_id;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
49 static float gTissue_nitrogen_bar[16];
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
50 static float gTissue_helium_bar[16];
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
51 static float gGF_value;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
52 static float gCNS;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 float gGF_low_depth_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 SStop gStop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 void buehlmann_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
61 static void buehlmann_backup_and_restore(_Bool backup_restore_otherwise)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 static float pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 static float gas_id;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 static float tissue_nitrogen_bar[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 static float tissue_helium_bar[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 static float gf_value;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 static float cns;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 if(backup_restore_otherwise)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 pressure = gPressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 gas_id = gGas_id;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 gf_value = gGF_value;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 cns = gCNS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 memcpy(tissue_nitrogen_bar, gTissue_nitrogen_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 memcpy(tissue_helium_bar, gTissue_helium_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 gPressure = pressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 gGas_id = gas_id;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 gGF_value = gf_value;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 gCNS = cns;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 memcpy(gTissue_nitrogen_bar, tissue_nitrogen_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 memcpy(gTissue_helium_bar, tissue_helium_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 float buehlmann_get_gCNS(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 return gCNS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 void buehlmann_calc_deco(SLifeData* pLifeData, SDiveSettings * pDiveSettings, SDecoinfo * pDecoInfo)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 float ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 int ascend_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 int tts_seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 float pressure_delta;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 float next_depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 _Bool deco_reached = false;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 unsigned short *stoplist;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 int i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 gCNS = 0;
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
108 pDecoInfo->output_time_to_surface_seconds = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 pDecoInfo->output_ndl_seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 for(int i=0;i<DECOINFO_STRUCT_MAX_STOPS;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 pDecoInfo->output_stop_length_seconds[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 /* internal copying */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 gSurface_pressure_bar = pLifeData->pressure_surface_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 gPressure = pLifeData->pressure_ambient_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 gGas_id = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16));
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
122 gGF_value = ((float)pDiveSettings->gf_low) / 100.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123
258
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
124 stoplist = pDecoInfo->output_stop_length_seconds;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125
305
305f251cc981 bugfix, consistency: show deco/NDL really after 1 minute divetime
Jan Mulder <jlmulder@xs4all.nl>
parents: 291
diff changeset
126 if(pLifeData->dive_time_seconds_without_surface_time < 60)
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
127 return;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 // clean stop list
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 for(i = 0; i < DECOINFO_STRUCT_MAX_STOPS; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 stoplist[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
133 if(pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero >= (gPressure - PRESSURE_150_CM))
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
134 {
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
135 deco_reached = true;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
136 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
138 gGF_value = ((float)pDiveSettings->gf_high) / 100.0f;
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
139 buehlmann_backup_and_restore(true);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
140 if(!dive1_check_deco(pDiveSettings) )
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 {
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
142 buehlmann_backup_and_restore(false);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 // no deco
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
144 pDecoInfo->output_time_to_surface_seconds = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 for(i = 0; i < DECOINFO_STRUCT_MAX_STOPS; i++)
254
a17f7fb3b2b5 Buehlmann: cleanup, remove global pDecolistBuehlmann
Jan Mulder <jlmulder@xs4all.nl>
parents: 253
diff changeset
146 pDecoInfo->output_stop_length_seconds[i] = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 // calc NDL
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
148 pDecoInfo->output_ndl_seconds = buehlmann_calc_ndl(pDiveSettings);;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 buehlmann_backup_and_restore(false);
254
a17f7fb3b2b5 Buehlmann: cleanup, remove global pDecolistBuehlmann
Jan Mulder <jlmulder@xs4all.nl>
parents: 253
diff changeset
152 pDecoInfo->output_ndl_seconds = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
154 gGF_value = get_gf_at_pressure(pDiveSettings, gPressure);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 //current ceiling at actual position
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 ceiling = tissue_tolerance();
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
157 ambient_bar_to_deco_stop_depth_bar(pDiveSettings, ceiling);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 // set the base for all upcoming parameters
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 ceiling = gStop.depth + gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 tts_seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 // modify parameters if there is ascend or parameter fine adjustment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 if(ceiling < (gPressure - PRESSURE_150_CM)) // more than 1.5 meter below ceiling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 // ascend within 10 mtr to GF_low // speed 12 mtr/min -> 50 sec / 10 mtr; 15 sec / 3 mtr.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 if(ceiling < (gPressure - PRESSURE_TEN_METER) )
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 { do {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
169 ascend_time = ascend_with_all_gaschanges(pDiveSettings, PRESSURE_TEN_METER);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 tts_seconds += ascend_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 ceiling = tissue_tolerance();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 if(tts_seconds > DECO_STOPS_MAX_TTS_CALCULATON_IN_SECONDS)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 {
254
a17f7fb3b2b5 Buehlmann: cleanup, remove global pDecolistBuehlmann
Jan Mulder <jlmulder@xs4all.nl>
parents: 253
diff changeset
174 pDecoInfo->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 return;// NINETY_NINE_MINUTES_IN_SECONDS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 } while ((ascend_time > 0 ) && ((gPressure - PRESSURE_TEN_METER ) > gSurface_pressure_bar) && (ceiling < (gPressure - PRESSURE_TEN_METER)));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 do {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 buehlmann_backup_and_restore(true);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
181 ascend_time = ascend_with_all_gaschanges(pDiveSettings, PRESSURE_THREE_METER);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 tts_seconds += ascend_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 ceiling = tissue_tolerance();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 if(tts_seconds > DECO_STOPS_MAX_TTS_CALCULATON_IN_SECONDS)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 {
254
a17f7fb3b2b5 Buehlmann: cleanup, remove global pDecolistBuehlmann
Jan Mulder <jlmulder@xs4all.nl>
parents: 253
diff changeset
186 pDecoInfo->output_time_to_surface_seconds = NINETY_NINE_MINUTES_IN_SECONDS;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 return;// NINETY_NINE_MINUTES_IN_SECONDS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 }
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
189 ambient_bar_to_deco_stop_depth_bar(pDiveSettings, ceiling);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 } while ((ascend_time > 0 ) && ((gStop.depth + gSurface_pressure_bar) < gPressure));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 if(gStop.depth + gSurface_pressure_bar > gPressure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 gPressure += PRESSURE_THREE_METER;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 buehlmann_backup_and_restore(false);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 tts_seconds -= ascend_time;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 // calculate first stop based on tissue saturation within 10 meters of stop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 //ambient_bar_to_deco_stop_depth_bar(ceiling);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 // initial values, upper code might not be executed (is within 150 cm)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
206 if (ceiling > gSurface_pressure_bar)
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
207 {
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
208 ceiling = gStop.depth + gSurface_pressure_bar;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
209 // ascend the last meters to first stop (especially consider any gas changes around)
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
210 pressure_delta = gPressure - ceiling;
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
211 ascend_time = (int) ceil(pressure_delta * 50.0f);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
212 tts_seconds += ascend_with_all_gaschanges(pDiveSettings, pressure_delta);
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
213 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 // NDL check
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 if(ceiling <= gSurface_pressure_bar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 // NDL with GF_low
254
a17f7fb3b2b5 Buehlmann: cleanup, remove global pDecolistBuehlmann
Jan Mulder <jlmulder@xs4all.nl>
parents: 253
diff changeset
218 pDecoInfo->output_time_to_surface_seconds = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 }
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
221 if (ceiling > pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero)
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
222 pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = ceiling;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 // calc gf loop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 if(deco_reached)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 gGF_low_depth_bar = pDiveSettings->internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero - gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 gGF_low_depth_bar = ceiling - gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 while(gStop.depth > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 do
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
234 next_depth = next_stop_depth_input_is_actual_stop_id(pDiveSettings, gStop.id);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
235 gGF_value = get_gf_at_pressure(pDiveSettings, next_depth + gSurface_pressure_bar);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 buehlmann_backup_and_restore(true);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
237 ascend_time = ascend_with_all_gaschanges(pDiveSettings, gStop.depth - next_depth);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 ceiling = tissue_tolerance();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /* pre check actual limit */
258
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
240 if(pDecoInfo->output_stop_length_seconds[gStop.id] >= 999*60)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 {
258
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
242 tts_seconds -= 999*60 - pDecoInfo->output_stop_length_seconds[gStop.id];
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
243 pDecoInfo->output_stop_length_seconds[gStop.id] = 999*60;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 /* more deco on the actual depth */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 if(ceiling > next_depth + gSurface_pressure_bar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 next_depth = -1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 buehlmann_backup_and_restore(false);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
251 decom_tissues_exposure2(10, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar); // some seconds at least at each stop
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
252 decom_oxygen_calculate_cns_exposure(10, &pDiveSettings->decogaslist[gGas_id], gPressure, &gCNS);
258
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
253 pDecoInfo->output_stop_length_seconds[gStop.id] += 10;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 tts_seconds += 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 } while(next_depth == -1);
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
257 tts_seconds += ascend_time;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 gStop.depth = next_depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
261 if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
262 || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
263 {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 break;
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
265 }
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
266 float pressureChange = ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 if(gStop.depth <= pressureChange + 0.00001f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 gGas_id = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 gStop.id--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278
258
0087d6251f59 Buehlmann: factor out another global gDecotable
Jan Mulder <jlmulder@xs4all.nl>
parents: 257
diff changeset
279 pDecoInfo->output_time_to_surface_seconds = tts_seconds;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
283 static float tissue_tolerance(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 float tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 float inertgas_a;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 float inertgas_b;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 float ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 float global_ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 int ci;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 global_ceiling = -1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 for (ci = 0; ci < 16; ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 if(gTissue_helium_bar[ci] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 inertgas_a = buehlmann_N2_a[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 inertgas_b = buehlmann_N2_b[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci] + gTissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 inertgas_a = ( ( buehlmann_N2_a[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_a[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 inertgas_b = ( ( buehlmann_N2_b[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_b[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 ceiling = (inertgas_b * ( tissue_inertgas_saturation - gGF_value * inertgas_a ) ) / (gGF_value - (inertgas_b * gGF_value) + inertgas_b);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 if(ceiling > global_ceiling)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 global_ceiling = ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 return global_ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
246
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
318 void buehlmann_super_saturation_calculator(SLifeData* pLifeData, SDecoinfo * pDecoInfo)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 float tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 float inertgas_a;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 float inertgas_b;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 float ceiling;
246
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
324 float super_saturation;
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
325 float pres_respiration = pLifeData->pressure_ambient_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 int ci;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327
246
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
328 pDecoInfo->super_saturation = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 for (ci = 0; ci < 16; ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 if(gTissue_helium_bar[ci] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 inertgas_a = buehlmann_N2_a[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 inertgas_b = buehlmann_N2_b[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci] + gTissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 inertgas_a = ( ( buehlmann_N2_a[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_a[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 inertgas_b = ( ( buehlmann_N2_b[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_b[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 }
246
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
344
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
345 ceiling = pres_respiration / inertgas_b + inertgas_a;
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
346 if(tissue_inertgas_saturation > pres_respiration)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 {
246
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
348 super_saturation =
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
349 (tissue_inertgas_saturation - pres_respiration) / (ceiling - pres_respiration);
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
350
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
351 if (super_saturation > pDecoInfo->super_saturation)
ff0d23625cd5 feature: replace Relative GF by saturation, computational only
Jan Mulder <jlmulder@xs4all.nl>
parents: 224
diff changeset
352 pDecoInfo->super_saturation = super_saturation;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
253
1663b3b204d7 Buehlmann: cleanup, whitespace, static
Jan Mulder <jlmulder@xs4all.nl>
parents: 250
diff changeset
358 static float buehlmann_tissue_test_tolerance(float depth_in_bar_absolute)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 float tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 float inertgas_a;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 float inertgas_b;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 float inertgas_tolerance;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 float gf_minus_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 gf_minus_1 = gGF_value - 1.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 for (int ci = 0; ci < 16; ci++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 if(gTissue_helium_bar[ci] == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 inertgas_a = buehlmann_N2_a[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 inertgas_b = buehlmann_N2_b[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 tissue_inertgas_saturation = gTissue_nitrogen_bar[ci] + gTissue_helium_bar[ci];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 inertgas_a = ( ( buehlmann_N2_a[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_a[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 inertgas_b = ( ( buehlmann_N2_b[ci] * gTissue_nitrogen_bar[ci]) + ( buehlmann_He_b[ci] * gTissue_helium_bar[ci]) ) / tissue_inertgas_saturation;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 inertgas_tolerance = ( (gGF_value / inertgas_b - gf_minus_1) * depth_in_bar_absolute ) + ( gGF_value * inertgas_a );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 if(inertgas_tolerance < tissue_inertgas_saturation)
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
384 return tissue_inertgas_saturation - inertgas_tolerance; // positive
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 }
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
386 return tissue_inertgas_saturation - inertgas_tolerance; // negative
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
390 static void ambient_bar_to_deco_stop_depth_bar(SDiveSettings *pDiveSettings, float ceiling)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 int i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 ceiling -= gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 if(ceiling <= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
398 gStop.depth = pDiveSettings->last_stop_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 gStop.id = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
403 if((ceiling - pDiveSettings->last_stop_depth_bar) <= 0)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
405 gStop.depth = pDiveSettings->last_stop_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 gStop.id = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
410 gStop.depth = pDiveSettings->input_second_to_last_stop_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 gStop.id = 1;
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
412 ceiling -= pDiveSettings->input_second_to_last_stop_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 if(ceiling <= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 for(i = 1; i < (DECOINFO_STRUCT_MAX_STOPS - 2); i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
419 ceiling -= pDiveSettings->input_next_stop_increment_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 if(ceiling <= 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 }
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
423 gStop.depth += i * pDiveSettings->input_next_stop_increment_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 gStop.id += i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
428 static float next_stop_depth_input_is_actual_stop_id(SDiveSettings *pDiveSettings, int actual_id)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 if(actual_id == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 if(actual_id == 1)
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
434 return pDiveSettings->last_stop_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 actual_id -= 2;
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
437 return pDiveSettings->input_second_to_last_stop_depth_bar + (actual_id * pDiveSettings->input_next_stop_increment_depth_bar);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
440 static int ascend_with_all_gaschanges(SDiveSettings *pDiveSettings, float pressure_decrease)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 float pressureTop, pressureTop_tmp, pressureBottom, pressureChange, ascendrate_in_seconds_for_one_bar, pressure_difference;
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
443 int time_for_ascend = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 int seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 int i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
447 ascendrate_in_seconds_for_one_bar = 60 * 10 / pDiveSettings->ascentRate_meterperminute;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 if(fabsf(gPressure - gSurface_pressure_bar) < PRESSURE_HALF_METER)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 gPressure = gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 pressureTop = gPressure - pressure_decrease;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 if( gSurface_pressure_bar > pressureTop)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 pressureTop = gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 pressureBottom = gPressure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 do{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 pressureTop_tmp = pressureTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 {
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
464 if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
465 || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
466 {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 break;
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
468 }
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
469 pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 if(pressureBottom <= pressureChange)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 gGas_id = i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 {
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
482 if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
483 || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
484 {
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 break;
862
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
486 }
974648b5ccfe Only use deco gas for calculation if option is enabled:
Ideenmodellierer
parents: 833
diff changeset
487
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
488 pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero)/ 10;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 if((pressureChange < pressureBottom) && (pressureChange > pressureTop))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 pressureTop_tmp = pressureChange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 pressure_difference = pressureBottom - pressureTop_tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 if(pressure_difference > 0.0001f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 time_for_ascend = (int)ceilf(pressure_difference * ascendrate_in_seconds_for_one_bar);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
498 decom_tissues_exposure_stage_schreiner(time_for_ascend, &pDiveSettings->decogaslist[gGas_id],
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 pressureBottom, pressureTop_tmp, gTissue_nitrogen_bar, gTissue_helium_bar);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
500 decom_oxygen_calculate_cns_stage_SchreinerStyle(time_for_ascend,&pDiveSettings->decogaslist[gGas_id],
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 pressureBottom, pressureTop_tmp, &gCNS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 pressureBottom = pressureTop_tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 seconds += time_for_ascend;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 }while(pressureTop_tmp > pressureTop);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 gPressure = pressureTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 return seconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
511 static float get_gf_at_pressure(SDiveSettings *pDiveSettings, float pressure)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 float gfSteigung = 0.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 if(gGF_low_depth_bar < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 gGF_low_depth_bar = PRESSURE_THREE_METER; // just to prevent erratic behaviour if variable is not set
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
518 gfSteigung = ((float)(pDiveSettings->gf_high - pDiveSettings->gf_low))/ gGF_low_depth_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 if((pressure - gSurface_pressure_bar) <= PRESSURE_HALF_METER)
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
522 return ((float)pDiveSettings->gf_high) / 100.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 if(pressure >= gSurface_pressure_bar + gGF_low_depth_bar)
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
525 return ((float)pDiveSettings->gf_low) / 100.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
527 return (pDiveSettings->gf_high - gfSteigung * (pressure - gSurface_pressure_bar) )/ 100.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529
291
24ff72e627f4 Deco Models: limit NDL to 240 minutes
Jan Mulder <jlmulder@xs4all.nl>
parents: 261
diff changeset
530 #define MAX_NDL 240
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
531 static int buehlmann_calc_ndl(SDiveSettings *pDiveSettings)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 float local_tissue_nitrogen_bar[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 float local_tissue_helium_bar[16];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 int i;
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
536 int ndl = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 //Check ndl always use gHigh
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
539 gGF_value = ((float)pDiveSettings->gf_high) / 100.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 //10 minutes steps
291
24ff72e627f4 Deco Models: limit NDL to 240 minutes
Jan Mulder <jlmulder@xs4all.nl>
parents: 261
diff changeset
541 while(ndl < (MAX_NDL * 60))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 memcpy(local_tissue_nitrogen_bar, gTissue_nitrogen_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 memcpy(local_tissue_helium_bar, gTissue_helium_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 //
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
546 ndl += 600;
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
547 decom_tissues_exposure2(600, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
548 decom_oxygen_calculate_cns_exposure(600,&pDiveSettings->decogaslist[gGas_id],gPressure,&gCNS);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 buehlmann_backup_and_restore(true);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
550 if(dive1_check_deco(pDiveSettings))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 buehlmann_backup_and_restore(false);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 buehlmann_backup_and_restore(false);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557
291
24ff72e627f4 Deco Models: limit NDL to 240 minutes
Jan Mulder <jlmulder@xs4all.nl>
parents: 261
diff changeset
558 if(ndl < (MAX_NDL * 60))
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
559 ndl -= 600;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560
291
24ff72e627f4 Deco Models: limit NDL to 240 minutes
Jan Mulder <jlmulder@xs4all.nl>
parents: 261
diff changeset
561 if(ndl > (MAX_NDL/2 * 60))
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
562 return ndl;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 // refine
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 memcpy(gTissue_nitrogen_bar, local_tissue_nitrogen_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 memcpy(gTissue_helium_bar, local_tissue_helium_bar, (4*16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 //One minutes step
256
d10f53e39374 Buehlmann: trivial performance improvement (NDL)
Jan Mulder <jlmulder@xs4all.nl>
parents: 255
diff changeset
569 for(i = 0; i < 10; i++)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 {
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
571 ndl += 60;
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
572 decom_tissues_exposure2(60, &pDiveSettings->decogaslist[gGas_id], gPressure,gTissue_nitrogen_bar,gTissue_helium_bar);
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
573 decom_oxygen_calculate_cns_exposure(60,&pDiveSettings->decogaslist[gGas_id],gPressure,&gCNS);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 buehlmann_backup_and_restore(true);
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
575 if(dive1_check_deco(pDiveSettings))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 buehlmann_backup_and_restore(false);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 }
257
21387d7e786f Buehlmann: factor out gNDL and gTTS
Jan Mulder <jlmulder@xs4all.nl>
parents: 256
diff changeset
579 return ndl;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 // ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 // dive1_check_deco
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 /// @brief for NDL calculations
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 /// 160614 using ceilingOther and not ceiling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 // ===============================================================================
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
588 static _Bool dive1_check_deco(SDiveSettings *pDiveSettings)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 // gGF_value is set in call routine;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 // internes Backup!
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 // calc like in deco
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 float ceiling;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 float ceilingOther; // new hw 160614
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 ceiling = tissue_tolerance();
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
598 ambient_bar_to_deco_stop_depth_bar(pDiveSettings, ceiling); // this will set gStop.depth :-) (and gStop.id)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 // set the base for all upcoming parameters
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 ceilingOther = gStop.depth + gSurface_pressure_bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 // modify parameters if there is ascend or parameter fine adjustment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 if(ceilingOther < (gPressure - PRESSURE_150_CM)) // more than 1.5 meter below ceiling
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 // ascend within 10 mtr to GF_low // speed 12 mtr/min -> 50 sec / 10 mtr; 15 sec / 3 mtr.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 while(((gPressure - PRESSURE_TEN_METER ) > gSurface_pressure_bar) && (ceiling < (gPressure - PRESSURE_TEN_METER)))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
609 ascend_with_all_gaschanges(pDiveSettings, PRESSURE_TEN_METER);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 ceiling = tissue_tolerance();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 while(((gPressure - PRESSURE_THREE_METER )> gSurface_pressure_bar) && (ceiling < gPressure))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 {
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
614 ascend_with_all_gaschanges(pDiveSettings, PRESSURE_THREE_METER);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 ceiling = tissue_tolerance();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 }
255
dcf7a3435fe1 Buehlmann: cleanup, factor out pBuDiveSettings
Jan Mulder <jlmulder@xs4all.nl>
parents: 254
diff changeset
618 return ceiling > gSurface_pressure_bar;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
621 // compute ceiling recursively, with a resolution of 10cm. Notice
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
622 // that the initial call shall guarantee that the found ceiling
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
623 // is between low and high parameters.
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
624 static float compute_ceiling(float low, float high)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 {
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
626 if ((high - low) < 0.01)
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
627 return low;
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
628 else {
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
629 float next_pressure_absolute = (low + high)/2;
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
630 float test_result = buehlmann_tissue_test_tolerance(next_pressure_absolute);
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
631 if (test_result < 0)
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
632 return compute_ceiling(low, next_pressure_absolute);
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
633 else
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
634 return compute_ceiling(next_pressure_absolute, high);
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
635 }
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
636 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
638 void buehlmann_ceiling_calculator(SLifeData *pLifeData, SDecoinfo *pDecoInfo)
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
639 {
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
640 float ceiling;
224
ceecabfddb57 Bugfix, deco: fix 2 (small) problems with calculated ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 130
diff changeset
641
261
cc2406b835ff Bugfix: do not reset saturation on surfacing
Jan Mulder <jlmulder@xs4all.nl>
parents: 258
diff changeset
642 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16));
cc2406b835ff Bugfix: do not reset saturation on surfacing
Jan Mulder <jlmulder@xs4all.nl>
parents: 258
diff changeset
643 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16));
cc2406b835ff Bugfix: do not reset saturation on surfacing
Jan Mulder <jlmulder@xs4all.nl>
parents: 258
diff changeset
644
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
645 // this is just performance optimizing. The code below runs just fine
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
646 // without this. There is never a ceiling in NDL deco state
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
647 if (!pDecoInfo->output_time_to_surface_seconds) {
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
648 pDecoInfo->output_ceiling_meter = 0;
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
649 return;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651
250
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
652 ceiling = compute_ceiling(pLifeData->pressure_surface_bar, 1.0f + pLifeData->max_depth_meter/10.0f);
822416168585 Buelmann: new implementation for ceiling
Jan Mulder <jlmulder@xs4all.nl>
parents: 247
diff changeset
653 pDecoInfo->output_ceiling_meter = (ceiling - pLifeData->pressure_surface_bar) * 10.0f;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 }