[chronojump] Bye bye RDotNet. Definetively.



commit c1b6b3c59c9817d5d4f01fc0c8bb159a7abb63bd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Apr 21 18:27:15 2015 +0200

    Bye bye RDotNet. Definetively.

 Makefile.am                                        |    2 +-
 build/build.environment.mk                         |   22 -
 rdotnet/Makefile.am                                |    1 -
 rdotnet/R.NET/BuiltinFunction.cs                   |   34 -
 rdotnet/R.NET/CharacterMatrix.cs                   |  122 ----
 rdotnet/R.NET/CharacterVector.cs                   |  117 ----
 rdotnet/R.NET/Closure.cs                           |   74 ---
 rdotnet/R.NET/ComplexMatrix.cs                     |  116 ----
 rdotnet/R.NET/ComplexVector.cs                     |  106 ----
 rdotnet/R.NET/DataFrame.cs                         |  273 ---------
 rdotnet/R.NET/DataFrameColumnAttribute.cs          |   74 ---
 rdotnet/R.NET/DataFrameRow.cs                      |  103 ----
 rdotnet/R.NET/DataFrameRowAttribute.cs             |   62 --
 rdotnet/R.NET/Devices/CharacterDeviceAdapter.cs    |  261 --------
 rdotnet/R.NET/Devices/ConsoleDevice.cs             |  143 -----
 rdotnet/R.NET/Devices/ICharacterDevice.cs          |  142 -----
 rdotnet/R.NET/Devices/NullCharacterDevice.cs       |   84 ---
 .../R.NET/Diagnostics/DataFrameColumnDisplay.cs    |   50 --
 rdotnet/R.NET/Diagnostics/DataFrameDebugView.cs    |   26 -
 rdotnet/R.NET/Diagnostics/FactorDebugView.cs       |   24 -
 rdotnet/R.NET/Diagnostics/MatrixDebugView.cs       |   25 -
 rdotnet/R.NET/Diagnostics/VectorDebugView.cs       |   25 -
 rdotnet/R.NET/Dynamic/DataFrameDynamicMeta.cs      |   42 --
 rdotnet/R.NET/Dynamic/ListDynamicMeta.cs           |   42 --
 .../R.NET/Dynamic/SymbolicExpressionDynamicMeta.cs |   41 --
 rdotnet/R.NET/DynamicVector.cs                     |  257 --------
 rdotnet/R.NET/Environment.cs                       |  115 ----
 rdotnet/R.NET/Expression.cs                        |   62 --
 rdotnet/R.NET/ExpressionVector.cs                  |   80 ---
 rdotnet/R.NET/Factor.cs                            |  108 ----
 rdotnet/R.NET/Function.cs                          |   26 -
 rdotnet/R.NET/GenericVector.cs                     |  120 ----
 rdotnet/R.NET/IntegerMatrix.cs                     |  110 ----
 rdotnet/R.NET/IntegerVector.cs                     |  143 -----
 rdotnet/R.NET/InternalString.cs                    |   71 ---
 rdotnet/R.NET/Internals/BusyType.cs                |   18 -
 rdotnet/R.NET/Internals/ConsoleOutputType.cs       |   13 -
 rdotnet/R.NET/Internals/Delegates.cs               |  163 -----
 rdotnet/R.NET/Internals/OutputMode.cs              |   31 -
 rdotnet/R.NET/Internals/ParseStatus.cs             |   46 --
 rdotnet/R.NET/Internals/SEXPREC.cs                 |  137 -----
 rdotnet/R.NET/Internals/SEXPREC_HEADER.cs          |   14 -
 rdotnet/R.NET/Internals/SaveActions.cs             |   54 --
 rdotnet/R.NET/Internals/SymbolicExpressionType.cs  |  188 ------
 rdotnet/R.NET/Internals/Unix/Delegates.cs          |   57 --
 rdotnet/R.NET/Internals/Unix/RStart.cs             |   41 --
 rdotnet/R.NET/Internals/VECTOR_SEXPREC.cs          |   60 --
 rdotnet/R.NET/Internals/Windows/Delegates.cs       |   27 -
 rdotnet/R.NET/Internals/Windows/RStart.cs          |   37 --
 rdotnet/R.NET/Internals/Windows/UiMode.cs          |    9 -
 rdotnet/R.NET/Internals/YesNoCancel.cs             |   23 -
 rdotnet/R.NET/Internals/sxpinfo.cs                 |   60 --
 rdotnet/R.NET/Language.cs                          |   38 --
 rdotnet/R.NET/LogicalMatrix.cs                     |  109 ----
 rdotnet/R.NET/LogicalVector.cs                     |  104 ----
 rdotnet/R.NET/Makefile.am                          |   79 ---
 rdotnet/R.NET/Matrix.cs                            |  314 ----------
 rdotnet/R.NET/NumericMatrix.cs                     |  118 ----
 rdotnet/R.NET/NumericVector.cs                     |  146 -----
 rdotnet/R.NET/Pairlist.cs                          |   51 --
 rdotnet/R.NET/ParseException.cs                    |   70 ---
 rdotnet/R.NET/Properties/AssemblyInfo.cs           |   38 --
 rdotnet/R.NET/ProtectedPointer.cs                  |   43 --
 rdotnet/R.NET/RDotNet.csproj                       |  136 -----
 rdotnet/R.NET/REngine.cs                           |  566 ------------------
 rdotnet/R.NET/REngineExtension.cs                  |  517 ----------------
 rdotnet/R.NET/RawMatrix.cs                         |  107 ----
 rdotnet/R.NET/RawVector.cs                         |  140 -----
 rdotnet/R.NET/SpecialFunction.cs                   |   34 -
 rdotnet/R.NET/StartupParameter.cs                  |  298 ---------
 rdotnet/R.NET/Symbol.cs                            |   76 ---
 rdotnet/R.NET/SymbolicExpression.cs                |  242 --------
 rdotnet/R.NET/SymbolicExpressionExtension.cs       |  632 --------------------
 rdotnet/R.NET/Utility.cs                           |   96 ---
 rdotnet/R.NET/Vector.cs                            |  245 --------
 rdotnet/RDotNet.NativeLibrary/Makefile.am          |   15 -
 rdotnet/RDotNet.NativeLibrary/NativeUtility.cs     |   50 --
 .../Properties/AssemblyInfo.cs                     |   38 --
 .../RDotNet.NativeLibrary.csproj                   |   57 --
 rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs      |  222 -------
 rdotnet/Rdll/i386/R.dll                            |  Bin 2928640 -> 0 bytes
 rdotnet/Rdll/i386/R.exe                            |  Bin 34816 -> 0 bytes
 rdotnet/Rdll/i386/RSetReg.exe                      |  Bin 20480 -> 0 bytes
 rdotnet/Rdll/i386/Rblas.dll                        |  Bin 239777 -> 0 bytes
 rdotnet/Rdll/i386/Rcmd.exe                         |  Bin 34304 -> 0 bytes
 rdotnet/Rdll/i386/Rgraphapp.dll                    |  Bin 348963 -> 0 bytes
 rdotnet/Rdll/i386/Rgui.exe                         |  Bin 17920 -> 0 bytes
 rdotnet/Rdll/i386/Riconv.dll                       |  Bin 102975 -> 0 bytes
 rdotnet/Rdll/i386/Rlapack.dll                      |  Bin 1914368 -> 0 bytes
 rdotnet/Rdll/i386/Rscript.exe                      |  Bin 21504 -> 0 bytes
 rdotnet/Rdll/i386/Rterm.exe                        |  Bin 18432 -> 0 bytes
 rdotnet/Rdll/i386/Rzlib.dll                        |  Bin 154917 -> 0 bytes
 rdotnet/Rdll/i386/open.exe                         |  Bin 12800 -> 0 bytes
 rdotnet/Rdll/x64/R.dll                             |  Bin 3056128 -> 0 bytes
 rdotnet/Rdll/x64/R.exe                             |  Bin 39424 -> 0 bytes
 rdotnet/Rdll/x64/RSetReg.exe                       |  Bin 23552 -> 0 bytes
 rdotnet/Rdll/x64/Rblas.dll                         |  Bin 343623 -> 0 bytes
 rdotnet/Rdll/x64/Rcmd.exe                          |  Bin 39424 -> 0 bytes
 rdotnet/Rdll/x64/Rgraphapp.dll                     |  Bin 377496 -> 0 bytes
 rdotnet/Rdll/x64/Rgui.exe                          |  Bin 22016 -> 0 bytes
 rdotnet/Rdll/x64/Riconv.dll                        |  Bin 131391 -> 0 bytes
 rdotnet/Rdll/x64/Rlapack.dll                       |  Bin 2120192 -> 0 bytes
 rdotnet/Rdll/x64/Rscript.exe                       |  Bin 25088 -> 0 bytes
 rdotnet/Rdll/x64/Rterm.exe                         |  Bin 22528 -> 0 bytes
 rdotnet/Rdll/x64/Rzlib.dll                         |  Bin 181309 -> 0 bytes
 rdotnet/Rdll/x64/open.exe                          |  Bin 16384 -> 0 bytes
 rdotnet/RecycleBin.snk.pub                         |  Bin 288 -> 0 bytes
 src/chronojump.cs                                  |   13 +-
 src/gui/encoder.cs                                 |  617 ++++---------------
 src/utilEncoder.cs                                 |  164 +-----
 110 files changed, 131 insertions(+), 9325 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1503bf0..acde7b6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@ CLEANFILES = win32/Makefile win32/chronojump_innosetup.iss
 ACLOCAL_AMFLAGS = -I build/m4 -I build/m4/shave -I build/m4/shamrock
 
 SUBDIRS = build chronopic-firmware \
