[chronojump] Stop capturing inertialBG if quit or capture grav or perform any other test



commit d2c08da3309cc3892c30ba11c8641d1cd9ce7403
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 25 16:37:13 2017 +0100

    Stop capturing inertialBG if quit or capture grav or perform any other test

 glade/app1.glade      |    4 ++++
 src/gui/chronojump.cs |   11 +++++++----
 src/gui/encoder.cs    |   21 +++++++++++++++++++++
 3 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 08c9c9c..00f46b3 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -13753,6 +13753,7 @@ Concentric</property>
                                                             <widget class="GtkHScale" 
id="hscale_encoder_capture_inertial_angle_now">
                                                             <property name="width_request">150</property>
                                                             <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="adjustment">0 -100 100 1 1 
0</property>
                                                             <property 
name="restrict_to_fill_level">False</property>
@@ -18506,6 +18507,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7329591..7164337 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2285,10 +2285,7 @@ public partial class ChronoJumpWindow
 
                //if capturing on the background finish it
                if(eCaptureInertialBG != null)
-               {
-                       eCaptureInertialBG.FinishBG();
-                       EncoderCaptureInertialBackgroundStatic.Abort();
-               }
+                       stopCapturingInertialBG();
 
                cp2016.SerialPortsCloseIfNeeded(true);
 
@@ -3649,6 +3646,12 @@ public partial class ChronoJumpWindow
 
        void on_button_execute_test_clicked (object o, EventArgs args) 
        {
+               // stop capturing inertial on the background if we start capturing another test
+               if(encoderThreadBG != null && encoderThreadBG.IsAlive)
+               {
+                       stopCapturingInertialBG();
+               }
+
                chronopicRegisterUpdate(false);
 
                int numContacts = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c2b2814..970550c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -621,6 +621,12 @@ public partial class ChronoJumpWindow
                if(! canCaptureEncoder())
                        return;
 
+               // stop capturing inertial on the background if we calibrate again
+               if(encoderThreadBG != null && encoderThreadBG.IsAlive)
+               {
+                       stopCapturingInertialBG();
+               }
+
                encoderThreadStart(encoderActions.CAPTURE_BG);
        }
 
@@ -637,6 +643,12 @@ public partial class ChronoJumpWindow
                if( ! (encoderThreadBG != null && encoderThreadBG.IsAlive) && ! canCaptureEncoder() )
                        return;
 
+               // stop capturing inertial on the background if we start capturing gravitatory
+               if(! encoderConfigurationCurrent.has_inertia && encoderThreadBG != null && 
encoderThreadBG.IsAlive)
+               {
+                       stopCapturingInertialBG();
+               }
+
                if(encoderConfigurationCurrent.has_inertia)
                        notebook_encoder_capture_or_instructions.Page = 1; //show inertia instructions
 
@@ -2104,6 +2116,15 @@ public partial class ChronoJumpWindow
                eCaptureInertialBG.CaptureBG();
        }
 
+       private void stopCapturingInertialBG()
+       {
+               LogB.Information("Stopping capturing Inertial BG");
+               eCaptureInertialBG.FinishBG();
+               EncoderCaptureInertialBackgroundStatic.Abort();
+               eCaptureInertialBG = null;
+               hscale_encoder_capture_inertial_angle_now.Value = 0;
+       }
+
        //this is called by non gtk thread. Don't do gtk stuff here
        //I suppose reading gtk is ok, changing will be the problem
        private void encoderDoCaptureCsharp () 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]