[chronojump] DB 1.29 reactiontimes differentiated and graph changes as jump or run



commit a85313c8fe79895a9eaf30266af34acc95dc84ae
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jun 23 06:49:13 2016 +0200

    DB 1.29 reactiontimes differentiated and graph changes as jump or run

 src/execute/reactionTime.cs |    7 +++--
 src/exportSession.cs        |    5 ++-
 src/gui/chronojump.cs       |   25 +++++++++++---------
 src/gui/eventExecute.cs     |   10 ++++----
 src/gui/reactionTime.cs     |   53 +++++++++++++++++++++++++++++++++---------
 src/gui/usefulObjects.cs    |    2 +-
 src/reactionTime.cs         |    7 +++--
 src/reactionTimeType.cs     |    4 +++
 src/report.cs               |    2 +-
 src/server.cs               |    2 +-
 src/sqlite/main.cs          |   10 +++++++-
 src/sqlite/reactionTime.cs  |   26 +++++++++++++--------
 src/treeViewEvent.cs        |    2 +-
 src/treeViewReactionTime.cs |    4 +-
 14 files changed, 106 insertions(+), 53 deletions(-)
---
diff --git a/src/execute/reactionTime.cs b/src/execute/reactionTime.cs
index 37048e8..eced1e7 100644
--- a/src/execute/reactionTime.cs
+++ b/src/execute/reactionTime.cs
@@ -40,7 +40,7 @@ public class ReactionTimeExecute : EventExecute
        }
 
        //reactionTime execution
-       public ReactionTimeExecute(int personID, string personName, int sessionID,   
+       public ReactionTimeExecute(int personID, string personName, int sessionID, string type,
                        Chronopic cp, Gtk.Label event_execute_label_message, Gtk.Window app, int pDN, bool 
volumeOn,
                        double progressbarLimit, ExecutingGraphData egd, string description
                        )
@@ -48,6 +48,7 @@ public class ReactionTimeExecute : EventExecute
                this.personID = personID;
                this.personName = personName;
                this.sessionID = sessionID;
+               this.type = type;
                
                this.cp = cp;
                this.event_execute_label_message = event_execute_label_message;
@@ -293,11 +294,11 @@ public class ReactionTimeExecute : EventExecute
 
                uniqueID = SqliteReactionTime.Insert(
                                false, table, 
-                               "NULL", personID, sessionID, "", //type
+                               "NULL", personID, sessionID, type,
                                time, description, Util.BoolToNegativeInt(simulated));
 
                //define the created object
-               eventDone = new ReactionTime(uniqueID, personID, sessionID, time, description, 
Util.BoolToNegativeInt(simulated)); 
+               eventDone = new ReactionTime(uniqueID, personID, sessionID, type, time, description, 
Util.BoolToNegativeInt(simulated)); 
                
                //event will be raised, and managed in chronojump.cs
                fakeButtonFinished.Click();
diff --git a/src/exportSession.cs b/src/exportSession.cs
index ff9d9e5..048e57f 100644
--- a/src/exportSession.cs
+++ b/src/exportSession.cs
@@ -174,7 +174,7 @@ public class ExportSession
                                Sqlite.Orders_by.DEFAULT, -1);
 
                myRunsInterval = SqliteRunInterval.SelectRuns(true, mySession.UniqueID, -1, "");
-               myReactionTimes = SqliteReactionTime.SelectReactionTimes(true, mySession.UniqueID, -1,
+               myReactionTimes = SqliteReactionTime.SelectReactionTimes(true, mySession.UniqueID, -1, "",
                                Sqlite.Orders_by.DEFAULT, -1);
 
                myPulses = SqlitePulse.SelectPulses(true, mySession.UniqueID, -1);
@@ -701,6 +701,7 @@ public class ExportSession
                                        Catalog.GetString("Person ID") + ":" +
                                        Catalog.GetString("Person name") + ":" +
                                        Catalog.GetString("Reaction time ID") + ":" + 
+                                       Catalog.GetString("Type") + ":" + 
                                        Catalog.GetString("Time") + ":" + 
                                        Catalog.GetString("Description") + ":" +
                                        Catalog.GetString("Simulated") );
