[chronojump] On analyze show progress of readed and smoothed repetitions



commit f5d9da14746959d852144f7577d1b5151c36ad39
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri May 13 18:19:54 2016 +0200

    On analyze show progress of readed and smoothed repetitions

 encoder/call_graph.R       |    6 +++---
 encoder/graph.R            |   14 ++++++++------
 encoder/graphSmoothingEC.R |   18 ++++++++++--------
 src/encoderRProc.cs        |   35 ++++++++++++++++++++++++++++-------
 src/gui/encoder.cs         |   28 ++++++++++++++++++++--------
 5 files changed, 69 insertions(+), 32 deletions(-)
---
diff --git a/encoder/call_graph.R b/encoder/call_graph.R
index caebb63..13756eb 100644
--- a/encoder/call_graph.R
+++ b/encoder/call_graph.R
@@ -53,15 +53,15 @@ file.create(paste(FeedbackFileBase,"2.txt",sep=""))
 
 loadLibraries(OperatingSystem)
        
-print("Creating (FeedbackFileBase)3.txt with touch method...")
-file.create(paste(FeedbackFileBase,"3.txt",sep=""))
-       
 #open stdin connection
 f <- file("stdin")
 open(f)
 
 
 while(TRUE) {
+       print("Creating (FeedbackFileBase)3.txt with touch method...")
+       file.create(paste(FeedbackFileBase,"3.txt",sep=""))
+       
        doProcess(options)
 
        input <- readLines(f, n = 1L)
diff --git a/encoder/graph.R b/encoder/graph.R
index d2fe54e..a3da7fe 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2363,6 +2363,7 @@ doProcess <- function(options)
 
                                count = count + length(dataTempPhase)
                        }
+                       write(paste("***",i,"***",sep=""), stderr())
                }               
 
                #position=cumsum(displacement)
@@ -2388,6 +2389,8 @@ doProcess <- function(options)
                                            stringsAsFactors=F,row.names=1)
                }
 
+               print("Creating (op$FeedbackFileBase)4.txt with touch method...")
+               file.create(paste(op$FeedbackFileBase,"4.txt",sep=""))
 
                n=length(curves[,1])
                quitIfNoData(n, curves, op$OutputData1)
@@ -2546,9 +2549,8 @@ doProcess <- function(options)
 
        #make some check here, because this file is being readed in chronojump
 
-       #write(paste("(4/5)",translateToPrint("Repetitions processed")), op$FeedbackFileBase)
-       print("Creating (op$FeedbackFileBase)4.txt with touch method...")
-       file.create(paste(op$FeedbackFileBase,"4.txt",sep=""))
+       print("Creating (op$FeedbackFileBase)5.txt with touch method...")
+       file.create(paste(op$FeedbackFileBase,"5.txt",sep=""))
        #print(curves)
 
 
@@ -3319,9 +3321,9 @@ doProcess <- function(options)
 
        #make some check here, because this file is being readed in chronojump
        #write(paste("(5/5)",translateToPrint("R tasks done")), op$FeedbackFileBase)
-       print("Creating (op$FeedbackFileBase)5.txt with touch method...")
-       file.create(paste(op$FeedbackFileBase,"5.txt",sep=""))
-       write("created ...5.txt", stderr())
+       print("Creating (op$FeedbackFileBase)6.txt with touch method...")
+       file.create(paste(op$FeedbackFileBase,"6.txt",sep=""))
+       write("created ...6.txt", stderr())
 
        warnings()
 }
