[chronojump] force sensor analyze a, b sliders now not crash with really low data



commit 05cd213ca157f8a74d714db39b089c6ae9b1b44e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 12 16:57:32 2021 +0100

    force sensor analyze a,b sliders now not crash with really low data

 src/gui/app1/forceSensorAnalyze.cs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 386ac577..9fec322a 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -1631,6 +1631,13 @@ public partial class ChronoJumpWindow
                        hscale_force_sensor_ai_b.Value = hscale_force_sensor_ai_a.Value;
 
                int count = Convert.ToInt32(hscale_force_sensor_ai_a.Value);
+               if(count > 0 && count >= fsAI.GetLength() -1)
+               {
+                       //it could happen when there is really little data
+                       LogB.Information("hscale_force_sensor_ai_a outside of boundaries");
+                       return;
+               }
+
                label_force_sensor_ai_time_a.Text = Math.Round(fsAI.GetTimeMS(count), 1).ToString();
                label_force_sensor_ai_force_a.Text = Math.Round(fsAI.GetForceAtCount(count), 1).ToString();
 
@@ -1694,6 +1701,13 @@ public partial class ChronoJumpWindow
                        hscale_force_sensor_ai_a.Value = hscale_force_sensor_ai_b.Value;
 
                int count = Convert.ToInt32(hscale_force_sensor_ai_b.Value);
+               if(count > 0 && count >= fsAI.GetLength() -1)
+               {
+                       //it could happen when there is really little data
+                       LogB.Information("hscale_force_sensor_ai_b outside of boundaries");
+                       return;
+               }
+
                label_force_sensor_ai_time_b.Text = Math.Round(fsAI.GetTimeMS(count), 1).ToString();
                label_force_sensor_ai_force_b.Text = Math.Round(fsAI.GetForceAtCount(count), 1).ToString();
 


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