[chronojump] showing force on encoder capture tab (done)



commit d367da0d23c142a050298a84e6bccf5b7a19eb3a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 20 17:41:01 2015 +0100

    showing force on encoder capture tab (done)

 encoder/capture.R           |    5 +++-
 encoder/graph.R             |    3 +-
 src/encoder.cs              |   10 ++++++-
 src/gui/encoder.cs          |   10 ++++---
 src/gui/encoderTreeviews.cs |   59 +++++++++++++++++++++++++++++++++++++------
 5 files changed, 72 insertions(+), 15 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 6f75c83..6cb0929 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -68,7 +68,10 @@ calcule <- function(displacement, start, end, op)
        cat(paste(#start, #start is not used because we have no data of the initial zeros
                  #(end-start), (position[end]-position[start]), #this is not used because the start, end 
values are not ok now
                  0, 0, 
-                 paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, paf$meanPower, paf$peakPower, paf$peakPowerT, 
paf$pp_ppt, sep=", "))
+                 paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, 
+                 paf$meanPower, paf$peakPower, paf$peakPowerT, paf$pp_ppt, 
+                 paf$meanForce, paf$maxForce, paf$maxForceT,
+                 sep=", "))
        cat("\n") #mandatory to read this from C#, but beware, there we will need a trim to remove the 
windows \r\n
 }
                
diff --git a/encoder/graph.R b/encoder/graph.R
index 2b8eb87..fa989a6 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2390,7 +2390,8 @@ doProcess <- function(options)
                                        "start","width","height",
                                        "meanSpeed","maxSpeed","maxSpeedT",
                                        "meanPower","peakPower","peakPowerT",
-                                       "pp_ppt")
+                                       "pp_ppt",
+                                       "meanForce", "maxForce", "maxForceT")
                        write.csv(paf, op$OutputData1, quote=FALSE)
                        print("curves written")
                }
diff --git a/src/encoder.cs b/src/encoder.cs
index 975b25c..38b0f72 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -211,6 +211,9 @@ public class EncoderCurve
        public string PeakPower;
        public string PeakPowerT;
        public string PP_PPT;
+       public string MeanForce;
+       public string MaxForce;
+       public string MaxForceT;
        
        public EncoderCurve () {
        }
@@ -220,7 +223,9 @@ public class EncoderCurve
                        string start, string duration, string height, 
                        string meanSpeed, string maxSpeed, string maxSpeedT,
                        string meanPower, string peakPower, string peakPowerT, 
-                       string PP_PPT)
+                       string PP_PPT,
+                       string meanForce, string maxForce, string maxForceT
+                       )
        {
                this.Record = record;
                this.N = n;
@@ -234,6 +239,9 @@ public class EncoderCurve
                this.PeakPower = peakPower;
                this.PeakPowerT = peakPowerT;
                this.PP_PPT = PP_PPT;   //PeakPower / PeakPowerTime
+               this.MeanForce = meanForce;
+               this.MaxForce = maxForce;
+               this.MaxForceT = maxForceT;
        }
 
        //used on TreeView analyze
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 459b254..62ce670 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2168,7 +2168,6 @@ public partial class ChronoJumpWindow
                                 * Just -1 all the past and future values of this capture
                                 * (we use the 'sum > 0' to know that it's going upwards)
                                 */
-                               LogB.Debug("--sum--", sum.ToString());
                                if(
                                                ! inertialCaptureDirectionChecked &&
                                                encoderConfigurationCurrent.has_inertia && 
@@ -4643,7 +4642,9 @@ public partial class ChronoJumpWindow
                                        treeviewEncoderCaptureRemoveColumns();
                                        encoderCaptureStringR = 
                                                ",series,exercise,mass,start,width,height," + 
-                                               
"meanSpeed,maxSpeed,maxSpeedT,meanPower,peakPower,peakPowerT,pp_ppt,NA,NA,NA";
+                                               "meanSpeed,maxSpeed,maxSpeedT," +
+                                               "meanPower,peakPower,peakPowerT,pp_ppt," +
+                                               "meanForce, maxForce, maxForceT";
 
                                        capturingCsharp = encoderCaptureProcess.CAPTURING;
 
@@ -5000,13 +5001,14 @@ LogB.Debug("D");
                        
                        string [] strs = trimmed.Split(new char[] {','});
 
-                       encoderCaptureStringR += 
string.Format("\n{0},2,a,3,4,{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},7",
+                       encoderCaptureStringR += 
string.Format("\n{0},2,a,3,4,{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}",
                                        0,
                                        0, strs[0],                     //start, width
                                        strs[1],                        //height
                                        strs[2], strs[3], strs[4],      //speeds
                                        strs[5], strs[6], strs[7],      //powers
-                                       strs[8]);                       //pp/ppt
+                                       strs[8],                        //pp/ppt
+                                       strs[9], strs[10], strs[11]);   //forces
                        
                        LogB.Debug("encoderCaptureStringR");
                        LogB.Debug(encoderCaptureStringR);
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index e5d12cd..ba26bdd 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -49,7 +49,10 @@ public partial class ChronoJumpWindow
                        "p" + "\n (W)",
                        "pmax" + "\n (W)",
                        "t->pmax" + "\n (s)",
-                       "pmax/t->pmax" + "\n (W/s)"
+                       "pmax/t->pmax" + "\n (W/s)",
+                       "F" + "\n (N)",
+                       "Fmax" + "\n (N)",
+                       "t->Fmax" + "\n (s)"
                };
 
                encoderCaptureCurves = new ArrayList ();
@@ -68,7 +71,7 @@ public partial class ChronoJumpWindow
                                curvesCount ++;
 
                                string [] cells = line.Split(new char[] {','});
-                               cells = fixDecimals(cells);
+                               cells = fixDecimals(cells, true); //useForce
 
                                encoderCaptureCurves.Add (new EncoderCurve (
                                                        false,                          //user need to mark 
to save them
@@ -77,10 +80,11 @@ public partial class ChronoJumpWindow
                                                        //cells[2],     //exerciseName
                                                        //cells[3],     //massBody
                                                        //cells[4],     //massExtra
-                                                       cells[5], cells[6], cells[7], //start, duration, 
height 
-                                                       cells[8], cells[9], cells[10], //meanSpeed, maxSpeed, 
maxSpeedT
-                                                       cells[11], cells[12], cells[13], //meanPower, 
peakPower, peakPowerT
-                                                       cells[14]                       //peakPower / 
peakPowerT
+                                                       cells[5], cells[6], cells[7],   //start, duration, 
height 
+                                                       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, 
maxSForce maxForceT
                                                        ));
 
                        } while(true);
