[chronojump] EncoderRhythm objects and SQL done!



commit a4bd8aa310b96d6ef7a78575aa31d1390d1a286b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 24 01:13:42 2018 +0100

    EncoderRhythm objects and SQL done!

 glade/app1.glade                  |    6 ++++
 glade/repetitive_conditions.glade |    4 +-
 src/encoderRhythm.cs              |   52 +++++++++++++++++++++++------------
 src/gui/chronojump.cs             |   24 +++++++++++-----
 src/gui/encoder.cs                |   26 ++++++++++-------
 src/gui/repetitiveConditions.cs   |   54 ++++++++++++++++++++++++++++---------
 src/preferences.cs                |   45 ++++++++++++++++++++++++++++++
 src/sqlite/main.cs                |   22 ++++++++++++++-
 src/sqlite/preferences.cs         |   33 ++++++++++++++++++++---
 9 files changed, 210 insertions(+), 56 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 00f8177..c1ebfb0 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1518,6 +1518,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -22584,6 +22587,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/glade/repetitive_conditions.glade b/glade/repetitive_conditions.glade
index 89c34a0..3c23fcd 100644
--- a/glade/repetitive_conditions.glade
+++ b/glade/repetitive_conditions.glade
@@ -3737,7 +3737,7 @@
                                 <property name="secondary_icon_activatable">False</property>
                                 <property name="primary_icon_sensitive">True</property>
                                 <property name="secondary_icon_sensitive">True</property>
-                                <property name="adjustment">1 0.10000000000000001 99 0.10000000000000001 1 
0</property>
+                                <property name="adjustment">1 0 99 0.10000000000000001 1 0</property>
                                 <property name="digits">2</property>
                               </widget>
                               <packing>
@@ -3824,7 +3824,7 @@
                                         <property name="secondary_icon_activatable">False</property>
                                         <property name="primary_icon_sensitive">True</property>
                                         <property name="secondary_icon_sensitive">True</property>
-                                        <property name="adjustment">5 1 30 1 10 0</property>
+                                        <property name="adjustment">5 2 30 1 10 0</property>
                                         <property name="digits">2</property>
                                       </widget>
                                       <packing>
diff --git a/src/encoderRhythm.cs b/src/encoderRhythm.cs
index 22f1a0f..0f7c712 100644
--- a/src/encoderRhythm.cs
+++ b/src/encoderRhythm.cs
@@ -21,17 +21,17 @@
 using System;
 using System.Data;
 
-public class EncoderRhythmObject
+public class EncoderRhythm
 {
        public double EccSeconds;
        public double ConSeconds;
        public double RestRepsSeconds; //rest between repetitions
 
        //cluster stuff
-       public double RepsCluster;
+       public int RepsCluster;
        public double RestClustersSeconds; //rest between clusters
 
-       public EncoderRhythmObject()
+       public EncoderRhythm()
        {
                //default values
                EccSeconds = .5;
@@ -42,19 +42,30 @@ public class EncoderRhythmObject
                RestClustersSeconds = 6;
        }
 
+       public EncoderRhythm(double eccSeconds, double conSeconds, double restRepsSeconds,
+                       int repsCluster, double restClustersSeconds)
+       {
+               EccSeconds = eccSeconds;
+               ConSeconds = conSeconds;
+               RestRepsSeconds = restRepsSeconds;
+
+               RepsCluster = repsCluster;
+               RestClustersSeconds = restClustersSeconds;
+       }
+
        public bool UseClusters()
        {
                return (RepsCluster > 1);
        }
 }
 
