[chronojump] ForceSensor does not crash on forces higher than 5000N (impossible) and bigger than int (like : -500



commit ef6de9e81520005d564c3e2409a74b19a9d3ccda
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Oct 11 18:00:52 2022 +0200

    ForceSensor does not crash on forces higher than 5000N (impossible) and bigger than int (like : 
-500000000)

 src/gui/app1/forceSensor.cs | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 77381f0c7..5823808aa 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1372,6 +1372,7 @@ public partial class ChronoJumpWindow
                        }
                        else {
                                str = portFS.ReadLine();
+                               //LogB.Information ("forceSensor captured str: " + str);
                                if(! forceSensorProcessCapturedLine(str, out time, out force,
                                                        readTriggers, out triggerCode))
                                        continue;
@@ -1544,6 +1545,14 @@ public partial class ChronoJumpWindow
                        return false;
 
                time = Convert.ToInt32(strFull[0]);
+
+               //bad tare or bad calibration or too much force
+               if (Math.Abs (Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]))) > 5000) // 5000 N 
(500 Kg)
+               {
+                       LogB.Information ("Error. Force too big: " + strFull[1]);
+                       return false;
+               }
+
                force = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]));
 
                return true;


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