diff --git a/encoder/graphSmoothingEC.R b/encoder/graphSmoothingEC.R
index f30bd29..b7e90e8 100644
--- a/encoder/graphSmoothingEC.R
+++ b/encoder/graphSmoothingEC.R
@@ -102,6 +102,8 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
        } else {
                #on every curve...
                for(i in 1:n) {
+                       write(paste("***",i,"***",sep=""), stderr())
+
                        #maybe the global eccon == "ec" or "ce" but the individual eccon of each curve is 
"c", then just do the same as above
                        if( (singleFile && eccon == "c") || (! singleFile && curves[i,8] == "c") )
                                smoothings[i] = 0
@@ -164,10 +166,10 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
                                #write(paste("x, y", x, y), stderr())
 
 
-                               write("smooth.spline x (a)", stderr())  
-                               write(x, stderr())
-                               write("smooth.spline y (a)", stderr())  
-                               write(y, stderr())
+                               #write("smooth.spline x (a)", stderr()) 
+                               #write(x, stderr())
+                               #write("smooth.spline y (a)", stderr()) 
+                               #write(y, stderr())
                        
                                #if less than 4 unique x or y cannot smooth spline. Just use smoothingOneC as 
default value
                                if(length(unique(x)) < 4 || length(unique(y)) < 4) {
@@ -223,10 +225,10 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
                                                myEncoderConfigurationName, myDiameter, 100, 
myInertiaMomentum, myGearedDown)
                                
                        
-                               write("smooth.spline x (b)", stderr())
-                               write(x, stderr())
-                               write("smooth.spline y (b)", stderr())  
-                               write(y, stderr())
+                               #write("smooth.spline x (b)", stderr())
+                               #write(x, stderr())
+                               #write("smooth.spline y (b)", stderr()) 
+                               #write(y, stderr())
                                
                                #if less than 4 unique x or y cannot smooth spline. Just use recent calculed 
smoothingOneEC as default value
                                if(length(unique(x)) < 4 || length(unique(y)) < 4) {
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index ca5d812..5356d9e 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -32,6 +32,7 @@ public abstract class EncoderRProc
        public Status status;
        public bool Debug = false;
        public bool CrossValidate;
+       public int CurvesReaded;
 
        protected string optionsFile;   
        protected EncoderStruct es;
@@ -213,8 +214,24 @@ public abstract class EncoderRProc
        */
        protected void readingError (object sendingProcess, DataReceivedEventArgs errorFromR)
        {
-               if (! String.IsNullOrEmpty(errorFromR.Data))
-                       LogB.Warning(errorFromR.Data);
+               if (String.IsNullOrEmpty(errorFromR.Data))
+                       return;
+
+               string str = errorFromR.Data;
+               if(str.Length > 6 && str.StartsWith("***") && str.EndsWith("***")) {
+                       /*
+                        * 0123456
+                        * ***1***
+                        * str.Substring(3,1) 1 is the length
+                        */
+                       str = str.Substring(3, str.Length -6); 
+                       if(Util.IsNumber(str,false))
+                               CurvesReaded = Convert.ToInt32(str);
+
+                       return;
+               }
+               
+               LogB.Warning(str);
        }
 
        public void SendEndProcess() 
@@ -345,6 +362,8 @@ public class EncoderRProcAnalyze : EncoderRProc
 
        protected override bool startProcess() 
        {
+               CurvesReaded = 0;
+               
                //If output file is not given, R will try to write in the running folder
                //in which we may haven't got permissions
        
@@ -409,9 +428,9 @@ public class EncoderRProcAnalyze : EncoderRProc
                if(outputFileCheck2 != "")
                        deleteFile(outputFileCheck2);
                
-               //delete status-5 mark used on export csv
+               //delete status-6 mark used on export csv
                if(es.Ep.Analysis == "exportCSV")
-                       Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt");
+                       Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt");
 
                //delete 1RM data if exists
                string specialData = UtilEncoder.GetEncoderSpecialDataTempFileName();
@@ -459,6 +478,8 @@ public class EncoderRProcAnalyze : EncoderRProc
        
        protected override bool continueProcess() 
        {
+               CurvesReaded = 0;
+               
                //TODO: outputFileCheck creation/deletion here and at startProcess, should be unique
                string outputFileCheck = "";
                string outputFileCheck2 = "";
@@ -481,9 +502,9 @@ public class EncoderRProcAnalyze : EncoderRProc
                if(outputFileCheck2 != "")
                        deleteFile(outputFileCheck2);
                
-               //delete status-5 mark used on export csv
+               //delete status-6 mark used on export csv
                if(es.Ep.Analysis == "exportCSV")
-                       Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt");
+                       Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt");
                
                //delete 1RM data if exists
                string specialData = UtilEncoder.GetEncoderSpecialDataTempFileName();
@@ -519,7 +540,7 @@ public class EncoderRProcAnalyze : EncoderRProc
        //copy export from temp file to the file that user has selected
        private void copyExportedFile() {
                //wait first this status mark that is created when file is fully exported
-               while ( ! Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt") ) 
+               while ( ! Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt") ) 
                        ;
                //copy the file
                File.Copy(es.OutputData1, ExportFileName, true);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 2d38951..cd339b6 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2328,9 +2328,9 @@ public partial class ChronoJumpWindow
 
                encoderRProcAnalyze.StartOrContinue(encoderStruct);
        }
-       
+               
        /*
-        * 1) neurmuscular should be separated
+        * 1) neuromuscular should be separated
         * 2) if we are analyzing current set and it's concentric separate phases button has to be unsensitive
         * 3) single and side are together
         */
@@ -4731,18 +4731,29 @@ public partial class ChronoJumpWindow
                        }
                        */
 
-                       if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt")) 
+                       if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt")) 
                        {
-                               fraction = 5;
+                               fraction = 6;
                                contents = Catalog.GetString("R tasks done");
+                       }
+                       else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt")) 
+                       {
+                               fraction = 5;
+                               contents = "Smoothing done";
                        } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt")) 
                        {
                                fraction = 4;
-                               contents = Catalog.GetString("Repetitions processed");
+                               if(encoderRProcAnalyze.CurvesReaded > 0)
+                                       contents = encoderRProcAnalyze.CurvesReaded.ToString();
+                               else
+                                       contents = Catalog.GetString("Repetitions processed");
                        } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt")) 
                        {
                                fraction = 3;
-                               contents = Catalog.GetString("Starting process");
+                               if(encoderRProcAnalyze.CurvesReaded > 0)
+                                       contents = encoderRProcAnalyze.CurvesReaded.ToString();
+                               else
+                                       contents = Catalog.GetString("Starting process");
                        } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "2.txt")) 
                        {
                                fraction = 2;
@@ -4757,14 +4768,14 @@ public partial class ChronoJumpWindow
                                if(fraction == -1)
                                        encoder_pulsebar_capture.Pulse();
                                else
-                                       encoder_pulsebar_capture.Fraction = Util.DivideSafeFraction(fraction, 
5); 
+                                       encoder_pulsebar_capture.Fraction = Util.DivideSafeFraction(fraction, 
6); 
                                
                                encoder_pulsebar_capture.Text = contents;
                        } else {
                                if(fraction == -1)
                                        encoder_pulsebar_analyze.Pulse();
                                else
-                                       encoder_pulsebar_analyze.Fraction = Util.DivideSafeFraction(fraction, 
5);
+                                       encoder_pulsebar_analyze.Fraction = Util.DivideSafeFraction(fraction, 
6);
 
                                encoder_pulsebar_analyze.Text = contents;
                        }
@@ -5268,6 +5279,7 @@ public partial class ChronoJumpWindow
                Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt");
                Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt");
                Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt");
+               Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt");
        }
 
        /*


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