[chronojump] Session load window shows force sensor tests



commit 7bbdf91a2ed25d91ea9abcceed1450503e3a4c65
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 16 18:26:22 2019 +0200

    Session load window shows force sensor tests

 glade/session_load.glade |  6 +++---
 src/gui/session.cs       | 45 ++++++++++++++++++++++++---------------------
 src/sqlite/session.cs    | 25 +++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 24 deletions(-)
---
diff --git a/glade/session_load.glade b/glade/session_load.glade
index 49310b00..2c4dd467 100644
--- a/glade/session_load.glade
+++ b/glade/session_load.glade
@@ -148,13 +148,13 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkCheckButton" id="checkbutton_show_data_encoder">
-                    <property name="label" translatable="yes">Show data of encoder tests</property>
+                  <widget class="GtkCheckButton" id="checkbutton_show_data_encoder_and_fs">
+                    <property name="label" translatable="yes">Show data of encoder and force 
sensor</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="on_checkbutton_show_data_encoder_toggled" swapped="no"/>
+                    <signal name="toggled" handler="on_checkbutton_show_data_encoder_and_fs_toggled" 
swapped="no"/>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 27f83f0d..2c416b0f 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -685,7 +685,7 @@ public class SessionLoadWindow {
        [Widget] Gtk.Button button_accept;
        [Widget] Gtk.Entry entry_search_filter;
        [Widget] Gtk.CheckButton checkbutton_show_data_jump_run;
-       [Widget] Gtk.CheckButton checkbutton_show_data_encoder;
+       [Widget] Gtk.CheckButton checkbutton_show_data_encoder_and_fs;
        [Widget] Gtk.Label file_path_import;
        [Widget] Gtk.VBox session_import_box;
        
@@ -706,7 +706,7 @@ public class SessionLoadWindow {
 
                // Hides and shows widgets only needed by some of the functionality
                session_import_box.Visible = (type == WindowType.IMPORT_SESSION);
-               checkbutton_show_data_encoder.Visible = (type == WindowType.LOAD_SESSION);
+               checkbutton_show_data_encoder_and_fs.Visible = (type == WindowType.LOAD_SESSION);
                checkbutton_show_data_jump_run.Visible = (type == WindowType.LOAD_SESSION);
 
                if (type == WindowType.LOAD_SESSION) {
@@ -747,18 +747,18 @@ public class SessionLoadWindow {
                */
        }
 
-       private TreeStore getStore(bool showContacts, bool showEncoder) {
+       private TreeStore getStore(bool showContacts, bool showEncoderAndForceSensor) {
                TreeStore s;
-               if(showContacts && showEncoder)
+               if(showContacts && showEncoderAndForceSensor)
                        s = new TreeStore(
                                typeof (string), typeof (string), typeof (string), typeof (string), //number 
(hidden), date, name, place
                                typeof (string), typeof (string), typeof (string), typeof (string), 
//persons, sport, spllity, level
                                typeof (string), typeof (string), typeof (string), typeof(string), //jumps 
s,r, runs s, i, 
                                typeof (string), typeof (string), typeof (string),      //rt, pulses, mc
-                               typeof (string), typeof (string),                       //encoder s, c
+                               typeof (string), typeof (string), typeof (string),      //encoder s, c, 
forceSensor
                                typeof (string)                                         //comments
                                );
-               else if(showContacts && ! showEncoder)
+               else if(showContacts && ! showEncoderAndForceSensor)
                        s = new TreeStore(
                                typeof (string), typeof (string), typeof (string), typeof (string), //number 
(hidden), date, name, place
                                typeof (string), typeof (string), typeof (string), typeof (string), 
//persons, sport, spllity, level
@@ -766,14 +766,14 @@ public class SessionLoadWindow {
                                typeof (string), typeof (string), typeof (string),      //rt, pulses, mc
                                typeof (string)                                         //comments
                                );
-               else if(! showContacts && showEncoder)
+               else if(! showContacts && showEncoderAndForceSensor)
                        s = new TreeStore(
                                typeof (string), typeof (string), typeof (string), typeof (string), //number 
(hidden), date, name, place
                                typeof (string), typeof (string), typeof (string), typeof (string), 
//persons, sport, spllity, level
-                               typeof (string), typeof (string),                       //encoder s, c
+                               typeof (string), typeof (string), typeof (string),      //encoder s, c, 
forceSensor
                                typeof (string)                                         //comments
                                );
-               else // ! showContacts && ! showEncoder
+               else // ! showContacts && ! showEncoderAndForceSensor
                        s = new TreeStore(
                                typeof (string), typeof (string), typeof (string), typeof (string), //number 
(hidden), date, name, place
                                typeof (string), typeof (string), typeof (string), typeof (string), 
//persons, sport, spllity, level
@@ -817,7 +817,7 @@ public class SessionLoadWindow {
                return SessionLoadWindowBox;
        }
        
-       private void createTreeView (Gtk.TreeView tv, bool showContacts, bool showEncoder)
+       private void createTreeView (Gtk.TreeView tv, bool showContacts, bool showEncoderAndForceSensor)
        {
                tv.HeadersVisible=true;
                int count = 0;
@@ -853,13 +853,14 @@ public class SessionLoadWindow {
                        tv.AppendColumn ( Catalog.GetString ("Pulses"), new CellRendererText(), "text", 
count++);
                        tv.AppendColumn ( Catalog.GetString ("MultiChronopic"), new CellRendererText(), 
"text", count++);
                }
-               if(showEncoder) {
+               if(showEncoderAndForceSensor) {
                        tv.AppendColumn ( Catalog.GetString ("Gravitatory encoder") + "\n" +
                                        Catalog.GetString("Sets") + " ; " + Catalog.GetString("Repetitions"),
                                        new CellRendererText(), "text", count++);
                        tv.AppendColumn ( Catalog.GetString ("Inertial encoder") + "\n" +
                                        Catalog.GetString("Sets") + " ; " + Catalog.GetString("Repetitions"),
                                        new CellRendererText(), "text", count++);
+                       tv.AppendColumn ( Catalog.GetString ("Force sensor"), new CellRendererText(), "text", 
count++);
                }
                tv.AppendColumn ( Catalog.GetString ("Comments"), new CellRendererText(), "text", count++);
        }
@@ -894,8 +895,8 @@ public class SessionLoadWindow {
        void on_checkbutton_show_data_jump_run_toggled (object o, EventArgs args) {
                recreateTreeView("jump run " + checkbutton_show_data_jump_run.Active.ToString());
        }
-       void on_checkbutton_show_data_encoder_toggled (object o, EventArgs args) {
-               recreateTreeView("encoder " + checkbutton_show_data_encoder.Active.ToString());
+       void on_checkbutton_show_data_encoder_and_fs_toggled (object o, EventArgs args) {
+               recreateTreeView("encoder and fs" + checkbutton_show_data_encoder_and_fs.Active.ToString());
        }
        void recreateTreeView(string message) {
                LogB.Information(message);
@@ -903,12 +904,12 @@ public class SessionLoadWindow {
                UtilGtk.RemoveColumns(treeview_session_load);
                
                createTreeView(treeview_session_load, 
-                               checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+                               checkbutton_show_data_jump_run.Active, 
checkbutton_show_data_encoder_and_fs.Active);
                store = getStore(
-                               checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+                               checkbutton_show_data_jump_run.Active, 
checkbutton_show_data_encoder_and_fs.Active);
                treeview_session_load.Model = store;
                fillTreeView(treeview_session_load, store,
-                               checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+                               checkbutton_show_data_jump_run.Active, 
checkbutton_show_data_encoder_and_fs.Active);
                
                store.SetSortColumnId(1, Gtk.SortType.Descending); //date
                store.ChangeSortColumn();
@@ -922,7 +923,7 @@ public class SessionLoadWindow {
                onSelectionEntry (treeview_session_load.Selection, new EventArgs ());
        }
 
-       private void fillTreeView (Gtk.TreeView tv, TreeStore store, bool showContacts, bool showEncoder) 
+       private void fillTreeView (Gtk.TreeView tv, TreeStore store, bool showContacts, bool 
showEncoderAndForceSensor)
        {
                string filterName = "";
                if(entry_search_filter.Text.ToString().Length > 0) 
@@ -953,7 +954,7 @@ public class SessionLoadWindow {
                        if (myStringFull[6] != Catalog.GetString(Constants.LevelUndefined)) 
                                myLevel = Catalog.GetString(myStringFull[6]);
 
-                       if(showContacts && showEncoder)
+                       if(showContacts && showEncoderAndForceSensor)
                                store.AppendValues (
                                                myStringFull[0],        //session num
                                                myStringFull[3],        //session date
@@ -972,9 +973,10 @@ public class SessionLoadWindow {
                                                myStringFull[15],       //number of multiChronopics x session
                                                myStringFull[16],       //number of encoder signal x session
                                                myStringFull[17],       //number of encoder curve x session
+                                               myStringFull[18],       //number of forceSensor
                                                myStringFull[7]         //description of session
                                                );
-                       else if(showContacts && ! showEncoder)
+                       else if(showContacts && ! showEncoderAndForceSensor)
                                store.AppendValues (
                                                myStringFull[0],        //session num
                                                myStringFull[3],        //session date
@@ -993,7 +995,7 @@ public class SessionLoadWindow {
                                                myStringFull[15],       //number of multiChronopics x session
                                                myStringFull[7]         //description of session
                                                );
-                       else if(! showContacts && showEncoder)
+                       else if(! showContacts && showEncoderAndForceSensor)
                                store.AppendValues (
                                                myStringFull[0],        //session num
                                                myStringFull[3],        //session date
@@ -1005,9 +1007,10 @@ public class SessionLoadWindow {
                                                myLevel,                //personsLevel
                                                myStringFull[16],       //number of encoder signal x session
                                                myStringFull[17],       //number of encoder curve x session
+                                               myStringFull[18],       //number of forceSensor
                                                myStringFull[7]         //description of session
                                                );
-                       else // ! showContacts && ! showEncoder
+                       else // ! showContacts && ! showEncoderAndForceSensor
                                store.AppendValues (
                                                myStringFull[0],        //session num
                                                myStringFull[3],        //session date
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 8c390e2d..853c4ea6 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -579,6 +579,20 @@ class SqliteSession : Sqlite
 
                reader_enc.Close();
 
+               //select force sensor of each session
+               dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.ForceSensorTable +
+                       " GROUP BY sessionID ORDER BY sessionID";
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+
+               SqliteDataReader reader_fs;
+               reader_fs = dbcmd.ExecuteReader();
+               ArrayList myArray_fs = new ArrayList(2);
+
+               while(reader_fs.Read()) {
+                       myArray_fs.Add (reader_fs[0].ToString() + ":" + reader_fs[1].ToString() + ":" );
+               }
+               reader_fs.Close();
 
 
                //mix nine arrayLists
@@ -712,6 +726,17 @@ class SqliteSession : Sqlite
                        }
                        lineNotReadOnly  = lineNotReadOnly + ":" + result_enc_s + " ; " + result_enc_r;
 
+                       //add force sensor for each session
+                       found = false;
+                       foreach (string line_fs in myArray_fs) {
+                               string [] myStringFull = line_fs.Split(new char[] {':'});
+                               if(myStringFull[0] == mixingSessionID) {
+                                       lineNotReadOnly  = lineNotReadOnly + ":" + myStringFull[1];
+                                       found = true;
+                               }
+                       }
+                       if (!found) { lineNotReadOnly  = lineNotReadOnly + ":0"; }
+
 
                        mySessions [count++] = lineNotReadOnly;
                }


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