# HG changeset patch # User jDG # Date 1433031249 -7200 # Node ID 7027d735ac623c432c22bb99c3dfef22ed4bb9db # Parent f97e439d711c1a78adf6416960be271971a56775 NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes diff -r f97e439d711c -r 7027d735ac62 src/Tests/deco_volume_test.cpp --- a/src/Tests/deco_volume_test.cpp Sat May 30 22:58:00 2015 +0200 +++ b/src/Tests/deco_volume_test.cpp Sun May 31 02:14:09 2015 +0200 @@ -38,8 +38,13 @@ { int depth = 3 * (stops ? strlen(stops) : 0); + if( ! depth ) + std::cout << " no deco" << std::endl; + int s = 0; while( depth > 0 && s < NUM_STOPS ) { + std::cout << " " << std::setw(2) << int(stops[s]) << "' @ " << depth << "m" << std::endl; + char_O_deco_time [s] = stops[s]; char_O_deco_depth[s] = depth; char_O_deco_gas [s] = gas ? gas[s] : 1; // Gas#1 by default @@ -188,13 +193,13 @@ ////////////////////////////////////////////////////////////////////////////// // v1.82 ZH-L16+GF, CCR, 30%/85% -TEST(gas_volume, CCR_13min30m) +TEST(gas_volume, CCR_23min30m) { char_I_const_ppO2 = 140;// SP 1.4 bar - setup_dive(13, 30); // 13' @ 30m --> no deco + setup_dive(23, 30); // 23' @ 30m --> no deco / no BAIL deco ASSERT_NO_THROW( deco_gas_volumes() ); - check_volumes(/*NO BTM CONSO*/ ascent(20,30,0), "Gas1: 1190 L", + check_volumes(/*NO BTM CONSO*/ ascent(20,30,0), "Gas1: 150 L", 0, "", 0, "", 0, "", @@ -203,37 +208,59 @@ ////////////////////////////////////////////////////////////////////////////// // v1.82 ZH-L16+GF, CCR, 30%/85% -TEST(gas_volume, CCR_15min30m) +TEST(gas_volume, CCR_25min30m) { - char_I_const_ppO2 = 140; // SP 1.4 bar + char_I_const_ppO2 = 140;// SP 1.4 bar char stops[] = {1, 0}; char gas[] = {3, 0}; - setup_dive(15, 30, stops, gas); // 15' @ 30m --> 1min at 3m + setup_dive(25, 30, stops, gas); // 25' @ 30m --> no deco / BAIL 1' @ 3m ASSERT_NO_THROW( deco_gas_volumes() ); - check_volumes(/*NO BTM CONSO*/ ascent(20,30,3), "Gas1: 1343 L", + check_volumes(/*NO BTM CONSO*/ ascent(20,30,3), "Gas1: 143 L", 0, "", - fixed(20, 1, 3) + ascent(20, 3,0), "Gas3: 33", + fixed(20, 1, 3) + ascent(20, 3,0), "Gas3: 33 L", 0, "", 0, ""); } ////////////////////////////////////////////////////////////////////////////// // v1.82 ZH-L16+GF, CCR, 30%/85% -TEST(gas_volume, CCR_29min30m) +TEST(gas_volume, CCR_45min30m) { char_I_const_ppO2 = 140; // SP 1.4 bar - char stops[] = {1, 1, 2, 4, 0}; - char gas[] = {1, 3, 3, 3, 0}; - setup_dive(29, 30, stops, gas); // 29' @ 30m --> 1' 1' 2' 4' + char stops[] = {1, 2, 5, 0}; + char gas[] = {3, 3, 3, 0}; + setup_dive(45, 30, stops, gas); // 45' @ 30m ASSERT_NO_THROW( deco_gas_volumes() ); - check_volumes(/*NO BTM CONSO*/ ascent(20,30,12) + - fixed(20, 1,12) + ascent(20,12, 9), "Gas1: 2488 L", + check_volumes(/*NO BTM CONSO*/ ascent(20,30, 9), "Gas1: 124 L", 0, "", fixed(20, 1, 9) + ascent(20, 9, 6) + fixed(20, 2, 6) + ascent(20, 6, 3) + - fixed(20, 4, 3) + ascent(20, 3, 0), "Gas3: 232 L", + fixed(20, 5, 3) + ascent(20, 3, 0), "Gas3: 258 L", + 0, "", + 0, ""); +} + +////////////////////////////////////////////////////////////////////////////// +// v1.82 ZH-L16+GF, CCR, 30%/85% +TEST(gas_volume, CCR_19min51m) +{ + char_I_const_ppO2 = 140; // SP 1.4 bar + char stops[] = {1, 2, 2, 4, 3, 4, 9, 0}; + char gas[] = {1, 1, 1, 1, 3, 3, 3, 0}; + setup_dive(19, 51, stops, gas); // 19' @ 51m --> 20' CCR / 31' BAIL + + ASSERT_NO_THROW( deco_gas_volumes() ); + check_volumes(/*NO BTM CONSO*/ ascent(20,51,21) + + fixed(20, 1,21) + ascent(20,21,18) + + fixed(20, 2,18) + ascent(20,18,15) + + fixed(20, 2,15) + ascent(20,15,12) + + fixed(20, 4,12) + ascent(20,12, 9), "Gas1: 786 L", + 0, "", + fixed(20, 3, 9) + ascent(20, 9, 6) + + fixed(20, 4, 6) + ascent(20, 6, 3) + + fixed(20, 9, 3) + ascent(20, 3, 0), "Gas3: 502 L", 0, "", 0, ""); } @@ -243,20 +270,21 @@ TEST(gas_volume, CCR_15min60m) { char_I_const_ppO2 = 140; // SP 1.4 bar - char stops[] = {2, 1, 2, 4, 3, 4, 9, 0}; - char gas[] = {1, 1, 1, 1, 3, 3, 3, 0}; + char stops[] = {1, 2, 2, 3, 4, 3, 5, 11, 0}; // BAILOUT mode + char gas[] = {1, 1, 1, 1, 1, 3, 3, 3, 0}; setup_dive(15, 60, stops, gas); // 15' @ 60m --> DTR 32' ASSERT_NO_THROW( deco_gas_volumes() ); - check_volumes(/*NO BTM CONSO*/ ascent(20,60,21) + + 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, 1,18) + ascent(20,18,15) + - fixed(20, 2,15) + ascent(20,15,12) + - fixed(20, 4,12) + ascent(20,12, 9), "Gas1: 3010 L", + 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", 0, "", fixed(20, 3, 9) + ascent(20, 9, 6) + - fixed(20, 4, 6) + ascent(20, 6, 3) + - fixed(20, 9, 3) + ascent(20, 3, 0), "Gas3: 502 L", + fixed(20, 5, 6) + ascent(20, 6, 3) + + fixed(20,11, 3) + ascent(20, 3, 0), "Gas3: 586 L", 0, "", 0, ""); } diff -r f97e439d711c -r 7027d735ac62 src/simulator.asm --- a/src/simulator.asm Sat May 30 22:58:00 2015 +0200 +++ b/src/simulator.asm Sun May 31 02:14:09 2015 +0200 @@ -326,7 +326,7 @@ banksel common ; Bank1 ;---- Specific settings ------------------------------------------------------ - +deco_planer_redo: banksel char_O_deco_status ; Bank 2 movlw .3 ; Start in surface state. movwf char_O_deco_status @@ -380,15 +380,34 @@ ;---- Wait until status reach zero ------------------------------------------- deco_planer_finishing: btg LEDg - clrf TMR5L - clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H +; 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 - bz deco_planer_finished + 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 - bra deco_planer_finishing + 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: call deco_calc_CNS_planning @@ -712,15 +731,29 @@ bra deco_show_plan_1 ; All stops shown -;---- In OC mode, show the gas Usage special page --------------------------- +;---- In CCR mode, compute a BAILOUT decoplan --------------------------------- + banksel common + btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active + bra simulator_show_decoplan5_0 ; NO: normal OC mode: just display + + btfsc is_bailout ; ALREADY in bailout mode ? + bra simulator_show_decoplan5_0 ; YES: alreay BAIL plan: display gas + +; Redo 2nd deco-plann, in bailout mode: + bsf is_bailout ; Set special bailout mode. + rcall deco_planer_redo ; Redo plan computation + + movff char_I_setpoint_cbar+0,char_I_const_ppO2 + bra deco_show_plan ; and display bailout stops + +;---- In OC+BAIL modes, show the gas Usage special page ----------------------- simulator_show_decoplan5_0: - btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active - return ; YES: Return to simulator menu + bcf is_bailout ; Back to normal ; Make sure to pass first gas - call get_first_gas_to_WREG ; Gets first gas (0-4) into WREG - incf WREG,f ; gas 1..5 - movff WREG,char_I_first_gas ; Copy for compatibility + call get_first_gas_to_WREG ; Gets first gas (0-4) into WREG + incf WREG,f ; gas 1..5 + movff WREG,char_I_first_gas ; Copy for compatibility ; Compute gas consumption for each tank. extern deco_gas_volumes @@ -780,7 +813,17 @@ WIN_COLOR color_greenish WIN_SMALL .80,.25 - STRCPY_TEXT tGasUsage + + btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active + bra simulator_show_decoplan5_4 ; YES: This is bailout mode + + STRCPY_TEXT tGasUsage ; OC: "Gas Usage" + bra simulator_show_decoplan5_5 + +simulator_show_decoplan5_4: + STRCPY_TEXT tDiveBailout ; CCR: "Bailout" + +simulator_show_decoplan5_5 STRCAT_PRINT ":" call TFT_standard_color