-public class EncoderRhythm
+public class EncoderRhythmExecute
 {
        public string TextRepetition;
        public string TextRest;
 
        private DateTime lastRepetitionDT;
-       private EncoderRhythmObject ero;
+       private EncoderRhythm encoderRhythm;
        private int nreps;
        private bool restClusterTimeEndedFlag;
 
@@ -63,13 +74,18 @@ public class EncoderRhythm
 
 
        //constructor
-       public EncoderRhythm()
+       public EncoderRhythmExecute(EncoderRhythm encoderRhythm)
+       {
+               this.encoderRhythm = encoderRhythm;
+               initialize();
+       }
+
+       private void initialize()
        {
                TextRepetition = "";
                TextRest = "";
 
                lastRepetitionDT = DateTime.MinValue;
-               ero = new EncoderRhythmObject();
                nreps = 0;
                restClusterTimeEndedFlag = false;
        }
@@ -81,7 +97,7 @@ public class EncoderRhythm
 
        private bool firstInCluster()
        {
-               return (nreps % ero.RepsCluster == 0);
+               return (nreps % encoderRhythm.RepsCluster == 0);
        }
 
        public void SetLastRepetitionDT()
@@ -96,9 +112,9 @@ public class EncoderRhythm
                if(restClusterTimeEndedFlag)
                        return false;
 
-               if(nreps > 0 && nreps % ero.RepsCluster == 0)
+               if(nreps > 0 && nreps % encoderRhythm.RepsCluster == 0)
                {
-                       if(totalSeconds < ero.RestClustersSeconds)
+                       if(totalSeconds < encoderRhythm.RestClustersSeconds)
                                return true;
                        else {
                                //resting time passed, force finish rest,
@@ -119,7 +135,7 @@ public class EncoderRhythm
                TimeSpan span = DateTime.Now - lastRepetitionDT;
                double totalSeconds = span.TotalSeconds;
 
-               if(ero.UseClusters() && checkIfRestingBetweenClusters(totalSeconds))
+               if(encoderRhythm.UseClusters() && checkIfRestingBetweenClusters(totalSeconds))
                        calculateClusterRestingFraction(totalSeconds);
                else
                        calculateRepetitionFraction(totalSeconds);
@@ -129,8 +145,8 @@ public class EncoderRhythm
        private void calculateRepetitionFraction(double totalSeconds)
        {
                //first repetition in cluster will not have rest
-               double restRepsSeconds = ero.RestRepsSeconds;
-               if(ero.UseClusters() && firstInCluster())
+               double restRepsSeconds = encoderRhythm.RestRepsSeconds;
+               if(encoderRhythm.UseClusters() && firstInCluster())
                        restRepsSeconds = 0;
 
                if(totalSeconds < restRepsSeconds)
@@ -143,18 +159,18 @@ public class EncoderRhythm
                        fractionRest = totalSeconds / restRepsSeconds;
                        return;
                }
-               else if((totalSeconds - restRepsSeconds) < ero.EccSeconds)
+               else if((totalSeconds - restRepsSeconds) < encoderRhythm.EccSeconds)
                {
                        TextRepetition = "Excentric";
                        TextRest = "";
-                       fractionRepetition = 1 - ((totalSeconds - restRepsSeconds) / ero.EccSeconds);
+                       fractionRepetition = 1 - ((totalSeconds - restRepsSeconds) / 
encoderRhythm.EccSeconds);
                        fractionRest = 0;
                        return;
                }
                else {
                        TextRepetition = "Concentric";
                        TextRest = "";
-                       fractionRepetition = (totalSeconds - (restRepsSeconds + ero.EccSeconds)) / 
ero.ConSeconds;
+                       fractionRepetition = (totalSeconds - (restRepsSeconds + encoderRhythm.EccSeconds)) / 
encoderRhythm.ConSeconds;
                        fractionRest = 0;
                        return;
                }
@@ -163,9 +179,9 @@ public class EncoderRhythm
        private void calculateClusterRestingFraction(double totalSeconds)
        {
                TextRepetition = "";
-               TextRest = "Resting " + Convert.ToInt32((ero.RestClustersSeconds - totalSeconds)).ToString() 
+ " s";
+               TextRest = "Resting " + Convert.ToInt32((encoderRhythm.RestClustersSeconds - 
totalSeconds)).ToString() + " s";
                fractionRepetition = 0;
-               fractionRest = totalSeconds / ero.RestClustersSeconds;
+               fractionRest = totalSeconds / encoderRhythm.RestClustersSeconds;
                return;
        }
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 2cc7bee..b3fc52f 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -562,7 +562,7 @@ public partial class ChronoJumpWindow
                
                //preferencesLoaded is a fix to a gtk#-net-windows-bug where radiobuttons raise signals
                //at initialization of chronojump and gives problems if this signals are raised while 
preferences are loading
-               loadPreferences ();
+               loadPreferencesAtStart ();
 
                //show send log if needed
 
@@ -791,7 +791,8 @@ public partial class ChronoJumpWindow
                        "   " + ((Label) radio_menuitem_mode_power_inertial.Child).Text;
        }
 
-       private void loadPreferences () 
+       //different than on_preferences_activate (opening preferences window)
+       private void loadPreferencesAtStart ()
        {
                preferences = Preferences.LoadAllFromSqlite();
                LogB.Mute = preferences.muteLogs;
@@ -801,6 +802,12 @@ public partial class ChronoJumpWindow
 
                configInitFromPreferences();
 
+               encoderRhythm = new EncoderRhythm(
+                               preferences.encoderRhythmEccSeconds, preferences.encoderRhythmConSeconds,
+                               preferences.encoderRhythmRestRepsSeconds,
+                               preferences.encoderRhythmRepsCluster, 
preferences.encoderRhythmRestClustersSeconds);
+
+
                checkbutton_allow_finish_rj_after_time.Active = preferences.allowFinishRjAfterTime;
 
                //---- video ----
@@ -6770,11 +6777,11 @@ LogB.Debug("X");
        }
                
        private void on_button_rj_bells_clicked(object o, EventArgs args) {
-               repetitiveConditionsWin.View(Constants.BellModes.JUMPS, preferences.volumeOn, 
preferences.gstreamer);
+               repetitiveConditionsWin.View(Constants.BellModes.JUMPS, preferences.volumeOn, 
preferences.gstreamer, encoderRhythm);
        }
 
        private void on_button_time_bells_clicked(object o, EventArgs args) {
-               repetitiveConditionsWin.View(Constants.BellModes.RUNS, preferences.volumeOn, 
preferences.gstreamer);
+               repetitiveConditionsWin.View(Constants.BellModes.RUNS, preferences.volumeOn, 
preferences.gstreamer, encoderRhythm);
        }
        
        private void on_repetitive_conditions_closed(object o, EventArgs args)
@@ -6812,10 +6819,8 @@ LogB.Debug("X");
                                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_bell_none.png");
 
                        image_encoder_bell.Pixbuf = pixbuf;
-               }
 
-               if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == 
Constants.Menuitem_modes.POWERINERTIAL)
-               {
+
                        //treeview_encoder should be updated (to colorize some cells)
                        //only if there was data
                        //this avoids misbehaviour when bell is pressed and there's no data in treeview
@@ -6837,6 +6842,11 @@ LogB.Debug("X");
                                } else
                                        UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea, 
