[chronojump] call_graph.py is no longer used
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] call_graph.py is no longer used
- Date: Wed, 16 Jan 2013 11:24:46 +0000 (UTC)
commit 2eec8ad60aa4e067c97595359b1c71e519f61e3f
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jan 16 12:24:13 2013 +0100
call_graph.py is no longer used
encoder/graph.R | 44 ++++++++++++++---------
src/constants.cs | 10 ++++-
src/encoder.cs | 6 ++--
src/gui/encoder.cs | 6 ++--
src/util.cs | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 137 insertions(+), 27 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 63b42eb..e2a1c31 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -647,26 +647,34 @@ colSpeed="springgreen3"; colForce="blue2"; colPower="tomato2" #colors
cols=c(colSpeed,colForce,colPower); lty=rep(1,3)
#--- user commands ---
-args <- commandArgs(TRUE)
-print(args)
-if(length(args) < 3) {
+
+#way A. passing options to a file
+#args <- commandArgs(TRUE)
+#optionsCon <- file(args[1], 'r')
+#options=readLines(optionsCon,n=15)
+
+#way B. put options as arguments
+options <- commandArgs(TRUE)
+
+print(options)
+if(length(options) < 3) {
# print("USAGE:\nRscript graph.R c superpose graph.png\neccons:curves, single, side, superpose, powerBars \nsingle and superpose needs a param at end (the jump):\nRscript graph.R c single graph.png 2\n")
} else {
- file=args[1]
- outputGraph=args[2]
- outputData1=args[3]
- outputData2=args[4] #currently used to display status
- minHeight=as.numeric(args[5])*10 #from cm to mm
- exercisePercentBodyWeight=as.numeric(args[6]) #was isJump=as.logical(args[6])
- Mass=as.numeric(args[7])
- eccon=args[8]
- analysis=args[9] #in cross comes as "cross.Force.Speed.mean"
- analysisOptions=args[10] #p: propulsive
- smoothingOne=args[11]
- jump=args[12]
- width=as.numeric(args[13])
- height=as.numeric(args[14])
- Title=args[15]
+ file=options[1]
+ outputGraph=options[2]
+ outputData1=options[3]
+ outputData2=options[4] #currently used to display status
+ minHeight=as.numeric(options[5])*10 #from cm to mm
+ exercisePercentBodyWeight=as.numeric(options[6]) #was isJump=as.logical(options[6])
+ Mass=as.numeric(options[7])
+ eccon=options[8]
+ analysis=options[9] #in cross comes as "cross.Force.Speed.mean"
+ analysisOptions=options[10] #p: propulsive
+ smoothingOne=options[11]
+ jump=options[12]
+ width=as.numeric(options[13])
+ height=as.numeric(options[14])
+ Title=options[15]
write("(1/4) Starting R", outputData2)
diff --git a/src/constants.cs b/src/constants.cs
index 45ace5c..1ac8790 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -576,8 +576,14 @@ public class Constants
* chronojump / encoder / sessionID / graphs
*/
- public static string EncoderScriptCapture = "/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/pyserial_pyper.py";
- public static string EncoderScriptGraphCall = "/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/call_graph.py";
+ public static string EncoderScriptCapture =
+ "/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/pyserial_pyper.py";
+ public static string EncoderScriptGraph =
+ "/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/graph.R";
+ //no longer used:
+ //public static string EncoderScriptGraphCall =
+ //"/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/call_graph.py";
+
public static string EncoderDataTemp = "chronojump-last-encoder-data.txt";
public static string EncoderCurvesTemp = "chronojump-last-encoder-curves.txt";
public static string EncoderGraphTemp = "chronojump-last-encoder-graph.png";
diff --git a/src/encoder.cs b/src/encoder.cs
index 7acd6eb..a4ce19f 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -112,10 +112,10 @@ public class EncoderParams
this.height = height;
}
- public string ToString2 ()
+ public string ToString2 (string sep)
{
- return minHeight + " " + exercisePercentBodyWeight + " " + mass + " " + eccon + " " +
- analysis + " " + analysisOptions + " " + smooth + " " + curve + " " + width + " " + height;
+ return minHeight + sep + exercisePercentBodyWeight + sep + mass + sep + eccon + sep +
+ analysis + sep + analysisOptions + sep + smooth + sep + curve + sep + width + sep + height;
}
public string Analysis {
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 7d42c05..38d18b4 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -319,7 +319,7 @@ public partial class ChronoJumpWindow
Util.GetEncoderStatusTempFileName(),
ep);
- Util.RunPythonEncoder(Constants.EncoderScriptGraphCall,
+ Util.RunPythonEncoder(Constants.EncoderScriptGraph,
Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" +
Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)) +
"-(" + findMass(true) + "Kg)",
@@ -509,7 +509,7 @@ public partial class ChronoJumpWindow
Util.GetEncoderGraphTempFileName(),
Util.GetEncoderExportTempFileName(), "NULL", ep);
- Util.RunPythonEncoder(Constants.EncoderScriptGraphCall,
+ Util.RunPythonEncoder(Constants.EncoderScriptGraph,
Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" +
Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)) +
"-(" + findMass(true) + "Kg)",
@@ -859,7 +859,7 @@ public partial class ChronoJumpWindow
if(radiobutton_encoder_analyze_data_user_curves.Active)
massString = "";
- Util.RunPythonEncoder(Constants.EncoderScriptGraphCall,
+ Util.RunPythonEncoder(Constants.EncoderScriptGraph,
Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" +
Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)) +
massString, encoderStruct, false);
diff --git a/src/util.cs b/src/util.cs
index 94b2edf..2d543c7 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1041,7 +1041,8 @@ public class Util
//maybe R is not installed
}
}
-
+
+ /*
//python program
public static void RunPythonEncoder(string pythonScript, string title, EncoderStruct es, bool capture) {
CancelRScript = false;
@@ -1101,7 +1102,102 @@ public class Util
p.WaitForExit();
while ( ! ( File.Exists(outputFileCheck) || CancelRScript) );
}
+ */
+ //python program
+ //script can be:
+ //python script to capture
+ //or
+ //R script to make graph
+ public static void RunPythonEncoder(string script, string title, EncoderStruct es, bool capture) {
+ CancelRScript = false;
+
+ ProcessStartInfo pinfo;
+ Process p;
+ //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="";
+ pinfo = new ProcessStartInfo();
+
+ string outputFileCheck = "";
+ if(capture) {
+ pBin="python";
+
+ //currently we are not using useTerminal. It was originally to encoder capture with text and graph
+ /*
+ bool useTerminal = false;
+ if(useTerminal)
+ pBin="xterm";
+ */
+
+ if (IsWindows())
+ pBin=System.IO.Path.Combine(GetPrefixDir(), "bin/python.exe");
+
+ /*
+ if(useTerminal) {
+ //currentl we are not using this
+ pinfo.Arguments = "-bg white -fg black -hold -geometry 72x34+100+40 -fn *-fixed-*-*-*-20-* -e \"python " +
+ script + " " + es.OutputData1 + " " + es.Ep.ToString1() + "\"";
+ } else
+ */
+ pinfo.Arguments = script + " " + title + " " + es.OutputData1 + " " + es.Ep.ToString1();
+
+ outputFileCheck = es.OutputData1;
+ } else {
+ pBin="Rscript";
+ if (IsWindows())
+ pBin=System.IO.Path.Combine(GetPrefixDir(), "bin/R.exe");
+
+ /*
+ //--- way A. passing options to a file
+ string scriptOptions = es.InputData + "\n" +
+ es.OutputGraph + "\n" + es.OutputData1 + "\n" + es.OutputData2 + "\n" +
+ es.Ep.ToString2("\n") + "\n" + title + "\n";
+
+ TextWriter writer = File.CreateText("/tmp/Roptions.txt");
+ writer.Write(scriptOptions);
+ writer.Flush();
+ ((IDisposable)writer).Dispose();
+
+ pinfo.Arguments = script + " " + "/tmp/Roptions.txt";
+ //pinfo.Arguments ="CMD BATCH --no-save '--args=/tmp/Roptions.txt' " + script + " " + "/tmp/error.txt";
+ */
+ //--- way B. put options as arguments
+ string argumentOptions = es.InputData + " " +
+ es.OutputGraph + " " + es.OutputData1 + " " + es.OutputData2 + " " +
+ es.Ep.ToString2(" ") + " " + title;
+ pinfo.Arguments = script + " " + argumentOptions;
+
+ //curves does first graph and then csv curves.
+ //Wait until this to update encoder gui (if don't wait then treeview will be outdated)
+ if(es.Ep.Analysis == "curves" || es.Ep.Analysis == "exportCSV")
+ outputFileCheck = es.OutputData1;
+ else
+ outputFileCheck = es.OutputGraph;
+ }
+
+ pinfo.FileName=pBin;
+
+ pinfo.CreateNoWindow = true;
+ pinfo.UseShellExecute = false;
+
+ /*
+ Console.WriteLine("-------------------");
+ Console.WriteLine(pBin);
+ Console.WriteLine(pinfo.Arguments);
+ */
+
+ Console.WriteLine(outputFileCheck);
+ if (File.Exists(outputFileCheck))
+ File.Delete(outputFileCheck);
+
+ p = new Process();
+ p.StartInfo = pinfo;
+ p.Start();
+ p.WaitForExit();
+ while ( ! ( File.Exists(outputFileCheck) || CancelRScript) );
+ }
private static string [] encoderFindPos(string contents, int start, int duration) {
int startPos = 0;
int durationPos = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]