[chronojump] Implemented max speed time everywhere



commit 3bc5fb10de761b53ebc678c8c9bc53d37e33ca56
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 6 11:32:32 2013 +0100

    Implemented max speed time everywhere

 encoder/graph.R    |   34 ++++++++++++++++++++++------------
 src/encoder.cs     |   15 +++++++++++----
 src/gui/encoder.cs |   43 +++++++++++++++++++++++++++++++------------
 3 files changed, 64 insertions(+), 28 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 18289f6..1c0c02b 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -264,7 +264,9 @@ kinematicsF <- function(a, mass, smoothingOne, g, eccon, analysisOptions) {
 
 powerBars <- function(eccon, kinematics) {
        meanSpeed <- mean(kinematics$speedy)
+       #max speed and max speed time can be at eccentric or concentric
        maxSpeed <- max(abs(kinematics$speedy))
+       maxSpeedT <- min(which(abs(kinematics$speedy) == maxSpeed))
 
        if(eccon == "c")
                meanPower <- mean(kinematics$power)
@@ -280,7 +282,7 @@ powerBars <- function(eccon, kinematics) {
        #here paf is generated
        #mass is not used by powerBars, but used by Kg/W (loadVSPower)
        #meanForce and maxForce are not used by powerBars, but used by F/S (forceVSSpeed)
-       return(data.frame(meanSpeed, maxSpeed, meanPower,peakPower,peakPowerT,pp_ppt,
+       return(data.frame(meanSpeed, maxSpeed, maxSpeedT, meanPower,peakPower,peakPowerT,pp_ppt,
                          kinematics$mass,meanForce,maxForce))
 }
 
@@ -692,7 +694,7 @@ paintPowerPeakPowerBars <- function(singleFile, title, paf, myEccons, Eccon, hei
                }
        }
        
-       powerData=rbind(paf[,3], paf[,4])
+       powerData=rbind(paf[,findPosInPaf("Power","mean")], paf[,findPosInPaf("Power","max")])
 
        #when eccon != c show always ABS power
        #peakPower is always ABS
@@ -716,7 +718,7 @@ paintPowerPeakPowerBars <- function(singleFile, title, paf, myEccons, Eccon, hei
        
        par(mar=c(2.5, 4, 5, 5))
        bp <- barplot(powerData,beside=T,col=pafColors[1:2],width=c(1.4,.6),
-                       names.arg=paste(myNums,"\n",paf[,7],sep=""),xlim=c(1,n*3+.5),cex.name=0.9,
+                       
names.arg=paste(myNums,"\n",paf[,findPosInPaf("Load","")],sep=""),xlim=c(1,n*3+.5),cex.name=0.9,
                        xlab="",ylab="Power (W)", 
                        ylim=c(lowerY,max(powerData)), xpd=FALSE) #ylim, xpd = F,  makes barplot starts high 
(compare between them)
        title(main=title,line=-2,outer=T)
@@ -724,10 +726,12 @@ paintPowerPeakPowerBars <- function(singleFile, title, paf, myEccons, Eccon, hei
        par(new=T, xpd=T)
        #on ecS, concentric has high value of time to peak power and eccentric has it very low. Don't draw 
lines
        if(Eccon=="ecS")
-               plot(bp[2,],paf[,5],type="p",lwd=2,xlim=c(1,n*3+.5),ylim=c(0,max(paf[,5])),
+               plot(bp[2,],paf[,findPosInPaf("Power","time")],type="p",lwd=2,
+                    xlim=c(1,n*3+.5),ylim=c(0,max(paf[,findPosInPaf("Power","time")])),
                     axes=F,xlab="",ylab="",col="blue", bg="lightblue",cex=1.5,pch=21)
        else
-               plot(bp[2,],paf[,5],type="b",lwd=2,xlim=c(1,n*3+.5),ylim=c(0,max(paf[,5])),
+               plot(bp[2,],paf[,findPosInPaf("Power","time")],type="b",lwd=2,
+                    xlim=c(1,n*3+.5),ylim=c(0,max(paf[,findPosInPaf("Power","time")])),
                     axes=F,xlab="",ylab="",col=pafColors[3])
        
        axis(4, col=pafColors[3], line=0,padj=-.5)
@@ -759,13 +763,15 @@ findPosInPaf <- function(var, option) {
        if(var == "Speed")
                pos = 1
        else if(var == "Power")
-               pos = 3
+               pos = 4
        else if(var == "Load") #or Mass
-               pos = 7
-       else if(var == "Force")
                pos = 8
+       else if(var == "Force")
+               pos = 9
        if( ( var == "Speed" || var == "Power" || var == "Force") & option == "max")
                pos=pos+1
+       if( ( var == "Speed" || var == "Power") & option == "time")
+               pos=pos+2
        return(pos)
 }
 
@@ -833,7 +839,7 @@ paintCrossVariables <- function (paf, varX, varY, option, isAlone, title, single
 
 #propulsive!!!!
 paint1RMBadillo2010 <- function (paf, title) {
-       curvesLoad = (paf[,7])                                  #mass: X
+       curvesLoad = (paf[,findPosInPaf("Load","")])            #mass: X
        curvesSpeed = (paf[,findPosInPaf("Speed", "mean")])     #mean speed Y
 
        par(mar=c(5,6,3,4))
@@ -1340,7 +1346,9 @@ doProcess <- function(options) {
                                          curves[,1],
                                          curves[,2]-curves[,1],rawdata.cumsum[curves[,2]]-curves[,3],paf)
                        else {
-                               curvesHeight = curvesHeight[-discardedCurves]
+                               if(discardingCurves)
+                                       curvesHeight = curvesHeight[-discardedCurves]
+
                                paf=cbind(
                                          curves[,4],           #exerciseName
                                          curves[,5],           #mass
@@ -1349,8 +1357,10 @@ doProcess <- function(options) {
                        }
 
                        colnames(paf)=c("exercise","mass",
-                                       "start","width","height","meanSpeed","maxSpeed",
-                                       "meanPower","peakPower","peakPowerT","pp_ppt")
+                                       "start","width","height",
+                                       "meanSpeed","maxSpeed","maxSpeedT",
+                                       "meanPower","peakPower","peakPowerT",
+                                       "pp_ppt")
                        write.csv(paf, OutputData1, quote=FALSE)
                        print("curves written")
                }
diff --git a/src/encoder.cs b/src/encoder.cs
index 702cd95..33022c1 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -165,8 +165,10 @@ public class EncoderCurve
 
        //used on TreeView capture
        public EncoderCurve (string n, 
-                       string start, string duration, string height, string meanSpeed, string maxSpeed, 
-                       string meanPower, string peakPower, string peakPowerT, string PP_PPT)
+                       string start, string duration, string height, 
+                       string meanSpeed, string maxSpeed, string maxSpeedT,
+                       string meanPower, string peakPower, string peakPowerT, 
+                       string PP_PPT)
        {
                this.N = n;
                this.Start = start;
@@ -174,6 +176,7 @@ public class EncoderCurve
                this.Height = height;
                this.MeanSpeed = meanSpeed;
                this.MaxSpeed = maxSpeed;
+               this.MaxSpeedT = maxSpeedT;
                this.MeanPower = meanPower;
                this.PeakPower = peakPower;
                this.PeakPowerT = peakPowerT;
@@ -182,8 +185,10 @@ public class EncoderCurve
 
        //used on TreeView analyze
        public EncoderCurve (string n, string exercise, double extraWeight,
-                       string start, string duration, string height, string meanSpeed, string maxSpeed, 
-                       string meanPower, string peakPower, string peakPowerT, string PP_PPT)
+                       string start, string duration, string height,
+                       string meanSpeed, string maxSpeed, string maxSpeedT,
+                       string meanPower, string peakPower, string peakPowerT, 
+                       string PP_PPT)
        {
                this.N = n;
                this.Exercise = exercise;
@@ -193,6 +198,7 @@ public class EncoderCurve
                this.Height = height;
                this.MeanSpeed = meanSpeed;
                this.MaxSpeed = maxSpeed;
+               this.MaxSpeedT = maxSpeedT;
                this.MeanPower = meanPower;
                this.PeakPower = peakPower;
                this.PeakPowerT = peakPowerT;
@@ -207,6 +213,7 @@ public class EncoderCurve
        public string Height;
        public string MeanSpeed;
        public string MaxSpeed;
+       public string MaxSpeedT;
        public string MeanPower;
        public string PeakPower;
        public string PeakPowerT;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 62b5049..f4447a1 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1629,6 +1629,7 @@ public partial class ChronoJumpWindow
                        Catalog.GetString("Range") + "\n (cm)",
                        Catalog.GetString("MeanSpeed") + "\n (m/s)",
                        Catalog.GetString("MaxSpeed") + "\n (m/s)",
+                       Catalog.GetString("MaxSpeedTime") + "\n (s)",
                        Catalog.GetString("MeanPower") + "\n (W)",
                        Catalog.GetString("PeakPower") + "\n (W)",
                        Catalog.GetString("PeakPowerTime") + "\n (s)",
@@ -1659,7 +1660,8 @@ public partial class ChronoJumpWindow
                                                        //cells[2],     //mass
                                                        cells[3], cells[4], cells[5], 
                                                        cells[6], cells[7], cells[8], 
-                                                       cells[9], cells[10], cells[11]
+                                                       cells[9], cells[10], cells[11],
+                                                       cells[12]
                                                        ));
 
                        } while(true);
@@ -1708,15 +1710,18 @@ public partial class ChronoJumpWindow
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
                                        break;
                                case 6:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
                                        break;
                                case 7:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
                                        break;
                                case 8:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
                                        break;
                                case 9:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       break;
+                               case 10:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
                                        break;
                        }
@@ -1736,6 +1741,7 @@ public partial class ChronoJumpWindow
                        Catalog.GetString("Range") + "\n (cm)",
                        Catalog.GetString("MeanSpeed") + "\n (m/s)",
                        Catalog.GetString("MaxSpeed") + "\n (m/s)",
+                       Catalog.GetString("MaxSpeedTime") + "\n (s)",
                        Catalog.GetString("MeanPower") + "\n (W)",
                        Catalog.GetString("PeakPower") + "\n (W)",
                        Catalog.GetString("PeakPowerTime") + "\n (s)",
@@ -1796,7 +1802,9 @@ Log.WriteLine("f");
                                                        Convert.ToDouble(mass),
                                                        cells[3], cells[4], cells[5], 
                                                        cells[6], cells[7], cells[8], 
-                                                       cells[9], cells[10], cells[11]));
+                                                       cells[9], cells[10], cells[11],
+                                                       cells[12]
+                                                       ));
 
 Log.WriteLine("g");
                        } while(true);
