[chronojump] Encoder capture data == graph.R data



commit 2640faa3aac4c4681467f52d4bedd5d4fa9ff657
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jan 22 00:06:26 2015 +0100

    Encoder capture data == graph.R data

 encoder/capture.R  |   42 ++----------------------------------------
 src/gui/encoder.cs |   39 +++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 52 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 6b997ec..c8dddc5 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -20,15 +20,12 @@ getOptionsFromFile <- function(optionsFile, lines) {
        return (options)
 }
 
-#options <- getOptionsFromFile(optionsFile, 1)
 options <- getOptionsFromFile(optionsFile, 32)
 
 
-#scriptUtilR = options[1]
 scriptUtilR = options[28]
 source(scriptUtilR)
 
-#print("Loaded libraries")
        
 input <- readLines(f, n = 1L)
 while(input[1] != "Q") {
@@ -54,33 +51,16 @@ while(input[1] != "Q") {
                displacement = getDisplacement(op$EncoderConfigurationName, displacement, op$diameter, 
op$diameterExt)
        }
        
-       write(displacement,stderr())
        position = cumsum(displacement)
-       write(position,stderr())
-               
-       #curves=findCurves(displacement, op$Eccon, op$MinHeight, FALSE, op$Title) #draw: FALSE
-       #print("curves",stderr())
-       #print(curves,stderr())
-                               
+
        if( ! isInertial(op$EncoderConfigurationName)) {
                reduceTemp = reduceCurveBySpeed(op$Eccon, 1, 
-                                               #curves[1,1], curves[1,3], #startT, startH
                                                1, 0, #startT, startH
                                                displacement, #displacement
                                                op$SmoothingOneC #SmoothingOneC
                                                )
-                               
-               #curves[1,1] = reduceTemp[1]
-               #curves[1,2] = reduceTemp[2]
-               #curves[1,3] = reduceTemp[3]
        }
                
-#      SmoothingsEC = findSmoothingsEC(singleFile, displacement, curves, op$Eccon, op$SmoothingOneC)
-#      write(c("SmoothingsEC:",SmoothingsEC),stderr())
-       
-       write("curves after reduceCurveBySpeed",stderr())
-       #write(as.vector(curves[1,]),stderr())
-
        start = reduceTemp[1]
        end = reduceTemp[2]
        #write("printing reduceTemp2", stderr())
@@ -88,16 +68,8 @@ while(input[1] != "Q") {
        if(end > length(displacement))
                end = length(displacement)
        
-       #write("printing reduceTemp", stderr())
-       #write(c(start, end, length(displacement)),stderr())
+       displacement = displacement[start:end]
 
-       #displacement = displacement[start:end]
-
-       #print("reduced")
-
-       #if(curves[1,2] > length(displacement)) 
-       #       curves[1,2] = length(displacement)
-                               
        g = 9.81
                    
        #read AnalysisOptions
@@ -110,28 +82,18 @@ while(input[1] != "Q") {
        #simplify on capture and have the SmoothingEC == SmoothingC
        SmoothingsEC = op$SmoothingOneC
 
-       #print("pre kinematicsResult")
-
-
-       #kinematicsResult <- kinematicsF(displacement[curves[1,1]:curves[1,2]], 
        kinematicsResult <- kinematicsF(displacement, 
                    op$MassBody, op$MassExtra, op$ExercisePercentBodyWeight,
                    op$EncoderConfigurationName, op$diameter, op$diameterExt, op$anglePush, op$angleWeight, 
op$inertiaMomentum, op$gearedDown,
-                   #SmoothingsEC[1], op$SmoothingOneC, 
                    SmoothingsEC, op$SmoothingOneC, 
                    g, op$Eccon, isPropulsive)
-       #print("kinematicsResult")
-       #print(kinematicsResult)
 
        paf = data.frame()
        paf = pafGenerate(op$Eccon, kinematicsResult, op$MassBody, op$MassExtra)
-       #write("paf",stderr())
-       #write(paf,stderr())
 
        #do not use print because it shows the [1] first. Use cat:
        cat(paste(#start, #start is not used because we have no data of the initial zeros
                  (end-start), (position[end]-position[start]),
-                 #curves[1,2]-curves[1,1], position[curves[1,2]]-curves[1,3],
                  paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, paf$meanPower, paf$peakPower, paf$peakPowerT, 
paf$pp_ppt, 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/src/gui/encoder.cs b/src/gui/encoder.cs
index e3090a7..71985eb 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2021,6 +2021,7 @@ public partial class ChronoJumpWindow
                int directionLastMSecond = 1;   // +1 or -1 (direction on last millisecond)
                int directionCompleted = -1;    // +1 or -1
                int previousFrameChange = 0;
+               int previousEnd = 0;
                int lastNonZero = 0;
 
                //this will be used to stop encoder automatically       
@@ -2125,16 +2126,22 @@ public partial class ChronoJumpWindow
                                        //count >= than change_period
                                        if(directionChangeCount > directionChangePeriod)
                                        {
-                                               int startFrame = previousFrameChange - directionChangeCount;  
  //startFrame
-                                                               //at startFrame we do the 
"-directionChangePeriod" because
-                                                               //we want data a little bit earlier, because 
we want some zeros
-                                                               //that will be removed by reduceCurveBySpeed
-                                                               //if not done, then the data:
-                                                               //0 0 0 0 0 0 0 0 0 1
-                                                               //will start at 10th digit (the 1)
-                                                               //if done, then at speed will be like this:
-                                                               //0 0 0 0.01 0.04 0.06 0.07 0.08 0.09 1
-                                                               //and will start at fourth digit
+                                               //int startFrame = previousFrameChange - 
directionChangeCount;  //startFrame
+                                                               /*
+                                                                * at startFrame we do the 
"-directionChangePeriod" because
+                                                                * we want data a little bit earlier, because 
we want some zeros
+                                                                * that will be removed by reduceCurveBySpeed
+                                                                * if not done, then the data:
+                                                                * 0 0 0 0 0 0 0 0 0 1
+                                                                * will start at 10th digit (the 1)
+                                                                * if done, then at speed will be like this:
+                                                                * 0 0 0 0.01 0.04 0.06 0.07 0.08 0.09 1
+                                                                * and will start at fourth digit
+                                                                */
+
+                                               //this is better, takes a lot of time before, and then 
reduceCurveBySpeed will cut it
+                                               int startFrame = previousEnd;   //startFrame
+                                               LogB.Debug("startFrame",startFrame.ToString());
                                                if(startFrame < 0)
                                                        startFrame = 0;
 
@@ -2146,9 +2153,11 @@ public partial class ChronoJumpWindow
                                                                //to find endFrame, first substract 
directionChangePeriod from i
                                                                //then find the middle point between that and 
lastNonZero
                                                                );
-                               
-                                               if(useRDotNet)
+               
+                                               if(useRDotNet) {
                                                        ecca.ecc.Add(ecc);
+                                                       previousEnd = ecc.endFrame;
+                                               }
                                                else {
                                                        //on 1.4.9 secundary thread was capturing
                                                        //while main thread was calculing with RDotNet and 
updating GUI
@@ -2166,6 +2175,8 @@ public partial class ChronoJumpWindow
                                                                        curve[k]=encoderReaded[j];
                                                                        k++;
                                                                }
+                                                                       
+                                                               previousEnd = ecc.endFrame;
                                                                
                                                                //check heightCurve in a fast way first to 
discard curves soon
                                                                //only process curves with height >= 
min_height
@@ -2185,9 +2196,13 @@ public partial class ChronoJumpWindow
                                                }
                                                
 
+                                               LogB.Debug("i", i.ToString());
+                                               LogB.Debug("directionChangeCount", 
directionChangeCount.ToString());
 
                                                previousFrameChange = i - directionChangeCount;
 
+                                               LogB.Debug("previousFrameChange", 
previousFrameChange.ToString());
+
                                                directionChangeCount = 0;
                                                directionCompleted = directionNow;
 


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