[chronojump] Unified CallR's methods into executeProcess.CallR()
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Unified CallR's methods into executeProcess.CallR()
- Date: Tue, 26 Jun 2018 09:55:58 +0000 (UTC)
commit 99c5b67a748109fc462276b1c56416afade27b23
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jun 26 11:54:47 2018 +0200
Unified CallR's methods into executeProcess.CallR()
src/executeProcess.cs | 29 +++++++++++++++++++++++++++++
src/forceSensor.cs | 30 ++----------------------------
src/runEncoder.cs | 31 ++-----------------------------
src/sprint.cs | 30 ++----------------------------
4 files changed, 35 insertions(+), 85 deletions(-)
---
diff --git a/src/executeProcess.cs b/src/executeProcess.cs
index fe3f6742..4a29abac 100644
--- a/src/executeProcess.cs
+++ b/src/executeProcess.cs
@@ -274,4 +274,33 @@ class ExecuteProcess
return false;
}
+ public static bool CallR(string script)
+ {
+ string executable = UtilEncoder.RProcessBinURL();
+ List<string> parameters = new List<string>();
+
+ //A) fix script name
+ if(UtilAll.IsWindows())
+ script = script.Replace("\\","/");
+
+ parameters.Insert(0, "\"" + script + "\"");
+
+ //B) tempPath
+ string tempPath = Path.GetTempPath();
+ if(UtilAll.IsWindows())
+ tempPath = tempPath.Replace("\\","/");
+
+ parameters.Insert(1, "\"" + tempPath + "\"");
+
+ LogB.Information("\nCalling R file ----->");
+
+ //C) call process
+ //ExecuteProcess.run (executable, parameters);
+ Result execute_result = run (executable, parameters);
+ //LogB.Information("Result = " + execute_result.stdout);
+
+ LogB.Information("\n<------ Done calling R file.");
+ return execute_result.success;
+ }
+
}
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index c177449f..7782e0d6 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -502,35 +502,9 @@ public class ForceSensorGraph
public bool CallR(int graphWidth, int graphHeight)
{
- string executable = UtilEncoder.RProcessBinURL();
- List<string> parameters = new List<string>();
-
- //A) mifcript
- string mifScript = UtilEncoder.GetmifScript();
- if(UtilAll.IsWindows())
- mifScript = mifScript.Replace("\\","/");
-
- parameters.Insert(0, "\"" + mifScript + "\"");
-
- //B) tempPath
- string tempPath = Path.GetTempPath();
- if(UtilAll.IsWindows())
- tempPath = tempPath.Replace("\\","/");
-
- parameters.Insert(1, "\"" + tempPath + "\"");
-
- //C) writeOptions
+ LogB.Information("\nforceSensor CallR ----->");
writeOptionsFile(graphWidth, graphHeight);
-
- LogB.Information("\nCalling mif R file ----->");
-
- //D) call process
- //ExecuteProcess.run (executable, parameters);
- ExecuteProcess.Result execute_result = ExecuteProcess.run (executable, parameters);
- //LogB.Information("Result = " + execute_result.stdout);
-
- LogB.Information("\n<------ Done calling mif R file.");
- return execute_result.success;
+ return ExecuteProcess.CallR(UtilEncoder.GetmifScript());
}
private void writeOptionsFile(int graphWidth, int graphHeight)
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 0b8950e6..e215c924 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -37,38 +37,11 @@ public class RunEncoderGraph
this.tempC = tempC;
}
- //moure la majoria d'aixo a ExecuteProcess per reciclar-ho a gui/runEncoder.cs linia 335
public bool CallR(int graphWidth, int graphHeight)
{
- string executable = UtilEncoder.RProcessBinURL();
- List<string> parameters = new List<string>();
-
- //A) script
- string script = UtilEncoder.GetRunEncoderScript();
- if(UtilAll.IsWindows())
- script = script.Replace("\\","/");
-
- parameters.Insert(0, "\"" + script + "\"");
-
- //B) tempPath
- string tempPath = Path.GetTempPath();
- if(UtilAll.IsWindows())
- tempPath = tempPath.Replace("\\","/");
-
- parameters.Insert(1, "\"" + tempPath + "\"");
-
- //C) writeOptions
+ LogB.Information("\nrunEncoder CallR ----->");
writeOptionsFile(graphWidth, graphHeight);
-
- LogB.Information("\nCalling R file ----->");
-
- //D) call process
- //ExecuteProcess.run (executable, parameters);
- ExecuteProcess.Result execute_result = ExecuteProcess.run (executable, parameters);
- //LogB.Information("Result = " + execute_result.stdout);
-
- LogB.Information("\n<------ Done calling R file.");
- return execute_result.success;
+ return ExecuteProcess.CallR(UtilEncoder.GetRunEncoderScript());
}
private void writeOptionsFile(int graphWidth, int graphHeight)
diff --git a/src/sprint.cs b/src/sprint.cs
index ddce0df5..3d0f18d0 100644
--- a/src/sprint.cs
+++ b/src/sprint.cs
@@ -60,35 +60,9 @@ public class Sprint
public bool CallR(int graphWidth, int graphHeight, string personName)
{
- string executable = UtilEncoder.RProcessBinURL();
- List<string> parameters = new List<string>();
-
- //A) photocellsScript
- string photocellsScript = UtilEncoder.GetSprintPhotocellsScript();
- if(UtilAll.IsWindows())
- photocellsScript = photocellsScript.Replace("\\","/");
-
- parameters.Insert(0, "\"" + photocellsScript + "\"");
-
- //B) tempPath
- string tempPath = Path.GetTempPath();
- if(UtilAll.IsWindows())
- tempPath = tempPath.Replace("\\","/");
-
- parameters.Insert(1, "\"" + tempPath + "\"");
-
- //C) writeOptions
+ LogB.Information("\nsprint CallR ----->");
writeOptionsFile(graphWidth, graphHeight, personName);
-
- LogB.Information("\nCalling sprint.R ----->");
-
- //D) call process
- //ExecuteProcess.run (executable, parameters);
- ExecuteProcess.Result execute_result = ExecuteProcess.run (executable, parameters);
- //LogB.Information("Result = " + execute_result.stdout);
-
- LogB.Information("\n<------ Done calling sprint.R.");
- return execute_result.success;
+ return ExecuteProcess.CallR(UtilEncoder.GetSprintPhotocellsScript());
}
private void writeOptionsFile(int graphWidth, int graphHeight, string personName)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]