[chronojump] Encoder data is sento to R in some lines. Better for having the buffer ok
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder data is sento to R in some lines. Better for having the buffer ok
- Date: Thu, 26 Feb 2015 17:05:43 +0000 (UTC)
commit 61030629f5392836010adfb5a59830209ee5e3a5
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Feb 26 18:05:10 2015 +0100
Encoder data is sento to R in some lines. Better for having the buffer ok
encoder/capture.R | 13 ++++++++++++-
src/gui/encoder.cs | 5 +++--
src/utilEncoder.cs | 18 ++++++++++++++++--
3 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/encoder/capture.R b/encoder/capture.R
index 559400f..c9fd0a1 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -127,7 +127,18 @@ doProcess <- function()
#from Chronojump first it's send the eg: "ps -1000", meaning curve starts at -1000
#then it's send the displacement
positionStart = getPositionStart(input)
- input <- readLines(f, n = 1L)
+
+ #-- read the curve (from some lines that finally end on an 'E')
+ readingCurve = TRUE
+ input = NULL
+ while(readingCurve) {
+ inputLine <- readLines(f, n = 1L)
+ if(inputLine[1] == "E")
+ readingCurve = FALSE
+ else
+ input = c(input, inputLine)
+ }
+ #-- curve readed
write("doProcess input", stderr())
#write(input, stderr())
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c128cd4..6514d8b 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2363,12 +2363,13 @@ public partial class ChronoJumpWindow
sendCurve = false;
}
+ //LogB.Debug(curve.ToString());
if(sendCurve) {
UtilEncoder.RunEncoderCaptureNoRDotNetSendCurve(
pCaptureNoRDotNet,
heightAtCurveStart,
- //curve);
//uncompressed
-
UtilEncoder.CompressData(curve) //compressed
+ //curve);
//uncompressed
+
UtilEncoder.CompressData(curve, 25) //compressed
);
ecca.curvesDone ++;
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index facc489..7e9f1d5 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -488,7 +488,8 @@ public class UtilEncoder
//TODO convert comma to point in this doubles
LogB.Debug("curveSend [displacement array]",curveSend);
- p.StandardInput.WriteLine(curveSend);
+ p.StandardInput.WriteLine(curveSend); //this will send some lines because compressed data
comes with '\n's
+ p.StandardInput.WriteLine("E"); //this will mean the 'E'nd of the curve. Then data
can be uncompressed on R
LogB.Debug("<-- writen line 1");
}
@@ -729,7 +730,12 @@ public class UtilEncoder
* this compression reduces size six times aproximately
*/
- public static string CompressData(double [] curve)
+ /*
+ * newlines help to send data to R (encoder) and read from there more safely
+ * valuesForNewLine is 25 means every 25 values there will be a newLine. 0 will mean no newlines
+ */
+
+ public static string CompressData(double [] curve, int valuesForNewLine)
{
string compressed = "";
@@ -737,12 +743,14 @@ public class UtilEncoder
int digit = -10000;
int digitPre = -10000; //just an impossible mark
int rep = 0;
+ int countNewLine = 0;
for(int i=0; i < curve.Length; i++)
{
digit = Convert.ToInt32(curve[i]);
if(start) {
rep ++;
start = false;
+ countNewLine ++;
} else if(digit == digitPre)
rep ++;
else {
@@ -752,6 +760,12 @@ public class UtilEncoder
compressed += digitPre.ToString() + "*" + rep.ToString() + " ";
rep = 1;
}
+ countNewLine ++;
+ }
+
+ if(valuesForNewLine > 0 && countNewLine >= valuesForNewLine) {
+ compressed += "\n";
+ countNewLine = 0;
}
digitPre = digit;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]