[chronojump] Encoder: capture c# started



commit 33979caddc481fccd265c4a7870b458449cd4d64
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 18 20:29:50 2013 +0100

    Encoder: capture c# started

 glade/chronojump.glade |   48 +++++++++++++++++++++++++++++++++
 rdotnet/Makefile       |   69 ++++++++++++++++++++++++++++++++---------------
 rdotnet/Makefile.in    |   29 ++++++++++++++++++-
 src/encoder.cs         |    3 ++
 src/gui/chronojump.cs  |    1 -
 src/gui/encoder.cs     |   60 +++++++++++++++++++++---------------------
 src/util.cs            |   46 ++++++++++++++++++++++++++++++-
 7 files changed, 199 insertions(+), 57 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 1db1aa7..61c8577 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12559,6 +12559,54 @@ on current Chronojump version.</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_encoder_capture_csharp">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="can_default">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <property 
name="use_action_appearance">False</property>
+                                                            <property name="use_underline">True</property>
+                                                            <property name="xalign">0</property>
+                                                            <signal name="clicked" 
handler="on_button_encoder_capture_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox74">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkImage" id="image2">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-apply</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label111">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">Capture safe</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/rdotnet/Makefile b/rdotnet/Makefile
index 1148772..cbb8de3 100644
--- a/rdotnet/Makefile
+++ b/rdotnet/Makefile
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
 # rdotnet/Makefile.  Generated from Makefile.in by configure.
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -16,6 +16,23 @@
 
 
 
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
 pkgdatadir = $(datadir)/chronojump
 pkgincludedir = $(includedir)/chronojump
 pkglibdir = $(libdir)/chronojump
@@ -32,8 +49,8 @@ POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = x86_64-unknown-linux-gnu
-host_triplet = x86_64-unknown-linux-gnu
+build_triplet = i686-pc-linux-gnu
+host_triplet = i686-pc-linux-gnu
 subdir = rdotnet
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -77,18 +94,23 @@ am__installdirs = "$(DESTDIR)$(chronojump_pkglibdir)"
 SCRIPTS = $(chronojump_pkglib_SCRIPTS)
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/andoni/git/chronojump/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/missing --run aclocal-1.11
 ACLOCAL_AMFLAGS = -I m4/shamrock -I m4/shave ${ACLOCAL_FLAGS}
 AMTAR = $${TAR-tar}
 AR = ar
-AUTOCONF = ${SHELL} /home/andoni/git/chronojump/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/andoni/git/chronojump/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/andoni/git/chronojump/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/missing --run automake-1.11
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
-CESARPLAYER_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include 
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 
-I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 
-I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gstreamer-0.10 
-I/usr/include/libxml2  
+CESARPLAYER_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include 
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 
-I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include 
-I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gstreamer-0.10 
-I/usr/include/libxml2  
 CESARPLAYER_LIBS = -pthread -lgtk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig -lgdk-x11-2.0 
-lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgio-2.0 -lgstaudio-0.10 -lgstvideo-0.10 
-lgstpbutils-0.10 -lgstinterfaces-0.10 -lgstapp-0.10 -lgstbase-0.10 -lgsttag-0.10 -lgstreamer-0.10 
-lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lglib-2.0  
 CFLAGS = -g -O2
 CPP = gcc -E
@@ -117,7 +139,7 @@ INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-LD = /usr/bin/ld -m elf_x86_64
+LD = /usr/bin/ld
 LDFLAGS = 
 LIBOBJS = 
 LIBS = 
@@ -126,7 +148,7 @@ LIPO =
 LN_S = ln -s
 LTLIBOBJS = 
 MAINT = 
-MAKEINFO = ${SHELL} /home/andoni/git/chronojump/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/missing --run makeinfo
 MANIFEST_TOOL = :
 MCS = /usr/bin/dmcs
 MKDIR_P = /bin/mkdir -p
