[chronojump] Leave opened encoder R Processes (capture better)



commit c4d16312ca99c22b563a54375a3945380d30699f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Apr 23 13:00:19 2015 +0200

    Leave opened encoder R Processes (capture better)

 encoder/capture.R     |    6 ++++--
 src/encoderRProc.cs   |   16 +++++++---------
 src/gui/chronojump.cs |    5 +++++
 src/gui/encoder.cs    |    8 --------
 4 files changed, 16 insertions(+), 19 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 9e2e6dd..a9b913c 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -130,8 +130,7 @@ doProcess <- function(options)
 
        curveNum = 0
        input <- readLines(f, n = 1L)
-       #while(input[1] != "Q") {
-       while(TRUE) {
+       while(input[1] != "Q") {
                if(debug) {
                        write("doProcess main while", stderr())
                        write(c("input = ", input), stderr())
@@ -148,6 +147,9 @@ doProcess <- function(options)
 
                        curveNum = 0
                        input <- readLines(f, n = 1L)
+       
+                       if(input[1] == "Q")
+                               quit("no") #quit without save
                }
                
                #Sys.sleep(4) #just to test how Chronojump reacts if process takes too long
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index becbd11..778f1dd 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -49,7 +49,7 @@ public abstract class EncoderRProc
                }
        }
 
-       private bool isRunning() 
+       protected bool isRunning() 
        {
                LogB.Debug("calling isRunning()");
                if(p == null) {
@@ -217,15 +217,13 @@ public class EncoderRProcCapture : EncoderRProc
                LogB.Debug("<-- writen line 1");
        }       
        
-       public void SendCaptureEnd() 
+       public void SendEndProcess() 
        {
-               /*
-                * don't send end line
-                * process should remain opened
-                *
-               LogB.Debug("sending end line");
-               p.StandardInput.WriteLine("Q");
-               */
+               if(isRunning()) {
+                       LogB.Debug("Closing R capture script");
+                       p.StandardInput.WriteLine("Q");
+               } else
+                       LogB.Debug("R capture script is not working. Don't need to close.");
        }
 
        protected override void writeOptionsFile()
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index b9393d2..dd01614 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2395,6 +2395,11 @@ public partial class ChronoJumpWindow
                
                LogB.Information("Bye2!");
                
+               encoderRProcCapture.SendEndProcess();
+               //encoderRProcAnalyze.SendEndProcess();
+
+               LogB.Information("Bye3!");
+               
                Log.End();
 
                Application.Quit();
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 1d1fed7..87fff22 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4703,14 +4703,6 @@ public partial class ChronoJumpWindow
                                encoderStopVideoRecord();
                        }
 
-                       /*
-                       UtilEncoder.RunEncoderCaptureNoRDotNetSendEnd(pCaptureNoRDotNet);
-                       pCaptureNoRDotNet.WaitForExit();
-                       */
-                       encoderRProcCapture.SendCaptureEnd();
-                       //maybe here wait for an R ending signal. R process should not end, but will be 
waiting next capture
-
-                       
                        LogB.ThreadEnded(); 
                        return false;
                }


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