[chronojump] InertialCapture passes guiTests. Logs muted on capture. Shorts instead of ints. Clear ListCapture on



commit 580baa686313e5158c3c99813c34aa3934c2938b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Apr 17 20:22:12 2017 +0200

    InertialCapture passes guiTests. Logs muted on capture. Shorts instead of ints. Clear ListCapture on each 
set.

 src/encoderCapture.cs           |   16 ++++++++++------
 src/encoderCaptureInertialBG.cs |   15 ++++++++-------
 src/gui/chronojump.cs           |    2 +-
 src/gui/encoder.cs              |    4 +++-
 src/logB.cs                     |    4 ++++
 5 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 6110fe2..2014c60 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -228,8 +228,15 @@ public abstract class EncoderCapture
 
                inertialCalibratedFirstCross0Pos = 0;
 
-               LogB.Information("sum = " + sum.ToString());
-               LogB.Information("sumInertialDisc = " + sumInertialDisc.ToString());
+               if(capturingInertialBG)
+               {
+                       /*
+                        * reset capture list. If not done here, list will grow at each set
+                        * also this fixes the initial 0s after a set
+                        */
+                       EncoderCaptureInertialBackgroundStatic.Initialize();
+               }
+
                do {
                        try {
                                byteReaded = readByte();
@@ -373,9 +380,6 @@ public abstract class EncoderCapture
                                        directionLastMSecond = directionNow;
                                        directionChangeCount = 0;
 
-               LogB.Information("sum = " + sum.ToString());
-               LogB.Information("sumInertialDisc = " + sumInertialDisc.ToString());
-
                                } 
                                else if(directionNow != directionCompleted) {
                                        //we are in a different direction than the last completed
@@ -595,7 +599,7 @@ public abstract class EncoderCapture
                } else {
                */
                        if(capturingInertialBG)
-                               return EncoderCaptureInertialBackgroundStatic.GetNext();
+                               return (int) EncoderCaptureInertialBackgroundStatic.GetNext();
                        else {
                                if(simulated)
                                        return simulateByte();
diff --git a/src/encoderCaptureInertialBG.cs b/src/encoderCaptureInertialBG.cs
index 409cfdf..7a37644 100644
--- a/src/encoderCaptureInertialBG.cs
+++ b/src/encoderCaptureInertialBG.cs
@@ -78,7 +78,7 @@ public class EncoderCaptureInertialBackground
                        angleNow += byteReaded;
 
                        if(StoreData)
-                               EncoderCaptureInertialBackgroundStatic.ListCaptured.Add(byteReaded);
+                               EncoderCaptureInertialBackgroundStatic.ListCaptured.Add((short) byteReaded);
                        //LogB.Information("angleNow = " + angleNow.ToString());
                } while (! finishBG);
 
@@ -96,7 +96,7 @@ public class EncoderCaptureInertialBackground
        private bool simulatedGoingUp = false;
        private int simulatedMaxValue = 400;
        private int simulatedLength;
-       private int simulatedMaxLength = 4000; //when signal stops
+       private int simulatedMaxLength = 10000; //ms when signal starts to shows 0s (will be stopped 3s 
again, depending on preferences)
 
        public void SimulatedReset()
        {
@@ -154,7 +154,7 @@ public class EncoderCaptureInertialBackground
  */
 public static class EncoderCaptureInertialBackgroundStatic
 {
-       public static List<int> ListCaptured;
+       public static List<short> ListCaptured;
        private static int pos;
 
        //abort allow to finish the capture process and don't get waiting GetNext forever
@@ -163,7 +163,7 @@ public static class EncoderCaptureInertialBackgroundStatic
        public static void Start()
        {
                abort = false;
-               ListCaptured = new List<int> ();
+               ListCaptured = new List<short> ();
                Initialize();
        }
 
@@ -174,16 +174,17 @@ public static class EncoderCaptureInertialBackgroundStatic
        }
 
        //TODO: write nicer
-       public static int GetNext()
+       public static short GetNext()
        {
                if(abort)
                        return 0;
 
                do {
-                       if(ListCaptured.Count > pos)
+                       if(ListCaptured != null && ListCaptured.Count > pos)
                                return ListCaptured[pos ++];
 
-                       System.Threading.Thread.Sleep(25);
+                       //LogB.Information("Problems at GetNext, L.Count: " + ListCaptured.Count.ToString() + 
";pos: " + pos.ToString());
+                       System.Threading.Thread.Sleep(5);
                } while (! abort);
 
                return 0;
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index b25fd7a..c46f201 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -6304,7 +6304,7 @@ LogB.Debug("X");
                encoderRProcCapture.Debug = true;
                encoderRProcAnalyze.Debug = true;
                LogB.PrintAllThreads = true;
-       
+
                hbox_gui_tests.Visible = true;
                button_carles.Visible = true;
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 10f3281..e6f73cb 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4737,6 +4737,7 @@ public partial class ChronoJumpWindow
                        GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureBG));
 
                        LogB.ThreadStart();
+                       LogB.Mute = true; //mute logs to improve stability (encoder inertial test only works 
with muted log
                        encoderThreadBG.Start();
                }
 
@@ -4861,6 +4862,7 @@ public partial class ChronoJumpWindow
                        encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
 
                        LogB.ThreadStart();
+                       LogB.Mute = true; //mute logs to improve stability (encoder inertial test only works 
with muted log
                        encoderThread.Start();
                } else if(
                                action == encoderActions.CURVES || 
@@ -5226,7 +5228,7 @@ public partial class ChronoJumpWindow
 
                Thread.Sleep (50);
 
-               //don't plot info here because this is sorking all the time
+               //don't plot info here because this is working all the time
                //LogB.Information(" CapBG:"+ encoderThreadBG.ThreadState.ToString());
 
                if(newValue < -100000 || newValue > 100000)
diff --git a/src/logB.cs b/src/logB.cs
index 642ef80..995f5b8 100644
--- a/src/logB.cs
+++ b/src/logB.cs
@@ -159,6 +159,7 @@ public static class LogB
         * default behaviour is to print only when on GTK thread, and messages from other threads
         * will be stored and printed by GTK thread before what it needs to print
         */
+       public static bool Mute = false;
        public static bool PrintAllThreads = false;
 
        private static bool debugging = false;
@@ -173,6 +174,9 @@ public static class LogB
 
        public static void Commit(LogEntryType type, string message, string details, bool showUser)
        {
+               if(Mute)
+                       return;
+
                if(message == null)
                        message = "";
 


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