[chronojump] Fixed capture Loss when there are few repetitions (since commit: Encoder inertial Loss...



commit d3ff9461c44d9c1f8677e1a41b34f51c7ecaa2de
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 23 17:50:33 2017 +0200

    Fixed capture Loss when there are few repetitions (since commit: Encoder inertial Loss...

 src/gui/encoder.cs |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 6970c5d..ace286b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4458,6 +4458,8 @@ public partial class ChronoJumpWindow
                //Get max min avg values of this set
                double maxThisSet = -100000;
                double minThisSet = 100000;
+               double maxThisSetForLoss = maxThisSet;
+               double minThisSetForLoss = minThisSet;
                double sum = 0;
                int count = 0;
 
@@ -4467,19 +4469,19 @@ public partial class ChronoJumpWindow
                {
                        sum += d;
 
-                       //discardFirstThree repetitions if needed for Loss
-                       if(encoderConfigurationCurrent.has_inertia && discardFirstThree &&
-                                       ((eccon == "c" && count < 3) || (eccon != "c" && count < 6)) )
-                       {
-                               count ++;
-                               continue;
-                       }
-
                        if(d > maxThisSet)
                                maxThisSet = d;
                        if(d < minThisSet)
                                minThisSet = d;
 
+                       //discardFirstThree repetitions if needed for Loss
+                       if(! ( encoderConfigurationCurrent.has_inertia && discardFirstThree &&
+                                       ((eccon == "c" && count < 3) || (eccon != "c" && count < 6)) ) )
+                       {
+                               maxThisSetForLoss  = maxThisSet;
+                               minThisSetForLoss  = minThisSet;
+                       }
+
                        count ++;
                }
                if(maxThisSet <= 0)
@@ -4762,7 +4764,9 @@ public partial class ChronoJumpWindow
                                Util.TrimDecimals( (sumSaved / countSaved), decimals) + 
                                " " + units;
 
-               title += "; Loss: " + Util.TrimDecimals(100.0 * (maxThisSet - minThisSet) / maxThisSet, 
decimals) + "%]";
+               if(maxThisSetForLoss > 0)
+                       title += "; Loss: " + Util.TrimDecimals(
+                                       100.0 * (maxThisSetForLoss - minThisSetForLoss) / maxThisSetForLoss, 
decimals) + "%]";
 
                layout_encoder_capture_curves_bars_text.SetMarkup(title);
                textWidth = 1;


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