[chronojump] DB:1.74 ForceSensorExercise Edit/Add SQL and GUI done



commit 14b443fe8b573928b44b923eb69ed63a10afd205
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Oct 3 18:13:17 2019 +0200

    DB:1.74 ForceSensorExercise Edit/Add SQL and GUI done

 glade/app1.glade                  |  81 ++++----------
 glade/force_sensor_exercise.glade | 142 +++++++++++++++++-------
 src/forceSensor.cs                |  56 +++++++++-
 src/gui/chronojumpIcons.cs        |   2 -
 src/gui/forceSensor.cs            | 165 +++-------------------------
 src/gui/forceSensorExercise.cs    | 220 ++++++++++++++++++++++++++++++++------
 src/sqlite/forceSensor.cs         |  66 +++++++-----
 src/sqlite/main.cs                |  22 +++-
 8 files changed, 442 insertions(+), 312 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 9c71a5e1..10c60b8b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -6621,53 +6621,6 @@ EncoderInertialCapture</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">8</property>
                                                             <child>
-                                                            <widget class="GtkButton" 
id="button_force_sensor_exercise_edit_experimental">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
-                                                            <property name="has_tooltip">True</property>
-                                                            <property name="tooltip" translatable="yes">Edit 
exercise type</property>
-                                                            <signal name="clicked" 
handler="on_button_force_sensor_exercise_edit_experimental_clicked" swapped="no"/>
-                                                            <child>
-                                                            <widget class="GtkHBox" id="hbox168">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">4</property>
-                                                            <child>
-                                                            <widget class="GtkImage" 
id="image_force_sensor_exercise_edit_wip">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="stock">gtk-new</property>
-                                                            <property name="icon-size">2</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label51">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label">WIP</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkButton" 
id="button_force_sensor_exercise_edit">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
@@ -6687,7 +6640,7 @@ EncoderInertialCapture</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">0</property>
                                                             </packing>
                                                             </child>
                                                             <child>
@@ -6710,7 +6663,7 @@ EncoderInertialCapture</property>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -21930,6 +21883,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23878,18 +23834,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -23926,6 +23870,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -30842,6 +30798,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/glade/force_sensor_exercise.glade b/glade/force_sensor_exercise.glade
index 25b8323b..43971091 100644
--- a/glade/force_sensor_exercise.glade
+++ b/glade/force_sensor_exercise.glade
@@ -46,7 +46,7 @@
                     <property name="secondary_icon_activatable">False</property>
                     <property name="primary_icon_sensitive">True</property>
                     <property name="secondary_icon_sensitive">True</property>
-                    <signal name="changed" handler="on_entries_changed" swapped="no"/>
+                    <signal name="changed" handler="on_entry_name_changed" swapped="no"/>
                   </widget>
                   <packing>
                     <property name="expand">True</property>
@@ -363,7 +363,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">100 1 100 1 10 0</property>
+                                    <property name="adjustment">100 0 100 1 10 0</property>
                                     <property name="snap_to_ticks">True</property>
                                     <property name="numeric">True</property>
                                   </widget>
@@ -463,11 +463,11 @@
                     <property name="border_width">8</property>
                     <property name="spacing">20</property>
                     <child>
-                      <widget class="GtkLabel" id="label_angle">
+                      <widget class="GtkLabel" id="label_other">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Angle</property>
+                        <property name="label" translatable="yes">Other</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
@@ -476,7 +476,7 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkTextView" id="textview_angle_explanation">
+                      <widget class="GtkTextView" id="textview_other_explanation">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="editable">False</property>
@@ -556,6 +556,48 @@
                         <property name="position">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <widget class="GtkHBox" id="hbox8">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <widget class="GtkLabel" id="label7">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Description</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkEntry" id="entry_description">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">●</property>
+                            <property name="invisible_char_set">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                            <property name="primary_icon_sensitive">True</property>
+                            <property name="secondary_icon_sensitive">True</property>
+                            <signal name="changed" handler="on_entry_description_changed" swapped="no"/>
+                          </widget>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
                   </widget>
                   <packing>
                     <property name="position">3</property>
@@ -565,7 +607,7 @@
                   <widget class="GtkLabel" id="label6">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label">angle</property>
+                    <property name="label">other</property>
                   </widget>
                   <packing>
                     <property name="position">3</property>
@@ -736,8 +778,8 @@
                                 <property name="stock">gtk-missing-image</property>
                               </widget>
                               <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
@@ -748,8 +790,8 @@
                                 <property name="label" translatable="yes">Back</property>
                               </widget>
                               <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
@@ -763,42 +805,68 @@
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkButton" id="button_next_or_accept">
+                      <widget class="GtkHBox" id="hbox3">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <signal name="clicked" handler="on_button_next_clicked" swapped="no"/>
-                        <accelerator key="Escape" signal="clicked"/>
+                        <property name="can_focus">False</property>
                         <child>
-                          <widget class="GtkHBox" id="hbox3">
+                          <widget class="GtkButton" id="button_next">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="spacing">10</property>
-                            <child>
-                              <widget class="GtkImage" id="image_next_or_accept">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="stock">gtk-missing-image</property>
-                              </widget>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <signal name="clicked" handler="on_button_next_clicked" swapped="no"/>
+                            <accelerator key="Escape" signal="clicked"/>
                             <child>
-                              <widget class="GtkLabel" id="label7">
+                              <widget class="GtkHBox" id="hbox6">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">Next</property>
+                                <property name="spacing">10</property>
+                                <child>
+                                  <widget class="GtkImage" id="image_next">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-missing-image</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label_next">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Next</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </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">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkButton" id="button_accept">
+                            <property name="label">gtk-ok</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                            <signal name="clicked" handler="on_button_accept_clicked" swapped="no"/>
+                            <accelerator key="Escape" signal="clicked"/>
+                          </widget>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
                         </child>
                       </widget>
                       <packing>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index de171798..a562678a 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -266,6 +266,15 @@ public class ForceSensorExercise
        private int angleDefault;
        private string description;
        private bool tareBeforeCapture;
