[chronojump] Session load separates gravitatory/inertial sets/repetitions



commit 6f2439bceb0b47c353bcb34e005171fbc91574db
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 4 17:26:57 2016 +0200

    Session load separates gravitatory/inertial sets/repetitions

 src/gui/session.cs    |    8 ++-
 src/sqlite/session.cs |  125 ++++++++++++++++++++++++++++++++-----------------
 2 files changed, 88 insertions(+), 45 deletions(-)
---
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 7f68056..ec703af 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -744,8 +744,12 @@ public class SessionLoadWindow {
                        tv.AppendColumn ( Catalog.GetString ("MultiChronopic"), new CellRendererText(), 
"text", count++);
                }
                if(showEncoder) {
-                       tv.AppendColumn ( Catalog.GetString ("Encoder sets"), new CellRendererText(), "text", 
count++);
-                       tv.AppendColumn ( Catalog.GetString ("Encoder repetitions"), new CellRendererText(), 
"text", count++);
+                       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 ("Comments"), new CellRendererText(), "text", count++);
        }
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 73dc560..85bf7f8 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -398,44 +398,75 @@ class SqliteSession : Sqlite
                }
                reader_mcs.Close();
        
-               //select encoder signal of each session
-               dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.EncoderTable + 
-                       " WHERE signalOrCurve == \"signal\" GROUP BY sessionID ORDER BY sessionID";
+       
+               //select encoder stuff of each session
+               dbcmd.CommandText = "SELECT sessionID, encoderConfiguration, signalOrCurve FROM " + 
Constants.EncoderTable + " ORDER BY sessionID";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
 