@@ -712,7 +713,7 @@ public class ExportSession
                                                myStr[2] + ":" +                        //personID
                                                myStr[0] + ":" +  myStr[1] + ":" +      //person.name, 
event.uniqueID
                                                //myStr[2] + ":" +  myStr[3] + ":" +    //jump.personID, 
jump.sessionID
-                                               //myStr[4] + ":" +  //type
+                                               myStr[4] + ":" +  //type
                                                Util.TrimDecimals(myStr[5], dec) + ":" +        //time
                                                Util.RemoveNewLine(myStr[6], true) + ":" + 
                                                Util.SimulatedTestNoYes(Convert.ToInt32(myStr[7]))      
//description, simulated
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 765b47e..520d2aa 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -1160,6 +1160,8 @@ public partial class ChronoJumpWindow
                        updateGraphJumpsSimple();
                else if(radio_mode_runs_small.Active) 
                        updateGraphRunsSimple();
+               else if(radio_mode_reaction_times_small.Active) 
+                       updateGraphReactionTimes();
                
                //2) change on encoder
                encoderPersonChanged();
@@ -1485,7 +1487,7 @@ public partial class ChronoJumpWindow
 
                //load the reaction_times treeview
                treeview_reaction_times_storeReset();
-               fillTreeView_reaction_times(true);
+               fillTreeView_reaction_times("reactionTime", true);
 
                //load the multiChronopic treeview
                treeview_multi_chronopic_storeReset(true);
@@ -1859,14 +1861,14 @@ public partial class ChronoJumpWindow
                tv.CursorChanged += on_treeview_reaction_times_cursor_changed; 
        }
 
-       private void fillTreeView_reaction_times () {
-               fillTreeView_reaction_times (false);
+       private void fillTreeView_reaction_times (string filter) {
+               fillTreeView_reaction_times (filter, false);
        }
-       private void fillTreeView_reaction_times (bool dbconOpened) {
-               string [] myRTs = SqliteReactionTime.SelectReactionTimes(dbconOpened, 
currentSession.UniqueID, -1,
+       private void fillTreeView_reaction_times (string filter, bool dbconOpened) {
+               string [] myRTs = SqliteReactionTime.SelectReactionTimes(dbconOpened, 
currentSession.UniqueID, -1, "", 
                                Sqlite.Orders_by.DEFAULT, -1);
 
-               myTreeViewReactionTimes.Fill(myRTs, "");
+               myTreeViewReactionTimes.Fill(myRTs, filter);
                expandOrMinimizeTreeView((TreeViewEvent) myTreeViewReactionTimes, treeview_reaction_times);
        }
        
@@ -2420,7 +2422,8 @@ public partial class ChronoJumpWindow
                fillTreeView_runs_interval(myText);
        }
 
-       //no need of reationTimes
+       //no need of reationTimes because is done in:
+       //gui/reactionTime on_extra_window_reaction_times_test_changed()
        
        private void on_combo_pulses_changed(object o, EventArgs args) {
                //combo_pulses.Changed -= new EventHandler (on_combo_pulses_changed);
@@ -3002,7 +3005,7 @@ public partial class ChronoJumpWindow
 
                        //currently no combo_reaction_times
                        treeview_reaction_times_storeReset();
-                       fillTreeView_reaction_times();
+                       fillTreeView_reaction_times("reactionTime");
 
                        //currently no combo_multi_chronopic
                        treeview_multi_chronopic_storeReset(false);
@@ -4623,7 +4626,7 @@ public partial class ChronoJumpWindow
                        description = spinbutton_flicker_lights_speed.Value.ToString() + " - " + 
label_animation_lights_interval.Text;
 
                currentEventExecute = new ReactionTimeExecute(currentPerson.UniqueID, currentPerson.Name, 
-                               currentSession.UniqueID, 
+                               currentSession.UniqueID, currentReactionTimeType.Name, 
                                chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
                                progressbarLimit, egd, description
                                );
@@ -5189,7 +5192,7 @@ LogB.Debug("X");
                                        PreparePulseGraph(Util.GetLast(currentPulse.TimesString), 
currentPulse.TimesString);
                                        break;
                                case EventType.Types.REACTIONTIME:
-                                       
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject);
+                                       
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject, false);
                                        break;
                                case EventType.Types.MULTICHRONOPIC:
                                        PrepareMultiChronopicGraph(
@@ -5395,7 +5398,7 @@ LogB.Debug("X");
                        myTreeViewReactionTimes.Update(myRT);
                else {
                        treeview_reaction_times_storeReset();
-                       fillTreeView_reaction_times();
+                       fillTreeView_reaction_times(currentReactionTimeType.Name);
                }
        }
        
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 9f538ad..719bf93 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -771,7 +771,7 @@ public partial class ChronoJumpWindow
                event_execute_drawingarea.QueueDraw();
        }
        
