[chronojump] force sensor capture thread improvements



commit 5f3383c7cd0031efe83a79a588eddc690e740238
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Oct 28 10:54:41 2017 +0200

    force sensor capture thread improvements

 src/gui/forceSensor.cs |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index bf5fc95..0e83299 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -486,18 +486,18 @@ public partial class ChronoJumpWindow
 
        private bool pulseGTKForceSensorCapture ()
        {
-               LogB.Information(" fc A ");
+LogB.Information(" fc A ");
                if(forceCaptureThread == null)
                {
                        Thread.Sleep (25);
                        return true;
                }
 
-               LogB.Information(" fc B ");
+LogB.Information(" fc B ");
                //LogB.Information(capturingForce.ToString())
                if(! forceCaptureThread.IsAlive || forceProcessFinish || forceProcessCancel)
                {
-               LogB.Information(" fc C ");
+LogB.Information(" fc C ");
                        LogB.ThreadEnding();
 
                        if(forceProcessFinish)
@@ -532,17 +532,17 @@ public partial class ChronoJumpWindow
                        return false;
                }
 
-               LogB.Information(" fc E ");
+LogB.Information(" fc E ");
                if(forceCaptureStartMark)
                {
                        event_execute_label_message.Text = "Capturing ...";
                        forceCaptureStartMark = false;
                }
-               LogB.Information(" fc F ");
+LogB.Information(" fc F ");
 
                if(capturingForce == forceStatus.CAPTURING)
                {
-               LogB.Information(" fc G ");
+LogB.Information(" fc G ");
                        //------------------- vscale -----------------
                        /*
                        //A) resize vscale if needed
@@ -573,44 +573,44 @@ public partial class ChronoJumpWindow
                                label_force_sensor_value_min.Text = forceSensorLast.ToString();
 
 
-               LogB.Information(" fc H ");
+LogB.Information(" fc H ");
                        //------------------- realtime graph -----------------
                        if(redoingPoints || fscPoints == null || fscPoints.Points == null || 
force_capture_drawingarea == null)
                                return true;
 
-               LogB.Information(" fc I ");
+LogB.Information(" fc I ");
                        //mark meaning screen should be erased
                        if(fscPoints.NumPainted == -1) {
                                UtilGtk.ErasePaint(force_capture_drawingarea, force_capture_pixmap);
                                fscPoints.NumPainted = 0;
                        }
 
-               LogB.Information(" fc J ");
+LogB.Information(" fc J ");
                        //use these integers and this List to not have errors by updating data on the other 
thread
                        int numCaptured = fscPoints.NumCaptured;
                        int numPainted = fscPoints.NumPainted;
                        List<Gdk.Point> points = fscPoints.Points;
 
-               LogB.Information(" fc K ");
+LogB.Information(" fc K ");
                        int toDraw = numCaptured - numPainted;
 
                        LogB.Information("points count: " + points.Count +
                                        "; NumCaptured: " + numCaptured + "; NumPainted: " + numPainted +
                                        "; toDraw: " + toDraw.ToString() );
 
-               LogB.Information(" fc L ");
+LogB.Information(" fc L ");
                        //fixes crash at the end
                        if(toDraw == 0)
                                return true;
 
-               LogB.Information(" fc M ");
+LogB.Information(" fc M ");
                        Gdk.Point [] paintPoints;
                        if(numPainted > 0)
                                paintPoints = new Gdk.Point[toDraw +1]; // if something has been painted, 
connected first point with previous points
                        else
                                paintPoints = new Gdk.Point[toDraw];
 
-               LogB.Information(" fc N ");
+LogB.Information(" fc N ");
                        int jStart = 0;
                        int iStart = 0;
                        if(numPainted > 0)
@@ -621,20 +621,27 @@ public partial class ChronoJumpWindow
                                iStart = numPainted;
                                //LogB.Information("X: " + paintPoints[0].X.ToString() + "; Y: " + 
paintPoints[0].Y.ToString());
                        }
-               LogB.Information(" fc O ");
+LogB.Information(" fc O ");
                        for(int j=jStart, i = iStart ; i < numCaptured ; i ++, j++)
                        {
                                if(points.Count > i)    //extra check to avoid going outside of arrays
                                        paintPoints[j] = points[i];
                                //LogB.Information("X: " + paintPoints[j].X.ToString() + "; Y: " + 
paintPoints[j].Y.ToString());
                        }
-               LogB.Information(" fc P ");
+LogB.Information(" fc P ");
                        force_capture_pixmap.DrawLines(pen_black_force_capture, paintPoints);
                        force_capture_drawingarea.QueueDraw(); // -- refresh
-                       fscPoints.NumPainted = numCaptured;
-               LogB.Information(" fc Q ");
+
+                       /*
+                        * update fscPoints.NumPainted by only if there's no -1 mark
+                        * because -1 mark should prevail until repainted the screen
+                        */
+                       if(fscPoints.NumPainted != -1)
+                               fscPoints.NumPainted = numCaptured;
+
+LogB.Information(" fc Q ");
                }
-               LogB.Information(" fc R ");
+LogB.Information(" fc R ");
 
                Thread.Sleep (25);
                //LogB.Information(" ForceSensor:"+ forceCaptureThread.ThreadState.ToString());


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