[chronojump] Encoder: Added RFD calculation



commit d5f5a310dfb74d39bb465b04b1e72cbc9fac43b5
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Oct 30 16:25:00 2019 +0100

    Encoder: Added RFD calculation

 encoder/capture.R           |  2 +-
 encoder/graph.R             | 14 +++++++++-----
 encoder/util.R              |  5 +++--
 src/encoder.cs              | 15 +++++++++++----
 src/gui/encoder.cs          |  8 +++++---
 src/gui/encoderTreeviews.cs | 46 ++++++++++++++++++++++++++++++++-------------
 6 files changed, 62 insertions(+), 28 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 8f9eecbf..d49f859e 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -95,7 +95,7 @@ calcule <- function(displacement, op, curveNum, startInSet)
                  sum(displacement), #height
                  paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, 
                  paf$meanPower, paf$peakPower, paf$peakPowerT, paf$pp_ppt, 
-                 paf$meanForce, paf$maxForce, paf$maxForceT,
+                 paf$meanForce, paf$maxForce, paf$maxForceT, paf$maxForce_maxForceT,
                  sep=", "), file = con)
        close(con)
        #if(debug)
diff --git a/encoder/graph.R b/encoder/graph.R
index 9e05c6fe..58349df6 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1486,15 +1486,15 @@ findPosInPaf <- function(var, option) {
         else if(var == "Force")
                 pos = 8
         else if(var == "Load") #MassDisplaced
-                pos = 11
-        else if(var == "MassBody")
                 pos = 12
-        else if(var == "MassExtra")
+        else if(var == "MassBody")
                 pos = 13
-        else if(var == "Laterality")
+        else if(var == "MassExtra")
                 pos = 14
-        else if(var == "Inertia")
+        else if(var == "Laterality")
                 pos = 15
+        else if(var == "Inertia")
+                pos = 16
         
         if( ( var == "Speed" || var == "Power" || var == "Force") & option == "max")
                 pos=pos+1
@@ -3826,6 +3826,7 @@ doProcess <- function(options)
                                                 "meanPower","peakPower","peakPowerT",
                                                 "pp_ppt",
                                                 "meanForce", "maxForce", "maxForceT",
+                                                "maxForce_maxForceT",
                                                 "laterality", "inertiaM"
                         )
                         
@@ -3844,6 +3845,7 @@ doProcess <- function(options)
                                                          
max(pafCurves$meanPower),max(pafCurves$peakPower),max(pafCurves$peakPowerT),
                                                          max(pafCurves$pp_ppt),
                                                          max(pafCurves$meanForce), max(pafCurves$maxForce), 
max(pafCurves$maxForceT),
+                                                         max(pafCurves$maxForce_maxForceT),
                                                          "", max(pafCurves$inertiaM)
                                         )
                                         
@@ -3854,6 +3856,7 @@ doProcess <- function(options)
                                                          
mean(pafCurves$meanPower),mean(pafCurves$peakPower),mean(pafCurves$peakPowerT),
                                                          mean(pafCurves$pp_ppt),
                                                          mean(pafCurves$meanForce), 
mean(pafCurves$maxForce), mean(pafCurves$maxForceT),
+                                                         mean(pafCurves$maxForce_maxForceT),
                                                          "", mean(pafCurves$inertiaM)
                                         )
                                         
@@ -3865,6 +3868,7 @@ doProcess <- function(options)
                                                                 
sd(pafCurves$meanPower),sd(pafCurves$peakPower),sd(pafCurves$peakPowerT),
                                                                 sd(pafCurves$pp_ppt),
                                                                 sd(pafCurves$meanForce), 
sd(pafCurves$maxForce), sd(pafCurves$maxForceT),
+                                                               sd(pafCurves$maxForce_maxForceT),
                                                                 "", sd(pafCurves$inertiaM)
                                                 )
                                         
