[chronojump] chronojump-networks initial stuff



commit 74f1f12279641a252797b0ddc82c8101e35b8533
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 4 16:13:19 2015 +0100

    chronojump-networks initial stuff

 src/Makefile.am     |    2 +
 src/gui/encoder.cs  |   15 +-------------
 src/gui/networks.cs |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/networks.cs     |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/util.cs         |    4 +-
 5 files changed, 113 insertions(+), 16 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f81c8d..ef17539 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,6 +42,7 @@ SOURCES = \
        gui/server.cs\
        gui/dialogServerStats.cs\
        gui/evaluator.cs\
+       gui/networks.cs\
        gui/queryServer.cs\
        gui/usefulObjects.cs\
        statType.cs\
@@ -123,6 +124,7 @@ SOURCES = \
        genericObjects.cs\
        jump.cs\
        jumpType.cs\
+       networks.cs\
        person.cs\
        personSession.cs\
        run.cs\
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index abd8e5a..9bc6776 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -174,10 +174,6 @@ public partial class ChronoJumpWindow
        Gdk.Pixmap encoder_capture_signal_pixmap = null;
        Gdk.Pixmap encoder_capture_curves_bars_pixmap = null;
 
-       //RFID
-       [Widget] Gtk.Box hbox_rfid;
-       [Widget] Gtk.Label label_rfid;
-
        ArrayList encoderCaptureCurves;
         Gtk.ListStore encoderCaptureListStore;
        Gtk.ListStore encoderAnalyzeListStore; //can be EncoderCurves or EncoderNeuromuscularData
@@ -329,16 +325,7 @@ public partial class ChronoJumpWindow
                        //it crashes on Raspberry, Banana
                }
 
-               if(Util.FileExists(Util.GetRFIDMarkFile()))
-                       hbox_rfid.Visible = true;
-       }
-
-       //rfid
-       void on_button_rfid_read_clicked (object o, EventArgs args) {
-               string file = "/tmp/chronojump_rfid.txt";
-
-               if(Util.FileExists(file))
-                       label_rfid.Text = Util.ReadFile(file, true);
+               networksInit();
        }
 
 
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
new file mode 100644
index 0000000..ce43490
--- /dev/null
+++ b/src/gui/networks.cs
@@ -0,0 +1,54 @@
+/*
+ * 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 Gdk;
+using Glade;
+using System.IO.Ports;
+using System.IO; //"File" things
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List
+       
+public partial class ChronoJumpWindow 
+{
+       //RFID
+       [Widget] Gtk.Box hbox_rfid;
+       [Widget] Gtk.Label label_rfid;
+
+
+       private void networksInit() {
+               Networks networks = new Networks();
+               networks.Test();
+               
+               if(Util.FileExists(Util.GetChronojumpNetworksFile()))
+                       hbox_rfid.Visible = true;
+       }
+       
+       //rfid
+       void on_button_rfid_read_clicked (object o, EventArgs args) {
+               string file = "/tmp/chronojump_rfid.txt";
+
+               if(Util.FileExists(file))
+                       label_rfid.Text = Util.ReadFile(file, true);
+       }
+
+}
diff --git a/src/networks.cs b/src/networks.cs
new file mode 100644
index 0000000..4c5ee0c
--- /dev/null
+++ b/src/networks.cs
@@ -0,0 +1,54 @@
+/*
+ * 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 System.Collections.Generic; //List<T>
+       
+public class Networks
+{
+       private List<int> UID;
+
+       public Networks() {
+       }
+
+       public void Test() {
+               UID = new List<int>{0,0,0,0};
+               LogB.Debug(UIDToInt().ToString());
+
+               UID = new List<int>{255,255,255,255};
+               LogB.Debug(UIDToInt().ToString());
+       }
+
+       private uint UIDToInt ()
+       {
+               uint total = 0; //total has to be an uint
+               int count = 0;
+               //maybe has to be done backwards (from 3 to 0)
+               foreach(int uid in UID) {
+                       total += Convert.ToUInt32(
+                                       uid *
+                                       Math.Pow(Convert.ToDouble(256), Convert.ToDouble(count))
+                                       );
+                       count ++;
+               }
+
+               return (total);
+       }
+}
diff --git a/src/util.cs b/src/util.cs
index bf49895..1424a9a 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -794,10 +794,10 @@ public class Util
 
        /********** end of database paths ************/
        
-       public static string GetRFIDMarkFile() {
+       public static string GetChronojumpNetworksFile() {
                return Path.Combine(
                                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
-                               "Chronojump" + Path.DirectorySeparatorChar + "rfid_mark_file.txt");
+                               "Chronojump" + Path.DirectorySeparatorChar + "chronojump_networks.txt");
        }
        
 


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