@@ -162,10 +184,10 @@ SET_MAKE =
 SHELL = /bin/bash
 STRIP = strip
 VERSION = 1.3.3
-abs_builddir = /home/andoni/git/chronojump/rdotnet
-abs_srcdir = /home/andoni/git/chronojump/rdotnet
-abs_top_builddir = /home/andoni/git/chronojump
-abs_top_srcdir = /home/andoni/git/chronojump
+abs_builddir = /home/xavier/informatica/progs_meus/chronojump/chronojump/rdotnet
+abs_srcdir = /home/xavier/informatica/progs_meus/chronojump/chronojump/rdotnet
+abs_top_builddir = /home/xavier/informatica/progs_meus/chronojump/chronojump
+abs_top_srcdir = /home/xavier/informatica/progs_meus/chronojump/chronojump
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -175,11 +197,11 @@ am__quote =
 am__tar = $${TAR-tar} chof - "$$tardir"
 am__untar = $${TAR-tar} xf -
 bindir = ${exec_prefix}/bin
-build = x86_64-unknown-linux-gnu
+build = i686-pc-linux-gnu
 build_alias = 
-build_cpu = x86_64
+build_cpu = i686
 build_os = linux-gnu
-build_vendor = unknown
+build_vendor = pc
 builddir = .
 datadir = ${datarootdir}
 datarootdir = ${prefix}/share
@@ -189,15 +211,15 @@ exec_prefix = /usr/local
 expanded_bindir = /usr/local/bin
 expanded_datadir = /usr/local/share
 expanded_libdir = /usr/local/lib
-host = x86_64-unknown-linux-gnu
+host = i686-pc-linux-gnu
 host_alias = 
-host_cpu = x86_64
+host_cpu = i686
 host_os = linux-gnu
-host_vendor = unknown
+host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/andoni/git/chronojump/install-sh
+install_sh = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
@@ -262,8 +284,11 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 install-chronojump_pkglibSCRIPTS: $(chronojump_pkglib_SCRIPTS)
        @$(NORMAL_INSTALL)
-       test -z "$(chronojump_pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(chronojump_pkglibdir)"
        @list='$(chronojump_pkglib_SCRIPTS)'; test -n "$(chronojump_pkglibdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(chronojump_pkglibdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(chronojump_pkglibdir)" || exit 1; \
+       fi; \
        for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
diff --git a/rdotnet/Makefile.in b/rdotnet/Makefile.in
index fbfe429..e10d145 100644
--- a/rdotnet/Makefile.in
+++ b/rdotnet/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -16,6 +16,23 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \  ]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -77,6 +94,11 @@ am__installdirs = "$(DESTDIR)$(chronojump_pkglibdir)"
 SCRIPTS = $(chronojump_pkglib_SCRIPTS)
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
@@ -262,8 +284,11 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 install-chronojump_pkglibSCRIPTS: $(chronojump_pkglib_SCRIPTS)
        @$(NORMAL_INSTALL)
-       test -z "$(chronojump_pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(chronojump_pkglibdir)"
        @list='$(chronojump_pkglib_SCRIPTS)'; test -n "$(chronojump_pkglibdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(chronojump_pkglibdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(chronojump_pkglibdir)" || exit 1; \
+       fi; \
        for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
diff --git a/src/encoder.cs b/src/encoder.cs
index a4ce19f..96da9d7 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -122,6 +122,9 @@ public class EncoderParams
                get { return analysis; }
        }
        
+       public int Time {
+               get { return time; }
+       }
 
        ~EncoderParams() {}
 }
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index abde1cb..393b6a7 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -5136,7 +5136,6 @@ Console.WriteLine("X");
                                extra_window_multichronopic_can_do(false);
                } else {
                        button_execute_test.Sensitive = myTreeViewPersons.IsThereAnyRecord();
-                       //button_encoder_capture.Sensitive = myTreeViewPersons.IsThereAnyRecord();
                }
 
                stats_win_change_test_type(notebook_execute.CurrentPage);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index d7c1ef8..0da42c6 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -36,6 +36,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.CheckButton checkbutton_encoder_propulsive;
 
        [Widget] Gtk.Button button_encoder_capture;
