[chronojump] Force sensor recalculate done!



commit 33c0622acc0274f62d2f91ad21ef1388326a18e4
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 9 14:18:08 2019 +0200

    Force sensor recalculate done!

 glade/app1.glade           | 36 ++++++++++++++++++++++++++++++++++--
 src/forceSensor.cs         | 14 ++++++++++++++
 src/gui/chronojumpIcons.cs |  1 +
 src/gui/forceSensor.cs     | 25 ++++++++++++++++++++++---
 src/sqlite/forceSensor.cs  | 19 +++++++++++++++++++
 5 files changed, 90 insertions(+), 5 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 5bac4182..786f1648 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -6729,10 +6729,42 @@ EncoderInertialCapture</property>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkButton" 
id="button_force_sensor_capture_recalculate">
-                                                            <property name="label" 
translatable="yes">Recalculate</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="sensitive">False</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
                                                             <signal name="clicked" 
handler="on_button_force_sensor_capture_recalculate_clicked" swapped="no"/>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox329">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_force_sensor_capture_recalculate">
+                                                            <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="label157">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Recalculate</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>
@@ -10422,7 +10454,7 @@ Inverted values</property>
                                                             <property name="use_underline">True</property>
                                                             <signal name="clicked" 
handler="on_button_run_encoder_recalculate_clicked" swapped="no"/>
                                                             <child>
-                                                            <widget class="GtkImage" 
id="image_force_sensor_capture_recalculate">
+                                                            <widget class="GtkImage" 
id="image_race_encoder_capture_recalculate">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property 
name="stock">gtk-missing-image</property>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index a7d9fa4d..fb9ceafb 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -119,21 +119,35 @@ public class ForceSensor
        {
                get { return filename; }
        }
+
+       public int UniqueID
+       {
+               get { return uniqueID; }
+       }
+       public int ExerciseID
+       {
+               get { return exerciseID; }
+               set { exerciseID = value; }
+       }
        public CaptureOptions CaptureOption
        {
                get { return captureOption; }
+               set { captureOption = value; }
        }
        public string Laterality
        {
                get { return laterality; }
+               set { laterality = value; }
        }
        public string Comments
        {
                get { return comments; }
+               set { comments = value; }
        }
        public string ExerciseName
        {
                get { return exerciseName; }
+               set { exerciseName = value; }
        }
 }
 
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index a8800a18..9987f9f7 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -348,6 +348,7 @@ public partial class ChronoJumpWindow
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_recalculate.png");
                image_recalculate.Pixbuf = pixbuf;
+               image_race_encoder_capture_recalculate.Pixbuf = pixbuf;
                image_force_sensor_capture_recalculate.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_build_24.png");
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 69d9b1a6..295cfdb8 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -80,6 +80,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Label label_force_sensor_adjust;
        [Widget] Gtk.Button button_force_sensor_tare;
        [Widget] Gtk.Button button_force_sensor_calibrate;
+       [Widget] Gtk.Button button_force_sensor_capture_recalculate;
        [Widget] Gtk.Label label_force_sensor_value_max;
        [Widget] Gtk.Label label_force_sensor_value;
        [Widget] Gtk.Label label_force_sensor_value_min;
@@ -109,6 +110,9 @@ public partial class ChronoJumpWindow
        int usbDisconnectedCount;
        int usbDisconnectedLastTime;
 