encoder_capture_curves_bars_pixmap);
                        }
+
+                       //rhythm
+                       encoderRhythm = repetitiveConditionsWin.Encoder_rhythm_get_values();
+                       //updates preferences object and Sqlite preferences
+                       preferences.UpdateEncoderRhythm(encoderRhythm);
                }
        }
        
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 2abfeef..5b1b07d 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -329,6 +329,7 @@ public partial class ChronoJumpWindow
        private static bool encoderProcessFinish;
        private static bool encoderProcessFinishContMode;
 
+       private static EncoderRhythmExecute encoderRhythmExecute;
        private static EncoderRhythm encoderRhythm;
 
        EncoderConfigurationWindow encoder_configuration_win;
@@ -611,9 +612,11 @@ public partial class ChronoJumpWindow
        private void on_button_encoder_bells_clicked(object o, EventArgs args)
        {
                if(current_menuitem_mode == Constants.Menuitem_modes.POWERGRAVITATORY)
-                       repetitiveConditionsWin.View(Constants.BellModes.ENCODERGRAVITATORY, 
preferences.volumeOn, preferences.gstreamer);
+                       repetitiveConditionsWin.View(Constants.BellModes.ENCODERGRAVITATORY,
+                                       preferences.volumeOn, preferences.gstreamer, encoderRhythm);
                else
-                       repetitiveConditionsWin.View(Constants.BellModes.ENCODERINERTIAL, 
preferences.volumeOn, preferences.gstreamer);
+                       repetitiveConditionsWin.View(Constants.BellModes.ENCODERINERTIAL,
+                                       preferences.volumeOn, preferences.gstreamer, encoderRhythm);
        }
 
        /*
@@ -5309,7 +5312,7 @@ public partial class ChronoJumpWindow
                                encoderRProcCapture.CutByTriggers = reallyCutByTriggers;
 
                                //initialize DateTime for rhythm
-                               encoderRhythm = new EncoderRhythm();
+                               encoderRhythmExecute = new EncoderRhythmExecute(encoderRhythm);
                                image_encoder_rhythm_alert.Visible = false;
 
                                encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
@@ -5789,7 +5792,7 @@ public partial class ChronoJumpWindow
                        {
                                //TODO: is better to do this before when the curves was sent,
                                //not when needToRefreshTreeviewCapture (because this is too later because 
it's returning from R)
-                               encoderRhythm.SetLastRepetitionDT();
+                               encoderRhythmExecute.SetLastRepetitionDT();
                                image_encoder_rhythm_alert.Visible = false;
 
                                //LogB.Error("HERE YES");
@@ -6017,7 +6020,7 @@ public partial class ChronoJumpWindow
 
        private void updatePulsebarRhythm()
        {
-               if(! encoderRhythm.FirstRepetitionDone())
+               if(! encoderRhythmExecute.FirstRepetitionDone())
                {
                        encoder_pulsebar_rhythm_eccon.Fraction = 0;
                        encoder_pulsebar_rhythm_wait.Fraction = 0;
@@ -6025,13 +6028,14 @@ public partial class ChronoJumpWindow
                        return;
                }
 
-               encoderRhythm.CalculateFractionsAndText();
-               encoder_pulsebar_rhythm_eccon.Fraction = encoderRhythm.FractionRepetition;
-               encoder_pulsebar_rhythm_eccon.Text = encoderRhythm.TextRepetition;
-               encoder_pulsebar_rhythm_wait.Fraction = encoderRhythm.FractionRest;
-               encoder_pulsebar_rhythm_wait.Text = encoderRhythm.TextRest;
+               encoderRhythmExecute.CalculateFractionsAndText();
+               encoder_pulsebar_rhythm_eccon.Fraction = encoderRhythmExecute.FractionRepetition;
+               encoder_pulsebar_rhythm_eccon.Text = encoderRhythmExecute.TextRepetition;
+               //TODO: this pulsebar should be a sofa and a label with seconds in one decimal
+               encoder_pulsebar_rhythm_wait.Fraction = encoderRhythmExecute.FractionRest;
+               encoder_pulsebar_rhythm_wait.Text = encoderRhythmExecute.TextRest;
 
-               if(encoderRhythm.FractionRepetition >= 1)
+               if(encoderRhythmExecute.FractionRepetition >= 1)
                        image_encoder_rhythm_alert.Visible = true;
        }
 
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index cc80b84..bb63d87 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -28,7 +28,7 @@ public class RepetitiveConditionsWindow
 {
        [Widget] Gtk.Window repetitive_conditions;
        [Widget] Gtk.Notebook notebook_main;
-//     [Widget] Gtk.ScrolledWindow scrolled_conditions;
+       //[Widget] Gtk.ScrolledWindow scrolled_conditions;
 
        [Widget] Gtk.Frame frame_best_and_worst;
        [Widget] Gtk.Box hbox_jump_best_worst;
@@ -175,7 +175,8 @@ public class RepetitiveConditionsWindow
        
        static RepetitiveConditionsWindow RepetitiveConditionsWindowBox;
                
-       RepetitiveConditionsWindow () {
+       RepetitiveConditionsWindow ()
+       {
                Glade.XML gladeXML;
                gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "repetitive_conditions.glade", 
"repetitive_conditions", "chronojump");
                gladeXML.Autoconnect(this);
@@ -208,19 +209,21 @@ public class RepetitiveConditionsWindow
                return RepetitiveConditionsWindowBox;
        }
        
-       public void View (Constants.BellModes bellMode, bool volumeOn, Preferences.GstreamerTypes gstreamer)
+       public void View (Constants.BellModes bellMode, bool volumeOn, Preferences.GstreamerTypes gstreamer,
+                       EncoderRhythm encoderRhythm)
        {
                //when user "deleted_event" the window
                if (RepetitiveConditionsWindowBox == null) {
                        RepetitiveConditionsWindowBox = new RepetitiveConditionsWindow (); 
                }
-               RepetitiveConditionsWindowBox.showWidgets(bellMode);
+               RepetitiveConditionsWindowBox.showWidgets(bellMode, encoderRhythm);
+
                RepetitiveConditionsWindowBox.repetitive_conditions.Show ();
                RepetitiveConditionsWindowBox.volumeOn = volumeOn;
                RepetitiveConditionsWindowBox.gstreamer = gstreamer;
        }
 
-       void showWidgets(Constants.BellModes bellMode)
+       void showWidgets(Constants.BellModes bellMode, EncoderRhythm encoderRhythm)
        {
                frame_best_and_worst.Hide();
                frame_conditions.Hide();
@@ -258,8 +261,7 @@ public class RepetitiveConditionsWindow
                                checkbutton_inertial_discard_first_three.Show();
 
                        notebook_main.GetNthPage(RHYTHMPAGE).Show();
-                       check_rhythm_use_clusters.Active = false;
-                       vbox_rhythm_cluster.Visible = false;
+                       encoder_rhythm_set_values(encoderRhythm);
                }
 
                label_test_sound_result.Text = "";
@@ -360,7 +362,7 @@ public class RepetitiveConditionsWindow
        {
                RepetitiveConditionsWindowBox.repetitive_conditions.Hide();
                FakeButtonClose.Click();
-//             RepetitiveConditionsWindowBox = null;
+               //RepetitiveConditionsWindowBox = null;
        }
 
        void on_delete_event (object o, DeleteEventArgs args)
@@ -579,13 +581,39 @@ public class RepetitiveConditionsWindow
 
        private void on_button_rhythm_default_clicked (object o, EventArgs args)
        {
-               spin_rhythm_ecc.Value = 0.5;
-               spin_rhythm_con.Value = 0.5;
-               spin_rhythm_rest_reps.Value = 1;
-               spin_rhythm_reps_cluster.Value = 5;
-               spin_rhythm_rest_clusters.Value = 6;
+               EncoderRhythm encoderRhythm = new EncoderRhythm();
+               encoder_rhythm_set_values(encoderRhythm);
+       }
+
+       private void encoder_rhythm_set_values(EncoderRhythm encoderRhythm)
+       {
+               spin_rhythm_ecc.Value = encoderRhythm.EccSeconds;
+               spin_rhythm_con.Value = encoderRhythm.ConSeconds;
+               spin_rhythm_rest_reps.Value = encoderRhythm.RestRepsSeconds;
+               spin_rhythm_reps_cluster.Value = encoderRhythm.RepsCluster;
+               spin_rhythm_rest_clusters.Value = encoderRhythm.RestClustersSeconds;
+
+               if(encoderRhythm.UseClusters()) {
+                       check_rhythm_use_clusters.Active = true;
+                       vbox_rhythm_cluster.Visible = true;
+               } else {
+                       check_rhythm_use_clusters.Active = false;
+                       vbox_rhythm_cluster.Visible = false;
+               }
+       }
+
+       public EncoderRhythm Encoder_rhythm_get_values()
+       {
+               int reps_cluster = Convert.ToInt32(spin_rhythm_reps_cluster.Value);
+               if(! check_rhythm_use_clusters.Active && reps_cluster > 1)
+                       reps_cluster = 1;
+
+               return new EncoderRhythm(
+                               spin_rhythm_ecc.Value, spin_rhythm_con.Value, spin_rhythm_rest_reps.Value,
+                               reps_cluster, spin_rhythm_rest_clusters.Value);
        }
 
+
        /* JUMPS */
        public bool TfTcBest {
                get { return checkbutton_jump_tf_tc_best.Active; }
diff --git a/src/preferences.cs b/src/preferences.cs
index 58b6eac..9e0b1fc 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -97,6 +97,13 @@ public class Preferences
        public Constants.MultimediaStorage multimediaStorage;
        public string databaseVersion;
 
+       //encoder rhythm
+       public double encoderRhythmEccSeconds;
+       public double encoderRhythmConSeconds;
+       public double encoderRhythmRestRepsSeconds;
+       public int encoderRhythmRepsCluster;
+       public double encoderRhythmRestClustersSeconds;
+
        public string forceSensorTareDateTime;
        public double forceSensorTare;
        public string forceSensorCalibrationDateTime;
@@ -155,6 +162,44 @@ public class Preferences
                return changed;
        }
 