diff --git a/encoder/util.R b/encoder/util.R
index 0bcb4875..dd428f04 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -768,11 +768,12 @@ pafGenerate <- function(eccon, kinematics, massBody, massExtra, laterality, iner
 
        peakPower <- max(abs(kinematics$power))
        peakPowerT <- min(which(abs(kinematics$power) == peakPower))
-       
        pp_ppt <- peakPower / (peakPowerT/1000) # ms->s
+
        meanForce <- mean(kinematics$force)
        maxForce <- max(abs(kinematics$force))
        maxForceT <- min(which(abs(kinematics$force) == maxForce))
+       maxForce_maxForceT <- maxForce / (maxForceT/1000)       # ms->s
 
        #here paf is generated
        #mass is not used by pafGenerate, but used by Kg/W (loadVSPower)
@@ -782,7 +783,7 @@ pafGenerate <- function(eccon, kinematics, massBody, massExtra, laterality, iner
        return(data.frame(
                          meanSpeed, maxSpeed, maxSpeedT,
                          meanPower, peakPower, peakPowerT, pp_ppt,
-                         meanForce, maxForce, maxForceT,
+                         meanForce, maxForce, maxForceT, maxForce_maxForceT,
                          mass, massBody, massExtra,            #kinematics$mass is Load
                          laterality, inertiaMomentum)) 
 }
diff --git a/src/encoder.cs b/src/encoder.cs
index 8aacc55f..0149309d 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -247,6 +247,7 @@ public class EncoderCurve
        public string MeanForce;
        public string MaxForce;
        public string MaxForceT;
+       public string MaxForce_MaxForceT;
 
        public EncoderCurve () {
        }
@@ -257,7 +258,8 @@ public class EncoderCurve
                        string meanSpeed, string maxSpeed, string maxSpeedT,
                        string meanPower, string peakPower, string peakPowerT, 
                        string PP_PPT,
-                       string meanForce, string maxForce, string maxForceT
+                       string meanForce, string maxForce, string maxForceT,
+                       string maxForce_maxForceT
                        )
        {
                this.Record = record;
@@ -275,6 +277,7 @@ public class EncoderCurve
                this.MeanForce = meanForce;
                this.MaxForce = maxForce;
                this.MaxForceT = maxForceT;
+               this.MaxForce_MaxForceT = maxForce_maxForceT;
        }
 
        //used on TreeView analyze
@@ -286,7 +289,8 @@ public class EncoderCurve
                        string meanSpeed, string maxSpeed, string maxSpeedT,
                        string meanPower, string peakPower, string peakPowerT, 
                        string PP_PPT,
-                       string meanForce, string maxForce, string maxForceT)
+                       string meanForce, string maxForce, string maxForceT,
+                       string maxForce_maxForceT)
        {
                this.N = n;
                this.Series = series;
@@ -308,6 +312,7 @@ public class EncoderCurve
                this.MeanForce = meanForce;
                this.MaxForce = maxForce;
                this.MaxForceT = maxForceT;
+               this.MaxForce_MaxForceT = maxForce_maxForceT;
        }
 
        public EncoderCurve Copy()
@@ -317,7 +322,8 @@ public class EncoderCurve
                                MeanSpeed, MaxSpeed, MaxSpeedT,
                                MeanPower, PeakPower, PeakPowerT,
                                PP_PPT,
-                               MeanForce, MaxForce, MaxForceT);
+                               MeanForce, MaxForce, MaxForceT,
+                               MaxForce_MaxForceT);
                return curveCopy;
        }
 
@@ -408,7 +414,8 @@ public class EncoderCurve
                                MeanSpeed + sep + MaxSpeed + sep + MaxSpeedT + sep + 
                                MeanPower + sep + PeakPower + sep + PeakPowerT + sep + 
                                PP_PPT + sep +
-                               MeanForce + sep + MaxForce + sep + MaxForceT;
+                               MeanForce + sep + MaxForce + sep + MaxForceT + sep +
+                               MaxForce_MaxForceT;
                
                if(decimalSeparator == "COMMA")
                        str = Util.ConvertToComma(str);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 9104eb78..3a6983f3 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5448,7 +5448,7 @@ public partial class ChronoJumpWindow
                                                ",series,exercise,mass,start,width,height," + 
                                                "meanSpeed,maxSpeed,maxSpeedT," +
                                                "meanPower,peakPower,peakPowerT,pp_ppt," +
-                                               "meanForce, maxForce, maxForceT");
+                                               "meanForce, maxForce, maxForceT, maxForce_maxForceT");
 
                                string filename = UtilEncoder.GetEncoderCaptureTempFileName();
                                if(File.Exists(filename))
@@ -5828,13 +5828,15 @@ public partial class ChronoJumpWindow
                        encoderCaptureStringR.Add(string.Format("\n" + 
                                                "{0},2,a,3,4," + //id, seriesName, exerciseName, massBody, 
massExtra
                                                "{1},{2},{3}," + //start, width, height
-                                               "{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}",
+                                               "{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}",
                                        strs[0],
                                        strs[1], strs[2], strs[3],      //start, width, height
                                        strs[4], strs[5], strs[6],      //speeds
                                        strs[7], strs[8], strs[9],      //powers
                                        strs[10],                       //pp/ppt
-                                       strs[11], strs[12], strs[13])); //forces
+                                       strs[11], strs[12], strs[13],   //forces
+                                       strs[14]                        //maxForce_maxForceT
+                                       ));
 
                        //LogB.Debug("encoderCaptureStringR");
                        //LogB.Debug(encoderCaptureStringR);
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 07babf24..e01600ed 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -78,7 +78,8 @@ public partial class ChronoJumpWindow
                        "pmax/t->pmax" + "\n (W/s)",
                        "F" + "\n (N)",
                        "Fmax" + "\n (N)",
-                       "t->Fmax" + "\n (s)"
+                       "t->Fmax" + "\n (s)",
+                       "Fmax/t->Fmax" + "\n (N/s)"
                };
 
                encoderCaptureCurves = new ArrayList ();
