[chronojump] DB: 2.32 RunEncoderExercise added isSprint



commit fe624402f04d5be30f6bea479345a2fd375d710f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Feb 2 15:56:16 2022 +0100

    DB: 2.32 RunEncoderExercise added isSprint

 glade/app1.glade           | 99 +++++++++++++++++++++++++++++++++++++++-------
 src/gui/app1/icons.cs      |  2 +
 src/gui/app1/runEncoder.cs | 16 +++++++-
 src/runEncoder.cs          | 12 ++++--
 src/sqlite/main.cs         | 18 +++++++--
 src/sqlite/runEncoder.cs   | 15 ++++---
 6 files changed, 133 insertions(+), 29 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 42c0841b8..ead2f4fdc 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -15416,7 +15416,7 @@ Resisted race analyzer</property>
                                                             <property name="spacing">10</property>
                                                             <child>
                                                             <widget class="GtkCheckButton" 
id="check_run_encoder_exercise_fixed_size">
-                                                            <property name="label" 
translatable="yes">Segments with fixed size</property>
+                                                            <property name="label" 
translatable="yes">Segments with fixed length</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property 
name="receives_default">False</property>
@@ -15430,11 +15430,27 @@ Resisted race analyzer</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkHBox" id="hbox139">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_run_encoder_exercise_fixed_segments_size">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
+                                                            <widget class="GtkLabel" id="label292">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Length</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkSpinButton" 
id="spin_race_encoder_exercise_segment_size_m">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
@@ -15450,7 +15466,7 @@ Resisted race analyzer</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">0</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -15462,31 +15478,25 @@ Resisted race analyzer</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
                                                             <packing>
-                                                            <property name="top_attach">1</property>
-                                                            <property name="bottom_attach">2</property>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
                                                             </packing>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkHBox" 
id="hbox_run_encoder_exercise_notfixed_segment_num">
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">20</property>
+                                                            <property name="spacing">6</property>
                                                             <child>
                                                             <widget class="GtkLabel" id="label302">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Number 
of segments</property>
+                                                            <property name="label" 
translatable="yes">Num</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -15516,11 +15526,70 @@ Resisted race analyzer</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
                                                             <property name="left_attach">1</property>
                                                             <property name="right_attach">2</property>
                                                             <property name="top_attach">1</property>
                                                             <property name="bottom_attach">2</property>
-                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox202">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">20</property>
+                                                            <child>
+                                                            <widget class="GtkCheckButton" 
id="check_run_encoder_exercise_is_sprint">
+                                                            <property name="label" translatable="yes">Is it 
an sprint?</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="button_run_encoder_exercise_is_sprint_help">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_button_run_encoder_exercise_is_sprint_help_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_run_encoder_exercise_is_sprint_help">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="stock">gtk-info</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index ffdfa93e1..db883307b 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -231,6 +231,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_run_encoder_analyze_image_save_graph;
        [Widget] Gtk.Image image_run_encoder_analyze_image_save_disk;
        [Widget] Gtk.Image image_run_encoder_export_cancel;
+       [Widget] Gtk.Image image_run_encoder_exercise_is_sprint_help;
 
        //video play icons
        [Widget] Gtk.Image image_video_play_this_test_contacts;
@@ -437,6 +438,7 @@ public partial class ChronoJumpWindow
                image_info4.Pixbuf = pixbuf;
                image_run_simple_with_reaction_time_help.Pixbuf = pixbuf;
                image_run_interval_with_reaction_time_help.Pixbuf = pixbuf;
+               image_run_encoder_exercise_is_sprint_help.Pixbuf = pixbuf;
                image_info_sessions_info.Pixbuf = pixbuf;
                image_encoder_1RM_info.Pixbuf = pixbuf;
                image_force_sensor_adjust_help.Pixbuf = pixbuf;
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 1abec1fc1..daa30697a 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -65,6 +65,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Frame frame_run_encoder_exercise;
        [Widget] Gtk.Entry entry_run_encoder_exercise_name;
        [Widget] Gtk.Entry entry_run_encoder_exercise_description;
+       [Widget] Gtk.CheckButton check_run_encoder_exercise_is_sprint;
        [Widget] Gtk.CheckButton check_run_encoder_exercise_fixed_size;
        [Widget] Gtk.HBox hbox_run_encoder_exercise_fixed_segments_size;
        [Widget] Gtk.HBox hbox_run_encoder_exercise_notfixed_segment_num;
@@ -1896,6 +1897,7 @@ public partial class ChronoJumpWindow
                show_contacts_exercise_add_edit (false);
                entry_run_encoder_exercise_name.Text = ex.Name;
                entry_run_encoder_exercise_description.Text = ex.Description;
+               check_run_encoder_exercise_is_sprint.Active = ex.IsSprint;
 
                if(list_segments_size_cm == null)
                        spin_race_encoder_exercise_segment_size_cm_create_list ();