+       public void UpdateEncoderRhythm(EncoderRhythm er)
+       {
+               if(encoderRhythmEccSeconds != er.EccSeconds)
+               {
+                       encoderRhythmEccSeconds = er.EccSeconds;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderRhythmEccSecondsStr,
+                                       Util.ConvertToPoint(er.EccSeconds), false);
+               }
+
+               if(encoderRhythmConSeconds != er.ConSeconds)
+               {
+                       encoderRhythmConSeconds = er.ConSeconds;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderRhythmConSecondsStr,
+                                       Util.ConvertToPoint(er.ConSeconds), false);
+               }
+
+               if(encoderRhythmRestRepsSeconds != er.RestRepsSeconds)
+               {
+                       encoderRhythmRestRepsSeconds = er.RestRepsSeconds;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderRhythmRestRepsSecondsStr,
+                                       Util.ConvertToPoint(er.RestRepsSeconds), false);
+               }
+
+               if(encoderRhythmRepsCluster != er.RepsCluster)
+               {
+                       encoderRhythmRepsCluster = er.RepsCluster;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderRhythmRepsClusterStr,
+                                       Util.ConvertToPoint(er.RepsCluster), false);
+               }
+
+               if(encoderRhythmRestClustersSeconds != er.RestClustersSeconds)
+               {
+                       encoderRhythmRestClustersSeconds = er.RestClustersSeconds;
+                       SqlitePreferences.Update(SqlitePreferences.EncoderRhythmRestClustersSecondsStr,
+                                       Util.ConvertToPoint(er.RestClustersSeconds), false);
+               }
+       }
+
        //force sensor
        public void UpdateForceSensorTare(double tare)
        {
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index b0eea00..018b07a 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -125,7 +125,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.51";
+       static string lastChronojumpDatabaseVersion = "1.52";
 
        public Sqlite() {
        }
@@ -2284,6 +2284,25 @@ class Sqlite
 
                                currentVersion = updateVersion("1.51");
                        }