-       public void PrepareReactionTimeGraph(PrepareEventGraphReactionTime eventGraph) 
+       public void PrepareReactionTimeGraph(PrepareEventGraphReactionTime eventGraph, bool animate) 
        {
                //check graph properties window is not null (propably user has closed it with the DeleteEvent
                //then create it, but not show it
@@ -800,7 +800,7 @@ public partial class ChronoJumpWindow
                
                //paint graph
                paintReactionTime (event_execute_drawingarea, eventGraph,
-                               maxValue, minValue, topMargin, bottomMargin);
+                               maxValue, minValue, topMargin, bottomMargin, animate);
 
                // -- refresh
                event_execute_drawingarea.QueueDraw();
@@ -1118,7 +1118,7 @@ public partial class ChronoJumpWindow
        }
        
        private void paintReactionTime (Gtk.DrawingArea drawingarea, PrepareEventGraphReactionTime eventGraph,
-                       double maxValue, double minValue, int topMargin, int bottomMargin)
+                       double maxValue, double minValue, int topMargin, int bottomMargin, bool animate)
        {
                int ancho=drawingarea.Allocation.Width;
                int alto=drawingarea.Allocation.Height;
@@ -1157,7 +1157,7 @@ public partial class ChronoJumpWindow
                                        topMargin, bottomMargin);
 
                        drawBar(x, y, barWidth, alto, pen_azul_claro, count == eventGraph.rtsAtSQL.Length,
-                                       rts[7] == "-1", Convert.ToDouble(rts[5]), layoutMid, true);
+                                       rts[7] == "-1", Convert.ToDouble(rts[5]), layoutMid, animate);
 
                        count --;
                }
@@ -1899,7 +1899,7 @@ public partial class ChronoJumpWindow
                                }
                                break;
                        case EventType.Types.REACTIONTIME:
-                                       
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject);
+                                       
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject, true);
                                break;
                        case EventType.Types.PULSE:
                                        PreparePulseGraph(
diff --git a/src/gui/reactionTime.cs b/src/gui/reactionTime.cs
index 531e0ef..9a38f0e 100644
--- a/src/gui/reactionTime.cs
+++ b/src/gui/reactionTime.cs
@@ -57,21 +57,50 @@ public partial class ChronoJumpWindow
 
                currentReactionTimeType = new ReactionTimeType("reactionTime");
 
-               if(extra_window_radio_reaction_time.Active) {
-                       currentReactionTimeType = new ReactionTimeType("reactionTime");
-               } else {
-                       if(extra_window_radio_reaction_time_animation_lights.Active)
-                               hbox_animation_lights.Visible = true;
-                       else if(extra_window_radio_reaction_time_flicker.Active)
-                               hbox_flicker_lights.Visible = true;
-                       else if(extra_window_radio_reaction_time_discriminative.Active) {
-                               hbox_discriminative_lights.Visible = true;
-                               currentReactionTimeType = new ReactionTimeType("Discriminative");
-                               changeTestImage("","", "reaction_time_discriminative.png");
-                       }
+               if(extra_window_radio_reaction_time_animation_lights.Active) {
+                       hbox_animation_lights.Visible = true;
+                       currentReactionTimeType = new ReactionTimeType("anticipation");
+               }
+               else if(extra_window_radio_reaction_time_flicker.Active) {
+                       hbox_flicker_lights.Visible = true;
+                       currentReactionTimeType = new ReactionTimeType("flickr");
+               }
+               else if(extra_window_radio_reaction_time_discriminative.Active) {
+                       hbox_discriminative_lights.Visible = true;
+                       currentReactionTimeType = new ReactionTimeType("Discriminative");
+                       changeTestImage("","", "reaction_time_discriminative.png");
                }
 
                currentEventType = currentReactionTimeType;
+       
+               if(currentSession != null) {    
+                       treeview_reaction_times_storeReset();
+                       fillTreeView_reaction_times(currentReactionTimeType.Name);
+               }
+                       
+               updateGraphReactionTimes();
+       }
+       private void updateGraphReactionTimes () 
+       {
+               if(currentPerson == null || currentSession == null)
+                       return;
+
+               //intializeVariables if not done before
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Phases"),      //name of the different moments
+                       Constants.ReactionTimeTable, //tableName
+                       currentReactionTimeType.Name 
+                       );
+
+               PrepareEventGraphReactionTime eventGraph = new PrepareEventGraphReactionTime(
+                               1, //unused
+                               currentSession.UniqueID, currentPerson.UniqueID, Constants.ReactionTimeTable, 
currentReactionTimeType.Name);
+               
+               if(eventGraph.rtsAtSQL.Length > 0)
+                       PrepareReactionTimeGraph(eventGraph, false); //don't animate
        }
 
        // ---- animation lights
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 4611042..3539bec 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -233,7 +233,7 @@ public class PrepareEventGraphReactionTime {
                Sqlite.Open();
 
                //obtain data
-               rtsAtSQL = SqliteReactionTime.SelectReactionTimes(true, sessionID, personID,
+               rtsAtSQL = SqliteReactionTime.SelectReactionTimes(true, sessionID, personID, type,
                                Sqlite.Orders_by.ID_DESC, 10); //select only last 10
                
                personMAXAtSQL = SqliteSession.SelectMAXEventsOfAType(
diff --git a/src/reactionTime.cs b/src/reactionTime.cs
index 0d57303..b6a1fe6 100644
--- a/src/reactionTime.cs
+++ b/src/reactionTime.cs
@@ -29,11 +29,12 @@ public class ReactionTime : Event
        }
 
        //after inserting database (SQL)
-       public ReactionTime(int uniqueID, int personID, int sessionID, double time, string description, int 
simulated)
+       public ReactionTime(int uniqueID, int personID, int sessionID, string type, double time, string 
description, int simulated)
        {
                this.uniqueID = uniqueID;
                this.personID = personID;
                this.sessionID = sessionID;
+               this.type = type;
                this.time = time;
                this.description = description;
                this.simulated = simulated;
@@ -44,7 +45,7 @@ public class ReactionTime : Event
                this.uniqueID = Convert.ToInt32(eventString[0]);
                this.personID = Convert.ToInt32(eventString[1]);
                this.sessionID = Convert.ToInt32(eventString[2]);
-               //this.type = eventString[3].ToString();
+               this.type = eventString[3].ToString();
                this.time = Convert.ToDouble(Util.ChangeDecimalSeparator(eventString[4]));
                this.description = eventString[5].ToString();
                this.simulated = Convert.ToInt32(eventString[6]);
@@ -54,7 +55,7 @@ public class ReactionTime : Event
                return SqliteReactionTime.Insert(dbconOpened, tableName, 
                                uniqueID.ToString(), 
                                personID, sessionID, 
-                               "", time, //type, time
+                               type, time,
                                description, simulated);
        }
 
diff --git a/src/reactionTimeType.cs b/src/reactionTimeType.cs
index 23cf92d..bf7ed6b 100644
--- a/src/reactionTimeType.cs
+++ b/src/reactionTimeType.cs
@@ -38,6 +38,10 @@ public class ReactionTimeType : EventType
                        imageFileName = "reaction_time.png";
                else if(name == "Discriminative")
                        imageFileName = "reaction_time_discriminative.png";
+               else if(name == "anticipation")
+                       imageFileName = "reaction_time.png";    //TODO
+               else if(name == "flickr")
+                       imageFileName = "reaction_time.png";    //TODO
        }
        
 }