-        rdotnet encoder libcesarplayer CesarPlayer src po manual chronojump_server
+        encoder libcesarplayer CesarPlayer src po manual chronojump_server
 
 if OSTYPE_LINUX
 SUBDIRS += chronopic-tests chronojump_server
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 3cf85d3..f3ae9b9 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -23,8 +23,6 @@ LINK_GLIB = $(GLIB_SHARP_20_LIBS)
 LINK_GTK = $(GTK_SHARP_20_LIBS)
 LINK_GLADE = $(GLADE_SHARP_20_LIBS)
 LINK_CESARPLAYER = -r:$(DIR_BIN)/CesarPlayer.dll
-LINK_RDOTNET = -r:$(DIR_BIN)/RDotNet.dll
-LINK_RDOTNET_NATIVE = -r:$(DIR_BIN)/RDotNet.NativeLibrary.dll
 LINK_JSON = -r:System.Json.dll
 
 REF_DEP_CHRONOJUMP = \
@@ -39,8 +37,6 @@ REF_DEP_CHRONOJUMP = \
        $(LINK_GLADE) \
        $(LINK_GTK) \
        $(LINK_CESARPLAYER) \
-       $(LINK_RDOTNET) \
-       $(LINK_RDOTNET_NATIVE) \
        $(LINK_JSON)
 
 REF_DEP_CESARPLAYER = \
@@ -49,24 +45,6 @@ REF_DEP_CESARPLAYER = \
        $(LINK_GLIB) \
        $(LINK_GTK)
 
-REF_DEP_RDOTNET_NATIVE = \
-       $(LINK_SYSTEM) \
-       $(LINK_SYSTEM_CORE) \
-       $(LINK_SYSTEM_DATA_DATASETEXTENSTIONS) \
-       $(LINK_SYSTEM_XML) \
-       $(LINK_SYSTEM_XML_LINQ) \
-       $(LINK_MICROSOFT_CSHARP)
-
-REF_DEP_RDOTNET = \
-       $(LINK_SYSTEM) \
-       $(LINK_SYSTEM_CORE) \
-       $(LINK_SYSTEM_DATA_DATASETEXTENSTIONS) \
-       $(LINK_SYSTEM_NUMERICS) \
-       $(LINK_SYSTEM_XML) \
-       $(LINK_SYSTEM_XML_LINQ) \
-       $(LINK_MICROSOFT_CSHARP) \
-       $(LINK_RDOTNET_NATIVE)
-
 REF_DEP_CHRONOJUMP_SERVER = \
        $(LINK_SYSTEM) \
        $(LINK_SYSTEMDATA) \
diff --git a/src/chronojump.cs b/src/chronojump.cs
index b08fcc4..4c9452c 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -28,9 +28,6 @@ using System.Threading;
 using System.Diagnostics; //Process
 
 using System.Collections; //ArrayList
-using System.Linq;
-using RDotNet;
-using RDotNet.NativeLibrary;
 
 
 public class ChronoJump 