+                       if(currentVersion == "1.51")
+                       {
+                               LogB.SQL("Added encoderRhtyhm stuff");
+
+                               EncoderRhythm er = new EncoderRhythm();
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderRhythmEccSecondsStr,
+                                               Util.ConvertToPoint(er.EccSeconds));
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderRhythmConSecondsStr,
+                                               Util.ConvertToPoint(er.ConSeconds));
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderRhythmRestRepsSecondsStr,
+                                               Util.ConvertToPoint(er.RestRepsSeconds));
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderRhythmRepsClusterStr,
+                                               Util.ConvertToPoint(er.RepsCluster));
+                               SqlitePreferences.Insert 
(SqlitePreferences.EncoderRhythmRestClustersSecondsStr,
+                                               Util.ConvertToPoint(er.RestClustersSeconds));
+
+                               currentVersion = updateVersion("1.52");
+                       }
+
 
 
 
@@ -2466,6 +2485,7 @@ class Sqlite
                SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);
 
                //changes [from - to - desc]
+               //1.51 - 1.52 Converted DB to 1.52 Added encoderRhtyhm stuff
                //1.50 - 1.51 Converted DB to 1.51 Updated encoderCaptureCutByTriggers variable
                //1.49 - 1.50 Converted DB to 1.50 Updated preferences: added crashLogLanguage
                //1.48 - 1.49 Converted DB to 1.49 Updated preferences: added force sensor tare/calibration 