@@ -1925,6 +1927,7 @@ public partial class ChronoJumpWindow
 
                entry_run_encoder_exercise_name.Text = "";
                entry_run_encoder_exercise_description.Text = "";
+               check_run_encoder_exercise_is_sprint.Active = true;
                spin_race_encoder_exercise_segment_size_m.Value = RunEncoderExercise.SegmentMetersDefault;
                spin_race_encoder_exercise_segments_num.Value = 2;
 
@@ -1938,6 +1941,13 @@ public partial class ChronoJumpWindow
                on_check_run_encoder_exercise_fixed_size_toggled (new object (), new EventArgs ());
        }
 
+       private void on_button_run_encoder_exercise_is_sprint_help_clicked (object o, EventArgs args)
+       {
+               new DialogMessage(Constants.MessageTypes.INFO,
+                               Catalog.GetString("In a sprint exercise, maximum acceleration is performed at 
the beginning and maximum sustained speed at a later time."));
+               return;
+       }
+
        private void on_check_run_encoder_exercise_fixed_size_toggled (object o, EventArgs args)
        {
                if(check_run_encoder_exercise_fixed_size.Active)
@@ -2077,13 +2087,15 @@ public partial class ChronoJumpWindow
                if(adding)
                {
                        RunEncoderExercise ex = new RunEncoderExercise (
-                                       -1, name, entry_run_encoder_exercise_description.Text, segmentMeters, 
segmentVariableCm);
+                                       -1, name, entry_run_encoder_exercise_description.Text,
+                                       segmentMeters, segmentVariableCm, 
check_run_encoder_exercise_is_sprint.Active);
                        ex.InsertSQL (false);
                        currentRunEncoderExercise = ex;
                } else {
                        RunEncoderExercise ex = new RunEncoderExercise(
                                        getExerciseIDFromAnyCombo(combo_run_encoder_exercise, 
runEncoderComboExercisesString, false),
-                                       name, entry_run_encoder_exercise_description.Text, segmentMeters, 
segmentVariableCm);
+                                       name, entry_run_encoder_exercise_description.Text,
+                                       segmentMeters, segmentVariableCm, 
check_run_encoder_exercise_is_sprint.Active);
 
                        SqliteRunEncoderExercise.Update(false, ex);
                        currentRunEncoderExercise = ex;
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 4fc3982fa..0e74471af 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -360,6 +360,7 @@ public class RunEncoderExercise
        private int segmentMeters;
        public static int SegmentMetersDefault = 5;
        private List<int> segmentVariableCm; //if segmentMeters == -1 then this is used
+       private bool isSprint;
 
        public RunEncoderExercise()
        {
@@ -370,18 +371,19 @@ public class RunEncoderExercise
                this.name = name;
        }
 
-       public RunEncoderExercise(int uniqueID, string name, string description, int segmentMeters, List<int> 
segmentVariableCm)
+       public RunEncoderExercise(int uniqueID, string name, string description, int segmentMeters, List<int> 
segmentVariableCm, bool isSprint)
        {
                this.uniqueID = uniqueID;
                this.name = name;
                this.description = description;
                this.segmentMeters = segmentMeters;
                this.segmentVariableCm = segmentVariableCm;
+               this.isSprint = isSprint;
        }
 
        public override string ToString()
        {
-               return string.Format("{0}:{1}:{2}:{3}", uniqueID, name, description, segmentMeters);
+               return string.Format("{0}:{1}:{2}:{3}", uniqueID, name, description, segmentMeters); //TODO: 
update this with new parameters
        }
 
        public void InsertSQL (bool dbconOpened)
@@ -397,7 +399,7 @@ public class RunEncoderExercise
 
                return
                        "(" + uniqueIDStr + ", \"" + name + "\", \"" + description + "\", " +
-                       segmentMeters + ", \"" + SegmentVariableCmToSQL + "\")";
+                       segmentMeters + ", \"" + SegmentVariableCmToSQL + "\", " + Util.BoolToInt(isSprint) + 
")";
        }
 
        public int UniqueID
@@ -424,6 +426,10 @@ public class RunEncoderExercise
        {
                get { return Util.ListIntToSQLString (segmentVariableCm, ";"); }
        }
+       public bool IsSprint
+       {
+               get { return isSprint; }
+       }
 }
 
 //results coming from analyze (load) using R. To be published on exportable table
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index ec2aa2eaa..e4126369e 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "2.31";
+       static string lastChronojumpDatabaseVersion = "2.32";
 
        public Sqlite()
        {
@@ -3088,7 +3088,7 @@ class Sqlite
                                if(exercises == null || exercises.Count == 0)
                                        SqliteForceSensorExercise.insertDefault();
 
-                               /* moved to 2.30 to do it after RunEncoderExercise added segmentVariableCm
+                               /* moved to 2.31 to do it after RunEncoderExercise added segmentVariableCm
                                exercises = SqliteRunEncoderExercise.Select(true, -1, true);
                                if(exercises == null || exercises.Count == 0)
                                        SqliteRunEncoderExercise.insertDefault();
@@ -3105,11 +3105,22 @@ class Sqlite
                                        LogB.SQL("Catched at Doing ALTER TABLE added segmentVariableCm.");
                                }
 
+                               currentVersion = updateVersion("2.31");
+                       }
+                       if(currentVersion == "2.31")
+                       {
+                               LogB.SQL("RunEncoderExercise ALTER TABLE added isSprint");
+                               try {
+                                       executeSQL("ALTER TABLE " + Constants.RunEncoderExerciseTable + " ADD 
COLUMN isSprint INT NOT NULL DEFAULT 1;");
+                               } catch {
+                                       LogB.SQL("Catched at Doing ALTER TABLE added isSprint.");
+                               }
+
                                ArrayList exercises = SqliteRunEncoderExercise.Select(true, -1, true);
                                if(exercises == null || exercises.Count == 0)
                                        SqliteRunEncoderExercise.insertDefault();
 
-                               currentVersion = updateVersion("2.31");
+                               currentVersion = updateVersion("2.32");
                        }
 
                        /*
@@ -3332,6 +3343,7 @@ class Sqlite
                //changes [from - to - desc]
 //just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved 
stiffnessString records there
 
+               //2.31 - 2.32 Converted DB to 2.32 RunEncoderExercise ALTER TABLE added isSprint
                //2.30 - 2.31 Converted DB to 2.31 RunEncoderExercise ALTER TABLE added segmentVariableCm
                //2.29 - 2.30 Converted DB to 2.30 Inserted default exercises of forceSensor and raceAnalyzer 
if empty
                //2.28 - 2.29 Converted DB to 2.29 ForceSensor ALTER TABLE added maxForceRaw, maxAvgForce1s
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index 906e60041..304ff4421 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -330,7 +330,7 @@ class SqliteRunEncoder : Sqlite
                //need to create an exercise to assign to the imported files
                if(importedSomething)
                {
-                       RunEncoderExercise ex = new RunEncoderExercise(0, "Sprint", "", 
RunEncoderExercise.SegmentMetersDefault, new List<int>());
+                       RunEncoderExercise ex = new RunEncoderExercise(0, "Sprint", "", 
RunEncoderExercise.SegmentMetersDefault, new List<int>(), true);
                        ex.InsertSQL(true);
                }
 
@@ -361,7 +361,8 @@ class SqliteRunEncoderExercise : Sqlite
                        "name TEXT, " +
                        "description TEXT, " +
                        "segmentMeters INT, " +
-                       "segmentVariableCm TEXT)"; //separator is ;
+                       "segmentVariableCm TEXT, " + //separator is ;
+                       "isSprint INT NOT NULL DEFAULT 1)"; //bool
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
        }
@@ -374,7 +375,7 @@ class SqliteRunEncoderExercise : Sqlite
                        Sqlite.Open();
 
                dbcmd.CommandText = "INSERT INTO " + table +
-                               " (uniqueID, name, description, segmentMeters, segmentVariableCm)" +
+                               " (uniqueID, name, description, segmentMeters, segmentVariableCm, isSprint)" +
                                " VALUES " + insertString;
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
@@ -392,7 +393,7 @@ class SqliteRunEncoderExercise : Sqlite
        //Default exercise for users without exercises (empty database creation or never used raceAnalyzer)
        protected internal static void insertDefault ()
        {
-               RunEncoderExercise re = new RunEncoderExercise (-1, "Sprint", "", 
RunEncoderExercise.SegmentMetersDefault, new List<int>());
+               RunEncoderExercise re = new RunEncoderExercise (-1, "Sprint", "", 
RunEncoderExercise.SegmentMetersDefault, new List<int>(), true);
                re.InsertSQL(true);
        }
 
@@ -412,7 +413,8 @@ class SqliteRunEncoderExercise : Sqlite
                        "\", description = \"" + ex.Description +
                        "\", segmentMeters = " + ex.SegmentMeters +
                        ", segmentVariableCm = \"" + ex.SegmentVariableCmToSQL +
-                       "\" WHERE uniqueID = " + ex.UniqueID;
+                       "\", isSprint = " + ex.IsSprint +
+                       " WHERE uniqueID = " + ex.UniqueID;
 
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
@@ -471,7 +473,8 @@ class SqliteRunEncoderExercise : Sqlite
                                                reader[1].ToString(),                   //name
                                                reader[2].ToString(),                   //description
                                                Convert.ToInt32(reader[3].ToString()),  //segmentMeters
-                                               Util.SQLStringToListInt(reader[4].ToString(), ";")      
//segmentVariableCm
+                                               Util.SQLStringToListInt(reader[4].ToString(), ";"),     
//segmentVariableCm
+                                               Util.IntToBool(Convert.ToInt32(reader[5].ToString()))
                                                );
                                array.Add(ex);
                        }


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