diff --git a/src/report.cs b/src/report.cs
index 264bc1e..0b66d3c 100644
--- a/src/report.cs
+++ b/src/report.cs
@@ -117,7 +117,7 @@ public class Report : ExportSession
                        myRunsInterval = SqliteRunInterval.SelectRuns(true, sessionID, -1, "");
                }
                if(ShowReactionTimes) {
-                       myReactionTimes= SqliteReactionTime.SelectReactionTimes(true, sessionID, -1,
+                       myReactionTimes= SqliteReactionTime.SelectReactionTimes(true, sessionID, -1, "",
                                        Sqlite.Orders_by.DEFAULT, -1);
                }
                if(ShowPulses) {
diff --git a/src/server.cs b/src/server.cs
index 95ef49c..eb1997d 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -457,7 +457,7 @@ public class Server
                                countE = 0;                                     
                                countS = 0;                                     
 
-                               string [] rts = SqliteReactionTime.SelectReactionTimes(false, 
currentSession.UniqueID, person.UniqueID,
+                               string [] rts = SqliteReactionTime.SelectReactionTimes(false, 
currentSession.UniqueID, person.UniqueID, "",
                                                Sqlite.Orders_by.DEFAULT, -1);
 
                                Sqlite.Open();
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 4adcfec..222c7a6 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -78,7 +78,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.28";
+       static string lastChronojumpDatabaseVersion = "1.29";
 
        public Sqlite() {
        }
@@ -1874,6 +1874,14 @@ class Sqlite
                                SqlitePreferences.Update ("databaseVersion", newVersion, true); 
                                currentVersion = newVersion;
                        }
+                       if(currentVersion == "1.28") {
+                               LogB.SQL("Changed reaction time rows have reactionTime as default value");
+                               Update(true, Constants.ReactionTimeTable, "type", "", "reactionTime", "", "");
+                               
+                               newVersion = "1.29";
+                               SqlitePreferences.Update ("databaseVersion", newVersion, true); 
+                               currentVersion = newVersion;
+                       }
 
 
                        // --- add more updates here
diff --git a/src/sqlite/reactionTime.cs b/src/sqlite/reactionTime.cs
index f37765d..0484634 100644
--- a/src/sqlite/reactionTime.cs
+++ b/src/sqlite/reactionTime.cs
@@ -43,7 +43,7 @@ class SqliteReactionTime : Sqlite
                        "uniqueID INTEGER PRIMARY KEY, " +
                        "personID INT, " +
                        "sessionID INT, " +
-                       "type TEXT, " + //now all as "default", but in the future...
+                       "type TEXT, " +
                        "time FLOAT, " +
                        "description TEXT, " +
                        "simulated INT )";              
@@ -84,7 +84,8 @@ class SqliteReactionTime : Sqlite
        }
 
        //if all persons, put -1 in personID
-       public static string[] SelectReactionTimes(bool dbconOpened, int sessionID, int personID,
+       //if all types put, "" in filterType
+       public static string[] SelectReactionTimes(bool dbconOpened, int sessionID, int personID, string 
filterType,
                        Orders_by order, int limit) 
        {
                if(!dbconOpened)
@@ -94,7 +95,11 @@ class SqliteReactionTime : Sqlite
 
                string filterPersonString = "";
                if(personID != -1)
-                       filterPersonString = " AND " + tp + ".uniqueID == " + personID;
+                       filterPersonString = " AND " + tp + ".uniqueID = " + personID;
+               
+               string filterTypeString = "";
+               if(filterType != "")
+                       filterTypeString = " AND reactionTime.type == \"" + filterType + "\" ";
                
                string orderByString = " ORDER BY upper(" + tp + ".name), reactionTime.uniqueID";
                if(order == Orders_by.ID_DESC)
@@ -107,9 +112,10 @@ class SqliteReactionTime : Sqlite
 
                dbcmd.CommandText = "SELECT " + tp + ".name, reactionTime.* " +
                        " FROM " + tp + ", reactionTime " +
-                       " WHERE " + tp + ".uniqueID == reactionTime.personID" + 
-                       " AND reactionTime.sessionID == " + sessionID + 
+                       " WHERE " + tp + ".uniqueID = reactionTime.personID" + 
+                       " AND reactionTime.sessionID = " + sessionID + 
                        filterPersonString +
+                       filterTypeString +
                        orderByString +
                        limitString;
                
@@ -126,11 +132,11 @@ class SqliteReactionTime : Sqlite
 
                while(reader.Read()) {
                        myArray.Add (reader[0].ToString() + ":" +       //person.name
-                                       reader[1].ToString() + ":" +    //jump.uniqueID
-                                       reader[2].ToString() + ":" +    //jump.personID
-                                       reader[3].ToString() + ":" +    //jump.sessionID
-                                       reader[4].ToString() + ":" +    //jump.type
-                                       Util.ChangeDecimalSeparator(reader[5].ToString()) + ":" +       
//jump.time
+                                       reader[1].ToString() + ":" +    //uniqueID
+                                       reader[2].ToString() + ":" +    //personID
+                                       reader[3].ToString() + ":" +    //sessionID
+                                       reader[4].ToString() + ":" +    //type
+                                       Util.ChangeDecimalSeparator(reader[5].ToString()) + ":" +       //time
                                        reader[6].ToString() + ":" +    //description
                                        reader[7].ToString()            //simulated
                                        );
diff --git a/src/treeViewEvent.cs b/src/treeViewEvent.cs
index 9b5f834..2b112cf 100644
--- a/src/treeViewEvent.cs
+++ b/src/treeViewEvent.cs
@@ -169,7 +169,7 @@ public class TreeViewEvent
                foreach (string singleEvent in myEvents) {
                        string [] myStringFull = singleEvent.Split(new char[] {':'});
 
-                       //show always the names of runners ...
+                       //show always the names of persons ...
                        if(tempPerson != myStringFull[dataLineNamePosition])
                        {
                                iter = store.AppendValues (myStringFull[dataLineNamePosition]);
diff --git a/src/treeViewReactionTime.cs b/src/treeViewReactionTime.cs
index 0272ce8..6fb8cdb 100644
--- a/src/treeViewReactionTime.cs
+++ b/src/treeViewReactionTime.cs
@@ -43,8 +43,7 @@ public class TreeViewReactionTimes : TreeViewEvent
                dataLineNamePosition = 0; //position of name in the data to be printed
 
 
-               //These are Not used, TreeViewEvent/Fill will be called always without "filter" here
-               dataLineTypePosition = -1; //position of type in the data to be printed
+               dataLineTypePosition = 4; //position of type in the data to be printed
                allEventsName = "";
                
 
@@ -60,6 +59,7 @@ public class TreeViewReactionTimes : TreeViewEvent
        protected override System.Object getObjectFromString(string [] myStringOfData) {
                ReactionTime myReactionTime = new ReactionTime();
                myReactionTime.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); 
+               myReactionTime.Type = myStringOfData[4].ToString();
                myReactionTime.Time = Convert.ToDouble(myStringOfData[5].ToString());
                myReactionTime.Description = myStringOfData[6].ToString();
                myReactionTime.Simulated = Convert.ToInt32(myStringOfData[7].ToString());


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