+       private bool forceResultant;
+       private bool elastic;
+
+       /*
+        * note percentBodyWeight and tareBeforeCapture will not be true at the same time, so there are three 
modes on total mass management (see diagrams/processes/forceSensorExerciseParameters)
+        *      add effect of the mass (percentBodyWeight > 0, tareBeforeCapture = false)
+        *      subtract effect off the mass (percentBodyWeight = 0, tareBeforeCapture = true)
+        *      effect of the mass is included in raw data (percentBodyWeight = 0, tareBeforeCapture = false)
+        */
 
        public ForceSensorExercise()
        {
@@ -277,7 +286,7 @@ public class ForceSensorExercise
        }
 
        public ForceSensorExercise(int uniqueID, string name, int percentBodyWeight, string resistance, int 
angleDefault,
-                       string description, bool tareBeforeCapture)
+                       string description, bool tareBeforeCapture, bool forceResultant, bool elastic)
        {
                this.uniqueID = uniqueID;
                this.name = name;
@@ -286,12 +295,45 @@ public class ForceSensorExercise
                this.angleDefault = angleDefault;
                this.description = description;
                this.tareBeforeCapture = tareBeforeCapture;
+               this.forceResultant = forceResultant;
+               this.elastic = elastic;
        }
 
        public override string ToString()
        {
                return uniqueID.ToString() + ":" + name + ":" + percentBodyWeight.ToString() + ":" +
-                       resistance + ":" + angleDefault.ToString() + ":" + description + ":" + 
tareBeforeCapture.ToString();
+                       resistance + ":" + angleDefault.ToString() + ":" + description + ":" +
+                       tareBeforeCapture.ToString() + ":" + forceResultant.ToString() + ":" + 
elastic.ToString();
+       }
+
+       public string ToSQLInsertString()
+       {
+               string uniqueIDStr = "NULL";
+               if(uniqueID != -1)
+                       uniqueIDStr = uniqueID.ToString();
+
+               return
+                       uniqueIDStr + ", \"" + name + "\", " + percentBodyWeight + ", \"" +
+                       resistance + "\", " + angleDefault + ", \"" + description + "\", " +
+                       Util.BoolToInt(tareBeforeCapture).ToString() + ", " +
+                       Util.BoolToInt(forceResultant).ToString() + ", " +
+                       Util.BoolToInt(elastic).ToString();
+       }
+
+       public bool Changed(ForceSensorExercise newEx)
+       {
+               if(
+                               name == newEx.Name &&
+                               percentBodyWeight == newEx.PercentBodyWeight &&
+                               resistance == newEx.Resistance &&
+                               angleDefault == newEx.AngleDefault &&
+                               description == newEx.Description &&
+                               tareBeforeCapture == newEx.TareBeforeCapture &&
+                               forceResultant == newEx.ForceResultant &&
+                               elastic == newEx.Elastic)
+                       return false;
+
+               return true;
        }
 
        public int UniqueID
