[chronojump/FS-TFT-Menu] Better code for findMaxPowerSpeedForceIntersession()



commit 4223a745732a90b37e6d724c10d32ba524d212ab
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 8 12:03:00 2022 +0200

    Better code for findMaxPowerSpeedForceIntersession()

 src/gui/app1/encoder.cs | 65 +++++++++++++++++++------------------------------
 1 file changed, 25 insertions(+), 40 deletions(-)
---
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index db5a8b539..a7bce4618 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -726,54 +726,39 @@ public partial class ChronoJumpWindow
                maxSpeedIntersessionDate = "";
                maxForceIntersessionDate = "";
 
+               double extraWeight = 0; //used on gravitatory
+               //TODO: do a regression to find maxPower with a value of extraWeight unused
                if(encGI == Constants.EncoderGI.GRAVITATORY)
+                       extraWeight = Convert.ToDouble(spin_encoder_extra_weight.Value);
+
+               foreach(EncoderSQL es in arrayTemp)
                {
-                       //TODO: do a regression to find maxPower with a value of extraWeight unused
-                       double extraWeight = Convert.ToDouble(spin_encoder_extra_weight.Value);
-                       foreach(EncoderSQL es in arrayTemp)
-                       {
-                               
if(Util.SimilarDouble(Convert.ToDouble(Util.ChangeDecimalSeparator(es.extraWeight)), extraWeight))
+                       if(
+                                       (encGI == Constants.EncoderGI.GRAVITATORY &&
+                                       
Util.SimilarDouble(Convert.ToDouble(Util.ChangeDecimalSeparator(es.extraWeight)), extraWeight)) ||
+                                       (encGI == Constants.EncoderGI.INERTIAL &&
+                                        encoderConfigurationCurrent.Equals(es.encoderConfiguration))
+                         ) {
+                               if(Convert.ToDouble(es.future1) > maxPowerIntersession)
                                {
-                                       if(Convert.ToDouble(es.future1) > maxPowerIntersession)
-                                       {
-                                               maxPowerIntersession = Convert.ToDouble(es.future1);
-                                               maxPowerIntersessionDate = es.GetDateStr();
-                                       }
-                                       if(Convert.ToDouble(es.future2) > maxSpeedIntersession)
-                                       {
-                                               maxSpeedIntersession = Convert.ToDouble(es.future2);
-                                               maxSpeedIntersessionDate = es.GetDateStr();
-                                       }
-                                       if(Convert.ToDouble(es.future3) > maxForceIntersession)
-                                       {
-                                               maxForceIntersession = Convert.ToDouble(es.future3);
-                                               maxForceIntersessionDate = es.GetDateStr();
-                                       }
+                                       maxPowerIntersession = Convert.ToDouble(es.future1);
+                                       maxPowerIntersessionDate = es.GetDateStr();
                                }
-                       }
-               }
-               else if(encGI == Constants.EncoderGI.INERTIAL)
-               {
-                       foreach(EncoderSQL es in arrayTemp)
-                       {
-                               if(encoderConfigurationCurrent.Equals(es.encoderConfiguration))
+                               if(Convert.ToDouble(es.future2) > maxSpeedIntersession)
                                {
-                                       if(Convert.ToDouble(es.future1) > maxPowerIntersession)
-                                       {
-                                               maxPowerIntersession = Convert.ToDouble(es.future1);
-                                               maxPowerIntersessionDate = es.GetDateStr();
-                                       } if(Convert.ToDouble(es.future2) > maxSpeedIntersession)
-                                       {
-                                               maxSpeedIntersession = Convert.ToDouble(es.future2);
-                                               maxSpeedIntersessionDate = es.GetDateStr();
-                                       } if(Convert.ToDouble(es.future3) > maxForceIntersession)
-                                       {
-                                               maxForceIntersession = Convert.ToDouble(es.future3);
-                                               maxForceIntersessionDate = es.GetDateStr();
-                                       }
+                                       maxSpeedIntersession = Convert.ToDouble(es.future2);
+                                       maxSpeedIntersessionDate = es.GetDateStr();
+                               }
+                               if(Convert.ToDouble(es.future3) > maxForceIntersession)
+                               {
+                                       maxForceIntersession = Convert.ToDouble(es.future3);
+                                       maxForceIntersessionDate = es.GetDateStr();
                                }
                        }
                }
+
+               //LogB.Information(string.Format("maxPowerIntersession: {0}, date: {1}",
+               //                      maxPowerIntersession, maxPowerIntersessionDate));
        }
 
        bool canCaptureEncoder()


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