+       [Widget] Gtk.Button button_encoder_capture_csharp;
        [Widget] Gtk.Button button_encoder_bells;
        [Widget] Gtk.Button button_encoder_capture_cancel;
        [Widget] Gtk.Button button_encoder_recalculate;
@@ -105,9 +106,10 @@ public partial class ChronoJumpWindow
        private string ecconLast;
        private string encoderTimeStamp;
        private string encoderSignalUniqueID;
-       
-       //difference between CAPTURE and RECALCULATE_OR_LOAD is: CAPTURE does a autosave at end
-       enum encoderModes { CAPTURE, RECALCULATE_OR_LOAD, ANALYZE } 
+
+       //CAPTURE is the capture from csharp (not from external python) 
+       //difference between CALCULECURVES and RECALCULATE_OR_LOAD is: CALCULECURVES does a autosave at end
+       enum encoderModes { CAPTURE, CALCULECURVES, RECALCULATE_OR_LOAD, ANALYZE } 
        enum encoderSensEnum { 
                NOSESSION, NOPERSON, YESPERSON, PROCESSING, DONENOSIGNAL, DONEYESSIGNAL, SELECTEDCURVE }
        encoderSensEnum encoderSensEnumStored; //tracks how was sensitive before PROCESSING
@@ -127,15 +129,6 @@ public partial class ChronoJumpWindow
        //TODO:put zoom,unzoom (at side of delete curve)  in capture curves (for every curve)
        //TODO: treeview on analyze (doing in separated window)
        
-       //to analyze: user has to select: session, athlete, exercise, 
-       //TODO: single curve, and side, checkbox to show1 param, 2 or three
-       //TODO: powerbars with checkbox to show1 param, 2 or three
-       //TODO: on capture (quasi-realtime), show powerbars or curves or both
-       //
-       //TODO: if a signal is loaded, exercise has to be updated on combo. (use exerciseID in database)
-       //
-       //TODO: do the graphical capturing with pygame
-       //
        //TODO: allow gui/generic.cs to select rows on treeview to be deleted
        //
        //TODO: calling to R should give feedback during the process
@@ -166,8 +159,7 @@ public partial class ChronoJumpWindow
                treeview_encoder_curves.CursorChanged += on_treeview_encoder_curves_cursor_changed; 
                createEncoderCombos();
        }
-
-       //TODO: garantir path windows   
+       
        void on_button_encoder_capture_clicked (object o, EventArgs args) 
        {
                if(chronopicWin.GetEncoderPort() == Util.GetDefaultPort()) {
@@ -236,16 +228,23 @@ public partial class ChronoJumpWindow
                                "",                                     //no graph ouptut
                                Util.GetEncoderDataTempFileName(), "", ep);                             
 
-               //title to sen to python software has to be without spaces
-               Util.RunEncoderCapture( 
-                               Util.ChangeSpaceForUnderscore(currentPerson.Name) + "----" + 
-                               Util.ChangeSpaceForUnderscore(exerciseNameShown) + "----(" + findMass(true) + 
"Kg)",
-                               es, chronopicWin.GetEncoderPort());
+               if (o == (object) button_encoder_capture) {
+                       //title to sen to python software has to be without spaces
+                       Util.RunEncoderCapturePython( 
+                                       Util.ChangeSpaceForUnderscore(currentPerson.Name) + "----" + 
+                                       Util.ChangeSpaceForUnderscore(exerciseNameShown) + "----(" + 
findMass(true) + "Kg)",
+                                       es, chronopicWin.GetEncoderPort());
+               } else if (o == (object) button_encoder_capture_csharp) {
+                       Util.RunEncoderCaptureCsharp( 
+                                       Util.ChangeSpaceForUnderscore(currentPerson.Name) + "----" + 
+                                       Util.ChangeSpaceForUnderscore(exerciseNameShown) + "----(" + 
findMass(true) + "Kg)",
+                                       es, chronopicWin.GetEncoderPort());
+               }
 
                encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
                encoderSignalUniqueID = "-1"; //mark to know that there's no ID for this until it's saved on 
database
 
-               encoderThreadStart(encoderModes.CAPTURE);
+               encoderThreadStart(encoderModes.CALCULECURVES);
        }
                
        void on_button_encoder_cancel_clicked (object o, EventArgs args) 
