[chronojump] Realtime capture better start/end curves



commit 3120082258e22508f3ae2a4b7777abc784498e38
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Nov 1 21:53:36 2013 +0100

    Realtime capture better start/end curves

 encoder/graph.R    |    8 +++++++-
 src/gui/encoder.cs |   28 +++++++++++++++++++++++-----
 2 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 9d16208..56bffd4 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1785,13 +1785,19 @@ doProcess <- function(options) {
                                #     side=1,text=myLabel, cex=.8, col="blue")
                                abline(v=c(curves[i,1],curves[i,2])/1000, lty=3, col="gray")
                        }
-                       
+               
+                       #abline(v=c(820,2361,3255)/1000,col="green")
+                       #abline(v=c(1441,2731,3630)/1000,col="red")
+
+
+
                        #plot speed
                        par(new=T)      
                        speed <- smooth.spline( 1:length(rawdata), rawdata, spar=smoothingAll)
                        plot((1:length(rawdata))/1000, speed$y, col="gray",
                                type="l", 
                                xlim=c(1,length(rawdata))/1000, #ms -> s
+                               #ylim=c(-.25,.25),              #to test speed at small changes
                                xlab="",ylab="",axes=F)
                        mtext("speed ",side=4,adj=1,line=-1,col="gray")
                        abline(h=0,lty=2,col="gray")
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 5c3f37b..6f1408f 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1903,16 +1903,32 @@ 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
+                                               if(startFrame < 0)
+                                                       startFrame = 0;
+
                                                EncoderCaptureCurve ecc = new EncoderCaptureCurve(
                                                                ! Util.IntToBool(directionNow), //if we go 
now UP, then record previous DOWN phase
-                                                               previousFrameChange,
-                                                               ( (i + lastNonZero)/2 ) //end between i and 
start of the zeros (end at 1/2 of zeros)
-                                                               - directionChangePeriod //and obviously - 
directionChangePeriod
+                                                               startFrame,
+                                                               (i - directionChangeCount + lastNonZero)/2    
  //endFrame
+                                                               //to find endFrame, first substract 
directionChangePeriod from i
+                                                               //then find the middle point between that and 
lastNonZero
                                                                );
                                                ecca.ecc.Add(ecc);
 
-                                               previousFrameChange = i;
+
+                                               previousFrameChange = i - directionChangeCount;
+
                                                directionChangeCount = 0;
                                                directionCompleted = directionNow;
                                        }
@@ -3886,6 +3902,8 @@ Log.WriteLine(str);
                        //this code:  pp_ppt = peakPower / peakPowerT
                        rengine.Evaluate("peakPowerT=min(which(power == peakPower))"); 
 
+                       //rengine.Evaluate("print(speed$y)");
+                       
                        rengine.Evaluate("meanSpeed = mean(abs(speed$y))");
                        double meanSpeed = rengine.GetSymbol("meanSpeed").AsNumeric().First();
 


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