@@ -1854,15 +1862,18 @@ Log.WriteLine("k");
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeed));
                                        break;
                                case 8:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxSpeedT));
                                        break;
                                case 9:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanPower));
                                        break;
                                case 10:
-                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPower));
                                        break;
                                case 11:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPeakPowerT));
+                                       break;
+                               case 12:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
                                        break;
                        }
@@ -2018,6 +2029,14 @@ Log.WriteLine("l");
                        String.Format("{0,10:0.000}",Convert.ToDouble(curve.MaxSpeed));
        }
        
+       private void RenderMaxSpeedT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               double time = Convert.ToDouble(curve.MaxSpeedT)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(time.ToString(),7,3),time);
+       }
+
        private void RenderMeanPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
        {
                EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
@@ -2066,7 +2085,7 @@ Log.WriteLine("l");
        {
                EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
                (cell as Gtk.CellRendererText).Text = 
-                       String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),curve.PP_PPT);
+                       String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),Convert.ToDouble(curve.PP_PPT));
        }
 
        /* end of rendering cols */
@@ -2077,12 +2096,12 @@ Log.WriteLine("l");
                for(int i=3; i <= 5; i++)
                        cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),1);
                
-               //meanSpeed,maxSpeed,meanPower,peakPower,peakPowerT
-               for(int i=6; i <= 10; i++)
+               //meanSpeed,maxSpeed,maxSpeedT, meanPower,peakPower,peakPowerT
+               for(int i=6; i <= 11; i++)
                        cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
                
                //pp/ppt
-               cells[11] = Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[11])),1); 
+               cells[12] = Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[12])),1); 
                return cells;
        }
        


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