comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 368:de3b267e1fd9

Adding calc_dive_interval()
author JeanDo
date Thu, 09 Jun 2011 23:06:25 +0200
parents b5b030c1ae7e
children 681bdc91114c
comparison
equal deleted inserted replaced
364:bdcc5a5aa8d5 368:de3b267e1fd9
129 static void backup_sim_pres_tissue(void); 129 static void backup_sim_pres_tissue(void);
130 static void restore_sim_pres_tissue(void); 130 static void restore_sim_pres_tissue(void);
131 static void sim_tissue(PARAMETER unsigned char period); 131 static void sim_tissue(PARAMETER unsigned char period);
132 static void sim_limit(PARAMETER float GF_current); 132 static void sim_limit(PARAMETER float GF_current);
133 static void sim_extra_time(void); 133 static void sim_extra_time(void);
134 static void calc_dive_interval(void);
134 135
135 static void calc_gradient_factor(void); 136 static void calc_gradient_factor(void);
136 static void calc_wo_deco_step_1_min(void); 137 static void calc_wo_deco_step_1_min(void);
137 138
138 static void calc_hauptroutine_data_input(void); 139 static void calc_hauptroutine_data_input(void);
961 deco_calc_desaturation_time(); 962 deco_calc_desaturation_time();
962 } 963 }
963 964
964 ////////////////////////////////////////////////////////////////////////////// 965 //////////////////////////////////////////////////////////////////////////////
965 966
967 void deco_calc_dive_interval(void)
968 {
969 RESET_C_STACK
970 calc_dive_interval();
971 }
972
973 //////////////////////////////////////////////////////////////////////////////
974
966 void deco_debug(void) 975 void deco_debug(void)
967 { 976 {
968 RESET_C_STACK 977 RESET_C_STACK
969 } 978 }
970 979
2140 flag_in_divemode = 0; 2149 flag_in_divemode = 0;
2141 set_dbg_end_of_dive(); 2150 set_dbg_end_of_dive();
2142 } 2151 }
2143 2152
2144 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann 2153 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann
2145 pres_respiration = int_I_pres_respiration * 0.001; // assembler code uses different digit system 2154 pres_respiration = pres_surface = int_I_pres_surface * 0.001;
2146 pres_surface = int_I_pres_surface * 0.001; // the b"uhlmann formula using pres_surface does not use the N2_ratio 2155 ppN2 = N2_ratio * (pres_respiration - ppWater);
2147 ppN2 = N2_ratio * (pres_respiration - ppWater); // ppWater is the extra pressure in the body
2148 ppHe = 0.0; 2156 ppHe = 0.0;
2149 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) 2157 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
2150 float_saturation_multiplier = char_I_saturation_multiplier * 0.01; 2158 float_saturation_multiplier = char_I_saturation_multiplier * 0.01;
2151 2159
2152 calc_tissue(1); // update the pressure in the tissues N2/He in accordance with the new ambient pressure 2160 calc_tissue(1); // update the pressure in the tissues N2/He in accordance with the new ambient pressure
2155 char_O_deco_status = 3; // surface new in v.102 : stays in surface state. 2163 char_O_deco_status = 3; // surface new in v.102 : stays in surface state.
2156 char_O_nullzeit = 0; 2164 char_O_nullzeit = 0;
2157 int_O_ascenttime = 0; 2165 int_O_ascenttime = 0;
2158 int_O_extra_ascenttime = 0; 2166 int_O_extra_ascenttime = 0;
2159 calc_gradient_factor(); 2167 calc_gradient_factor();
2168 }
2169
2170 //////////////////////////////////////////////////////////////////////////////
2171 // calc_dive_interval
2172 //
2173 // Prepare tissue for delay before the next dive simulation.
2174 //
2175 // Inputs: char_I_dive_interval == delay before dive (in 10' steps).
2176 // Outputs: pres_tissue_N2/He[], CNS_fraction
2177 //
2178 // Should be protected by deco_push_tissues_to_vault(),
2179 // deco_pull_tissues_from_vault()
2180 //
2181 // desaturation slowed down to 70,42%.
2182 //
2183 static void calc_dive_interval()
2184 {
2185 overlay unsigned char t;
2186
2187 //---- Initialize simulation parameters ----------------------------------
2188 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann
2189 pres_respiration = pres_surface = int_I_pres_surface * 0.001;
2190 ppN2 = N2_ratio * (pres_respiration - ppWater);
2191 ppHe = 0.0;
2192 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
2193 float_saturation_multiplier = char_I_saturation_multiplier * 0.01;
2194
2195 //---- Perform simulation ------------------------------------------------
2196 for(t=0; t<char_I_dive_interval; ++t)
2197 {
2198 calc_tissue(2); // period = 10min.
2199 CNS_fraction = 0.92587471 * CNS_fraction; // Half-time = 90min: (1/2)^(1/9)
2200 }
2201 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5);
2160 } 2202 }
2161 2203
2162 ////////////////////////////////////////////////////////////////////////////// 2204 //////////////////////////////////////////////////////////////////////////////
2163 ////////////////////////////////////////////////////////////////////////////// 2205 //////////////////////////////////////////////////////////////////////////////
2164 ////////////////////////////////// deco_hash ///////////////////////////////// 2206 ////////////////////////////////// deco_hash /////////////////////////////////