@@ -309,6 +351,7 @@ public class ForceSensorExercise
        public string Resistance
        {
                get { return resistance; }
+               set { resistance = value; }
        }
        public int AngleDefault
        {
@@ -317,11 +360,20 @@ public class ForceSensorExercise
        public string Description
        {
                get { return description; }
+               set { description = value; }
        }
        public bool TareBeforeCapture
        {
                get { return tareBeforeCapture; }
        }
+       public bool ForceResultant
+       {
+               get { return forceResultant; }
+       }
+       public bool Elastic
+       {
+               get { return elastic; }
+       }
 }
 
 /*
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index 35376781..add0311a 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -173,7 +173,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_force_sensor_capture_recalculate;
        [Widget] Gtk.Image image_force_sensor_analyze_analyze;
        [Widget] Gtk.Image image_force_sensor_exercise_edit;
-       [Widget] Gtk.Image image_force_sensor_exercise_edit_wip;
        [Widget] Gtk.Image image_force_sensor_laterality_both;
        [Widget] Gtk.Image image_force_sensor_laterality_r;
        [Widget] Gtk.Image image_force_sensor_laterality_l;
@@ -398,7 +397,6 @@ public partial class ChronoJumpWindow
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_edit.png");
                image_encoder_exercise_edit.Pixbuf = pixbuf;
                image_force_sensor_exercise_edit.Pixbuf = pixbuf;
-               image_force_sensor_exercise_edit_wip.Pixbuf = pixbuf;
                image_run_encoder_exercise_edit.Pixbuf = pixbuf;
                image_edit_current_person.Pixbuf = pixbuf;
                image_edit_current_person_h.Pixbuf = pixbuf;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 9f0082ce..9480e67f 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -96,6 +96,8 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.SpinButton spin_force_sensor_capture_feedback_at;
        [Widget] Gtk.SpinButton spin_force_sensor_capture_feedback_range;
 
+       ForceSensorExerciseWindow forceSensorExerciseWin;
+
        Gdk.Pixmap force_capture_pixmap = null;
 
        Thread forceCaptureThread;
@@ -2221,8 +2223,6 @@ LogB.Information(" fs R ");
                        combo_force_sensor_exercise.Active = 
UtilGtk.ComboMakeActive(combo_force_sensor_exercise, name);
        }
 
-       ForceSensorExerciseWindow forceSensorExerciseWin; //TODO: clean
-       //info is now info and edit (all values can be changed), and detete (there's delete button)
        void on_button_force_sensor_exercise_edit_clicked (object o, EventArgs args)
        {
                if(UtilGtk.ComboGetActive(combo_force_sensor_exercise) == "")
@@ -2236,166 +2236,33 @@ LogB.Information(" fs R ");
 
                LogB.Information("selected exercise: " + ex.ToString());
 
-               ArrayList bigArray = new ArrayList();
-
-               ArrayList a1 = new ArrayList();
-               ArrayList a2 = new ArrayList();
-               ArrayList a3 = new ArrayList();
-               ArrayList a4 = new ArrayList();
-               ArrayList a5 = new ArrayList();
-
-               //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(true); a1.Add(ex.Name); //name can be 
changed (opposite to encoder), because we use always the uniqueID
-               bigArray.Add(a1);
-
-               a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(true); a2.Add("");
-               bigArray.Add(a2);
-
-               a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(true); a3.Add(ex.Resistance);
-               bigArray.Add(a3);
-
-               a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add(ex.Description);
-               bigArray.Add(a4);
-
-               a5.Add(Constants.GenericWindowShow.CHECK1); a5.Add(true); 
a5.Add(Util.BoolToRBool(ex.TareBeforeCapture));
-               bigArray.Add(a5);
-
-
-               genericWin = GenericWindow.Show(Catalog.GetString("Exercise"), false,   //don't show now
-                               Catalog.GetString("Force sensor exercise:"), bigArray);
-               genericWin.LabelSpinInt = Catalog.GetString("Involved body weight") + " (%)";
-               genericWin.SetSpinRange(0, 100);
-               genericWin.SetSpinValue(ex.PercentBodyWeight);
+               forceSensorExerciseWin = ForceSensorExerciseWindow.ShowEdit (Catalog.GetString("Exercise"),
+                               Catalog.GetString("Force sensor exercise:"), ex);
 
-               genericWin.LabelEntry2 = Catalog.GetString("Resistance");
-               genericWin.LabelEntry3 = Catalog.GetString("Description");
-               //genericWin.LabelSpinInt2 = Catalog.GetString("Default angle");
-               //genericWin.SetSpin2Range(0,180);
-               genericWin.SetCheck1Label(Catalog.GetString("Tare before capture"));
-
-               genericWin.ShowButtonCancel(false);
-
-               genericWin.ShowButtonDelete(true);
-               genericWin.Button_delete.Clicked += new EventHandler(on_button_force_sensor_exercise_delete);
-
-               genericWin.nameUntranslated = ex.Name;
-               genericWin.uniqueID = ex.UniqueID;
-
-               genericWin.Button_accept.Clicked += new 
EventHandler(on_button_force_sensor_exercise_edit_accepted);
-               genericWin.ShowNow();
+               forceSensorExerciseWin.FakeButtonReadValues.Clicked += new 
EventHandler(on_button_force_sensor_exercise_edit_add_accepted);
        }
 
-       void on_button_force_sensor_exercise_edit_experimental_clicked (object o, EventArgs args)
+       void on_button_force_sensor_exercise_add_clicked (object o, EventArgs args)
        {
-               forceSensorExerciseWin = ForceSensorExerciseWindow.Show(Catalog.GetString("Exercise"),
+               forceSensorExerciseWin = ForceSensorExerciseWindow.ShowAdd (Catalog.GetString("Exercise"),
                                Catalog.GetString("Force sensor exercise:"));
-       }
-
-       private void on_button_force_sensor_exercise_add_clicked (object o, EventArgs args)
-       {
-               ArrayList bigArray = new ArrayList();
-
-               ArrayList a1 = new ArrayList();
-               ArrayList a2 = new ArrayList();
-               ArrayList a3 = new ArrayList();
-               ArrayList a4 = new ArrayList();
-               ArrayList a5 = new ArrayList();
-
-               //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(true); a1.Add("");
-               bigArray.Add(a1);
-
-               a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(true); a2.Add("");
-               bigArray.Add(a2);
-
-               a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(true); a3.Add("");
-               bigArray.Add(a3);
-
-               a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add("");
-               bigArray.Add(a4);
-
-               a5.Add(Constants.GenericWindowShow.CHECK1); a5.Add(true); a5.Add("False");
-               bigArray.Add(a5);
-
-
-               genericWin = GenericWindow.Show(Catalog.GetString("Exercise"), false,   //don't show now
-                               Catalog.GetString("Write the name of the exercise:"), bigArray);
-               genericWin.LabelSpinInt = Catalog.GetString("Involved body weight") + " (%)";
-               genericWin.SetSpinRange(0, 100);
-               genericWin.LabelEntry2 = Catalog.GetString("Resistance");
-               genericWin.LabelEntry3 = Catalog.GetString("Description");
-               //genericWin.LabelSpinInt2 = Catalog.GetString("Default angle");
-               //genericWin.SetSpin2Range(0,180);
-               genericWin.SetCheck1Label(Catalog.GetString("Tare before capture"));
 
-               genericWin.SetButtonAcceptLabel(Catalog.GetString("Add"));
-
-               genericWin.HideOnAccept = false;
-
-               genericWin.Button_accept.Clicked += new 
EventHandler(on_button_force_sensor_exercise_add_accepted);
-               genericWin.ShowNow();
+               forceSensorExerciseWin.FakeButtonReadValues.Clicked += new 
EventHandler(on_button_force_sensor_exercise_edit_add_accepted);
        }
 
-       void on_button_force_sensor_exercise_edit_accepted (object o, EventArgs args)
+       void on_button_force_sensor_exercise_edit_oldTODO_accepted (object o, EventArgs args)
        {
-               if(force_sensor_exercise_do_add_or_edit(false))
-               {
-                       genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_edit_accepted);
-                       genericWin.HideAndNull();
-               }
-       }
-       void on_button_force_sensor_exercise_add_accepted (object o, EventArgs args)
-       {
-               if(force_sensor_exercise_do_add_or_edit(true))
-               {
-                       genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_add_accepted);
-                       genericWin.HideAndNull();
-               }
+               //TODO: cridat des del delete
        }
 
-       bool force_sensor_exercise_do_add_or_edit (bool adding)
+       void on_button_force_sensor_exercise_edit_add_accepted (object o, EventArgs args)
        {
-               string name = 
Util.MakeValidSQLAndFileName(Util.RemoveTildeAndColonAndDot(genericWin.EntrySelected));
-               name = Util.RemoveChar(name, '"');
-
-               if(adding)
-                       LogB.Information("force_sensor_exercise_do - Trying to insert: " + name);
-               else
-                       LogB.Information("force_sensor_exercise_do - Trying to edit: " + name);
-
-               if(name == "")
-                       genericWin.SetLabelError(Catalog.GetString("Error: Missing name of exercise."));
-               else if (adding && Sqlite.Exists(false, Constants.ForceSensorExerciseTable, name))
-                       genericWin.SetLabelError(string.Format(Catalog.GetString(
-                                                       "Error: An exercise named '{0}' already exists."), 
name));
-               else {
-                       if(adding)
-                               SqliteForceSensorExercise.Insert(false, -1, name, genericWin.SpinIntSelected,
-                                               genericWin.Entry2Selected,
-                                               genericWin.SpinInt2Selected,
-                                               genericWin.Entry3Selected,
-                                               genericWin.GetCheck1
-                                               );
-                       else {
-                               ForceSensorExercise ex = new ForceSensorExercise(
-                                               genericWin.uniqueID,
-                                               name,
-                                               genericWin.SpinIntSelected,
-                                               genericWin.Entry2Selected,
-                                               genericWin.SpinInt2Selected,
-                                               genericWin.Entry3Selected,
-                                               genericWin.GetCheck1
-                                               );
-                               SqliteForceSensorExercise.Update(false, ex);
-                       }
+               forceSensorExerciseWin.FakeButtonReadValues.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_edit_add_accepted);
 
-                       fillForceSensorExerciseCombo(name);
-
-                       LogB.Information("done");
-                       return true;
-               }
+               if(forceSensorExerciseWin.Success)
+                       fillForceSensorExerciseCombo(forceSensorExerciseWin.Exercise.Name);
 
-               return false;
+               forceSensorExerciseWin.HideAndNull();
        }
 
        //based on: on_button_encoder_exercise_delete
@@ -2428,7 +2295,7 @@ LogB.Information(" fs R ");
                        genericWin.ShowButtonDelete(false);
                        genericWin.DeletingExerciseHideSomeWidgets();
 
-                       genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_edit_accepted);
+                       genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_force_sensor_exercise_edit_oldTODO_accepted);
                        genericWin.Button_accept.Clicked += new 
EventHandler(on_button_force_sensor_exercise_do_not_delete);
                } else {
                        //forceSensor table has not records of this exercise. Delete exercise
diff --git a/src/gui/forceSensorExercise.cs b/src/gui/forceSensorExercise.cs
index 97667885..63998d6a 100644
--- a/src/gui/forceSensorExercise.cs
+++ b/src/gui/forceSensorExercise.cs
@@ -32,10 +32,8 @@ public class ForceSensorExerciseWindow
 {
        [Widget] Gtk.Window force_sensor_exercise;
        [Widget] Gtk.Label label_header;
-       /*
-          [Widget] Gtk.Box hbox_error;
-          [Widget] Gtk.Label label_error;
-          */
+       [Widget] Gtk.Box hbox_error;
+       [Widget] Gtk.Label label_error;
        [Widget] Gtk.Entry entry_name;
        [Widget] Gtk.Notebook notebook_main;
 