stuff
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 8f00eef..9b53fbc 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -46,7 +46,7 @@ class SqlitePreferences : Sqlite
        public const string EncoderRhythmConSecondsStr = "encoderRhythmConSeconds";
        public const string EncoderRhythmRestRepsSecondsStr = "encoderRhythmRestRepsSeconds";
        public const string EncoderRhythmRepsClusterStr = "encoderRhythmRepsCluster";
-       public const string EncoderRhythmRestClusterSecondsStr = "encoderRhythmRestClusterSeconds";
+       public const string EncoderRhythmRestClustersSecondsStr = "encoderRhythmRestClustersSeconds";
 
        protected internal static new void createTable()
        {
@@ -151,6 +151,14 @@ class SqlitePreferences : Sqlite
                                Insert (EncoderMassGravitatory, "10", dbcmdTr);
                                Insert (EncoderWeightsInertial, "0", dbcmdTr);
 
+                               //encoderRhythm
+                               EncoderRhythm er = new EncoderRhythm();
+                               Insert (EncoderRhythmEccSecondsStr, Util.ConvertToPoint(er.EccSeconds), 
dbcmdTr);
+                               Insert (EncoderRhythmConSecondsStr, Util.ConvertToPoint(er.ConSeconds), 
dbcmdTr);
+                               Insert (EncoderRhythmRestRepsSecondsStr, 
Util.ConvertToPoint(er.RestRepsSeconds), dbcmdTr);
+                               Insert (EncoderRhythmRepsClusterStr, Util.ConvertToPoint(er.RepsCluster), 
dbcmdTr);
+                               Insert (EncoderRhythmRestClustersSecondsStr, 
Util.ConvertToPoint(er.RestClustersSeconds), dbcmdTr);
+
 
                                Insert ("videoDevice", "0", dbcmdTr); //first
                                Insert ("inertialmomentum", "0.01", dbcmdTr);
@@ -239,7 +247,9 @@ class SqlitePreferences : Sqlite
 
                return myReturn;
        }
