[chronojump] sprint.R test call



commit d5d7b38cecf789a47063bf68a578c4d72706a6ed
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 16 20:53:07 2017 +0100

    sprint.R test call

 chronojump.csproj     |    3 ++-
 src/Makefile.am       |    1 +
 src/encoderRProc.cs   |   21 ++-------------------
 src/gui/chronojump.cs |    4 ++++
 src/sprint.cs         |   37 +++++++++++++++++++++++++++++++++++++
 src/utilEncoder.cs    |   26 ++++++++++++++++++++++++++
 6 files changed, 72 insertions(+), 20 deletions(-)
---
diff --git a/chronojump.csproj b/chronojump.csproj
index 5c6e3a4..698b7bb 100644
--- a/chronojump.csproj
+++ b/chronojump.csproj
@@ -1112,6 +1112,7 @@
     <Compile Include="src\Mini\chronojump_mini.cs" />
     <Compile Include="src\encoderCaptureInertialBG.cs" />
     <Compile Include="src\gui\chronojumpIcons.cs" />
+    <Compile Include="src\sprint.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="src\" />
@@ -2158,4 +2159,4 @@
       </Properties>
     </MonoDevelop>
   </ProjectExtensions>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/src/Makefile.am b/src/Makefile.am
index 84b2a20..1190e51 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -159,6 +159,7 @@ SOURCES = \
        exportSession.cs\
        preferences.cs\
        restTime.cs\
+       sprint.cs\
        threshold.cs\
        treeViewEvent.cs\
        treeViewPerson.cs\
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index ec0e423..158d0e8 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -63,23 +63,6 @@ public abstract class EncoderRProc
        }
 
 
-       protected string pBinURL()
-       {
-               string pBin="Rscript";
-               if (UtilAll.IsWindows())
-               {
-                       //on Windows we need the \"str\" to call without problems in path with spaces
-                       pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" + 
Path.DirectorySeparatorChar + "Rscript.exe") + "\"";
-               }
-               else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
-               {
-                       pBin = Constants.RScriptOSX;
-               }
-
-               LogB.Information("pBin:", pBin);
-               return pBin;
-       }
-
        protected virtual void writeOptionsFile()
        {
        }
@@ -162,7 +145,7 @@ public class EncoderRProcCapture : EncoderRProc
                //If output file is not given, R will try to write in the running folder
                //in which we may haven't got permissions
 
-               string pBin = pBinURL();
+               string pBin = UtilEncoder.RProcessBinURL();
 
                pinfo = new ProcessStartInfo();
 
@@ -283,7 +266,7 @@ public class EncoderRProcAnalyze : EncoderRProc
        
                pinfo = new ProcessStartInfo();
 
-               string pBin = pBinURL();
+               string pBin = UtilEncoder.RProcessBinURL();
                
                if (UtilAll.IsWindows()) {
                        //On win32 R understands backlash as an escape character and 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index df886ba..fb5cf95 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -640,9 +640,13 @@ public partial class ChronoJumpWindow
                pingThread.Start();
 
                //moveStartTestInitial();
+
+               //test calling sprint.R file
+               //new Sprint();
        }
 
 
+
 /*
        private void chronopicAtStart(object o, EventArgs args) {
                //make active menuitem chronopic, and this
diff --git a/src/sprint.cs b/src/sprint.cs
new file mode 100644
index 0000000..f78980c
--- /dev/null
+++ b/src/sprint.cs
@@ -0,0 +1,37 @@
+/*
+ * 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) 2017   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.Collections.Generic; //List<T>
+
+public class Sprint
+{
+       public Sprint()
+       {
+               string executable = UtilEncoder.RProcessBinURL();
+               List<string> parameters = new List<string>();
+               parameters.Insert(0, "\"" + UtilEncoder.GetScriptSprint() + "\"");
+
+               LogB.Information("\nCalling sprint.R ----->");
+               ExecuteProcess.Result execute_result = ExecuteProcess.run (executable, parameters);
+               //LogB.Information("Result = " + execute_result.stdout);
+               LogB.Information("\n<------ Done calling sprint.R.");
+       }
+}
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 364387f..5139e5e 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -233,6 +233,15 @@ public class UtilEncoder
        
        /********** end of encoder paths ************/
 
+
+       /********** start of r-scripts paths ************/
+
+       public static string GetScriptSprint() {
+               return System.IO.Path.Combine(Util.GetDataDir(), "r-scripts", "sprint.R");
+       }
+
+       /********** end of r-scripts paths ************/
+
        private static string changeSpaceToSpaceMark(string myString) 
        {
                StringBuilder myStringBuilder = new StringBuilder(myString);
@@ -355,6 +364,23 @@ public class UtilEncoder
                                );
        }
 
+       public static string RProcessBinURL()
+       {
+               string pBin="Rscript";
+               if (UtilAll.IsWindows())
+               {
+                       //on Windows we need the \"str\" to call without problems in path with spaces
+                       pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" + 
Path.DirectorySeparatorChar + "Rscript.exe") + "\"";
+               }
+               else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
+               {
+                       pBin = Constants.RScriptOSX;
+               }
+
+               LogB.Information("pBin:", pBin);
+               return pBin;
+       }
+
 
        //Inertia Momentum
        //TODO: make this work with encoderRProc


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