[chronojump] Safer forceSensor.GetTimeAtCount() method



commit b9a38db056b2945ba5ef0fe39a72ad7b523eb190
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Feb 16 00:09:51 2020 +0100

    Safer forceSensor.GetTimeAtCount() method

 src/forceSensor.cs | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 73132384..434a716c 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -815,12 +815,21 @@ public class ForceSensorCapturePoints
 
        public double GetTimeAtCount(int count)
        {
+               //LogB.Information(string.Format("At GetTimeAtCount, count:{0}, times.Count:{1}", count, 
times.Count));
+
+               //safe check
+               if(count < 0)
+                       return times[0];
+               else if (count >= times.Count)
+                       return times[times.Count -1];
+
                return times[count];
        }
        public double GetForceAtCount(int count)
        {
                return forces[count];
        }
+
        public void GetAverageAndMaxForce(int countA, int countB, out double avg, out double max)
        {
                if(countA == countB) {


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