[chronojump] capture.R has repetition start. Good to display on GUI and will be used to autosave on cont without



commit 8f3cf392547743668207f4f8c701dab999633066
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 8 19:05:36 2017 +0100

    capture.R has repetition start. Good to display on GUI and will be used to autosave on cont without R 
curves

 encoder/capture.R     |   21 +++++++++++++++------
 src/encoder.cs        |   15 +++++++++++----
 src/encoderCapture.cs |    4 +++-
 src/encoderRProc.cs   |    6 +++++-
 src/gui/encoder.cs    |   12 ++++++------
 5 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 3dd4a70..5bec050 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -27,7 +27,8 @@ filenameCompose <- function(curveNum)
 }
 
 #calcule <- function(displacement, start, end, op, curveNum)
-calcule <- function(displacement, op, curveNum)
+#startInSet: know when this repetition starts in the current set
+calcule <- function(displacement, op, curveNum, startInSet)
 {
        #if(debug)
        #       write("At calcule", stderr())
@@ -89,7 +90,8 @@ calcule <- function(displacement, op, curveNum)
        filename <- filenameCompose(curveNum)
        con <- file(filename, "w")
        cat(paste(#start, #start is not used because we have no data of the initial zeros
-                 (curveNum +1), sum(displacement), #title, height
+                 (curveNum +1), startInSet, length(displacement), #title, start, width
+                 sum(displacement), #height
                  paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, 
                  paf$meanPower, paf$peakPower, paf$peakPowerT, paf$pp_ppt, 
                  paf$meanForce, paf$maxForce, paf$maxForceT,
@@ -134,6 +136,7 @@ doProcess <- function(options)
        #print (op)
 
        curveNum = 0
+       startInSet = 1
 
        #Don't measure on first phase (initial eccentric) 
        #inertialCapturingFirstPhase = TRUE
@@ -163,8 +166,8 @@ doProcess <- function(options)
                        op <- assignOptions(options)
                        DEBUG <<- op$Debug
 
-
                        curveNum = 0
+
                        #inertialCapturingFirstPhase = TRUE
                        input <- readLines(f, n = 1L)
        
@@ -177,6 +180,9 @@ doProcess <- function(options)
 
                #-- read the curve (from some lines that finally end on an 'E')
                readingCurve = TRUE
+               startInSet <- as.numeric(input)
+               input = ""
+               print(paste("startInSet: ", startInSet))
                while(readingCurve) {
                        inputLine <- readLines(f, n = 1L)
                        if(inputLine[1] == "E")
@@ -223,6 +229,10 @@ doProcess <- function(options)
                start = reduceTemp[1]
                end = reduceTemp[2]
 
+               #reduceCurveBySpeed reduces the curve. Then startInSet has to change:
+               print(paste("start:",start))
+               startInSet = startInSet + start
+
                #reduceCurveBySpeed, on inertial doesn't do a good right adjust on changing phase,
                #it adds a value at right, and this value is a descending value that can produce a high 
acceleration there
                #delete that value
@@ -248,12 +258,11 @@ doProcess <- function(options)
                {
                        if(abs(max(position) - min(position)) >= op$MinHeight) {
                                #Update. Since 1.6.1 on inertial at C# two curves are sent "e" and "c"
-                               curveNum <- calcule(displacement, op, curveNum)
+                               curveNum <- calcule(displacement, op, curveNum, startInSet)
                        }
                } else {
-                       curveNum <- calcule(displacement, op, curveNum)
+                       curveNum <- calcule(displacement, op, curveNum, startInSet)
                }
-               
 
                #if(debug)
                #       write("doProcess 4", stderr())
diff --git a/src/encoder.cs b/src/encoder.cs
index ae4492e..7b68bd4 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -969,7 +969,8 @@ public class Encoder1RM
        ~Encoder1RM() {}
 }
 
-public class EncoderCaptureCurve {
+public class EncoderCaptureCurve
+{
        public bool up;
        public int startFrame;
         public int endFrame;
@@ -987,18 +988,24 @@ public class EncoderCaptureCurve {
                        return "DOWN";
        }
 
+       public override string ToString()
+       {
+               return "ECC: " + up.ToString() + ";" + startFrame.ToString() + ";" + endFrame.ToString();
+       }
+
        ~EncoderCaptureCurve() {}
 }
 
-public class EncoderCaptureCurveArray {
+public class EncoderCaptureCurveArray
+{
        public ArrayList ecc;   //each of the EncoderCaptureCurve
        public int curvesAccepted; //starts at int 0. How many ecc have been accepted (will be rows in 
treeview_encoder_capture_curves)
        
        public EncoderCaptureCurveArray() {
-               ecc = new ArrayList();
+               ecc = new ArrayList(0);
                curvesAccepted = 0;
        }
-       
+
        ~EncoderCaptureCurveArray() {}
 }
 
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index b4e34c3..12b7f51 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -482,11 +482,13 @@ public abstract class EncoderCapture
                                                                Networks.WakeUpRaspberryIfNeeded();
 
                                                        encoderRProcCapture.SendCurve(
+                                                                       ecc.startFrame,
                                                                        UtilEncoder.CompressData(curve, 25)   
  //compressed
                                                                        );
 
                                                        Ecca.curvesAccepted ++;
                                                        Ecca.ecc.Add(ecc);
+                                                       LogB.Information(ecc.ToString());
 
                                                        lastDirectionStoredIsUp = ecc.up;
                                                }
@@ -941,7 +943,7 @@ public class BoolMsList
        }
 
        //just to debug
-       public void ToString()
+       public void Print()
        {
                LogB.Information("Printing BoolMSList");
                foreach(BoolMs boolMs in l)
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index c40279b..cfdc9b3 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -209,7 +209,7 @@ public class EncoderRProcCapture : EncoderRProc
        }
        
        //here curve is sent compressed (string. eg: "0*5 1 0 -1*3 2")
-       public void SendCurve(string curveCompressed)
+       public void SendCurve(int startFrame, string curveCompressed)
        {
                /*
                 * curveCompressed print has made crash Chronojump once.
@@ -218,6 +218,10 @@ public class EncoderRProcCapture : EncoderRProc
                 */
                //LogB.Information("curveSend [displacement array]",curveCompressed);
 
+               //since 1.7.1 it's needed to send the startFrame in order to know the startFrame of the 
accepted repetitions (on R)
+               //then this data will be used to save the "Best?" repetitions on C# without calling curves on 
cont mode
+               p.StandardInput.WriteLine(startFrame.ToString());
+
                p.StandardInput.WriteLine(curveCompressed);     //this will send some lines because 
compressed data comes with '\n's
                p.StandardInput.WriteLine("E");         //this will mean the 'E'nd of the curve. Then data 
can be uncompressed on R
        }       
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 11693aa..9fcc488 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5118,12 +5118,12 @@ public partial class ChronoJumpWindow
                                                "{1},{2},{3}," + //start, width, height
                                                "{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}",
                                        strs[0],
-                                       0, 0, strs[1],                  //start, width, height
-                                       strs[2], strs[3], strs[4],      //speeds
-                                       strs[5], strs[6], strs[7],      //powers
-                                       strs[8],                        //pp/ppt
-                                       strs[9], strs[10], strs[11]));  //forces
-                       
+                                       strs[1], strs[2], strs[3],      //start, width, height
+                                       strs[4], strs[5], strs[6],      //speeds
+                                       strs[7], strs[8], strs[9],      //powers
+                                       strs[10],                       //pp/ppt
+                                       strs[11], strs[12], strs[13])); //forces
+
                        //LogB.Debug("encoderCaptureStringR");
                        //LogB.Debug(encoderCaptureStringR);
 


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