@@ -99,8 +96,8 @@ public class ChronoJump
                        Environment.SetEnvironmentVariable ("R_HOME", baseDirectory);
                        LogB.Information("R_HOME:", baseDirectory);
                } else {
-                       switch (NativeUtility.GetPlatform()) {
-                               case PlatformID.MacOSX:
+                       switch (UtilAll.GetOSEnum()) {
+                               case UtilAll.OperatingSystems.MACOSX:
                                        LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
                                        rBinPath = "/Library/Frameworks/R.Framework/Libraries";
                                                Environment.SetEnvironmentVariable ("R_HOME", 
"/Library/Frameworks/R.Framework/Resources");
@@ -109,7 +106,7 @@ public class ChronoJump
                                        LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
                                        LogB.Information(Environment.GetEnvironmentVariable("PATH"));
                                        break;
-                               case PlatformID.Unix:
+                               case UtilAll.OperatingSystems.LINUX:
                                        rBinPath = @"/usr/lib/R/lib";
                                        Environment.SetEnvironmentVariable ("R_HOME", @"/usr/lib/R");
                                        Environment.SetEnvironmentVariable("PATH", envPath + 
Path.PathSeparator + rBinPath);
@@ -118,10 +115,6 @@ public class ChronoJump
                }
                
                LogB.Information("Platform:" + Environment.OSVersion.Platform);
-               //LogB.Information("initializing rdotnet");
-               //REngine rengineProva = REngine.CreateInstance("RDotNet");
-
-               //Environment.Exit(1);
                
                LogB.Information("baseDir0:", System.AppDomain.CurrentDomain.BaseDirectory);
                LogB.Information("baseDir1:", baseDirectory);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index ff2685d..625ed13 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -28,8 +28,6 @@ using System.Collections;
 using System.Collections.Generic; //List<T>
 using System.Threading;
 using Mono.Unix;
-using System.Linq;
-using RDotNet;
 using System.Diagnostics;      //for detect OS and for Process
 using LongoMatch.Gui;
 
@@ -296,9 +294,6 @@ public partial class ChronoJumpWindow
        
 
 
-       Constants.Status RInitialized;  
-       bool useRDotNet = false; //on 1.5.0 no more RDotNet use
-       
        private void encoderInitializeStuff() {
                encoder_pulsebar_capture.Fraction = 1;
                encoder_pulsebar_capture.Text = "";
@@ -328,8 +323,6 @@ public partial class ChronoJumpWindow
 
                captureCurvesBarsData = new ArrayList(0);
                
-               RInitialized = Constants.Status.UNSTARTED;
-
                try {   
                        playVideoEncoderInitialSetup();
                } catch {
@@ -345,20 +338,6 @@ public partial class ChronoJumpWindow
        }
 
 
-       void on_menuitem_test_rdotnet_activate (object o, EventArgs args) {
-               if(useRDotNet) {
-                       if(RInitialized == Constants.Status.UNSTARTED)
-                               rengine = UtilEncoder.RunEncoderCaptureCsharpInitializeR(rengine, out 
RInitialized);
-
-                       if(RInitialized == Constants.Status.OK)
-                               new DialogMessage(Constants.MessageTypes.INFO, "RDotNet OK");
-                       else
-                               new DialogMessage(Constants.MessageTypes.WARNING, "RDotNet does not work");
-               } else 
-                       new DialogMessage(Constants.MessageTypes.INFO, "RDotNet is not being used anymore");
-       }
-       
-
        void on_button_encoder_select_clicked (object o, EventArgs args) {
                encoder_configuration_win = EncoderConfigurationWindow.View(encoderConfigurationCurrent);
                encoder_configuration_win.Button_accept.Clicked += new 
EventHandler(on_encoder_configuration_win_accepted);
@@ -2008,7 +1987,6 @@ public partial class ChronoJumpWindow
        }
 
 
-       REngine rengine;
        int encoderSelectedMinimumHeight;
 
        //on inertial moment calculation don't need to send curves to R
@@ -2039,7 +2017,7 @@ public partial class ChronoJumpWindow
                
                //initialize
                int [] encoderReadedRaw = new int[recordingTime]; //stored to file in this method
-               encoderReaded = new double[recordingTime];        //readed from drawing process: 
updateEncoderCaptureGraphRCalc() 
+               encoderReaded = new double[recordingTime];
        
                double sum = 0;
                string dataString = "";
@@ -2262,106 +2240,101 @@ public partial class ChronoJumpWindow
                                                                //this means that the end is in central point 
at displacements == 0
                                                                );
                
-                                               if(useRDotNet) {
-                                                       ecca.ecc.Add(ecc);
-                                                       previousEnd = ecc.endFrame;
-                                               }
-                                               else {
-                                                       //on 1.4.9 secundary thread was capturing
-                                                       //while main thread was calculing with RDotNet and 
updating GUI
-                                                       //
-                                                       //on 1.5.0 secundary thread is capturing and sending 
data to R process
-                                                       //while main thread is reading data coming from R and 
updating GUI
                                                        
-                                                       string eccon = findEccon(true);
-                                                       LogB.Debug("curve stuff" + ecc.startFrame + ":" + 
ecc.endFrame + ":" + encoderReaded.Length);
-                                                       if(ecc.endFrame - ecc.startFrame > 0 ) 
-                                                       {
-                                                               heightAtCurveStart = heightAccumulated;
-
-                                                               double heightCurve = 0;
-                                                               double [] curve = new double[ecc.endFrame - 
ecc.startFrame];
-                                                               for(int k=0, j=ecc.startFrame; j < 
ecc.endFrame ; j ++) {
-                                                                       heightCurve += encoderReaded[j];
-                                                                       curve[k]=encoderReaded[j];
-                                                                       k++;
-                                                               }
-                                                                       
-                                                               previousEnd = ecc.endFrame;
-
-                                                               heightAccumulated += heightCurve;
-                                                               
-                                                               heightCurve = Math.Abs(heightCurve / 10); 
//mm -> cm
-                                                               LogB.Information(" height: " + 
heightCurve.ToString());
-                                                               
-                                                               //1) check heightCurve in a fast way first to 
discard curves soon
-                                                               //   only process curves with height >= 
min_height
-                                                               //2) if it's concentric, only take the 
concentric curves, 
-                                                               //   but if it's concentric and inertial: 
take both.
-                                                               //   
-                                                               //   When capturing on inertial, we have the 
first graph
-                                                               //   that will be converted to the second.
-                                                               //   we need the eccentric phase in order to 
detect the Ci2
-                                                               
-                                                               /*               
-                                                                *             /\
-                                                                *            /  \
-                                                                *           /    \
-                                                                *____      C1     \      ___
-                                                                *    \    /        \    /
-                                                                *     \  /          \  C2
-                                                                *      \/            \/
-                                                                *
-                                                                * C1, C2: two concentric phases
-                                                                */
-                                                               
-                                                               /*               
-                                                                *____                    ___
-                                                                *    \    /\      /\    /
-                                                                *     \ Ci1 \   Ci2 \ Ci3
-                                                                *      \/    \  /    \/
-                                                                *             \/
-                                                                *
-                                                                * Ci1, Ci2, Ci3: three concentric phases on 
inertial
-                                                                */
-                                                               
-                                                               //3) if it's ecc-con, don't record first 
curve if first curve is concentric
-                                               
-                                                               /*
-                                                                * on inertiaMomentCalculation we don't need 
to send data to R and get curves
-                                                                * we will call R at the end
-                                                                */
+                                               //on 1.4.9 secundary thread was capturing
+                                               //while main thread was calculing with RDotNet and updating 
GUI
+                                               //
+                                               //on 1.5.0 secundary thread is capturing and sending data to 
R process
+                                               //while main thread is reading data coming from R and 
updating GUI
+
+                                               string eccon = findEccon(true);
+                                               LogB.Debug("curve stuff" + ecc.startFrame + ":" + 
ecc.endFrame + ":" + encoderReaded.Length);
+                                               if(ecc.endFrame - ecc.startFrame > 0 ) 
+                                               {
+                                                       heightAtCurveStart = heightAccumulated;
+
+                                                       double heightCurve = 0;
+                                                       double [] curve = new double[ecc.endFrame - 
ecc.startFrame];
+                                                       for(int k=0, j=ecc.startFrame; j < ecc.endFrame ; j 
++) {
+                                                               heightCurve += encoderReaded[j];
+                                                               curve[k]=encoderReaded[j];
+                                                               k++;
+                                                       }
 
-                                                               if(! inertiaMomentCalculation) {        
-                                                                       bool sendCurve = true;
-                                                                       if(heightCurve >= 
encoderSelectedMinimumHeight)         //1
-                                                                       {
-                                                                               
if(encoderConfigurationCurrent.has_inertia) {
-                                                                                       
if(capturingFirstPhase)
-                                                                                               sendCurve = 
false;
-                                                                               } else { // ! 
encoderConfigurationCurrent.has_inertia
-                                                                                       if( eccon == "c" && ! 
ecc.up )
-                                                                                               sendCurve = 
false;
-                                                                                       if( (eccon == "ec" || 
eccon == "ecS") && ecc.up && capturingFirstPhase ) //3
-                                                                                               sendCurve = 
false;
-                                                                               }
-                                                                               capturingFirstPhase = false;
-                                                                       } else {
-                                                                               sendCurve = false;
-                                                                       }
+                                                       previousEnd = ecc.endFrame;
 
-                                                                       if(sendCurve) {
-                                                                               
UtilEncoder.RunEncoderCaptureNoRDotNetSendCurve(
-                                                                                               
pCaptureNoRDotNet, 
-                                                                                               
heightAtCurveStart, 
-                                                                                               //curve);     
                          //uncompressed
-                                                                                       
UtilEncoder.CompressData(curve, 25)     //compressed
-                                                                                               );
-
-                                                                               ecca.curvesDone ++;
-                                                                               ecca.curvesAccepted ++;
-                                                                               ecca.ecc.Add(ecc);
+                                                       heightAccumulated += heightCurve;
+
+                                                       heightCurve = Math.Abs(heightCurve / 10); //mm -> cm
+                                                       LogB.Information(" height: " + 
heightCurve.ToString());
+
+                                                       //1) check heightCurve in a fast way first to discard 
curves soon
+                                                       //   only process curves with height >= min_height
+                                                       //2) if it's concentric, only take the concentric 
curves, 
+                                                       //   but if it's concentric and inertial: take both.
+                                                       //   
+                                                       //   When capturing on inertial, we have the first 
graph
+                                                       //   that will be converted to the second.
+                                                       //   we need the eccentric phase in order to detect 
the Ci2
+
+                                                       /*               
+                                                        *             /\
+                                                        *            /  \
+                                                        *           /    \
+                                                        *____      C1     \      ___
+                                                        *    \    /        \    /
+                                                        *     \  /          \  C2
+                                                        *      \/            \/
+                                                        *
+                                                        * C1, C2: two concentric phases
+                                                        */
+
+                                                       /*               
+                                                        *____                    ___
+                                                        *    \    /\      /\    /
+                                                        *     \ Ci1 \   Ci2 \ Ci3
+                                                        *      \/    \  /    \/
+                                                        *             \/
+                                                        *
+                                                        * Ci1, Ci2, Ci3: three concentric phases on inertial
+                                                        */
+
+                                                       //3) if it's ecc-con, don't record first curve if 
first curve is concentric
+
+                                                       /*
+                                                        * on inertiaMomentCalculation we don't need to send 
data to R and get curves
+                                                        * we will call R at the end
+                                                        */
+
+                                                       if(! inertiaMomentCalculation) {        
+                                                               bool sendCurve = true;
+                                                               if(heightCurve >= 
encoderSelectedMinimumHeight)         //1
+                                                               {
+                                                                       
if(encoderConfigurationCurrent.has_inertia) {
+                                                                               if(capturingFirstPhase)
+                                                                                       sendCurve = false;
+                                                                       } else { // ! 
encoderConfigurationCurrent.has_inertia
+                                                                               if( eccon == "c" && ! ecc.up )
+                                                                                       sendCurve = false;
+                                                                               if( (eccon == "ec" || eccon 
== "ecS") && ecc.up && capturingFirstPhase ) //3
+                                                                                       sendCurve = false;
                                                                        }
+                                                                       capturingFirstPhase = false;
+                                                               } else {
+                                                                       sendCurve = false;
+                                                               }
+
+                                                               if(sendCurve) {
+                                                                       
UtilEncoder.RunEncoderCaptureNoRDotNetSendCurve(
+                                                                                       pCaptureNoRDotNet, 
+                                                                                       heightAtCurveStart, 
+                                                                                       //curve);             
                  //uncompressed
+                                                                               
UtilEncoder.CompressData(curve, 25)     //compressed
+                                                                                       );
+
+                                                                       ecca.curvesDone ++;
+                                                                       ecca.curvesAccepted ++;
+                                                                       ecca.ecc.Add(ecc);
                                                                }
                                                        }
                                                }
@@ -3855,19 +3828,11 @@ public partial class ChronoJumpWindow
         * update encoder capture graph stuff
         */
 
-       private void updateEncoderCaptureGraph(bool graphSignal, bool calcCurves, bool plotCurvesBars) 
-       {
-               if(encoderCapturePoints != null) 
-               {
-                       if(graphSignal)
-                               updateEncoderCaptureGraphPaint(); 
-                       if(calcCurves)
-                               updateEncoderCaptureGraphRCalcPre(plotCurvesBars); 
-               }
-       }
-       
        private void updateEncoderCaptureGraphPaint() 
        {
+               if(encoderCapturePoints == null)
+                       return;
+
                bool refreshAreaOnly = false;
                
                //mark meaning screen should be erased
@@ -3945,301 +3910,9 @@ public partial class ChronoJumpWindow
 
        static List<string> encoderCaptureStringR;
        static ArrayList captureCurvesBarsData;
-       static bool updatingEncoderCaptureGraphRCalc;
        
        double massDisplacedEncoder = 0;
        
-       private void updateEncoderCaptureGraphRCalcPre(bool plotCurvesBars) 
-       {
-               //check if this helps to show bars on slow computers
-               if(! updatingEncoderCaptureGraphRCalc) {
-                       updateEncoderCaptureGraphRCalc(plotCurvesBars);
-                       updatingEncoderCaptureGraphRCalc = false;
-               }
-       }
-       
-       private void updateEncoderCaptureGraphRCalc(bool plotCurvesBars) 
-       {
-               if(RInitialized == Constants.Status.UNSTARTED || RInitialized == Constants.Status.ERROR)
-                       return;
-               
-               if(! eccaCreated)
-                       return;
-               if(ecca.ecc.Count <= ecca.curvesDone) 
-                       return;
-               
-               updatingEncoderCaptureGraphRCalc = true;
-               LogB.Debug("updateEncoderCaptureGraphRCalc");
-
-               EncoderCaptureCurve ecc = (EncoderCaptureCurve) ecca.ecc[ecca.curvesDone];
-               LogB.Debug("\n" + ecc.DirectionAsString() + " " + ecc.startFrame.ToString() + " " + 
ecc.endFrame.ToString());
-               
-               string eccon = findEccon(true);
-                       
-               LogB.Debug("eccon: + " + eccon + "; endFrame: " + ecc.endFrame + "; startFrame: " + 
ecc.startFrame + 
-                               "; duration: " + (ecc.endFrame - ecc.startFrame).ToString() );
-               
-               if( ( ( eccon == "c" && ecc.up ) || eccon != "c" ) &&
-                               (ecc.endFrame - ecc.startFrame) > 0 ) 
-               {
-                       LogB.Information("Processing... ");
-
-                       //on excentric-concentric discard if first curve is concentric
-                       if ( (eccon == "ec" || eccon == "ecS") && ecc.up && ecca.curvesAccepted == 0 ) {
-                               ecca.curvesDone ++;
-                               LogB.Warning("Discarded curve. eccentric-concentric and first curve is 
concentric.");
-                               return; 
-                       }
-                       
-                       double height = 0;
-
-                       double [] curve = new double[ecc.endFrame - ecc.startFrame];
-                       for(int k=0, j=ecc.startFrame; j < ecc.endFrame ; j ++) {
-                               height += encoderReaded[j];
-                               curve[k]=encoderReaded[j];
-                               k++;
-                       }
-                       
-                       //check height in a fast way first to discard curves soon
-                       //only process curves with height >= min_height
-                       height = Math.Abs(height / 10); //mm -> cm
-                       LogB.Information(" height: " + height.ToString());
-                       if(height < (int) encoderCaptureOptionsWin.spin_encoder_capture_min_height.Value) {
-                               ecca.curvesDone ++;
-                               LogB.Warning("Discarded curve. height is very low.");
-                               return; 
-                       }
-
-                       
-                       LogB.Information("rdotnet 1 speedCut...");
-
-                       NumericVector curveToR = rengine.CreateNumericVector(curve);
-                       rengine.SetSymbol("curveToR", curveToR);
-
-                       //cannot do smooth.spline with less than 4 values
-                       if(curveToR.Length <= 4)
-                               return;
-                       try {
-                               rengine.Evaluate("speedCut <- smooth.spline( 1:length(curveToR), curveToR, 
spar=0.7)");
-                       } catch {
-                               return;
-                       }
-
-                       LogB.Information("rdotnet 2 extrema...");
-                       //reduce curve by speed, the same way as graph.R
-                       rengine.Evaluate("b=extrema(speedCut$y)");
-
-
-                       if(ecc.up) { //concentric
-                               rengine.Evaluate("speedT1 <- min(which(speedCut$y == max(speedCut$y)))");
-                               rengine.Evaluate("speedT2 <- max(which(speedCut$y == max(speedCut$y)))");
-                       } else {
-                               rengine.Evaluate("speedT1 <- min(which(speedCut$y == min(speedCut$y)))");
-                               rengine.Evaluate("speedT2 <- max(which(speedCut$y == min(speedCut$y)))");
-                       }
-                       
-                       LogB.Information("rdotnet 3 crossings...");
-                       int speedT1 = rengine.GetSymbol("speedT1").AsInteger().First();
-                       int speedT2 = rengine.GetSymbol("speedT2").AsInteger().First();
-
-                       rengine.Evaluate("bcrossLen <- length(b$cross[,2])");
-                       int bcrossLen = rengine.GetSymbol("bcrossLen").AsInteger().First();
-
-                       rengine.Evaluate("bcross <- b$cross[,2]");
-                       IntegerVector bcross = rengine.GetSymbol("bcross").AsInteger();
-
-                       //left adjust
-                       //find the b$cross at left of max speed
-
-                       LogB.Debug("rdotnet 4 reduceCurveBySpeed left...");
-
-                       int x_ini = 0;  
-                       if(bcrossLen == 0)
-                               x_ini = 0;
-                       else if(bcrossLen == 1) {
-                               if(bcross[0] < speedT1)
-                                       x_ini = bcross[0];
-                       } else {
-                               x_ini = bcross[0];      //not 1, we are in C# now
-                               for(int i=0; i < bcross.Length; i++) {
-                                       if(bcross[i] < speedT1)
-                                               x_ini = bcross[i];      //left adjust
-                               }
-                       }
-                       LogB.Debug("rdotnet 5 reduceCurveBySpeed right...");
-
-                       //rengine.Evaluate("curveToRcumsum = cumsum(curveToR)");
-
-                       //TODO: this has to be at right of x_ini
-                       //rengine.Evaluate("firstFrameAtTop <- min(which(curveToRcumsum == max 
(curveToRcumsum)))");
-                       //int x_end = rengine.GetSymbol("firstFrameAtTop").AsInteger().First();
-
-
-                       //right adjust
-                       //find the b$cross at right of max speed
-       
-                       int x_end = curveToR.Length; //good to declare here
-                       if(bcrossLen == 0) {
-                               x_end = curveToR.Length;
-                       } else if(bcrossLen == 1) {
-                               if(bcross[0] > speedT2)
-                                       x_end = bcross[0];
-                       } else {
-                               for(int i=bcross.Length -1; i >= 0; i--) {
-                                       if(bcross[i] > speedT2)
-                                               x_end = bcross[i];      //right adjust
-                               }
-                       }
-                       
-                       LogB.Debug("rdotnet 6 more process...");
-
-                       LogB.Information("reducedCurveBySpeed (start, end)");
-                       LogB.Information((ecc.startFrame + x_ini).ToString());
-                       LogB.Information((ecc.startFrame + x_end).ToString());
-
-                       //TODO: this is to get info about previous TODO bug
-                       if(ecc.startFrame + x_end <= ecc.startFrame + x_ini)
-                               for(int i=x_end; i < x_ini; i ++)
-                                       LogB.Information(curveToR[i] + ","); //TODO: provar aixo!!            
                  
-
-                       //create a curveToR with only reduced curve
-                       NumericVector curveToRreduced = rengine.CreateNumericVector(new double[x_end - 
x_ini]);
-                       for(int k=0, i=x_ini; i < x_end; i ++)
-                               curveToRreduced[k++] = curveToR[i];                             
-                       rengine.SetSymbol("curveToRreduced", curveToRreduced);
-
-                       //2) do speed and accel for curve once reducedCurveBySpeed
-
-                       //cannot do smooth.spline with less than 4 values
-                       if(curveToRreduced.Length <= 4)
-                               return;
-                       try {
-                               rengine.Evaluate("speed <- smooth.spline( 1:length(curveToRreduced), 
curveToRreduced, spar=0.7)");
-                       } catch {
-                               return;
-                       }
-
-                       //height (or range)     
-                       rengine.Evaluate("curveToRreduced.cumsum <- cumsum(curveToRreduced)");
-                       rengine.Evaluate("range <- 
abs(curveToRreduced.cumsum[length(curveToRreduced)]-curveToRreduced.cumsum[1])");
-                       
-                       //check height now in a more accurate way than before
-                       height = rengine.GetSymbol("range").AsNumeric().First();
-                       height = Math.Abs(height / 10); //mm -> cm
-
-                       //only process curves with height >= min_height
-                       if(height < (int) encoderCaptureOptionsWin.spin_encoder_capture_min_height.Value) {
-                               ecca.curvesDone ++;
-                               LogB.Warning("Discarded curve. height (after reduceCurveBySpeed) is very 
low.");
-                               return; 
-                       }
-
-
-                       //accel and propulsive stuff
-                       rengine.Evaluate("accel <- predict( speed, deriv=1 )");
-                       rengine.Evaluate("accel$y <- accel$y * 1000"); //input data is in mm, conversion to m
-
-                       //propulsive stuff
-                       //int propulsiveEnd = curveToRreduced.Length;
-                       rengine.Evaluate("g <- 9.81");
-                       if(ecc.up && preferences.encoderPropulsive) {
-                               //check if propulsive phase ends
-                               LogB.Information("accel$y");
-                               //rengine.Evaluate("print(accel$y)");
-                               rengine.Evaluate("propulsiveStuffAtRight <- length(which(accel$y <= -g))"); 
-                               int propulsiveStuffAtRight = 
rengine.GetSymbol("propulsiveStuffAtRight").AsInteger().First();
-                               LogB.Information(string.Format("propulsiveStuffAtRight: {0}", 
propulsiveStuffAtRight));
-                               if(propulsiveStuffAtRight > 0) {
-                                       rengine.Evaluate("propulsiveEnd <- min(which(accel$y <= -g))");
-                                       int propulsiveEnd = 
rengine.GetSymbol("propulsiveEnd").AsInteger().First();
-
-                                       rengine.Evaluate("curveToRreduced <- 
curveToRreduced[1:propulsiveEnd]");
-                                       rengine.Evaluate("speed$y <- speed$y[1:propulsiveEnd]");
-                                       rengine.Evaluate("accel$y <- accel$y[1:propulsiveEnd]");
-                               }
-                       }
-                       //end of propulsive stuff
-
-
-                       NumericVector mass = rengine.CreateNumericVector(new double[] { massDisplacedEncoder 
});
-                       rengine.SetSymbol("mass", mass);
-               
-
-                       //if isJump == "True":
-                       rengine.Evaluate("force <- mass*(accel$y+9.81)");
-                       //else:
-                       //rengine.Evaluate("force <- mass*accel$y')
-                       rengine.Evaluate("power <- force*speed$y");
-
-                       if(ecc.up) //concentric
-                               rengine.Evaluate("meanPower <- mean(power)");
-                       else
-                               rengine.Evaluate("meanPower <- mean(abs(power))");
-
-                       rengine.Evaluate("peakPower <- max(power)");
-
-                       //without the 'min', if there's more than one value it returns a list and this make 
crash later in
-                       //this code:  pp_ppt = peakPower / peakPowerT
-                       rengine.Evaluate("peakPowerT=min(which(power == peakPower))"); 
-
-                       //rengine.Evaluate("print(speed$y)");
-                       
-                       rengine.Evaluate("meanSpeed = mean(abs(speed$y))");
-                       double meanSpeed = rengine.GetSymbol("meanSpeed").AsNumeric().First();
-
-                       double maxSpeed = 0;
-                       if(ecc.up) {
-                               rengine.Evaluate("maxSpeed = max(speed$y)");
-                               maxSpeed = rengine.GetSymbol("maxSpeed").AsNumeric().First();
-                               //phase = "   up,"
-                       }
-                       else {
-                               rengine.Evaluate("maxSpeed = min(speed$y)");
-                               maxSpeed = rengine.GetSymbol("maxSpeed").AsNumeric().First();
-                               //phase = " down,"
-                       }
-                       
-                       double meanPower = rengine.GetSymbol("meanPower").AsNumeric().First();
-                       double peakPower = rengine.GetSymbol("peakPower").AsNumeric().First();
-                       double peakPowerT = rengine.GetSymbol("peakPowerT").AsNumeric().First();
-
-                       peakPowerT = peakPowerT / 1000; //ms -> s
-                       double pp_ppt = peakPower / peakPowerT;
-
-                       //plot
-                       if(plotCurvesBars) {
-                               string title = "";
-                               string mainVariable = encoderCaptureOptionsWin.GetMainVariable();
-                               double mainVariableHigher = 
encoderCaptureOptionsWin.GetMainVariableHigher(mainVariable);
-                               double mainVariableLower = 
encoderCaptureOptionsWin.GetMainVariableLower(mainVariable);
-                               captureCurvesBarsData.Add(new EncoderBarsData(meanSpeed, maxSpeed, 0, 0, 
meanPower, peakPower)); //0,0: meanForce, maxForce
-
-                               plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, 
captureCurvesBarsData, 
-                                               true);  //capturing
-                       }
-
-
-                       LogB.Information(string.Format(
-                                               "height: {0}\nmeanSpeed: {1}\n, maxSpeed: {2}\n, maxSpeedT: 
{3}\n" + 
-                                               "meanPower: {4}\npeakPower: {5}\npeakPowerT: {6}", 
-                                               height, meanSpeed, maxSpeed, speedT1, meanPower, peakPower, 
peakPowerT));
-                       
-                       
encoderCaptureStringR.Add(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    
-                                       Util.ConvertToPoint(meanSpeed), Util.ConvertToPoint(maxSpeed), 
speedT1,
-                                       Util.ConvertToPoint(meanPower), Util.ConvertToPoint(peakPower), 
-                                       Util.ConvertToPoint(peakPowerT*1000), Util.ConvertToPoint(peakPower / 
peakPowerT) 
-                                       ));
-               
-                       treeviewEncoderCaptureRemoveColumns();
-                       ecca.curvesAccepted = createTreeViewEncoderCapture(encoderCaptureStringR);
-               }
-
-               ecca.curvesDone ++;
-       }
-
        //if we are capturing, play sounds
        void plotCurvesGraphDoPlot(string mainVariable, double mainVariableHigher, double mainVariableLower, 
                        ArrayList data6Variables, bool capturing) 
@@ -4658,24 +4331,7 @@ public partial class ChronoJumpWindow
                        LogB.Information("encoderThreadStart begins");
                        if( runEncoderCaptureCsharpCheckPort(chronopicWin.GetEncoderPort()) ) {
                                if(action == encoderActions.CAPTURE) {
-                                       if(useRDotNet) {
-                                               if(RInitialized == Constants.Status.UNSTARTED)
-                                                       rengine = 
UtilEncoder.RunEncoderCaptureCsharpInitializeR(rengine, out RInitialized);
-
-                                               /* 
-                                                * if error means a problem with RDotNet, not necessarily a 
problem with R
-                                                * we can contnue but without realtime data
-                                                *
-                                                if(RInitialized == Constants.Status.ERROR) {
-                                                new DialogMessage(Constants.MessageTypes.WARNING,
-                                                Catalog.GetString("Sorry. Error doing graph.") +
-                                                "\n" + Catalog.GetString("Maybe R or EMD are not 
installed.") +
-                                                "\n\nhttp://www.r-project.org/";);
-                                                return;
-                                                }
-                                                */
-                                       } else
-                                               runEncoderCaptureNoRDotNetInitialize();
+                                       runEncoderCaptureNoRDotNetInitialize();
                                }
                                
                                image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5; 
@@ -4716,7 +4372,6 @@ public partial class ChronoJumpWindow
 
                                if(action == encoderActions.CAPTURE) {
                                        captureCurvesBarsData = new ArrayList();
-                                       updatingEncoderCaptureGraphRCalc = false;
 
                                        needToRefreshTreeviewCapture = false;
                                        encoderSelectedMinimumHeight =(int) 
encoderCaptureOptionsWin.spin_encoder_capture_min_height.Value;
@@ -5184,10 +4839,8 @@ LogB.Debug("D");
                                encoderStopVideoRecord();
                        }
 
-                       if(! useRDotNet) {
-                               UtilEncoder.RunEncoderCaptureNoRDotNetSendEnd(pCaptureNoRDotNet);
-                               pCaptureNoRDotNet.WaitForExit();
-                       }
+                       UtilEncoder.RunEncoderCaptureNoRDotNetSendEnd(pCaptureNoRDotNet);
+                       pCaptureNoRDotNet.WaitForExit();
                        
                        LogB.ThreadEnded(); 
                        return false;
@@ -5196,53 +4849,35 @@ LogB.Debug("D");
                {
                        updatePulsebar(encoderActions.CAPTURE); //activity on pulsebar
                        
-                       if(useRDotNet) {
-                               //calculations with RDotNet are not available yet on inertial   
-                               if(encoderConfigurationCurrent.has_inertia) {
-                                       UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea, 
encoder_capture_curves_bars_pixmap);
-                                       layout_encoder_capture_curves_bars.SetMarkup("Realtime inertial 
calculations\nnot available in this version");
-                                       int textWidth = 1;
-                                       int textHeight = 1;
-                                       int 
graphWidth=encoder_capture_curves_bars_drawingarea.Allocation.Width;
-                                       layout_encoder_capture_curves_bars.GetPixelSize(out textWidth, out 
textHeight); 
-                                       encoder_capture_curves_bars_pixmap.DrawLayout 
(pen_black_encoder_capture, 
-                                                       Convert.ToInt32( (graphWidth/2) - textWidth/2), 0, 
//x, y 
-                                                       layout_encoder_capture_curves_bars);
-
-                                       updateEncoderCaptureGraph(true, true, true); //graphSignal, 
calcCurves, plotCurvesBars
-                               } else
-                                       updateEncoderCaptureGraph(true, true, true); //graphSignal, 
calcCurves, plotCurvesBars
-                       } else {
-                               //capturingSendCurveToR(); //unused, done while capturing
-                               readingCurveFromR();
-                               
-                               updateEncoderCaptureGraph(true, false, false); //graphSignal, no calcCurves, 
no plotCurvesBars
-       
-                               if(needToRefreshTreeviewCapture) 
-                               {
-                                       //LogB.Error("HERE YES");
-                                       //LogB.Error(encoderCaptureStringR);
-                                       
-                                       treeviewEncoderCaptureRemoveColumns();
-                                       ecca.curvesAccepted = 
createTreeViewEncoderCapture(encoderCaptureStringR);
-                       
-                                       //if(plotCurvesBars) {
-                                               string title = "";
-                                               string mainVariable = 
encoderCaptureOptionsWin.GetMainVariable();
-                                               double mainVariableHigher = 
encoderCaptureOptionsWin.GetMainVariableHigher(mainVariable);
-                                               double mainVariableLower = 
encoderCaptureOptionsWin.GetMainVariableLower(mainVariable);
-                                               //TODO:
-                                               //captureCurvesBarsData.Add(new EncoderBarsData(meanSpeed, 
maxSpeed, meanPower, peakPower));
-                                               //captureCurvesBarsData.Add(new EncoderBarsData(20, 39, 10, 
40));
-
-                                               plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, 
mainVariableLower, captureCurvesBarsData, 
-                                                               true);  //capturing
-                                       //}
+                       //capturingSendCurveToR(); //unused, done while capturing
+                       readingCurveFromR();
 
-                                       needToRefreshTreeviewCapture = false;
-                               }
+                       updateEncoderCaptureGraphPaint();
+
+                       if(needToRefreshTreeviewCapture) 
+                       {
+                               //LogB.Error("HERE YES");
+                               //LogB.Error(encoderCaptureStringR);
+
+                               treeviewEncoderCaptureRemoveColumns();
+                               ecca.curvesAccepted = createTreeViewEncoderCapture(encoderCaptureStringR);
+
+                               //if(plotCurvesBars) {
+                               string title = "";
+                               string mainVariable = encoderCaptureOptionsWin.GetMainVariable();
+                               double mainVariableHigher = 
encoderCaptureOptionsWin.GetMainVariableHigher(mainVariable);
+                               double mainVariableLower = 
encoderCaptureOptionsWin.GetMainVariableLower(mainVariable);
+                               //TODO:
+                               //captureCurvesBarsData.Add(new EncoderBarsData(meanSpeed, maxSpeed, 
meanPower, peakPower));
+                               //captureCurvesBarsData.Add(new EncoderBarsData(20, 39, 10, 40));
+
+                               plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, 
captureCurvesBarsData, 
+                                               true);  //capturing
+                               //}
+
+                               needToRefreshTreeviewCapture = false;
                        }
-                       
+
                        LogB.Debug(" Cap:", encoderThread.ThreadState.ToString());
                } else if(capturingCsharp == encoderCaptureProcess.STOPPING) {
                        //stop video            
@@ -5271,7 +4906,7 @@ LogB.Debug("D");
                        return false;
                }
                updatePulsebar(encoderActions.CAPTURE_IM); //activity on pulsebar
-               updateEncoderCaptureGraph(true, false, false); //graphSignal, not calcCurves, not 
plotCurvesBars
+               updateEncoderCaptureGraphPaint();
 
                Thread.Sleep (25);
                LogB.Debug(" CapIM:", encoderThread.ThreadState.ToString());
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 7cdae63..3f2788e 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -26,8 +26,6 @@ using System.Diagnostics;     //for detect OS and for Process
 using System.IO;               //for detect OS
 using Mono.Unix;
 
-using System.Linq;     //RDotNet
-using RDotNet;         //RDotNet
 
 //this class tries to be a space for methods that are used in different classes
 public class UtilEncoder
@@ -233,7 +231,7 @@ public class UtilEncoder
 
        
        /*
-        * DEPRECATED, now use always RDotNet
+        * DEPRECATED, now use always RDotNet. Until 1.5.0 where RDotNet is not used anymore. Neither this 
Pyton method.
        public static void RunEncoderCapturePython(string title, EncoderStruct es, string port) 
        {
                CancelRScript = false;
@@ -286,81 +284,6 @@ public class UtilEncoder
        }
        */
        
-       public static REngine RunEncoderCaptureCsharpInitializeR(REngine rengine, out Constants.Status 
RInitialized) 
-       {
-               LogB.Information("initializing rdotnet");
-               
-               //RDotNet.StartupParameter rsup = new RDotNet.StartupParameter();
-               //rsup.Interactive = false;
-               //rsup.Quiet = false;
-
-               rengine = REngine.CreateInstance("RDotNet");
-               
-               // From v1.5, REngine requires explicit initialization.
-               // You can set some parameters.
-
-               try {
-                       //rengine.Initialize(rsup);
-                       rengine.Initialize();
-               } catch {
-                       RInitialized = Constants.Status.ERROR;
-                       return rengine;
-               }
-               //Previous command, unfortunatelly localizes all GUI to english
-               //then call Catalog.Init again in order to see new windows localised            
-               //Catalog.Init("chronojump",System.IO.Path.Combine(Util.GetPrefixDir(),"share/locale"));
-
-               //load extrema method copied from EMD package
-               string utilRPath = GetEncoderScriptUtilR();
-               string graphRPath = GetEncoderScriptGraph();
-               
-               //On win32 R understands backlash as an escape character and 
-               //a file path uses Unix-like path separator '/'
-               if(UtilAll.IsWindows()) {
-                       utilRPath = utilRPath.Replace("\\","/");
-                       graphRPath = graphRPath.Replace("\\","/");
-               }
-               LogB.Information(utilRPath);
-               LogB.Information(graphRPath);
-               
-               try {
-                       //load extrema
-                       rengine.Evaluate("source('" + utilRPath + "')");
-                       //load more stuff and call later using RDotNet
-                       rengine.Evaluate("source('" + graphRPath + "')");
-               } catch {
-                       RInitialized = Constants.Status.ERROR;
-                       return rengine;
-               }
-
-               try {
-                       // .NET Framework array to R vector.
-                       NumericVector group1 = rengine.CreateNumericVector(new double[] { 30.02, 29.99, 
30.11, 29.97, 30.01, 29.99 });
-                       rengine.SetSymbol("group1", group1);
-                       // Direct parsing from R script.
-                       NumericVector group2 = rengine.Evaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 
30.02, 29.98)").AsNumeric();
-
-                       // Test difference of mean and get the P-value.
-                       GenericVector testResult = rengine.Evaluate("t.test(group1, group2)").AsList();
-                       double p = testResult["p.value"].AsNumeric().First();
-
-                       //not using LogB because like with Console the format of numbers is displayed better
-                       Console.WriteLine("Group1: [{0}]", string.Join(", ", group1));
-                       Console.WriteLine("Group2: [{0}]", string.Join(", ", group2));
-                       Console.WriteLine("P-value = {0:0.000}", p);
-               } catch {
-                       RInitialized = Constants.Status.ERROR;
-                       return rengine;
-               }
-
-               LogB.Information("initialized rdotnet");
-               
-               RInitialized = Constants.Status.OK;
-
-               return rengine;
-       }
-       
-       
        public static EncoderGraphROptions PrepareEncoderGraphOptions(string title, EncoderStruct es, bool 
neuromuscularProfileDo, bool translate) 
        {
                string scriptUtilR = GetEncoderScriptUtilR();
@@ -419,70 +342,6 @@ public class UtilEncoder
                                scriptGraphR);
        }
 