@@ -300,7 +299,7 @@ public partial class ChronoJumpWindow
 
        //this is called by non gtk thread. Don't do gtk stuff here
        //I suppose reading gtk is ok, changing will be the problem
-       //called on capture, recalculate and load
+       //called on calculatecurves, recalculate and load
        private void encoderCreateCurvesGraphR() 
        {
                string analysisOptions = "-";
@@ -1766,7 +1765,7 @@ public partial class ChronoJumpWindow
 
        private void encoderButtonsSensitive(encoderSensEnum option) {
                //columns
-               //c0 button_encoder_capture, button_encoder_bells
+               //c0 button_encoder_capture, button_encoder_capture_csharp, button_encoder_bells
                //c1 button_encoder_recalculate
                //c2 button_encoder_load_signal
                //c3 button_encoder_save_all_curves, button_encoder_export_all_curves,
@@ -1822,6 +1821,7 @@ public partial class ChronoJumpWindow
                }
 
                button_encoder_capture.Sensitive = Util.IntToBool(table[0]);
+               button_encoder_capture_csharp.Sensitive = Util.IntToBool(table[0]);
                button_encoder_bells.Sensitive = Util.IntToBool(table[0]);
                button_encoder_recalculate.Sensitive = Util.IntToBool(table[1]);
                button_encoder_load_signal.Sensitive = Util.IntToBool(table[2]);
@@ -1864,7 +1864,7 @@ public partial class ChronoJumpWindow
        /* thread stuff */
 
        private void encoderThreadStart(encoderModes mode) {
-               if(mode == encoderModes.CAPTURE || mode == encoderModes.RECALCULATE_OR_LOAD) {
+               if(mode == encoderModes.CALCULECURVES || mode == encoderModes.RECALCULATE_OR_LOAD) {
                        //image is inside (is smaller than) viewport
                        image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5; 
                        image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;
@@ -1872,7 +1872,7 @@ public partial class ChronoJumpWindow
 //                     encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
                        treeview_encoder_curves.Sensitive = false;
                        encoderThread = new Thread(new ThreadStart(encoderCreateCurvesGraphR));
-                       if(mode == encoderModes.CAPTURE)
+                       if(mode == encoderModes.CALCULECURVES)
                                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCapture));
                        else // mode == encoderModes.RECALCULATE_OR_LOAD
                                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderRecalculateOrLoad));
@@ -1898,11 +1898,11 @@ public partial class ChronoJumpWindow
                                Util.CancelRScript = true;
                        }
 
-                       finishPulsebar(encoderModes.CAPTURE);
+                       finishPulsebar(encoderModes.CALCULECURVES);
                        Log.Write("dying");
                        return false;
                }
-               updatePulsebar(encoderModes.CAPTURE); //activity on pulsebar
+               updatePulsebar(encoderModes.CALCULECURVES); //activity on pulsebar
                Thread.Sleep (50);
                Log.Write(encoderThread.ThreadState.ToString());
                return true;
@@ -1919,7 +1919,7 @@ public partial class ChronoJumpWindow
                        Log.Write("dying");
                        return false;
                }
-               updatePulsebar(encoderModes.CAPTURE); //activity on pulsebar
+               updatePulsebar(encoderModes.CALCULECURVES); //activity on pulsebar
                Thread.Sleep (50);
                Log.Write(encoderThread.ThreadState.ToString());
                return true;
