[chronojump] Merging



commit 2f6bf7c219b22973e3f7cb32c6292c4956fba2f3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Apr 5 12:13:40 2015 +0200

    Merging

 src/Makefile.am                      |    2 +
 src/chronopicDialogAutoController.cs |  111 ++++++++++++++++++++++++++++++++++
 src/gui/chronojump.cs                |   26 ++++++++
 src/gui/chronopicAuto.cs             |   53 ++++++++++++++++
 4 files changed, 192 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 18ebead..136717c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,7 @@ LINK = $(REF_DEP_CHRONOJUMP)
 SOURCES = \
        gui/chronojump.cs\
        gui/chronopic.cs\
+       gui/chronopicAuto.cs\
        gui/confirm.cs\
        gui/encoder.cs\
        gui/encoderTreeviews.cs\
@@ -163,6 +164,7 @@ SOURCES = \
        serverEvaluator.cs\
        server.cs\
        chronopic.cs\
+       chronopicDialogAutoController.cs\
        oldCodeNeedToDBConvert/person.cs\
        oldCodeNeedToDBConvert/personSession.cs\
        oldCodeNeedToDBConvert/sqlite/person.cs\
diff --git a/src/chronopicDialogAutoController.cs b/src/chronopicDialogAutoController.cs
new file mode 100644
index 0000000..cd50649
--- /dev/null
+++ b/src/chronopicDialogAutoController.cs
@@ -0,0 +1,111 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2015   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System.Threading;
+using System;
+using Gtk;
+
+public class ChronopicDialogAutoController
+{
+       ChronopicDialogAuto cp_dialog_auto;
+       Thread thread;
+       
+       private static bool cancel;
+       public string Detected;
+       
+       public Gtk.Button FakeButtonDone;
+       
+       
+       public ChronopicDialogAutoController ()
+       {
+               cp_dialog_auto = new ChronopicDialogAuto();
+               cp_dialog_auto.button_cancel.Clicked += new EventHandler(on_button_cancel_clicked);
+               FakeButtonDone = new Gtk.Button();
+       }
+       
+       public void Detect(string mode)
+       {
+               if(mode == "ENCODER") {
+                       LogB.Information("Detecting encoder... ");
+                       
+                       cancel = false;
+                       Detected = "";
+               
+                       thread = new Thread(new ThreadStart(detectEncoder));
+                       GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+
+                       LogB.ThreadStart();
+                       thread.Start(); 
+               }
+       }
+
+       private void detectEncoder()
+       {
+               /*
+                * testing a fault in drivers
+               int count = 0;
+               bool crash = true;
+               while(crash) {
+                       count ++;
+                       if(count >= 1000) {
+                               LogB.Debug(" at detectEncoder\n ");
+                               count = 0;
+                       }
+               }
+               */
+
+               ChronopicAutoDetect cad = 
+                       new ChronopicAutoDetect(ChronopicAutoDetect.ChronopicType.ENCODER);
+
+               Detected = cad.Detected;
+       }
+       
+       private bool PulseGTK ()
+       {
+               if(cancel || ! thread.IsAlive) {
+                       LogB.ThreadEnding();
+
+                       if(cancel)
+                               thread.Abort();
+                       
+                       FakeButtonDone.Click();
+                       
+                       LogB.ThreadEnded();
+                       return false;
+               }
+
+               cp_dialog_auto.progressbar.Pulse();
+               
+               Thread.Sleep (50);
+               LogB.Debug(thread.ThreadState.ToString());
+               return true;
+       }
+       
+       private void on_button_cancel_clicked (object o, EventArgs args)
+       {
+               cp_dialog_auto.button_cancel.Clicked -= new EventHandler(on_button_cancel_clicked);
+
+               Detected = "Cancelled";
+               cancel = true;
+       }
+
+       ~ChronopicDialogAutoController() {}
+}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index fdef517..212c685 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2881,8 +2881,10 @@ public partial class ChronoJumpWindow
                change_multitest_firmware(m);
        }
        
+       ChronopicDialogAutoController cp_dialog_auto_c;
        private void autoDetectChronopic(menuitem_modes m)
        {
+               /*
                ChronopicAutoDetect cad;
                if(m == menuitem_modes.POWER) {
                        LogB.Information("Detecting encoder... ");
@@ -2897,12 +2899,36 @@ public partial class ChronoJumpWindow
                                createChronopicWindow(true, Util.GetDefaultPort());
                        }
                } else {
+               */
+               if(m == menuitem_modes.POWER) 
+               {
+                       cp_dialog_auto_c = new ChronopicDialogAutoController();
+                       
+                       cp_dialog_auto_c.Detect("ENCODER");
+
+                       cp_dialog_auto_c.FakeButtonDone.Clicked += new 
EventHandler(on_autoDetectChronopic_done);
+               } 
+               else {
                        LogB.Information("Detecting normal Chronopic... ");
                        //cad = new ChronopicAutoDetect(ChronopicAutoDetect.ChronopicType.NORMAL);
                        LogB.Warning("Disabled until full chronopic connection is done on 4MHz Chronopics");
                }
        }
+       
+       private void on_autoDetectChronopic_done(object o, EventArgs args) 
+       {
+               cp_dialog_auto_c.FakeButtonDone.Clicked -= new EventHandler(on_autoDetectChronopic_done);
 
+               string str = cp_dialog_auto_c.Detected;
+
+               if(str != null && str != "") {
+                       LogB.Information("Detected at port: " + str);
+               }
+               else {
+                       LogB.Information("Not detected.");
+               }
+       }
+                       
        //change debounce time automatically on change menuitem mode (if multitest firmware)
        private void change_multitest_firmware(menuitem_modes m) 
        {
diff --git a/src/gui/chronopicAuto.cs b/src/gui/chronopicAuto.cs
new file mode 100644
index 0000000..eb33b8d
--- /dev/null
+++ b/src/gui/chronopicAuto.cs
@@ -0,0 +1,53 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2015   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Glade;
+
+public class ChronopicDialogAuto
+{
+       [Widget] Gtk.Dialog dialog_chronopic_auto;
+       [Widget] public Gtk.ProgressBar progressbar;
+       [Widget] public Gtk.Button button_cancel;
+
+       public ChronopicDialogAuto ()
+       {
+               Glade.XML gladeXML;
+               gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", 
"dialog_chronopic_auto", "chronojump");
+               gladeXML.Autoconnect(this);
+
+               //put an icon to window
+               UtilGtk.IconWindow(dialog_chronopic_auto);
+
+               LogB.Information("ChronopicDialogAuto");
+       }
+       
+       private void on_button_cancel_clicked (object o, EventArgs args) {
+               dialog_chronopic_auto.Destroy ();
+       }
+
+       private void on_delete_event (object o, DeleteEventArgs args) {
+               button_cancel.Click();
+               dialog_chronopic_auto.Destroy ();
+       }
+}
+


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