comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 240:d995e220ddac

BUGFIX Gas Usage when first gas is not #1 (bug BB22).
author JeanDo
date Mon, 21 Mar 2011 23:27:46 +0100
parents 55178aa1f972
children f44274d8440a
comparison
equal deleted inserted replaced
239:3ed240d60341 240:d995e220ddac
2155 // new in v.111 2155 // new in v.111
2156 // 2156 //
2157 // calculates volumes for each gas. 2157 // calculates volumes for each gas.
2158 // 2158 //
2159 // Input: char_I_bottom_depth, char_I_bottom_time for planned dive. 2159 // Input: char_I_bottom_depth, char_I_bottom_time for planned dive.
2160 /// Gas list. First gas is the bottom gas. 2160 // Gas list.
2161 // char_I_first_gas is the bottom gas.
2161 // decoplan (char_O_deco_depth, char_O_deco_time). 2162 // decoplan (char_O_deco_depth, char_O_deco_time).
2162 // CF#54 == TRUE if shallowest stop first. 2163 // CF#54 == TRUE if shallowest stop first.
2163 // CF#56 == bottom deci-liters/minutes (0.5 .. 50.0) 2164 // CF#56 == bottom deci-liters/minutes (0.5 .. 50.0)
2164 // CF#57 == deco deci-liters/minutes (0.5 .. 50.0). 2165 // CF#57 == deco deci-liters/minutes (0.5 .. 50.0).
2165 // Output: int_O_gas_volumes[0..4] in litters * 0.1 2166 // Output: int_O_gas_volumes[0..4] in litters * 0.1
2170 overlay float ascent_usage; 2171 overlay float ascent_usage;
2171 overlay unsigned char i, deepest_first; 2172 overlay unsigned char i, deepest_first;
2172 RESET_C_STACK 2173 RESET_C_STACK
2173 2174
2174 //---- initialize with bottom consumption -------------------------------- 2175 //---- initialize with bottom consumption --------------------------------
2175 volumes[0] = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar. 2176 for(i=0; i<5; ++i) // Nothing yet...
2176 * char_I_bottom_time // in minutes.
2177 * read_custom_function(56) // In deci-liter/minutes.
2178 * 0.1; // deci-liters --> liters.
2179
2180 for(i=1; i<5; ++i) // Nothing yet...
2181 volumes[i] = 0.0; 2177 volumes[i] = 0.0;
2182 2178
2179 assert( 1 <= char_I_first_gas && char_I_first_gas <= 5);
2180 volumes[char_I_first_gas - 1]
2181 = (char_I_bottom_depth*0.1 + 1.0) // Use Psurface = 1.0 bar.
2182 * char_I_bottom_time // in minutes.
2183 * read_custom_function(56) // In deci-liter/minutes.
2184 * 0.1; // deci-liters --> liters.
2185
2183 //---- Ascent usage ------------------------------------------------------ 2186 //---- Ascent usage ------------------------------------------------------
2184 2187
2185 deepest_first = read_custom_function(54) == 0; 2188 deepest_first = read_custom_function(54) == 0;
2186 ascent_usage = read_custom_function(57) * 0.1; // In litter/minutes. 2189 ascent_usage = read_custom_function(57) * 0.1; // In liter/minutes.
2187 2190
2188 // Usage up to the first stop: 2191 // Usage up to the first stop:
2189 // - computed at MAX depth (easier, safer), 2192 // - computed at MAX depth (easier, safer),
2190 // - with an ascent speed of 10m/min. 2193 // - with an ascent speed of 10m/min.
2191 // - with ascent litter / minutes. 2194 // - with ascent litter / minutes.
2192 // - still using bottom gas: 2195 // - still using bottom gas:
2193 volumes[0] += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar 2196 volumes[char_I_first_gas - 1]
2194 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min) 2197 += (char_I_bottom_depth*0.1 + 1.0) // Depth -> bar
2195 * ascent_usage; // Consumption ( xxx / min @ 1 bar) 2198 * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1 // ascent time (min)
2199 * ascent_usage; // Consumption ( xxx / min @ 1 bar)
2196 2200
2197 for(i=0; i<32; ++i) 2201 for(i=0; i<32; ++i)
2198 { 2202 {
2199 overlay unsigned char j, gas; 2203 overlay unsigned char j, gas;
2200 overlay unsigned char depth, time, ascent; 2204 overlay unsigned char depth, time, ascent;