@@ -58,9 +56,10 @@ public class ForceSensorExerciseWindow
        [Widget] Gtk.HBox hbox_body_mass_add;
        [Widget] Gtk.SpinButton spin_body_mass_add;
 
-       [Widget] Gtk.Label label_angle;
-       [Widget] Gtk.TextView textview_angle_explanation;
+       [Widget] Gtk.Label label_other;
+       [Widget] Gtk.TextView textview_other_explanation;
        [Widget] Gtk.SpinButton spin_angle;
+       [Widget] Gtk.Entry entry_description;
 
        [Widget] Gtk.Notebook notebook_desc_examples;
        [Widget] Gtk.Label label_notebook_desc_examples_desc;
@@ -68,15 +67,23 @@ public class ForceSensorExerciseWindow
        [Widget] Gtk.TextView textview_description;
        [Widget] Gtk.TextView textview_examples;
 
-       [Widget] Gtk.Button button_next_or_accept;
+       [Widget] Gtk.Button button_next;
+       [Widget] Gtk.Button button_accept;
        [Widget] Gtk.Button button_back;
 
        [Widget] Gtk.Image image_cancel;
-       [Widget] Gtk.Image image_next_or_accept;
+       [Widget] Gtk.Image image_next;
        [Widget] Gtk.Image image_back;
 
-       private enum Pages { FORCE, FIXATION, MASS, ANGLE }
-       private enum Options { FORCE_SENSOR, FORCE_RESULTANT, FIXATION_ELASTIC, FIXATION_NOT_ELASTIC, 
MASS_ADD, MASS_SUBTRACT, MASS_NOTHING, ANGLE }
+       [Widget] Gtk.Button fakeButtonReadValues;
+
+       public bool Success;
+       private ForceSensorExercise exercise;
+
+       private enum modesEnum { EDIT, ADD }
+       private modesEnum modeEnum;
+       private enum Pages { FORCE, FIXATION, MASS, OTHER }
+       private enum Options { FORCE_SENSOR, FORCE_RESULTANT, FIXATION_ELASTIC, FIXATION_NOT_ELASTIC, 
MASS_ADD, MASS_SUBTRACT, MASS_NOTHING, OTHER }
 
        static ForceSensorExerciseWindow ForceSensorExerciseWindowBox;
 
