changeset 579:fff1d38625f0

BUGFIX: GasVolumes should check for a gas switch before the first stop.
author JeanDo
date Tue, 24 Apr 2012 23:47:13 +0200
parents fbd5e2b75a63
children 32448d5ca734
files code_part1/OSTC_code_c_part2/p2_deco.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Tue Apr 24 08:39:43 2012 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Tue Apr 24 23:47:13 2012 +0200
@@ -2345,11 +2345,23 @@
             = (char_I_bottom_depth*0.1 + 1.0)           // Use Psurface = 1.0 bar.
             * char_I_bottom_time                        // in minutes.
             * bottom_usage;                             // In liter/minutes.
-    else
-        volumes[gas] = 65535.0;
+
+    //---- Starts by a gas switch ? ------------------------------------------
+    // If there is no special gas-switch stops inserted, then
+    // we should pay attention to the gas when starting to ascent, before
+    // the first stop...
+    if( read_custom_function(55) == 0 )
+    {
+        overlay unsigned char j;
+        for(j=0; j<NUM_GAS; ++j)
+        {
+            if( char_O_first_deco_depth < char_I_deco_gas_change[j] )
+                if( !char_I_deco_gas_change[gas] || (char_I_deco_gas_change[gas] > char_I_deco_gas_change[j]) )
+                    gas = j;
+        }
+    }
 
     //---- Ascent usage ------------------------------------------------------
-
     deepest_first = read_custom_function(54) == 0;
     deco_usage    = (float) read_custom_function(57); // In liter/minutes.
 
@@ -2363,8 +2375,6 @@
             += (char_I_bottom_depth*0.1 + 1.0)          // Depth -> bar
              * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1  // ascent time (min)
              * deco_usage;                              // Consumption ( xxx / min @ 1 bar)
-    else
-        volumes[gas] = 65535.0;
 
     for(i=0; i<NUM_STOPS; ++i)
     {