changeset 296:af13a18a233b

Slight more efficient bail deco, Test with 2 bail tanks.
author jDG
date Sun, 31 May 2015 02:47:50 +0200
parents 7027d735ac62
children 65f6a7bfc205
files src/Tests/deco_volume_test.cpp src/simulator.asm
diffstat 2 files changed, 21 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/Tests/deco_volume_test.cpp	Sun May 31 02:14:09 2015 +0200
+++ b/src/Tests/deco_volume_test.cpp	Sun May 31 02:47:50 2015 +0200
@@ -270,21 +270,22 @@
 TEST(gas_volume, CCR_15min60m)
 {
     char_I_const_ppO2 = 140;    // SP 1.4 bar
-    char stops[] = {1, 2, 2, 3, 4, 3, 5, 11, 0};   // BAILOUT mode
-    char gas[]   = {1, 1, 1, 1, 1, 3, 3,  3, 0};
+    char stops[] = {2, 1, 1, 3, 5, 4, 8, 0};   // BAILOUT mode
+    char gas[]   = {3, 3, 3, 3, 3, 5, 5, 0};
     setup_dive(15, 60, stops, gas);     // 15' @ 60m --> DTR 32'
 
+    DEFINE_GAS(3, 32, 0, 40, 3);    // Gas#3 : Nx32 @ 40m DECO
+    DEFINE_GAS(5, 90, 0,  6, 3);    // Gas#5 : Nx90 @  6m DECO
+
     ASSERT_NO_THROW( deco_gas_volumes() );
-    check_volumes(/*NO BTM CONSO*/  ascent(20,60,24) +
-                  fixed(20, 1,24) + ascent(20,24,21) +
-                  fixed(20, 2,21) + ascent(20,21,18) +
-                  fixed(20, 2,18) + ascent(20,18,15) +
-                  fixed(20, 3,15) + ascent(20,15,12) +
-                  fixed(20, 4,12) + ascent(20,12, 9), "Gas1: 1084 L",
+    check_volumes(/*NO BTM CONSO*/  ascent(20,60,21), "Gas1: 394 L",
                   0, "",
-                  fixed(20, 3, 9) + ascent(20, 9, 6) +
-                  fixed(20, 5, 6) + ascent(20, 6, 3) +
-                  fixed(20,11, 3) + ascent(20, 3, 0), "Gas3:  586 L",
+                  fixed(20, 2,21) + ascent(20,21,18) +
+                  fixed(20, 1,18) + ascent(20,18,15) +
+                  fixed(20, 1,15) + ascent(20,15,12) +
+                  fixed(20, 3,12) + ascent(20,12, 9) +
+                  fixed(20, 5, 9) + ascent(20, 9, 6), "Gas3: 623 L",
                   0, "",
-                  0, "");
+                  fixed(20, 4, 6) + ascent(20, 6, 3) +
+                  fixed(20, 8, 3) + ascent(20, 3, 0), "Gas5: 352 L");
 }
--- a/src/simulator.asm	Sun May 31 02:14:09 2015 +0200
+++ b/src/simulator.asm	Sun May 31 02:47:50 2015 +0200
@@ -377,6 +377,13 @@
         banksel char_I_step_is_1min
         clrf    char_I_step_is_1min     ; Back to 2sec loops
 
+;---- BAILOUT: Switch to OC gases for ascent cycles --------------------------
+        banksel common
+        btfss   is_bailout              ; Doing a bailout decoplan ?
+        bra     deco_planer_finishing   ; NO: keep gases
+        
+        rcall   deco_setup_oc_gases     ; Switch to OC gas and no const_ppO2
+
 ;---- Wait until status reach zero -------------------------------------------
 deco_planer_finishing:
         btg     LEDg
@@ -388,28 +395,7 @@
         movf    char_O_deco_status,W
         bnz     deco_planer_finishing
 
-;---- Optional extra cycle to recompute stops in bailout mode ---------------
-        banksel common
-        btfss   is_bailout              ; Doing a bailout decoplan ?
-        bra     deco_planer_finished    ; NO: so we are done.
-        
-        rcall   deco_setup_oc_gases     ; Switch to OC gas and no const_ppO2
-        
-        movlw   .3                      ; restart 2sec cycles.
-        movff   WREG,char_O_deco_status
-        call    deco_calc_hauptroutine  ; Reset + simulate first 2secs.
-        
-deco_planer_bail_loop:
-        btg     LEDg
-;       clrf    TMR5L
-;       clrf    TMR5H                   ; 30,51757813µs/bit in TMR5L:TMR5H
-        call    deco_calc_hauptroutine  ; Simulate 2sec more
-        
-        banksel char_O_deco_status      ; Bank 2
-        movf    char_O_deco_status,W
-        bnz     deco_planer_bail_loop
-
-deco_planer_finished:
+;---- Done: add CNS from decoplan, and restore tissues
         call    deco_calc_CNS_planning
         movff   int_O_CNS_fraction+0,decoplan_CNS+0
         movff   int_O_CNS_fraction+1,decoplan_CNS+1