[chronojump] pyserial gets portname from chronopic window



commit c2ca96cb5d6e07875e84c11d95fd897d1f879e27
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 29 02:52:36 2013 +0100

    pyserial gets portname from chronopic window

 encoder/pyserial_pyper.py |    3 ++-
 src/gui/chronopic.cs      |   17 ++++++++++++++++-
 src/gui/encoder.cs        |    2 +-
 src/util.cs               |    4 ++--
 4 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index 55620b6..c897453 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -62,12 +62,13 @@ powerLowerCondition = int(sys.argv[16])
 peakPowerHigherCondition = int(sys.argv[17])
 peakPowerLowerCondition = int(sys.argv[18])
 mainVariable = sys.argv[19]
+w_serial_port = sys.argv[20]
 
 delete_initial_time = 20			#delete first records because there's encoder bug
 #w_baudrate = 9600                           # Setting the baudrate of Chronopic(9600)
 w_baudrate = 115200                           # Setting the baudrate of Chronopic(115200)
 #w_serial_port = 4                           # Setting the serial port (Windows), windows's device number need minus 1
-w_serial_port = "/dev/ttyUSB0"             # Setting the serial port (Linux)
+#w_serial_port = "/dev/ttyUSB0"             # Setting the serial port (Linux)
 direction_change_period = 25                # how long to recognize as change direction. (I am not sure if this describe correctly.)
 direction_change_count = 0
 direction_pull_to_push = 'pull_to_push'     # if people change the motion for pull to push, record this value.
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 013c067..84fc970 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -824,6 +824,21 @@ Log.WriteLine("bbb");
 		return count;
 	}
 
+	public string GetEncoderPort() {
+		if(Util.IsWindows()) {
+			string fullName = UtilGtk.ComboGetActive(combo_windows_encoder);
+			if(fullName.Length < 3)
+				return "0";
+			else {
+				//COM5
+				int number = Convert.ToInt32(fullName.Substring(3));
+				return (number -1).ToString(); //returns a "4", because eg: COM1 is port 0
+			}
+		}
+		else
+			return UtilGtk.ComboGetActive(combo_linux_encoder);
+	}
+
 
 	public Chronopic CP {
 		get { return cp; }
@@ -849,7 +864,7 @@ Log.WriteLine("bbb");
 	public Button FakeWindowDone {
 		get { return fakeWindowDone; }
 	}
-
+	
 	/*	
 	public Button FakeWindowReload
 	{
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a0beba3..c68d162 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -233,7 +233,7 @@ public partial class ChronoJumpWindow
 		Util.RunEncoderCapture(Constants.EncoderScriptCapture, 
 				Util.ChangeSpaceForUnderscore(currentPerson.Name) + "----" + 
 				Util.ChangeSpaceForUnderscore(exerciseNameShown) + "----(" + findMass(true) + "Kg)",
-				es);
+				es, chronopicWin.GetEncoderPort());
 
 		encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
 		encoderSignalUniqueID = "-1"; //mark to know that there's no ID for this until it's saved on database
diff --git a/src/util.cs b/src/util.cs
index 8c055e3..f3842e5 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1046,7 +1046,7 @@ public class Util
 		}
 	}
 
-	public static void RunEncoderCapture(string script, string title, EncoderStruct es) {
+	public static void RunEncoderCapture(string script, string title, EncoderStruct es, string port) {
 		CancelRScript = false;
 
 		ProcessStartInfo pinfo;
@@ -1079,7 +1079,7 @@ public class Util
 		script + " " + es.OutputData1 + " " + es.Ep.ToString1() + "\"";
 		} else 
 		*/
-		pinfo.Arguments = script + " " + title + " " + es.OutputData1 + " " + es.Ep.ToString1();
+		pinfo.Arguments = script + " " + title + " " + es.OutputData1 + " " + es.Ep.ToString1() + " " + port;
 
 		outputFileCheck = es.OutputData1;
 



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