-               SqliteDataReader reader_enc_s;
-               reader_enc_s = dbcmd.ExecuteReader();
-               ArrayList myArray_enc_s = new ArrayList(2);
-               
-               while(reader_enc_s.Read()) {
-                       myArray_enc_s.Add (reader_enc_s[0].ToString() + ":" + reader_enc_s[1].ToString() + 
":" );
+               SqliteDataReader reader_enc = dbcmd.ExecuteReader();
+               ArrayList myArray_enc_g_s = new ArrayList(2); //gravitatory sets
+               ArrayList myArray_enc_g_r = new ArrayList(2); //gravitatory repetitions
+               ArrayList myArray_enc_i_s = new ArrayList(2); //inertial sets
+               ArrayList myArray_enc_i_r = new ArrayList(2); //inertial repetitions
+               
+               int count_g_s = 0;      
+               int count_g_r = 0;      
+               int count_i_s = 0;
+               int count_i_r = 0;
+               int sessionBefore = -1;
+               int sessionNow = -1;
+               while(reader_enc.Read()) 
+               {
+                       //get econf to separate gravitatory and inertial
+                       string [] strFull = reader_enc[1].ToString().Split(new char[] {':'});
+                       EncoderConfiguration econf = new EncoderConfiguration(
+                               (Constants.EncoderConfigurationNames) 
+                               Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
+
+                       sessionNow = Convert.ToInt32(reader_enc[0].ToString());
+                       if(sessionNow != sessionBefore && sessionBefore != -1) {
+                               myArray_enc_g_s.Add (sessionBefore.ToString() + ":" + count_g_s.ToString() + 
":" );
+                               myArray_enc_g_r.Add (sessionBefore.ToString() + ":" + count_g_r.ToString() + 
":" );
+                               myArray_enc_i_s.Add (sessionBefore.ToString() + ":" + count_i_s.ToString() + 
":" );
+                               myArray_enc_i_r.Add (sessionBefore.ToString() + ":" + count_i_r.ToString() + 
":" );
+                               count_g_s = 0;
+                               count_g_r = 0;
+                               count_i_s = 0;
+                               count_i_r = 0;
+                       }
+                       sessionBefore = sessionNow;
+
+                       if(! econf.has_inertia) {
+                               if(reader_enc[2].ToString() == "signal")
+                                       count_g_s ++;
+                               else
+                                       count_g_r ++;
+                       } else {
+                               if(reader_enc[2].ToString() == "signal")
+                                       count_i_s ++;
+                               else
+                                       count_i_r ++;
+                       }
                }
-               reader_enc_s.Close();
-       
-               //select encoder curve of each session
-               dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.EncoderTable + 
-                       " WHERE signalOrCurve == \"curve\" GROUP BY sessionID ORDER BY sessionID";
-               LogB.SQL(dbcmd.CommandText.ToString());
-               dbcmd.ExecuteNonQuery();
+               myArray_enc_g_s.Add (sessionBefore.ToString() + ":" + count_g_s.ToString() + ":" );
+               myArray_enc_g_r.Add (sessionBefore.ToString() + ":" + count_g_r.ToString() + ":" );
+               myArray_enc_i_s.Add (sessionBefore.ToString() + ":" + count_i_s.ToString() + ":" );
+               myArray_enc_i_r.Add (sessionBefore.ToString() + ":" + count_i_r.ToString() + ":" );
+
+               reader_enc.Close();
 
-               SqliteDataReader reader_enc_c;
-               reader_enc_c = dbcmd.ExecuteReader();
-               ArrayList myArray_enc_c = new ArrayList(2);
                
-               while(reader_enc_c.Read()) {
-                       myArray_enc_c.Add (reader_enc_c[0].ToString() + ":" + reader_enc_c[1].ToString() + 
":" );
-               }
-               reader_enc_c.Close();
-       
                
                //close database connection
                Sqlite.Close();
 
-               //mix seven arrayLists
+               //mix nine arrayLists
                string [] mySessions = new string[count];
                count =0;
                bool found;
+               string result_enc_s;    //sets
+               string result_enc_r;    //repetitions
                foreach (string line in myArray) {
                        string lineNotReadOnly = line;
 
@@ -531,27 +562,35 @@ class SqliteSession : Sqlite
                        }
                        if (!found) { lineNotReadOnly  = lineNotReadOnly + ":0"; }
 
-                       //add encoder signal for each session
-                       found = false;
-                       foreach (string line_enc_s in myArray_enc_s) {
-                               string [] myStringFull = line_enc_s.Split(new char[] {':'});
-                               if(myStringFull[0] == mixingSessionID) {
-                                       lineNotReadOnly  = lineNotReadOnly + ":" + myStringFull[1];
-                                       found = true;
-                               }
+                       //add encoder gravitatory for each session (sets ; repetitions)
+                       result_enc_s = "0";
+                       result_enc_r = "0";
+                       foreach (string line_enc_g_s in myArray_enc_g_s) {
+                               string [] myStringFull = line_enc_g_s.Split(new char[] {':'});
+                               if(myStringFull[0] == mixingSessionID)
+                                       result_enc_s = myStringFull[1];
                        }
-                       if (!found) { lineNotReadOnly  = lineNotReadOnly + ":0"; }
-
-                       //add encoder curve for each session
-                       found = false;
-                       foreach (string line_enc_c in myArray_enc_c) {
-                               string [] myStringFull = line_enc_c.Split(new char[] {':'});
-                               if(myStringFull[0] == mixingSessionID) {
-                                       lineNotReadOnly  = lineNotReadOnly + ":" + myStringFull[1];
-                                       found = true;
-                               }
+                       foreach (string line_enc_g_r in myArray_enc_g_r) {
+                               string [] myStringFull = line_enc_g_r.Split(new char[] {':'});
+                               if(myStringFull[0] == mixingSessionID)
+                                       result_enc_r = myStringFull[1];
                        }
-                       if (!found) { lineNotReadOnly  = lineNotReadOnly + ":0"; }
+                       lineNotReadOnly  = lineNotReadOnly + ":" + result_enc_s + " ; " + result_enc_r;
+
+                       //add encoder inertial for each session (sets ; repetitions)
+                       result_enc_s = "0";
+                       result_enc_r = "0";
+                       foreach (string line_enc_i_s in myArray_enc_i_s) {
+                               string [] myStringFull = line_enc_i_s.Split(new char[] {':'});
+                               if(myStringFull[0] == mixingSessionID)
+                                       result_enc_s = myStringFull[1];
+                       }
+                       foreach (string line_enc_i_r in myArray_enc_i_r) {
+                               string [] myStringFull = line_enc_i_r.Split(new char[] {':'});
+                               if(myStringFull[0] == mixingSessionID)
+                                       result_enc_r = myStringFull[1];
+                       }
+                       lineNotReadOnly  = lineNotReadOnly + ":" + result_enc_s + " ; " + result_enc_r;
 
                        
                        mySessions [count++] = lineNotReadOnly;


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