[chronojump] Encoder inertial show mass equivalent on analyze treeview



commit 2d0dd742399eb6442a701184b5e22c92424d9033
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Nov 13 23:14:56 2020 +0100

    Encoder inertial show mass equivalent on analyze treeview

 encoder/capture.R           |  2 +-
 encoder/graph.R             | 11 +++++-----
 encoder/util.R              | 11 ++++++++--
 src/encoder.cs              |  4 +++-
 src/gui/encoderTreeviews.cs | 53 +++++++++++++++++++++++++++++----------------
 5 files changed, 53 insertions(+), 28 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 71f7f9f1..4c9ceaab 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -84,7 +84,7 @@ calcule <- function(displacement, op, curveNum, startInSet)
 
        paf = data.frame()
        myLaterality = "" #TODO
-       paf = pafGenerate(op$Eccon, kinematicsResult, op$MassBody, op$MassExtra, myLaterality, 
op$inertiaMomentum, op$diameter)
+       paf = pafGenerate(op$Eccon, kinematicsResult, op$MassBody, op$MassExtra, myLaterality, 
op$inertiaMomentum, op$diameter, op$gearedDown)
                
        position = cumsum(displacement)
 
diff --git a/encoder/graph.R b/encoder/graph.R
index 36a9825d..a4088e6c 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -3676,7 +3676,7 @@ doProcess <- function(options)
                                             repOpSeparated,
                                             SmoothingsEC[i],op$SmoothingOneC, 
                                             g, isPropulsive, TRUE),
-                                repOp$massBody, repOp$massExtra, repOp$laterality, repOp$inertiaM, 
repOp$diameter
+                                repOp$massBody, repOp$massExtra, repOp$laterality, repOp$inertiaM, 
repOp$diameter, repOp$gearedDown
                         )))
                 }
                 
@@ -3910,7 +3910,8 @@ doProcess <- function(options)
                                                 "meanForce", "maxForce", "maxForceT",
                                                 "maxForce_maxForceT",
                                                "workJ", "impulse",
-                                                "laterality", "inertiaM", "diameter"
+                                                "laterality", "inertiaM", "diameter",
+                                               "massEq" #calculation of massEquivalent using gearedDown
                         )
                         
                         #Add "Max", "AVG" and "SD" when analyzing, not on "curves", not on "curvesAC", not 
on "curvesProcessMultiDB"
@@ -3930,7 +3931,7 @@ doProcess <- function(options)
                                                          max(pafCurves$meanForce), max(pafCurves$maxForce), 
max(pafCurves$maxForceT),
                                                          max(pafCurves$maxForce_maxForceT),
                                                         max(pafCurves$workJ), max(pafCurves$impulse),
-                                                         "", max(pafCurves$inertiaM), max(pafCurves$diameter)
+                                                         "", max(pafCurves$inertiaM), 
max(pafCurves$diameter), max(pafCurves$massEq)
                                         )
                                         
                                         #2) AVG
@@ -3942,7 +3943,7 @@ doProcess <- function(options)
                                                          mean(pafCurves$meanForce), 
mean(pafCurves$maxForce), mean(pafCurves$maxForceT),
                                                          mean(pafCurves$maxForce_maxForceT),
                                                         mean(pafCurves$workJ), mean(pafCurves$impulse),
-                                                         "", mean(pafCurves$inertiaM), 
mean(pafCurves$diameter)
+                                                         "", mean(pafCurves$inertiaM), 
mean(pafCurves$diameter), mean(pafCurves$massEq)
                                         )
                                         
                                         #3) Add SD if there's more than one data row.
@@ -3955,7 +3956,7 @@ doProcess <- function(options)
                                                                 sd(pafCurves$meanForce), 
sd(pafCurves$maxForce), sd(pafCurves$maxForceT),
                                                                sd(pafCurves$maxForce_maxForceT),
                                                                sd(pafCurves$workJ), sd(pafCurves$impulse),
-                                                                "", sd(pafCurves$inertiaM), 
sd(pafCurves$diameter)
+                                                                "", sd(pafCurves$inertiaM), 
sd(pafCurves$diameter), sd(pafCurves$massEq)
                                                 )
                                         
                                         
diff --git a/encoder/util.R b/encoder/util.R
index 27e02808..6586dda4 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -760,7 +760,7 @@ findPropulsiveEnd <- function(accel, concentric, maxSpeedTInConcentric,
        return (propulsiveEnd)
 }
 