-       /*      
-        *      Currently unused because this was called in main thread and when a pulse thread exists
-        *      It should be without threading or in the GTK thread
-        *      Now graph call is so fast with the call_graph.R
-        *      then there's no need to add the complexity of calling RunEncoderGraphRDotNet outside the 
thread
-        *      because the GTK thread has some interesting things that it does when it ends.
-        *      We have enough speed now and we don't want to add more bugs
-        *
-       public static bool RunEncoderGraph(REngine rengine, Constants.Status RInitialized,
-                       string title, EncoderStruct es, bool neuromuscularProfileDo) 
-       {
-               if(RInitialized == Constants.Status.UNSTARTED)
-                       RunEncoderCaptureCsharpInitializeR(rengine, out RInitialized);
-               
-               bool result = false;
-               if(RInitialized == Constants.Status.ERROR)
-                       result = RunEncoderGraphNoRDotNet(title, es, neuromuscularProfileDo);
-               else if(RInitialized == Constants.Status.OK)
-                       result = RunEncoderGraphRDotNet(rengine, title, es, neuromuscularProfileDo);
-
-               return result;
-       }
-
-       //this method uses RDotNet
-       public static bool RunEncoderGraphRDotNet(REngine rengine, string title, EncoderStruct es, bool 
neuromuscularProfileDo) 
-       {
-               //if RDotNet is ok, graph.R is already loaded
-               rengine.Evaluate("meanPower <- mean(c(2,3,4,5,6,7,8))");
-               double meanPower = rengine.GetSymbol("meanPower").AsNumeric().First();
-               Log.WriteLine(meanPower.ToString());
-               rengine.Evaluate("print(findPosInPaf(\"Power\", \"max\"))");
-
-               EncoderGraphROptions roptions = PrepareEncoderGraphOptions(title, es, neuromuscularProfileDo);
-               Log.WriteLine(roptions.ToString());     
-
-               //--------------------------------------------
-               //              Attention
-               //this code should be the same as call_graph.R
-               //--------------------------------------------
-
-               //TODO: pass roptions to RDotNet objects and then call graph.R
-               CharacterVector charVec;
-       
-               Log.WriteLine("-1-");   
-               string str_string = roptions.outputData2;
-               Log.WriteLine(str_string);
-               
-               charVec = rengine.CreateCharacterVector(new[] { str_string });
-               rengine.SetSymbol("OutputData2", charVec);
-       
-               Log.WriteLine("-2-");   
-               Log.WriteLine(roptions.specialData);    
-               Log.WriteLine("-3-");   
-               CharacterVector charVec2 = rengine.CreateCharacterVector(new[] { roptions.specialData });
-               rengine.SetSymbol("SpecialData", charVec2);
-               
-               Log.WriteLine(roptions.operatingSystem);        
-               charVec = rengine.CreateCharacterVector(new[] { roptions.operatingSystem });
-               rengine.SetSymbol("OperatingSystem", charVec);
-
-               return true;
-       }
-       */
-
 
 
        //here curve is sent compressed (string. eg: "0*5 1 0 -1*3 2")
@@ -504,27 +363,6 @@ public class UtilEncoder
                
                LogB.Debug("<-- writen line 1");
        }
-       /* unused
-        * here curve is sent uncompressed ([] double)
-       public static void RunEncoderCaptureNoRDotNetSendCurve(Process p, double heightAtStart, double [] d)
-       {
-               LogB.Debug("writing line 1 -->");
-               
-               string curveSend = "ps " + Util.ConvertToPoint(heightAtStart);
-               LogB.Debug("curveSend [heightAtStart]",curveSend);
-               p.StandardInput.WriteLine(curveSend);
-
-               //maybe this method falis when there's lots of data
-               curveSend = string.Join(" ", Array.ConvertAll(d, x => x.ToString()));
-               
-               //TODO convert comma to point in this doubles
-
-               LogB.Debug("curveSend [displacement array]",curveSend);
-               p.StandardInput.WriteLine(curveSend);
-               
-               LogB.Debug("<-- writen line 1");
-       }
-       */
        
        public static void RunEncoderCaptureNoRDotNetSendEnd(Process p)
        {



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