[chronojump] Capture.R called with a small call_capture.R to be faster



commit 0e27ab98c2a41c19e9655f0c3e764400882567cd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Mar 13 10:40:34 2015 +0100

    Capture.R called with a small call_capture.R to be faster

 encoder/Makefile.am    |    1 +
 encoder/call_capture.R |   41 +++++++++++++++++++++++++++++++++++++++++
 encoder/call_graph.R   |   22 ----------------------
 encoder/capture.R      |   43 +------------------------------------------
 src/constants.cs       |    1 +
 src/gui/encoder.cs     |    6 +++---
 src/utilEncoder.cs     |    5 +++++
 7 files changed, 52 insertions(+), 67 deletions(-)
---
diff --git a/encoder/Makefile.am b/encoder/Makefile.am
index a485df8..9edd899 100644
--- a/encoder/Makefile.am
+++ b/encoder/Makefile.am
@@ -1,6 +1,7 @@
 encoderdatadir = @datadir@/@PACKAGE@/encoder
 
 dist_encoderdata_DATA = pyserial_pyper.py \
+            call_capture.R \
             call_graph.R \
             capture.R \
             graph.R \
diff --git a/encoder/call_capture.R b/encoder/call_capture.R
new file mode 100644
index 0000000..522e005
--- /dev/null
+++ b/encoder/call_capture.R
@@ -0,0 +1,41 @@
+# 
+#  This file is part of ChronoJump
+#   Copyright (C) 2015         Xavier de Blas <xaviblas gmail com> 
+# 
+
+#Is A LOT faster to call this file from C#, and this file will do a source(scriptCaptureR)
+#than calling that file directly
+#
+
+
+args <- commandArgs(TRUE)
+optionsFile <- args[1]
+#print(optionsFile)
+
+#--- user commands ---
+getOptionsFromFile <- function(optionsFile, lines) {
+       optionsCon <- file(optionsFile, 'r')
+       options=readLines(optionsCon, n=lines)
+       close(optionsCon)
+       return (options)
+}
+
+options <- getOptionsFromFile(optionsFile, 32)
+
+scriptUtilR = options[28]
+source(scriptUtilR)
+
+scriptCaptureR = options[1]
+
+#comes ".../chronojump-captured"
+#will be ".../chronojump-captured-000.txt", 001 ... 999
+filenameBegins = options[2] 
+
+source(scriptCaptureR)
+
+f <- file("stdin")
+open(f)
+
+doProcess(options)
+write("Ending capture.R", stderr())
+quit()
diff --git a/encoder/call_graph.R b/encoder/call_graph.R
index a0e699b..72b2ca8 100644
--- a/encoder/call_graph.R
+++ b/encoder/call_graph.R
@@ -1,32 +1,10 @@
 # 
 #  This file is part of ChronoJump
-# 
-#  ChronoJump is free software; you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or   
-#     (at your option) any later version.
-#     
-#  ChronoJump is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
-#     GNU General Public License for more details.
-# 
-#  You should have received a copy of the GNU General Public License
-#   along with this program; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# 
 #   Copyright (C) 2014-2015    Xavier de Blas <xaviblas gmail com> 
 # 
 
 #Is A LOT faster to call this file from C#, and this file will do a source(scriptGraphR)
 #than calling that file directly
-#
-#This call_graph.R is not written for this purpose,
-#it's written to be called if RDotNet is not working. Then this fill will call graph.R
-#
-#if RDotNet works, then graph.R will be in memory and there's no need to write Roptions.txt,
-#and there's no nead reading it from here because it will be done using RDotNet
-
 
 
 args <- commandArgs(TRUE)
diff --git a/encoder/capture.R b/encoder/capture.R
index ae008f9..f532303 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -1,20 +1,6 @@
 # 
 #  This file is part of ChronoJump
 # 
-#  ChronoJump is free software; you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or   
-#     (at your option) any later version.
-#     
-#  ChronoJump is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
-#     GNU General Public License for more details.
-# 
-#  You should have received a copy of the GNU General Public License
-#   along with this program; if not, write to the Free Software
-#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# 
 #   Copyright (C) 2014-2015    Xavier de Blas <xaviblas gmail com> 
 # 
 