-pafGenerate <- function(eccon, kinematics, massBody, massExtra, laterality, inertiaMomentum, diameter)
+pafGenerate <- function(eccon, kinematics, massBody, massExtra, laterality, inertiaMomentum, diameter, 
gearedDown)
 {
        meanSpeed <- mean(kinematics$speedy)
 
@@ -823,13 +823,20 @@ pafGenerate <- function(eccon, kinematics, massBody, massExtra, laterality, iner
        #meanForce and maxForce are not used by pafGenerate, but used by F/S (forceVSSpeed)
        mass = kinematics$mass
        #names will be used on graph.R writeCurves
+
+       #massEq calculation
+       massEq <- 0
+       if(inertiaMomentum > 0 && gearedDown > 0 && diameter > 0)
+               massEq <- 10000 * inertiaMomentum * gearedDown / 4 / (diameter^2)
+
        return(data.frame(
                          meanSpeed, maxSpeed, maxSpeedT,
                          meanPower, peakPower, peakPowerT, pp_ppt,
                          meanForce, maxForce, maxForceT, maxForce_maxForceT,
                          mass, massBody, massExtra,            #kinematics$mass is Load
                          workJ, impulse,
-                         laterality, inertiaMomentum, diameter
+                         laterality, inertiaMomentum, diameter,
+                         massEq
                          ))
 }
 
diff --git a/src/encoder.cs b/src/encoder.cs
index baa221eb..0bca0504 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -235,6 +235,7 @@ public class EncoderCurve
        public double DisplacedWeight;
        public int Inertia;             //analyze inertial
        public double Diameter;         //analyze inertial
+       public double MassEquivalent;   //analyze inertial
        public string Start;
        public string Duration;
        public string Height;
@@ -290,7 +291,7 @@ public class EncoderCurve
        public EncoderCurve (string n, string series, string exercise, 
                        string laterality,
                        double extraWeight, double displacedWeight,
-                       int inertia, double diameter,
+                       int inertia, double diameter, double massEquivalent,    //3 inertial params
                        string start, string duration, string height,
                        string meanSpeed, string maxSpeed, string maxSpeedT,
                        string meanPower, string peakPower, string peakPowerT, 
@@ -307,6 +308,7 @@ public class EncoderCurve
                this.DisplacedWeight = displacedWeight;
                this.Inertia = inertia;         //inertial
                this.Diameter = diameter;       //inertial
+               this.MassEquivalent = massEquivalent;   //inertial
                this.Start = start;
                this.Duration = duration;
                this.Height = height;
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index f528d16f..1ee31961 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -614,6 +614,7 @@ public partial class ChronoJumpWindow
                        Catalog.GetString("Total weight") + "\n(Kg)",
                        Catalog.GetString("Inertia M.") + "\n(Kg*cm^2)",        //inertial
                        Catalog.GetString("Diameter") + "\n(cm)",               //inertial
+                       Catalog.GetString("Mass equivalent") + "\n(Kg)",                //inertial
                        Catalog.GetString("Start") + "\n" + timeUnits,
                        Catalog.GetString("Duration") + "\n" + timeUnits,
                        Catalog.GetString("Distance") + "\n" + distanceUnits,
@@ -712,6 +713,7 @@ public partial class ChronoJumpWindow
                                                        totalMass,                                            
          //displaceWeight
                                                        Convert.ToInt32(cells[22]),                           
          //inertia M. (inertial)
                                                        Convert.ToDouble(cells[23]),                          
          //diameter (inertial)
+                                                       Convert.ToDouble(cells[24]),                          
          //mass equivalent (inertial)
                                                        cells[5], cells[6], cells[7], 
                                                        cells[8], cells[9], cells[10], 
                                                        cells[11], cells[12], cells[13],
@@ -750,8 +752,8 @@ public partial class ChronoJumpWindow
                int i=0;
                foreach(string myCol in columnsString)
                {
-                       //do not show inertia moment and diameter on powergravitatory
-                       if(encoderMode == Constants.Menuitem_modes.POWERGRAVITATORY && (i == 6 || i == 7))
+                       //do not show inertia moment, diameter, mass equivalent on powergravitatory
+                       if(encoderMode == Constants.Menuitem_modes.POWERGRAVITATORY && (i == 6 || i == 7 || i 
== 8))
                        {
                                i ++;
                                continue;
@@ -791,51 +793,54 @@ public partial class ChronoJumpWindow
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDiameter));     //inertial
                                        break;
                                case 8:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMassEquivalent));       //inertial
                                        break;
                                case 9:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderStart));
                                        break;
                                case 10:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderDuration));
                                        break;
                                case 11:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderHeight));
                                        break;
                                case 12:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanSpeed));
                                        break;
                                case 13:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
                                        break;
                                case 14:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
                                        break;
                                case 15:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
                                        break;
                                case 16:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
                                        break;
                                case 17:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
                                        break;
                                case 18:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanForce));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
                                        break;
                                case 19:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanForce));
                                        break;
                                case 20:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForceT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce));
                                        break;
                                case 21:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce_maxForceT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForceT));
                                        break;
                                case 22:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderWork));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce_maxForceT));
                                        break;
                                case 23:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderWork));
+                                       break;
+                               case 24:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderImpulse));
                                        break;
                        }
@@ -1180,6 +1185,15 @@ public partial class ChronoJumpWindow
                renderBoldIfNeeded(cell, curve, str);
        }
 
+       private void RenderMassEquivalent (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.MassEquivalent.ToString(),6,2),Convert.ToDouble(curve.MassEquivalent));
+
+               renderBoldIfNeeded(cell, curve, str);
+       }
+
        private void RenderStart (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
        {
                EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
@@ -1603,7 +1617,7 @@ public partial class ChronoJumpWindow
                //LogB.Information(string.Format("cellsString: {0}", Util.StringArrayToString(cells, ";")));
                if(captureOrAnalyze && cells.Length < 21)               //from 0 to 20
                        return false;
-               else if(! captureOrAnalyze && cells.Length < 24)        //from 0 to 23
+               else if(! captureOrAnalyze && cells.Length < 25)        //from 0 to 24
                        return false;
 
                return true;
@@ -1643,11 +1657,12 @@ public partial class ChronoJumpWindow
 
                //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
-               //analyze returns also diameter (used on inertial)
+               //analyze returns also diameter and massEquivalent (both used on inertial)
                if(! captureOrAnalyze) {
                        double inertiaInM = Convert.ToDouble(Util.ChangeDecimalSeparator(cells[22]));
                        cells[22] = (Convert.ToInt32(inertiaInM * 10000)).ToString();
                        cells[23] = Util.ChangeDecimalSeparator(cells[23]);
+                       cells[24] = Util.ChangeDecimalSeparator(cells[24]);
                }
 
                return cells;


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