[chronojump] Fixed new code for ForceSensor tare+capture



commit 5459c44ae9331e562ef4b889cf8bbc6be47c4a86
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Dec 17 12:26:12 2021 +0100

    Fixed new code for ForceSensor tare+capture

 src/gui/app1/forceSensor.cs | 46 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 0249745de..96a6927da 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1056,7 +1056,11 @@ public partial class ChronoJumpWindow
                        if(! forceSensorConnect())
                                return;
 
-               forceSensorOtherMessage = "Please, wait ...";
+               if(currentForceSensorExercise.TareBeforeCapture)
+                       forceSensorOtherMessage = "The tare will soon begin";
+               else
+                       forceSensorOtherMessage = "Please, wait ...";
+
                capturingForce = arduinoCaptureStatus.STARTING;
        }
 
@@ -1290,6 +1294,7 @@ public partial class ChronoJumpWindow
                if(currentForceSensorExercise.TareBeforeCapture)
                {
                        forceSensorOtherMessage = "Taring ...";
+                       LogB.Information("Taring starts");
                        int taringSample = 0;
                        int taringSamplesTotal = 50;
                        double taringSum = 0;
@@ -1311,8 +1316,14 @@ public partial class ChronoJumpWindow
                                }
                        }
 
-                       if(taringSum > 0)
+                       if(taringSample > 0)
+                       {
+                               /*
+                                  In positive a 10Kg tare, will do on a 40Kg force: force = 40 -(10) = 30 Kg
+                                  In negative a -10Kg tare, will do on a -40Kg force: force = -40 -(-10) = 
-30 Kg
+                                  */
                                forceTared = UtilAll.DivideSafe(taringSum, taringSamplesTotal);
+                       }
                }
 
                str = "";
@@ -1346,7 +1357,11 @@ public partial class ChronoJumpWindow
                        }
 
                        if(currentForceSensorExercise.TareBeforeCapture && forceTared != 0)
+                       {
+                               LogB.Information(string.Format("forceTared: {0}, force: {1}, forceFixed: {2}",
+                                                       forceTared, force, force - forceTared));
                                force -= forceTared;
+                       }
 
                        //measurement does not start at 0 time. When we start receiving data, mark this as 
firstTime
                        if(firstTime == 0)
@@ -1684,15 +1699,20 @@ LogB.Information(" fs F ");
                if(capturingForce == arduinoCaptureStatus.CAPTURING)
                {
 LogB.Information(" fs G ");
-                       label_force_sensor_value_max.Text = string.Format("{0:0.##} N", 
forceSensorValues.Max);
-                       label_force_sensor_value_min.Text = string.Format("{0:0.##} N", 
forceSensorValues.Min);
-                       label_force_sensor_value.Text = string.Format("{0:0.##} N", 
forceSensorValues.ValueLast);
+                       //do this if we are not on tare and TareBeforeCapture
+                       if( ! (currentForceSensorExercise.TareBeforeCapture && ! forceCaptureStartMark) )
+                       {
 
+                               label_force_sensor_value_max.Text = string.Format("{0:0.##} N", 
forceSensorValues.Max);
+                               label_force_sensor_value_min.Text = string.Format("{0:0.##} N", 
forceSensorValues.Min);
+                               label_force_sensor_value.Text = string.Format("{0:0.##} N", 
forceSensorValues.ValueLast);
 
-LogB.Information(" fs H ");
-                       //------------------- realtime graph -----------------
-                       if(redoingPoints || fscPoints == null || fscPoints.Points == null || 
force_capture_drawingarea == null)
-                               return true;
+
+                               LogB.Information(" fs H ");
+                               //------------------- realtime graph -----------------
+                               if(redoingPoints || fscPoints == null || fscPoints.Points == null || 
force_capture_drawingarea == null)
+                                       return true;
+                       }
 
 LogB.Information(" fs H2 ");
                        if(usbDisconnectedLastTime == forceSensorValues.TimeLast)
@@ -1725,6 +1745,14 @@ LogB.Information(" fs H2 ");
                                usbDisconnectedCount = 0;
                        }
 
+                       //if taring at TareBeforeCapture, just show message
+                       if( currentForceSensorExercise.TareBeforeCapture && ! forceCaptureStartMark)
+                       {
+                               event_execute_label_message.Text = forceSensorOtherMessage; //"Taring ..."
+                               Thread.Sleep(25);
+                               return true;
+                       }
+
 LogB.Information(" fs I ");
                        //mark meaning screen should be erased
                        //but only applies when not in scroll


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