[chronojump] Encoder graph returns feedback on process



commit 9cc7760f3b1b6ec0ea5aeadd3aacb8879bca213a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 15 11:49:08 2013 +0100

    Encoder graph returns feedback on process

 encoder/graph.R    |   15 ++++++++++++---
 src/constants.cs   |    1 +
 src/gui/encoder.cs |   15 ++++++++++++---
 src/util.cs        |   16 ++++++++++++----
 4 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 3d1bd2c..7c95f81 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -18,8 +18,6 @@
 #   Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
 # 
 
-library("EMD")
-#library("sfsmisc")
 
 #this will replace below methods: findPics1ByMinindex, findPics2BySpeed
 findCurves <- function(rawdata, eccon, min_height, draw, title) {
@@ -653,7 +651,7 @@ if(length(args) < 3) {
 	file=args[1]
 	outputGraph=args[2]
 	outputData1=args[3]
-	outputData2=args[4]
+	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])
@@ -666,6 +664,13 @@ if(length(args) < 3) {
 	height=as.numeric(args[14])
 	Title=args[15]
 
+	write("(1/4) Starting R", outputData2)
+
+	library("EMD")
+	#library("sfsmisc")
+
+	write("(2/4) Starting process", outputData2)
+
 	if(analysis != "exportCSV") {
 		png(outputGraph, width=width, height=height)
 		Title=gsub('_',' ',Title)
@@ -831,6 +836,8 @@ if(length(args) < 3) {
 			}
 		}
 	}
+	
+	write("(3/4) Curves processed", outputData2)
 		
 	if(analysis=="single") {
 		if(jump>0) {
@@ -1042,6 +1049,8 @@ print("----------------------------")
 	}
 	if(analysis != "exportCSV")
 		dev.off()
+
+	write("(4/4) R tasks done", outputData2)
 }
 
 warnings()
diff --git a/src/constants.cs b/src/constants.cs
index c64c2ce..91caceb 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -581,6 +581,7 @@ public class Constants
 	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";
+	public static string EncoderStatusTemp = "chronojump-encoder-status.txt";
 
 	//note next has 40 chars, and its used also in encoder/graph.R to detect how a file will be treated
 	//if this name changes, change it in encoder/graph.R
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f10ca93..f43852b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -255,7 +255,7 @@ public partial class ChronoJumpWindow
 	
 	private void encoderUpdateTreeView()
 	{
-		string contents = Util.ReadFile(Util.GetEncoderCurvesTempFileName());
+		string contents = Util.ReadFile(Util.GetEncoderCurvesTempFileName(), false);
 		if (contents == null || contents == "") {
 			encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
 		} else {
@@ -843,7 +843,9 @@ public partial class ChronoJumpWindow
 		EncoderStruct encoderStruct = new EncoderStruct(
 				dataFileName, 
 				Util.GetEncoderGraphTempFileName(),
-				"NULL", "NULL", ep);		//no data ouptut
+				"NULL", //no data ouptut
+				Util.GetEncoderStatusTempFileName(),
+				ep);
 
 		//show mass in title except if it's curves because then can be different mass
 		string massString = "-(" + findMass(true) + "Kg)";
@@ -1723,6 +1725,7 @@ public partial class ChronoJumpWindow
 			image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_analyze)-5;
 
 			encoder_pulsebar_analyze.Text = Catalog.GetString("Please, wait.");
+
 		
 			encoderThread = new Thread(new ThreadStart(analyze));
 			GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderAnalyze));
@@ -1785,8 +1788,12 @@ public partial class ChronoJumpWindow
 	private void updatePulsebar (encoderModes mode) {
 		if(mode == encoderModes.CAPTURE || mode == encoderModes.RECALCULATE_OR_LOAD) 
 			encoder_pulsebar_capture.Pulse();
-		else
+		else {
 			encoder_pulsebar_analyze.Pulse();
+			string contents = Util.ReadFile(Util.GetEncoderStatusTempFileName(), true);
+			if(contents != "")
+				encoder_pulsebar_analyze.Text = contents;
+		}
 	}
 	
 	private void finishPulsebar(encoderModes mode) {
@@ -1829,6 +1836,8 @@ public partial class ChronoJumpWindow
 			encoderButtonsSensitive(encoderSensEnumStored);
 			if(analyzedCurvesOk)
 				image_encoder_analyze.Sensitive = true;
+			
+			Util.FileDelete(Util.GetEncoderStatusTempFileName());
 		}
 
 		treeview_encoder_curves.Sensitive = true;
diff --git a/src/util.cs b/src/util.cs
index 55b2dcf..76f25a6 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -887,6 +887,9 @@ public class Util
 	public static string GetEncoderGraphInputMulti() {
 		return Path.Combine(Path.GetTempPath(), Constants.EncoderGraphInputMulti);
 	}
+	public static string GetEncoderStatusTempFileName() {
+		return Path.Combine(Path.GetTempPath(), Constants.EncoderStatusTemp);
+	}
 
 
 //	public static void MoveTempToEncoderData(int sessionID, int uniqueID) {
@@ -981,12 +984,17 @@ public class Util
 		return false;
 	}
 
-	public static string ReadFile(string fileName)
+	public static string ReadFile(string fileName, bool removeEOL)
 	{
 		try {
 			StreamReader reader = File.OpenText(fileName);
 			string contents = reader.ReadToEnd ();
 			reader.Close();
+			
+			//delete the '\n' that ReaderToEnd() has put
+			if(removeEOL)
+				contents = contents.TrimEnd(new char[1] {'\n'});
+			
 			return contents;
 		} catch {
 			return null;
@@ -1079,7 +1087,7 @@ public class Util
 		Console.WriteLine(outputFileCheck);
 		if (File.Exists(outputFileCheck))
 			File.Delete(outputFileCheck);
-
+		
 		p = new Process();
 		p.StartInfo = pinfo;
 		p.Start();
@@ -1128,7 +1136,7 @@ public class Util
 	}
 
 	public static void EncoderDeleteCurveFromSignal(string fileName, int start, int duration) {
-		string contents = ReadFile(fileName);
+		string contents = ReadFile(fileName, false);
 		string [] startAndDuration = encoderFindPos(contents, start, duration);
 
 		StringBuilder myStringBuilder = new StringBuilder(contents);
@@ -1146,7 +1154,7 @@ public class Util
 	public static string EncoderSaveCurve(string fileNameSignal, int start, int duration, 
 			int sessionID, int uniqueID, string personName, string timeStamp, int curveIDMax) 
 	{
-		string contents = ReadFile(fileNameSignal);
+		string contents = ReadFile(fileNameSignal, false);
 		string [] startAndDuration = encoderFindPos(contents, start, duration);
 
 		contents = contents.Substring(



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