-       
+
+       //Some are sent to preferences window, others not
+       //check: preferences.cs at the top
        public static Preferences SelectAll () 
        {
                Sqlite.Open();
@@ -256,7 +266,6 @@ class SqlitePreferences : Sqlite
                        //LogB.Debug("Reading preferences");
                        //LogB.Information(reader[0].ToString() + ":" + reader[1].ToString());
 
-                       //these are sent to preferences window
                        if(reader[0].ToString() == "maximized")
                                preferences.maximized = (Preferences.MaximizedTypes)
                                        Enum.Parse(typeof(Preferences.MaximizedTypes), reader[1].ToString());
@@ -317,6 +326,23 @@ class SqlitePreferences : Sqlite
                        else if(reader[0].ToString() == "encoder1RMMethod")
                                preferences.encoder1RMMethod = (Constants.Encoder1RMMethod) 
                                        Enum.Parse(typeof(Constants.Encoder1RMMethod), reader[1].ToString()); 
+
+                       //encoder rhythm
+                       else if(reader[0].ToString() == EncoderRhythmEccSecondsStr)
+                               preferences.encoderRhythmEccSeconds = Convert.ToDouble(
+                                               Util.ChangeDecimalSeparator(reader[1].ToString()));
+                       else if(reader[0].ToString() == EncoderRhythmConSecondsStr)
+                               preferences.encoderRhythmConSeconds = Convert.ToDouble(
+                                               Util.ChangeDecimalSeparator(reader[1].ToString()));
+                       else if(reader[0].ToString() == EncoderRhythmRestRepsSecondsStr)
+                               preferences.encoderRhythmRestRepsSeconds = Convert.ToDouble(
+                                               Util.ChangeDecimalSeparator(reader[1].ToString()));
+                       else if(reader[0].ToString() == EncoderRhythmRepsClusterStr)
+                               preferences.encoderRhythmRepsCluster = Convert.ToInt32(reader[1].ToString());
+                       else if(reader[0].ToString() == EncoderRhythmRestClustersSecondsStr)
+                               preferences.encoderRhythmRestClustersSeconds = Convert.ToDouble(
+                                               Util.ChangeDecimalSeparator(reader[1].ToString()));
+
                        //video... other
                        else if(reader[0].ToString() == "videoDevice")
                                preferences.videoDeviceNum = Convert.ToInt32(reader[1].ToString());
@@ -330,7 +356,6 @@ class SqlitePreferences : Sqlite
                                preferences.RGraphsTranslate = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "useHeightsOnJumpIndexes")
                                preferences.useHeightsOnJumpIndexes = reader[1].ToString() == "True";
-                       //these are NOT sent to preferences window
                        else if(reader[0].ToString() == "allowFinishRjAfterTime")
                                preferences.allowFinishRjAfterTime = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "volumeOn")


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