@@ -26,33 +12,10 @@
 
 write("Arriving at capture.R", stderr())
 
-f <- file("stdin")
-open(f)
-
-
-args <- commandArgs(TRUE)
-optionsFile <- args[1]
-
-
-getOptionsFromFile <- function(optionsFile, lines) {
-       optionsCon <- file(optionsFile, 'r')
-       options=readLines(optionsCon, n=lines)
-       close(optionsCon)
-       return (options)
-}
-
-options <- getOptionsFromFile(optionsFile, 32)
-
-
-scriptUtilR = options[28]
-source(scriptUtilR)
-
 g = 9.81
 
 debug = FALSE
                    
-filenameBegins = options[1] #comes ".../chronojump-captured". will be ".../chronojump-captured-000.txt", 001 
... 999
-
 filenameCompose <- function(curveNum)
 {
        if(curveNum > 99)
@@ -155,7 +118,7 @@ uncompress <- function(curveSent)
        return (as.numeric(ints))
 }
 
-doProcess <- function() 
+doProcess <- function(options) 
 {
        if(debug)
                write("doProcess", stderr())
@@ -270,7 +233,3 @@ doProcess <- function()
 
 }
                
-
-doProcess()
-write("Ending capture.R", stderr())
-quit()
diff --git a/src/constants.cs b/src/constants.cs
index f01740e..e893890 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -702,6 +702,7 @@ public class Constants
        
        //public static string EncoderScriptCapturePythonLinux = "pyserial_pyper.py";
        //public static string EncoderScriptCapturePythonWindows = "pyserial_pyper_windows.exe";
+       public static string EncoderScriptCallCaptureNoRDotNet = "call_capture.R";
        public static string EncoderScriptCaptureNoRDotNet = "capture.R";
        public static string EncoderScriptCallGraph = "call_graph.R";
        public static string EncoderScriptGraph = "graph.R";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f885265..aa27f61 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4921,8 +4921,8 @@ public partial class ChronoJumpWindow
                                );
 
                EncoderStruct es = new EncoderStruct(
-                               UtilEncoder.GetEncoderCaptureTempFileName(), 
//UtilEncoder.GetEncoderDataTempFileName(), //used here print the captured data file
-                               "none", //UtilEncoder.GetEncoderGraphTempFileName(),
+                               UtilEncoder.GetEncoderScriptCaptureNoRdotNet(),//1st option used here to 
allow to call the main capture script
+                               UtilEncoder.GetEncoderCaptureTempFileName(),   //2nd option used here to 
print the captured data file
                                "none", //UtilEncoder.GetEncoderCurvesTempFileName(), 
                                "none", //UtilEncoder.GetEncoderStatusTempBaseFileName(),
                                "none", //SpecialData
@@ -4972,7 +4972,7 @@ LogB.Debug("B");
        
                //on Windows we need the \"str\" to call without problems in path with spaces
                //pinfo.Arguments = "\"" + "passToR.R" + "\" " + optionsFile;
-               pinfo.Arguments = "\"" + UtilEncoder.GetEncoderScriptCaptureNoRdotNet() + "\" " + optionsFile;
+               pinfo.Arguments = "\"" + UtilEncoder.GetEncoderScriptCallCaptureNoRdotNet() + "\" " + 
optionsFile;
        
                LogB.Information("Arguments:", pinfo.Arguments);
                LogB.Information("--- 1 --- " + optionsFile.ToString() + " ---");
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index de18bf3..2645986 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -180,6 +180,11 @@ public class UtilEncoder
                                        Util.GetDataDir(), "encoder", 
Constants.EncoderScriptCapturePythonLinux);
        }
        */
+       public static string GetEncoderScriptCallCaptureNoRdotNet() {
+               return System.IO.Path.Combine(
+                               Util.GetDataDir(), "encoder", Constants.EncoderScriptCallCaptureNoRDotNet);
+       }
+       
        public static string GetEncoderScriptCaptureNoRdotNet() {
                return System.IO.Path.Combine(
                                Util.GetDataDir(), "encoder", Constants.EncoderScriptCaptureNoRDotNet);


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