@@ -129,7 +130,8 @@ public partial class ChronoJumpWindow
                                                cells[8], cells[9], cells[10],  //meanSpeed, maxSpeed, 
maxSpeedT
                                                cells[11], cells[12], cells[13],//meanPower, peakPower, 
peakPowerT
                                                cells[14],                      //peakPower / peakPowerT
-                                               cells[15], cells[16], cells[17] //meanForce, maxForce 
maxForceT
+                                               cells[15], cells[16], cells[17], //meanForce, maxForce 
maxForceT
+                                               cells[18]                       //meanForce / meanForceT
                                                ));
 
                }
@@ -227,6 +229,9 @@ public partial class ChronoJumpWindow
                                case 13:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForceT));
                                        break;
+                               case 14:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce_maxForceT));
+                                       break;
                        }
                                        
                        if( ! ( (i == 1 || i == 2) && ! showStartAndDuration ) )
@@ -583,7 +588,8 @@ public partial class ChronoJumpWindow
                        "pmax/t->pmax" + "\n(W/s)",
                        "F" + "\n(N)",
                        "Fmax" + "\n(N)",
-                       "t->Fmax" + "\n" + timeUnits
+                       "t->Fmax" + "\n" + timeUnits,
+                       "Fmax/t->Fmax" + "\n(N/s)"
                };
                return treeviewEncoderAnalyzeHeaders;
        }
@@ -660,15 +666,16 @@ public partial class ChronoJumpWindow
                                                        cells[0], 
                                                        cells[1],       //seriesName 
                                                        exerciseName,
-                                                       cells[18],      //laterality
-                                                       
Convert.ToDouble(Util.ChangeDecimalSeparator(cells[4])),
-                                                       totalMass,
-                                                       Convert.ToInt32(cells[19]),
+                                                       cells[19],      //laterality
+                                                       
Convert.ToDouble(Util.ChangeDecimalSeparator(cells[4])),        //extraWeight
+                                                       totalMass,                                            
          //displaceWeight
+                                                       Convert.ToInt32(cells[20]),                           
          //inertia
                                                        cells[5], cells[6], cells[7], 
                                                        cells[8], cells[9], cells[10], 
                                                        cells[11], cells[12], cells[13],
                                                        cells[14],
-                                                       cells[15], cells[16], cells[17] //meanForce, 
maxSForce maxForceT
+                                                       cells[15], cells[16], cells[17], //meanForce, 
maxSForce maxForceT
+                                                       cells[18]
                                                        ));
 
                        } while(true);
@@ -761,6 +768,9 @@ public partial class ChronoJumpWindow
                                case 19:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForceT));
                                        break;
+                               case 20:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce_maxForceT));
+                                       break;
                        }
                        
                        treeview_encoder_analyze_curves.AppendColumn (aColumn);
@@ -1338,6 +1348,12 @@ public partial class ChronoJumpWindow
                renderBoldIfNeeded(cell, curve, str);
        }
 
+       private void RenderMaxForce_maxForceT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, 
Gtk.TreeModel model, Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               string str = 
String.Format(UtilGtk.TVNumPrint(curve.MaxForce_MaxForceT,6,1),Convert.ToDouble(curve.MaxForce_MaxForceT));
+               renderBoldIfNeeded(cell, curve, str);
+       }
        
        /* end of rendering capture and analyze cols */
 
@@ -1452,9 +1468,9 @@ public partial class ChronoJumpWindow
        private bool fixDecimalsWillWork(bool captureOrAnalyze, string [] cells)
        {
                LogB.Information(string.Format("captureOrAnalyze: {0}, cells.Length: {1}", captureOrAnalyze, 
cells.Length));
-               if(captureOrAnalyze && cells.Length < 18)               //from 0 to 17
+               if(captureOrAnalyze && cells.Length < 19)               //from 0 to 18
                        return false;
-               else if(! captureOrAnalyze && cells.Length < 20)        //from 0 to 19
+               else if(! captureOrAnalyze && cells.Length < 21)        //from 0 to 20
                        return false;
 
                return true;
@@ -1478,13 +1494,17 @@ public partial class ChronoJumpWindow
                for(int i=15; i <= 17; i++)
                        cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
 
-               //cells[18] laterality
+               //maxForce_maxForceT
+               int maxForce_maxForceT = 18;
+               cells[maxForce_maxForceT] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[maxForce_maxForceT])),1);
+
+               //cells[19] laterality
 
                //capture does not return inerta
                //analyze returns inertia (can be different on "saved curves") comes as Kg*m^2, convert it to 
Kg*cm^2
                if(! captureOrAnalyze) {
-                       double inertiaInM = Convert.ToDouble(Util.ChangeDecimalSeparator(cells[19]));
-                       cells[19] = (Convert.ToInt32(inertiaInM * 10000)).ToString();
+                       double inertiaInM = Convert.ToDouble(Util.ChangeDecimalSeparator(cells[20]));
+                       cells[20] = (Convert.ToInt32(inertiaInM * 10000)).ToString();
                }
 
                return cells;


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