@@ -97,6 +104,7 @@ public class ForceSensorExerciseWindow
                force_sensor_exercise.Resizable = false;
                setTitle(title);
                label_header.Text = textHeader;
+               fakeButtonReadValues = new Gtk.Button();
 
                initializeGuiAtCreation();
 
@@ -104,7 +112,26 @@ public class ForceSensorExerciseWindow
                //DestroyOnAccept = false;
        }
 
-       static public ForceSensorExerciseWindow Show (string title, string textHeader)
+       static public ForceSensorExerciseWindow ShowEdit (string title, string textHeader, 
ForceSensorExercise exercise)
+       {
+               if (ForceSensorExerciseWindowBox == null) {
+                       ForceSensorExerciseWindowBox = new ForceSensorExerciseWindow(title, textHeader);
+               } else {
+                       ForceSensorExerciseWindowBox.setTitle(title);
+                       ForceSensorExerciseWindowBox.label_header.Text = textHeader;
+               }
+
+               ForceSensorExerciseWindowBox.modeEnum = modesEnum.EDIT;
+               ForceSensorExerciseWindowBox.Success = false;
+               ForceSensorExerciseWindowBox.initializeGuiAtShow();
+               ForceSensorExerciseWindowBox.exercise = exercise;
+               ForceSensorExerciseWindowBox.exerciseToGUI();
+               ForceSensorExerciseWindowBox.force_sensor_exercise.Show ();
+
+               return ForceSensorExerciseWindowBox;
+       }
+
+       static public ForceSensorExerciseWindow ShowAdd (string title, string textHeader)
        {
                if (ForceSensorExerciseWindowBox == null) {
                        ForceSensorExerciseWindowBox = new ForceSensorExerciseWindow(title, textHeader);
@@ -113,7 +140,10 @@ public class ForceSensorExerciseWindow
                        ForceSensorExerciseWindowBox.label_header.Text = textHeader;
                }
 
+               ForceSensorExerciseWindowBox.modeEnum = modesEnum.ADD;
+               ForceSensorExerciseWindowBox.Success = false;
                ForceSensorExerciseWindowBox.initializeGuiAtShow();
+               ForceSensorExerciseWindowBox.exercise = null;
                ForceSensorExerciseWindowBox.force_sensor_exercise.Show ();
 
                return ForceSensorExerciseWindowBox;
@@ -131,22 +161,22 @@ public class ForceSensorExerciseWindow
                label_force.Text = "<b>" + label_force.Text + "</b>";
                label_fixation.Text = "<b>" + label_fixation.Text + "</b>";
                label_mass.Text = "<b>" + label_mass.Text + "</b>";
-               label_angle.Text = "<b>" + label_angle.Text + "</b>";
+               label_other.Text = "<b>" + label_other.Text + "</b>";
 
                label_force.UseMarkup = true;
                label_fixation.UseMarkup = true;
                label_mass.UseMarkup = true;
-               label_angle.UseMarkup = true;
+               label_other.UseMarkup = true;
 
                // 2. textviews of explanations of each page
                textview_force_explanation.Buffer.Text = getTopExplanations(Pages.FORCE);
                textview_fixation_explanation.Buffer.Text = getTopExplanations(Pages.FIXATION);
                textview_mass_explanation.Buffer.Text = getTopExplanations(Pages.MASS);
-               // done below textview_angle_explanation.Buffer.Text = getTopExplanations(Pages.ANGLE);
+               // done below textview_other_explanation.Buffer.Text = getTopExplanations(Pages.OTHER);
 
                // 3. icons
                image_cancel.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_cancel.png");
-               image_next_or_accept.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
"arrow_forward.png");
+               image_next.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "arrow_forward.png");
                image_back.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "arrow_back.png");
        }
 
@@ -157,6 +187,33 @@ public class ForceSensorExerciseWindow
                spin_body_mass_add.Value = 100;
        }
 
+       private void exerciseToGUI()
+       {
+               entry_name.Text = exercise.Name;
+
+               if(exercise.ForceResultant)
+                       radio_force_resultant.Active = true;
+               else
+                       radio_force_sensor.Active = true;
+
+               if(exercise.Elastic)
+                       radio_fixation_elastic.Active = true;
+               else
+                       radio_fixation_not_elastic.Active = true;
+
+               if(exercise.PercentBodyWeight > 0 && ! exercise.TareBeforeCapture)
+                       radio_mass_add.Active = true;
+
+               else if(exercise.PercentBodyWeight == 0 && exercise.TareBeforeCapture)
+                       radio_mass_subtract.Active = true;
+               else
+                       radio_mass_nothing.Active = true;
+
+               spin_body_mass_add.Value = exercise.PercentBodyWeight;
+               spin_angle.Value = exercise.AngleDefault;
+               entry_description.Text = exercise.Description;
+       }
+
        //just to have shorter code
        //and to be able to upload this without bothering the translators at the moment
        private string ss (string s)