@@ -1947,7 +1947,7 @@ public partial class ChronoJumpWindow
                if(Util.FileExists(Util.GetEncoderStatusTempFileName()))
                        contents = Util.ReadFile(Util.GetEncoderStatusTempFileName(), true);
 
-               if(mode == encoderModes.CAPTURE || mode == encoderModes.RECALCULATE_OR_LOAD) {
+               if(mode == encoderModes.CALCULECURVES || mode == encoderModes.RECALCULATE_OR_LOAD) {
                        encoder_pulsebar_capture.Pulse();
                        encoder_pulsebar_capture.Text = contents;
                } else {
@@ -1957,7 +1957,7 @@ public partial class ChronoJumpWindow
        }
        
        private void finishPulsebar(encoderModes mode) {
-               if(mode == encoderModes.CAPTURE || mode == encoderModes.RECALCULATE_OR_LOAD) {
+               if(mode == encoderModes.CALCULECURVES || mode == encoderModes.RECALCULATE_OR_LOAD) {
                        if(encoderProcessCancel) {
                                encoderProcessCancel = false;
                                encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
@@ -1969,7 +1969,7 @@ public partial class ChronoJumpWindow
                                image_encoder_capture.Sensitive = true;
                
                                //autosave signal (but not in recalculate or load)
-                               if(mode == encoderModes.CAPTURE)
+                               if(mode == encoderModes.CALCULECURVES)
                                        encoder_pulsebar_capture.Text = encoderSaveSignalOrCurve("signal", 0);
                                else
                                        encoder_pulsebar_capture.Text = "";
diff --git a/src/util.cs b/src/util.cs
index a72c6f6..c73c865 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -24,6 +24,7 @@ using System.Text; //StringBuilder
 using System.Collections; //ArrayList
 using System.Diagnostics;      //for detect OS
 using System.IO;               //for detect OS
+using System.IO.Ports;
 
 //this class tries to be a space for methods that are used in different classes
 public class Util
@@ -1076,8 +1077,48 @@ public class Util
                        //maybe R is not installed
                }
        }
+       
+       public static void RunEncoderCaptureCsharp(string title, EncoderStruct es, string port) 
+       {
+               Log.WriteLine("00a");
+               SerialPort sp = new SerialPort(port);
+               Log.WriteLine("00b");
+               sp.BaudRate = 115200;
+               Log.WriteLine("00c");
+               sp.Open();
+               Log.WriteLine("00d");
+               int recordingTime = es.Ep.Time * 1000;
+               int i=-20; //delete first records because there's encoder bug
+               int b;
+               int sum = 0;
+               string dataString = "";
+               string sep = "";
+               do {
+                       b = sp.ReadByte();
+                       if(b>200)
+                               b=b-256;
+                       i=i+1;
+                       if(i >= 0) {
+                               Log.Write(sep + b.ToString());
+                               dataString += sep + b.ToString();
+                               //sum += b;
+                               sep = ", ";
+                       }
+               } while (i < recordingTime);
+               //Log.WriteLine(sum.ToString());
 
-       public static void RunEncoderCapture(string title, EncoderStruct es, string port) {
+               Log.WriteLine("00e");
+               sp.Close();
+               Log.WriteLine("00f");
+               
+               TextWriter writer = File.CreateText(es.OutputData1);
+               writer.Write(dataString);
+               writer.Flush();
+               ((IDisposable)writer).Dispose();
+       }
+
+       public static void RunEncoderCapturePython(string title, EncoderStruct es, string port) 
+       {
                CancelRScript = false;
 
                ProcessStartInfo pinfo;
@@ -1129,7 +1170,8 @@ public class Util
                while ( ! ( File.Exists(outputFileCheck) || CancelRScript) );
        }
        
-       public static void RunEncoderGraph(string title, EncoderStruct es) {
+       public static void RunEncoderGraph(string title, EncoderStruct es) 
+       {
                CancelRScript = false;
 
                ProcessStartInfo pinfo;


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