[chronojump] Encoder Capture from R is being displayed on treeview
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder Capture from R is being displayed on treeview
- Date: Thu, 15 Jan 2015 18:51:10 +0000 (UTC)
commit e28941ede6a314cad6362e26bcc833d280570504
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jan 15 19:50:41 2015 +0100
Encoder Capture from R is being displayed on treeview
encoder/capture.R | 16 +++++++---------
encoder/util.R | 3 +++
src/gui/encoder.cs | 47 ++++++++++++++++++++++++++++-------------------
3 files changed, 38 insertions(+), 28 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 1396fc6..8fca49b 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -1,6 +1,8 @@
#http://stackoverflow.com/questions/26053302/is-there-a-way-to-use-standard-input-output-stream-to-communicate-c-sharp-and-r/26058010#26058010
-cat("Arrived at capture.R\n")
+#Caution: Do not 'print, cat' stuff because it's readed from gui/encoder as results
+
+#cat("Arrived at capture.R\n")
f <- file("stdin")
open(f)
@@ -8,7 +10,6 @@ open(f)
args <- commandArgs(TRUE)
optionsFile <- args[1]
-#print(optionsFile)
getOptionsFromFile <- function(optionsFile, lines) {
@@ -20,10 +21,8 @@ getOptionsFromFile <- function(optionsFile, lines) {
options <- getOptionsFromFile(optionsFile, 1)
-#print(options)
scriptUtilR = options[1]
-#print(scriptUtilR)
source(scriptUtilR)
@@ -32,7 +31,7 @@ source(scriptUtilR)
input <- readLines(f, n = 1L)
while(input[1] != "Q") {
#Sys.sleep(4) #just to test how Chronojump reacts if process takes too long
- cat(paste("input is:", input, "\n"))
+ #cat(paste("input is:", input, "\n"))
displacement = as.numeric(unlist(strsplit(input, " ")))
#if data file ends with comma. Last character will be an NA. remove it
@@ -40,8 +39,6 @@ while(input[1] != "Q") {
displacement = displacement[!is.na(displacement)]
position = cumsum(displacement)
- #print("position")
- #print(position)
reduceTemp = reduceCurveBySpeed("c", 1,
1, 0, #startT, startH
@@ -87,11 +84,12 @@ while(input[1] != "Q") {
#print(kinematicsResult)
paf = pafGenerate("c", kinematicsResult, myMassBody, myMassExtra)
- print("paf")
- print(paf)
+ #print("paf")
+ #print(paf)
#do not use print because it shows the [1] first. Use cat:
cat(paste(paf$meanSpeed, paf$maxSpeed, paf$maxSpeedT, paf$meanPower, paf$peakPower, paf$peakPowerT,
paf$pp_ppt, sep=", "))
+ cat("\n") #mandatory
input <- readLines(f, n = 1L)
diff --git a/encoder/util.R b/encoder/util.R
index 30864f8..a5e2057 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -1,6 +1,9 @@
#extrema function is part of R EMD package
#It's included here to save time, because 'library("EMD")' is quite time consuming
+#Caution: do not 'print, cat' stuff because (on captureR) it's readed from gui/encoder as results
+
+
extrema <- function(y, ndata = length(y), ndatam1 = ndata - 1) {
minindex <- maxindex <- NULL; nextreme <- 0; cross <- NULL; ncross <- 0
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 9a676a2..851c282 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4452,6 +4452,8 @@ public partial class ChronoJumpWindow
if(action == encoderActions.CAPTURE) {
captureCurvesBarsData = new ArrayList();
updatingEncoderCaptureGraphRCalc = false;
+
+ needToRefreshTreeviewCapture = false;
encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
GLib.Idle.Add (new GLib.IdleHandler
(pulseGTKEncoderCaptureAndCurves));
@@ -4704,17 +4706,17 @@ LogB.Debug("D");
ecca.curvesDone ++;
}
*/
-
+
+
+ bool needToRefreshTreeviewCapture;
private void readingCurveFromR (object sendingProcess, DataReceivedEventArgs curveFromR)
{
if (!String.IsNullOrEmpty(curveFromR.Data))
{
LogB.Warning(curveFromR.Data);
-
- /*
+
+ /*
encoderCaptureStringR +=
string.Format("\n{0},2,a,3,4,{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},7",
- */
- /*
ecca.curvesAccepted +1,
ecc.startFrame, ecc.endFrame-ecc.startFrame,
Util.ConvertToPoint(height*10), //cm
@@ -4722,23 +4724,19 @@ LogB.Debug("D");
Util.ConvertToPoint(meanPower), Util.ConvertToPoint(peakPower),
Util.ConvertToPoint(peakPowerT*1000), Util.ConvertToPoint(peakPower /
peakPowerT)
*/
- /*
+
+ string [] strs = curveFromR.Data.Split(new char[] {','});
+
+ encoderCaptureStringR +=
string.Format("\n{0},2,a,3,4,{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},7",
0,
0, 0,
0,
- */
- /*
- meanSpeed, maxSpeed, maxSpeedT,
- meanPower, peakPower, peakPowerT,
- peakPowerDividedByPeakPowerT
- */
- /*
- curveFromR.Data
- );
- */
- //TODO: this has to be done by the GTK thread on pulse method
- //treeviewEncoderCaptureRemoveColumns();
- //ecca.curvesAccepted = createTreeViewEncoderCapture(encoderCaptureStringR);
+ strs[0], strs[1], strs[2],
+ strs[3], strs[4], strs[5],
+ strs[6]);
+
+ //executed on GTK thread pulse method
+ needToRefreshTreeviewCapture = true;
}
}
private void readingCurveFromRerror (object sendingProcess, DataReceivedEventArgs curveFromR)
@@ -4788,6 +4786,17 @@ LogB.Debug("D");
//readingCurveFromR();
updateEncoderCaptureGraph(true, false, false); //graphSignal, no calcCurves,
no plotCurvesBars
+
+ if(needToRefreshTreeviewCapture)
+ {
+ LogB.Error("HERE YES");
+ LogB.Error(encoderCaptureStringR);
+
+ treeviewEncoderCaptureRemoveColumns();
+ ecca.curvesAccepted =
createTreeViewEncoderCapture(encoderCaptureStringR);
+
+ needToRefreshTreeviewCapture = false;
+ }
}
LogB.Debug(" Cap:" + encoderThread.ThreadState.ToString());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]