@@ -174,7 +231,7 @@ public class ForceSensorExerciseWindow
                        str = ss("How the force is transmitted to the sensor");
                else if(p == Pages.MASS)
                        str = ss("Depending on the exercise and configuration of the test, the total mass 
(mass of the person and the extra load) can affect to the sensor measuring. Select how to manage this 
effect.");
-               else { //if(p == Pages.ANGLE)
+               else { //if(p == Pages.OTHER)
                        if(radio_force_resultant.Active && radio_mass_add.Active)
                                str = ss("In current exercise configuration, it is necessary to enter the 
angle in which the sensor is measuring.");
                        else
@@ -201,7 +258,7 @@ public class ForceSensorExerciseWindow
                        str = ss("In some cases the weight if the mass is supported by the sensor but it is 
not a force that the subject is exerting. In this case, the sensor will be tared before starting the test.");
                else if(o == Options.MASS_NOTHING)
                        str = ss("In some cases the weight is transmitted to the sensor and it is also 
supported by the measured limb. If the effect of the mass is not significant, use this option also.");
-               else //if(o == Options.ANGLE)
+               else //if(o == Options.OTHER)
                        str = ss("0 means horizontally") + "\n" +
                                ss("90 means vertically with the person above the sensor") + "\n" +
                                ss("-90 means vertically with the person below the sensor");
@@ -232,7 +289,7 @@ public class ForceSensorExerciseWindow
                else if(o == Options.MASS_NOTHING)
                        str = "1.- " + ss("Nordic hamstring. In a Nordic hamstring with the sensor attached 
to the ankle, the weight affects the values of the sensor but this weight is supported by the hamstrings we 
are measuring.") +
                                "\n2.- " + ss("Pulling on a TRX. Pulling from a TRX implies overcome the body 
weight. This body weight is also measured by the sensor.");
-               else //if(o == Options.ANGLE)
+               else //if(o == Options.OTHER)
                        str = "";
 
                return str;
@@ -256,8 +313,8 @@ public class ForceSensorExerciseWindow
                        str = ss("Subtract mass");
                else if(o == Options.MASS_NOTHING)
                        str = ss("Mass is included");
-               else //if(o == Options.ANGLE)
-                       str = ss("Description");
+               else //if(o == Options.OTHER)
+                       str = ss("Angle explanation");
 
                label_notebook_desc_examples_desc.Text = str;
                label_notebook_desc_examples_examples.Text = ss("Examples of:") + " " + str;
@@ -275,7 +332,8 @@ public class ForceSensorExerciseWindow
                string ex;
 
                //default for most of the pages
-               button_next_or_accept.Sensitive = true;
+               button_next.Visible = true;
+               button_accept.Visible = false;
                button_back.Sensitive = true;
                notebook_desc_examples.GetNthPage(1).Show();
 
@@ -324,14 +382,15 @@ public class ForceSensorExerciseWindow
                        }
                        hbox_body_mass_add.Sensitive = radio_mass_add.Active;
                }
-               else // if(p == Pages.ANGLE)
+               else // if(p == Pages.OTHER)
                {
-                       button_next_or_accept.Sensitive = false;
-                       textview_angle_explanation.Buffer.Text = getTopExplanations(Pages.ANGLE);
+                       button_next.Visible = false;
+                       button_accept.Visible = true;
+                       textview_other_explanation.Buffer.Text = getTopExplanations(Pages.OTHER);
 
-                       desc = getDescription(Options.ANGLE);
-                       ex = getExample(Options.ANGLE);
-                       set_notebook_desc_example_labels(Options.ANGLE);
+                       desc = getDescription(Options.OTHER);
+                       ex = getExample(Options.OTHER);
+                       set_notebook_desc_example_labels(Options.OTHER);
 
                        notebook_desc_examples.CurrentPage = 0;
                        notebook_desc_examples.GetNthPage(1).Hide();
@@ -345,8 +404,8 @@ public class ForceSensorExerciseWindow
        private void on_button_next_clicked (object o, EventArgs args)
        {
                if(notebook_main.CurrentPage == Convert.ToInt32(Pages.FORCE) && radio_force_sensor.Active)
-                       notebook_main.CurrentPage = Convert.ToInt32(Pages.ANGLE);
-               else if(notebook_main.CurrentPage < Convert.ToInt32(Pages.ANGLE))
+                       notebook_main.CurrentPage = Convert.ToInt32(Pages.OTHER);
+               else if(notebook_main.CurrentPage < Convert.ToInt32(Pages.OTHER))
                        notebook_main.CurrentPage ++;
                else
                        return;
@@ -355,7 +414,7 @@ public class ForceSensorExerciseWindow
        }
        private void on_button_back_clicked (object o, EventArgs args)
        {
-               if(notebook_main.CurrentPage == Convert.ToInt32(Pages.ANGLE) && radio_force_sensor.Active)
+               if(notebook_main.CurrentPage == Convert.ToInt32(Pages.OTHER) && radio_force_sensor.Active)
                        notebook_main.CurrentPage = Convert.ToInt32(Pages.FORCE);
                else if(notebook_main.CurrentPage > Convert.ToInt32(Pages.FORCE))
                        notebook_main.CurrentPage --;
@@ -378,13 +437,107 @@ public class ForceSensorExerciseWindow
                managePage(Pages.MASS);
        }
 
-       private void on_entries_changed (object o, EventArgs args)
+       private void on_entry_name_changed (object o, EventArgs args)
+       {
+               Gtk.Entry entry = o as Gtk.Entry;
+               if (o == null)
+                       return;
+
+               entry_name.Text = Util.MakeValidSQL(entry.Text);
+       }
+       private void on_entry_description_changed (object o, EventArgs args)
        {
-               Gtk.Entry entry_name = o as Gtk.Entry;
+               Gtk.Entry entry = o as Gtk.Entry;
                if (o == null)
                        return;
 
-               entry_name.Text = Util.MakeValidSQL(entry_name.Text);
+               entry_description.Text = Util.MakeValidSQL(entry.Text);
+       }
+
+       private void on_button_accept_clicked (object o, EventArgs args)
+       {
+               string name = entry_name.Text;
+
+               if(name == "")
+               {
+                       label_error.Text = ss("Error: Missing name of exercise.");
+                       hbox_error.Show();
+                       return;
+               }
+               else if (modeEnum == modesEnum.ADD && Sqlite.Exists(false, 
Constants.ForceSensorExerciseTable, name))
+               {
+                       //if we add, check that this name does not exists
+                       label_error.Text = string.Format(ss("Error: An exercise named '{0}' already 
exists."), name);
+                       hbox_error.Show();
+                       return;
+               }
+               else if (modeEnum == modesEnum.EDIT)
+               {
+                       //if we edit, check that this name does not exists (on other exercise, on current 
editing exercise is obviously fine)
+                       int getIdOfThis = Sqlite.ExistsAndGetUniqueID(false, 
Constants.ForceSensorExerciseTable, name); //if not exists will be -1
+                       if(getIdOfThis != -1 && getIdOfThis != exercise.UniqueID)
+                       {
+                               label_error.Text = string.Format(ss("Error: An exercise named '{0}' already 
exists."), name);
+                               hbox_error.Show();
+                               return;
+                       }
+               }
+
+               //compare exercise (opening window) with exerciseNew (changes maybe done)
+
+               //only store percentBodyWeight at SQL if radio_mass_add is active
+               int percentBodyWeight = 0;
+               if(radio_mass_add.Active && Convert.ToInt32(spin_body_mass_add.Value) > 0)
+                       percentBodyWeight = Convert.ToInt32(spin_body_mass_add.Value);
+
+               int myID = -1;
+               if(modeEnum == modesEnum.EDIT)
+                       myID = exercise.UniqueID;
+
+               ForceSensorExercise exerciseTemp = new ForceSensorExercise(
+                               myID, entry_name.Text,
+                               percentBodyWeight,
+                               "", //resistance (unused, now merged on description)
+                               Convert.ToInt32(spin_angle.Value),
+                               entry_description.Text,
+                               radio_mass_subtract.Active,     //tareBeforeCapture
+                               radio_force_resultant.Active,
+                               radio_fixation_elastic.Active);
+
+               if(modeEnum == modesEnum.ADD)
+               {
+                       exercise = exerciseTemp;
+                       SqliteForceSensorExercise.Insert(false, exercise);
+                       Success = true;
+               } else {
+                       //we are editing the exercise
+                       if(exercise.Changed(exerciseTemp))
+                       {
+                               exercise = exerciseTemp;
+                               SqliteForceSensorExercise.Update(false, exercise);
+                               Success = true;
+                       }
+               }
+
+               //"exercise" will be read by reading "Exercise"
+               fakeButtonReadValues.Click();
+       }
+
+       public Button FakeButtonReadValues {
+               //set { fakeButtonReadValues = value; }
+               get { return fakeButtonReadValues; }
+       }
+
+       //at the moment only name will be used
+       public ForceSensorExercise Exercise
+       {
+               get { return exercise; }
+       }
+
+       public void HideAndNull()
+       {
+               ForceSensorExerciseWindowBox.force_sensor_exercise.Hide();
+               ForceSensorExerciseWindowBox = null;
        }
 
        void on_button_cancel_clicked (object o, EventArgs args)
@@ -403,7 +556,6 @@ public class ForceSensorExerciseWindow
                ForceSensorExerciseWindowBox = null;
        }
 
-
        ~ForceSensorExerciseWindow() {}
 }
 
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index d0a1a3e5..f626faa2 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -263,7 +263,11 @@ class SqliteForceSensor : Sqlite
                                if(fslt.Exercise == "" || exerciseID == -1)
                                {
                                        if(unknownExerciseID == -1)
-                                               unknownExerciseID = SqliteForceSensorExercise.Insert (true, 
-1, Catalog.GetString("Unknown"), 0, "", 0, "", false);
+                                       {
+                                               ForceSensorExercise fse = new ForceSensorExercise (-1, 
Catalog.GetString("Unknown"), 0, "", 0, "", false, false, false);
+                                               unknownExerciseID = SqliteForceSensorExercise.Insert(true, 
fse);
+                                               //note this import already goes to 1.73, then that import 
will produce a catch
+                                       }
 
                                        exerciseID = unknownExerciseID;
                                        exerciseName = Catalog.GetString("Unknown");
@@ -327,31 +331,27 @@ class SqliteForceSensorExercise : Sqlite
                        "uniqueID INTEGER PRIMARY KEY, " +
                        "name TEXT, " +
                        "percentBodyWeight INT, " +
-                       "resistance TEXT, " +
+                       "resistance TEXT, " +                           //unused
                        "angleDefault INT, " +
                        "description TEXT, " +
-                       "tareBeforeCapture INT)";
+                       "tareBeforeCapture INT, " +
+                       "forceResultant INT, " +
+                       "elastic INT)";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
        }
 
        //undefined defaultAngle will be 1000
        //note execution can have a different angle than the default angle
-       public static int Insert (bool dbconOpened, int uniqueID, string name, int percentBodyWeight,
-                       string resistance, int angleDefault, string description, bool tareBeforeCapture)
+       public static int Insert (bool dbconOpened, ForceSensorExercise ex)
        {
                if(! dbconOpened)
                        Sqlite.Open();
 
-               string uniqueIDStr = "NULL";
-               if(uniqueID != -1)
-                       uniqueIDStr = uniqueID.ToString();
-
                dbcmd.CommandText = "INSERT INTO " + table +
-                               " (uniqueID, name, percentBodyWeight, resistance, angleDefault, description, 
tareBeforeCapture)" +
-                               " VALUES (" + uniqueIDStr + ", \"" + name + "\", " + percentBodyWeight + ", 
\"" +
-                               resistance + "\", " + angleDefault + ", \"" + description + "\", " +
-                               Util.BoolToInt(tareBeforeCapture).ToString() + ")";
+                               " (uniqueID, name, percentBodyWeight, resistance, angleDefault, " +
+                               " description, tareBeforeCapture, forceResultant, elastic)" +
+                               " VALUES (" + ex.ToSQLInsertString() + ")";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
 
@@ -370,19 +370,15 @@ class SqliteForceSensorExercise : Sqlite
                if(! dbconOpened)
                        Sqlite.Open();
 
-               /*
-                  string uniqueIDStr = "NULL";
-                  if(ex.UniqueID != -1)
-                          uniqueIDStr = ex.UniqueID.ToString();
-                  */
-
                dbcmd.CommandText = "UPDATE " + table + " SET " +
                        " name = \"" + ex.Name +
                        "\", percentBodyWeight = " + ex.PercentBodyWeight +
-                       ", resistance = \"" + ex.Resistance +
+                       ", resistance = \"" + ex.Resistance +                                   //unused
                        "\", angleDefault = " + ex.AngleDefault +
                        ", description = \"" + ex.Description +
                        "\", tareBeforeCapture = " + Util.BoolToInt(ex.TareBeforeCapture).ToString() +
+                       ", forceResultant = " + Util.BoolToInt(ex.ForceResultant).ToString() +
+                       ", elastic = " + Util.BoolToInt(ex.Elastic).ToString() +
                        " WHERE uniqueID = " + ex.UniqueID;
 
                LogB.SQL(dbcmd.CommandText.ToString());
@@ -435,16 +431,16 @@ class SqliteForceSensorExercise : Sqlite
                        }
                } else {
                        while(reader.Read()) {
-                               int angleDefault = 0;
-
                                ex = new ForceSensorExercise (
                                                Convert.ToInt32(reader[0].ToString()),  //uniqueID
                                                reader[1].ToString(),                   //name
                                                Convert.ToInt32(reader[2].ToString()),  //percentBodyWeight
-                                               reader[3].ToString(),                   //resistance
-                                               angleDefault,
+                                               reader[3].ToString(),                   //resistance (unused)
+                                               Convert.ToInt32(reader[4].ToString()),  //angleDefault
                                                reader[5].ToString(),                   //description
-                                               Util.IntToBool(Convert.ToInt32(reader[6].ToString()))   
//tareBeforeCapture
+                                               Util.IntToBool(Convert.ToInt32(reader[6].ToString())),  
//tareBeforeCapture
+                                               Util.IntToBool(Convert.ToInt32(reader[7].ToString())),  
//forceResultant
+                                               Util.IntToBool(Convert.ToInt32(reader[8].ToString()))   
//elastic
                                                );
                                array.Add(ex);
                        }
@@ -457,6 +453,26 @@ class SqliteForceSensorExercise : Sqlite
                return array;
        }
 
+       //database is opened
+       protected internal static void import_partially_from_1_73_to_1_74_unify_resistance_and_description()
+       {
+               ArrayList exercises = Select(true, -1, false);
+               foreach (ForceSensorExercise ex in exercises)
+               {
+                       LogB.Information(ex.ToString());
+                       if(ex.Resistance == "")
+                               continue;
+
+                       if(ex.Description == "")
+                               ex.Description = ex.Resistance;
+                       else
+                               ex.Description = ex.Resistance + " - " + ex.Description;
+
+                       ex.Resistance = "";
+
+                       Update(true, ex);
+               }
+       }
 }
 
 
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 76e1313f..43ffc20f 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.73";
+       static string lastChronojumpDatabaseVersion = "1.74";
 
        public Sqlite() {
        }
@@ -2427,7 +2427,7 @@ class Sqlite
                        }
                        if(currentVersion == "1.66")
                        {
-                               LogB.SQL("Doing alter table ...");
+                               LogB.SQL("Doing alter table forceSensorExercise adding tarebeforeCapture 
...");
                                try {
                                        executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + " 
ADD COLUMN tareBeforeCapture INT NOT NULL DEFAULT 0;");
                                } catch {
@@ -2488,6 +2488,23 @@ class Sqlite
 
                                currentVersion = updateVersion("1.73");
                        }
+                       if(currentVersion == "1.73")
+                       {
+                               LogB.SQL("Doing alter table forceSensorExercise adding forceResultant, 
elastic ...");
+                               try {
+                                       //sqlite does not have drop column
+                                       executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + " 
ADD COLUMN forceResultant INT NOT NULL DEFAULT 0;");
+                                       executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + " 
ADD COLUMN elastic INT NOT NULL DEFAULT 0;");
+
+                                       
SqliteForceSensorExercise.import_partially_from_1_73_to_1_74_unify_resistance_and_description();
+                               } catch {
+                                       LogB.SQL("Catched. forceResultant or elastic already exists, or at 
unify resitance and desc.");
+
+                               }
+                               LogB.SQL("Done!");
+
+                               currentVersion = updateVersion("1.74");
+                       }
 
 
                        // --- add more updates here
@@ -2681,6 +2698,7 @@ class Sqlite
                SqliteJson.createTableUploadExhibitionTestTemp ();
 
                //changes [from - to - desc]
+               //1.73 - 1.74 Converted DB to 1.74 ALTER TABLE Constants.ForceSensorExerciseTable ADD COLUMN 
forceResultant, clastic INT
                //1.72 - 1.73 Converted DB to 1.73 Inserted into preferences: jumpsDjGraphHeights
                //1.71 - 1.72 Converted DB to 1.72 Inserted into preferences: forceSensorCaptureWidthSeconds, 
forceSensorCaptureScroll
                //1.70 - 1.71 Converted DB to 1.71 Imported run encoder text files into SQL


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