[chronojump] Encoder Analyzer: Implemented Load-Speed graph with L0, V0



commit 8003a02f7128cf23c1843c628ba1bb61c87c9b51
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Oct 17 15:46:31 2022 +0200

    Encoder Analyzer: Implemented Load-Speed graph with L0, V0

 encoder/graph.R         | 27 +++++++++++++++++++++++----
 src/gui/app1/encoder.cs | 13 ++++++++++---
 2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index e869010a6..e4949af8a 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2063,11 +2063,13 @@ paintCrossVariables <- function (paf, varX, varY, option,
                                         }
                                 }
                                 else {
-                                        if(varX == "Speed" && varY == "Force") #is "Force,Power" but using 
Force to have less problems
+                                       #is "Force,Power" but using Force to have less problems, or
+                                       #is "Load,Power" but using Load to have less problems
+                                        if(varX == "Speed" && (varY == "Force" || varY == "Load"))
                                         {
                                                 fit = lm(y ~ x)
                                                 V0 = -coef(fit)[[1]] / coef(fit)[[2]]
-                                                F0 = coef(fit)[[1]]
+                                                F0 = coef(fit)[[1]] #or L0
                                                 plot(x,y,
                                                      xlim=c(0, max(x,V0)), ylim=c(0, max(y,F0)),
                                                      xlab=varXut, ylab="", pch=pchVector, 
col=colBalls,bg=bgBalls,cex=cexBalls,axes=F)
@@ -2092,7 +2094,12 @@ paintCrossVariables <- function (paf, varX, varY, option,
                                                 points(V0,0,col="darkgreen")
                                                 points(0,F0,col="blue")
                                                 text(x=V0, y=0, paste("V0=", round(V0,2), "m/s", sep=""), 
col="darkgreen", pos = 1)
-                                                text(x=0, y=F0, paste("F0=", round(F0,2), "N", sep=""), 
col="blue", pos = 4)
+                                               if(varY == "Force")
+                                               {
+                                                       text(x=0, y=F0, paste("F0=", round(F0,2), "N", 
sep=""), col="blue", pos = 4)
+                                               } else { #(varY == "Load")
+                                                       text(x=0, y=F0, paste("L0=", round(F0,2), "Kg", 
sep=""), col="blue", pos = 4)
+                                               }
                                         } else {
                                                 plot(x,y, xlab=varXut, ylab="", pch=pchVector, 
col=colBalls,bg=bgBalls,cex=cexBalls,axes=F)
                                         }
@@ -2141,8 +2148,16 @@ paintCrossVariables <- function (paf, varX, varY, option,
                                                                   paste("Pmax = ", round(F0*V0/4, digits = 
0), "W", sep = "")
                                                                   #,paste("Load = ", round(optimLoad, 
digits=1), "Kg", sep = "")),
                                                                   ))
-                                                
                                         }
+                                       else if(varX == "Speed" && varY == "Load") #is "Load,Power" but using 
Force to have less problems
+                                        {
+                                                legend(x = V0*1.04, y = V0 * F0 * 0.2, xjust = 1, yjust = 
0.1,
+                                                       text.col = c("Blue", "darkgreen", "red", "black"), 
cex = 1.3,
+                                                       legend = c(paste("L0 = ", round(F0, digits = 0), 
"Kg", sep = ""),
+                                                                  paste("V0 = ", round(V0, digits = 2), 
"m/s", sep = "")
+                                                                  #,paste("Load = ", round(optimLoad, 
digits=1), "Kg", sep = "")),
+                                                                  ))
+                                       }
                                 }
                         }
                 }
@@ -3800,6 +3815,10 @@ doProcess <- function(options)
                                if(op$AnalysisVariables[1] == "Force,Power") {
                                        op$AnalysisVariables[1] = "Force";
                                }
+                               #same for Load,Power
+                               else if(op$AnalysisVariables[1] == "Load,Power") {
+                                       op$AnalysisVariables[1] = "Load";
+                               }
 
                                 dateAsX <- FALSE
                                 if(length(op$AnalysisVariables) == 4 && op$AnalysisVariables[4] == "Date")
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index 0d0a03853..aeaa9a6b8 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -3548,12 +3548,15 @@ public partial class ChronoJumpWindow
                                        crossName == "Power - Load" || crossName == "Speed - Load" || 
crossName == "Force - Load" ||
                                        crossName == "Pmax(F0,V0)" ||
                                        crossName == "(Speed,Power) - Load" ||
-                                       crossName == "(Force,Power) - Speed"|| crossName == "Power - Speed" )
+                                       crossName == "(Force,Power) - Speed"||
+                                       crossName == "(Load,Power) - Speed"||
+                                       crossName == "Power - Speed" )
                        {
                                if(crossName == "Pmax(F0,V0)")
                                        analysisVariables = "Pmax(F0,V0);Pmax(F0,V0)"; //this is not used but 
we want to preserve chunks between ';'
                                else {
                                        //convert: "(Force,Power) - Speed" in: "(Force,Power);Speed;mean"
+                                       //convert: "(Load,Power) - Speed" in: "(Load,Power);Speed;mean"
                                        string [] crossNameFull = crossName.Split(new char[] {' '});
 
                                        //remove the '(', ')'
@@ -4835,7 +4838,10 @@ public partial class ChronoJumpWindow
                        comboAnalyzeCrossOptions = new string [] { 
                                "Power - Load", "Speed - Load", "Force - Load",
                                        "Pmax(F0,V0)",
-                                       "(Speed,Power) - Load", "(Force,Power) - Speed", "Power - Speed"
+                                       "(Speed,Power) - Load",
+                                       "(Force,Power) - Speed",
+                                       "(Load,Power) - Speed",
+                                       "Power - Speed"
                        };
                        comboAnalyzeCrossOptionsTranslated = new string [] { 
                                Catalog.GetString ("Power - Load"),
@@ -4844,10 +4850,11 @@ public partial class ChronoJumpWindow
                                "Pmax(F0,V0)", //will not be translated
                                Catalog.GetString ("(Speed,Power) - Load"),
                                Catalog.GetString ("(Force,Power) - Speed"),
+                               Catalog.GetString ("(Load,Power) - Speed"),
                                Catalog.GetString ("Power - Speed")
                        }; //if added more, change the int in the 'for' below
                        encoderAnalyzeCrossTranslation = new String [comboAnalyzeCrossOptions.Length];
-                       for(int j=0; j < 7 ; j++)
+                       for(int j=0; j < 8 ; j++)
                                encoderAnalyzeCrossTranslation[j] = 
                                        comboAnalyzeCrossOptions[j] + ":" + 
comboAnalyzeCrossOptionsTranslated[j];
                } else {


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