[chronojump] Encoder calls on linux fixed



commit f242f059be1ff71bf036388f4f210658c87c60a7
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 30 03:23:05 2013 +0100

    Encoder calls on linux fixed

 Makefile.am         |    2 +-
 configure.ac        |    1 +
 encoder/Makefile.am |    4 ++++
 src/constants.cs    |    9 +++------
 src/gui/encoder.cs  |    6 +++---
 src/util.cs         |   26 ++++++++++++++++++++++----
 6 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index fe6418b..fb3c534 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@ EXTRA_DIST = m4 expansions.m4
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = chronopic-firmware \
-	libcesarplayer CesarPlayer src po manual
+	encoder libcesarplayer CesarPlayer src po manual
 
 if OSTYPE_LINUX
  SUBDIRS += chronopic-tests chronojump_server
diff --git a/configure.ac b/configure.ac
index bcc74db..9857188 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,7 @@ chronopic-tests/Makefile
 src/Makefile
 po/Makefile
 chronojump_server/Makefile
+encoder/Makefile
 manual/Makefile
 src/AssemblyInfo.cs
 src/chronojump
diff --git a/encoder/Makefile.am b/encoder/Makefile.am
new file mode 100644
index 0000000..a6d014d
--- /dev/null
+++ b/encoder/Makefile.am
@@ -0,0 +1,4 @@
+encoderdatadir = @datadir@/@PACKAGE@/encoder
+
+dist_encoderdata_DATA = pyserial_pyper.py \
+	     graph.R
diff --git a/src/constants.cs b/src/constants.cs
index 6febf11..123dcc6 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -576,12 +576,9 @@ public class Constants
 	 * chronojump / encoder / sessionID / graphs
 	 */
 	
-	public static string EncoderScriptCaptureLinux = 
-		"/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/pyserial_pyper.py";
-	public static string EncoderScriptCaptureWindows = 
-		"TODO_PATH_pyserial_pyper_windows.exe";
-	public static string EncoderScriptGraph = 
-		"/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/graph.R";
+	public static string EncoderScriptCaptureLinux = "pyserial_pyper.py";
+	public static string EncoderScriptCaptureWindows = "pyserial_pyper_windows.exe";
+	public static string EncoderScriptGraph = "graph.R";
 	//no longer used:
 	//public static string EncoderScriptGraphCall = 
 		//"/home/xavier/informatica/progs_meus/chronojump/chronojump/encoder/call_graph.py";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 67838cb..90bd9fc 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -326,7 +326,7 @@ public partial class ChronoJumpWindow
 				Util.GetEncoderStatusTempFileName(),
 				ep);
 		
-		Util.RunEncoderGraph(Constants.EncoderScriptGraph, 
+		Util.RunEncoderGraph(
 				Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" + 
 				Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)) + 
 				"-(" + findMass(true) + "Kg)",
@@ -516,7 +516,7 @@ public partial class ChronoJumpWindow
 				Util.GetEncoderGraphTempFileName(),
 				Util.GetEncoderExportTempFileName(), "NULL", ep);
 
-		Util.RunEncoderGraph(Constants.EncoderScriptGraph, 
+		Util.RunEncoderGraph(
 				Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" + 
 				Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)) + 
 					"-(" + findMass(true) + "Kg)",
@@ -875,7 +875,7 @@ public partial class ChronoJumpWindow
 		//if(radiobutton_encoder_analyze_data_user_curves.Active)
 		//	massString = "";
 
-		Util.RunEncoderGraph(Constants.EncoderScriptGraph, 
+		Util.RunEncoderGraph(
 				Util.ChangeSpaceForUnderscore(currentPerson.Name) + "-" + 
 				Util.ChangeSpaceForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise)), encoderStruct);
 	}
diff --git a/src/util.cs b/src/util.cs
index 8b5aa40..6fd471b 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -928,6 +928,23 @@ public class Util
 	}
 	
 	
+	private static string getEncoderScriptsDir(){
+		return System.IO.Path.Combine(getDataDir(),"encoder");
+	}
+	
+	private static string getEncoderScriptCapture() {
+		if(IsWindows())
+			return System.IO.Path.Combine(
+					getEncoderScriptsDir(), Constants.EncoderScriptCaptureWindows);
+		else
+			return System.IO.Path.Combine(
+					getEncoderScriptsDir(), Constants.EncoderScriptCaptureLinux);
+	}
+	
+	private static string getEncoderScriptGraph() {
+		return System.IO.Path.Combine(getEncoderScriptsDir(), Constants.EncoderScriptGraph);
+	}
+
 	
 	/********** end of encoder paths ************/
 
@@ -1062,12 +1079,13 @@ public class Util
 		
 
 		if (IsWindows()) {
-			pBin=Constants.EncoderScriptCaptureWindows;
+			pBin=getEncoderScriptCapture();
 			pinfo.Arguments = title + " " + es.OutputData1 + " " + es.Ep.ToString1() + " " + port;
 		}
 		else {
 			pBin="python";
-			pinfo.Arguments = Constants.EncoderScriptCaptureLinux + " " + title + " " + es.OutputData1 + " " + es.Ep.ToString1() + " " + port;
+			pinfo.Arguments = getEncoderScriptCapture() + " " + title + " " + 
+				es.OutputData1 + " " + es.Ep.ToString1() + " " + port;
 		}
 
 		outputFileCheck = es.OutputData1;
@@ -1090,7 +1108,7 @@ public class Util
 		while ( ! ( File.Exists(outputFileCheck) || CancelRScript) );
 	}
 	
-	public static void RunEncoderGraph(string script, string title, EncoderStruct es) {
+	public static void RunEncoderGraph(string title, EncoderStruct es) {
 		CancelRScript = false;
 
 		ProcessStartInfo pinfo;
@@ -1125,7 +1143,7 @@ public class Util
 		string argumentOptions = es.InputData + " " + 
 			es.OutputGraph + " " + es.OutputData1 + " " + es.OutputData2 + " " + 
 			es.Ep.ToString2(" ") + " " + title;
-		pinfo.Arguments = script + " " + argumentOptions;
+		pinfo.Arguments = getEncoderScriptGraph() + " " + 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)



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