@@ -158,6 +162,15 @@ public partial class ChronoJumpWindow
                                case 10:
                                        aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderPP_PPT));
                                        break;
+                               case 11:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMeanForce));
+                                       break;
+                               case 12:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForce));
+                                       break;
+                               case 13:
+                                       aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc 
(RenderMaxForceT));
+                                       break;
                        }
                                        
                        if( ! ( (i == 1 || i == 2) && ! showStartAndDuration ) )
@@ -479,7 +492,7 @@ public partial class ChronoJumpWindow
                                curvesCount ++;
 
                                string [] cells = line.Split(new char[] {','});
-                               cells = fixDecimals(cells);
+                               cells = fixDecimals(cells, false); //not useForce
                                
                                
                                if(! check_encoder_analyze_signal_or_curves.Active) {   //user curves
@@ -963,6 +976,31 @@ public partial class ChronoJumpWindow
                        String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),Convert.ToDouble(curve.PP_PPT));
        }
        
+       /* end of rendering analyze cols. Following gols are only on capture */
+
+       private void RenderMeanForce (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = 
+                       
String.Format(UtilGtk.TVNumPrint(curve.MeanPower,7,1),Convert.ToDouble(curve.MeanForce));
+       }
+
+       private void RenderMaxForce (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               (cell as Gtk.CellRendererText).Text = 
+                       
String.Format(UtilGtk.TVNumPrint(curve.MeanPower,7,1),Convert.ToDouble(curve.MaxForce));
+       }
+       
+       private void RenderMaxForceT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, 
Gtk.TreeIter iter)
+       {
+               EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+               double time = Convert.ToDouble(curve.MaxForceT)/1000; //ms->s
+               (cell as Gtk.CellRendererText).Text = 
+                       String.Format(UtilGtk.TVNumPrint(time.ToString(),5,3),time);
+       }
+
+       
        /* end of rendering capture and analyze cols */
 
        /* start rendering neuromuscular cols */
@@ -1073,7 +1111,7 @@ public partial class ChronoJumpWindow
        /* end of rendering neuromuscular cols */
        
        
-       private string [] fixDecimals(string [] cells) {
+       private string [] fixDecimals(string [] cells, bool useForce) {
                //start, width, height
                for(int i=5; i <= 7; i++)
                        cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),1);
@@ -1085,6 +1123,11 @@ public partial class ChronoJumpWindow
                //pp/ppt
                int pp_ppt = 14;
                cells[pp_ppt] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[pp_ppt])),1); 
+
+               if(useForce)
+                       for(int i=15; i <= 17; i++)
+                               cells[i] = 
Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
+
                return cells;
        }
        


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