+       private ForceSensor currentForceSensor;
+       private ForceSensorExercise currentForceSensorExercise;
+
        /*
         * arduinoCaptureStatus:
         * STOP is when is not used
@@ -730,7 +734,6 @@ public partial class ChronoJumpWindow
                //printDataRow(dataRow);
        }
 
-       private ForceSensorExercise currentForceSensorExercise;
        private void assignCurrentForceSensorExercise()
        {
                currentForceSensorExercise = (ForceSensorExercise) SqliteForceSensorExercise.Select (
@@ -894,14 +897,14 @@ public partial class ChronoJumpWindow
                ((IDisposable)writer).Dispose();
                capturingForce = arduinoCaptureStatus.STOP;
 
-               ForceSensor forceSensor = new ForceSensor(-1, currentPerson.UniqueID, currentSession.UniqueID,
+               currentForceSensor = new ForceSensor(-1, currentPerson.UniqueID, currentSession.UniqueID,
                                currentForceSensorExercise.UniqueID, getForceSensorCaptureOptions(),
                                ForceSensor.AngleUndefined, getLaterality(false),
                                Util.GetLastPartOfPath(fileName), //filename
                                Util.MakeURLrelative(Util.GetForceSensorSessionDir(currentSession.UniqueID)), 
//url
                                UtilDate.ToFile(forceSensorTimeStartCapture), captureComment, "", //dateTime, 
comment, videoURL
                                currentForceSensorExercise.Name);
-               forceSensor.InsertSQL(false);
+               currentForceSensor.InsertSQL(false);
 
                if(forceProcessCancel || forceProcessError)
                        Util.FileDelete(fileName);
@@ -950,6 +953,7 @@ LogB.Information(" re C ");
                                                forceSensorZoomDefaultValues();
                                                forceSensorDoGraphAI();
                                        }
+                                       button_force_sensor_capture_recalculate.Sensitive = true;
 
                                        if( configChronojump.Exhibition &&
                                                        ( configChronojump.ExhibitionStationType == 
ExhibitionTest.testTypes.FORCE_ROPE ||
@@ -1300,6 +1304,7 @@ LogB.Information(" re R ");
                        return;
                }
 
+               currentForceSensor = fs;
                lastForceSensorFile = Util.RemoveExtension(fs.Filename);
                lastForceSensorFullPath = fs.FullURL;
 
@@ -1318,6 +1323,7 @@ LogB.Information(" re R ");
                        forceSensorDoGraphAI();
                }
                //event_execute_label_message.Text = "Loaded: " + 
Util.GetLastPartOfPath(filechooser.Filename);
+               button_force_sensor_capture_recalculate.Sensitive = true;
        }
 
        /*
@@ -1396,8 +1402,21 @@ LogB.Information(" re R ");
                        return;
                }
 
+               //getForceSensorCaptureOptions is called on doing the graphs
+               //recalculate graphs will be different if exercise changed, so need to know the exercise
+               assignCurrentForceSensorExercise();
+
                if(lastForceSensorFullPath != null && lastForceSensorFullPath != "")
                        forceSensorCopyTempAndDoGraphs();
+
+               //update SQL with exercise, captureOptions, laterality, comments
+               currentForceSensor.ExerciseID = currentForceSensorExercise.UniqueID;
+               currentForceSensor.ExerciseName = currentForceSensorExercise.Name; //just in case
+               currentForceSensor.CaptureOption = getForceSensorCaptureOptions();
+               currentForceSensor.Laterality = getLaterality(false);
+               currentForceSensor.Comments = getCaptureComment();
+
+               SqliteForceSensor.Update(false, currentForceSensor);
        }
 
        private void on_button_force_sensor_analyze_analyze_clicked (object o, EventArgs args)
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 12e5a783..91dedb3b 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -75,6 +75,25 @@ class SqliteForceSensor : Sqlite
                        Sqlite.Close();
        }
 
+       public static void Update (bool dbconOpened, ForceSensor fs)
+       {
+               if(! dbconOpened)
+                       Sqlite.Open();
+
+               dbcmd.CommandText = "UPDATE " + table + " SET " +
+                       " exerciseID = " + fs.ExerciseID +
+                       ", captureOption = \"" + fs.CaptureOption.ToString() +
+                       "\", laterality = \"" + fs.Laterality +
+                       "\", comments = \"" + fs.Comments +
+                       "\" WHERE uniqueID = " + fs.UniqueID;
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+
+               if(! dbconOpened)
+                       Sqlite.Close();
+       }
+
        //SELECT forceSensor.*, forceSensorExercise.Name FROM forceSensor, forceSensorExercise WHERE 
forceSensor.exerciseID = forceSensorExercise.UniqueID ORDER BY forceSensor.uniqueID;
        public static ArrayList Select (bool dbconOpened, int uniqueID, int personID, int sessionID)
        {


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