[chronojump] Ensure forceSensor tareBeforeCapture only applies when exercise is forceResultant



commit d360e8b258265931d998dec4362075f90795509a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 27 12:41:08 2022 +0200

    Ensure forceSensor tareBeforeCapture only applies when exercise is forceResultant

 src/forceSensor.cs             | 20 ++++++++++++++++++--
 src/gui/app1/forceSensor.cs    | 12 ++++++------
 src/gui/forceSensorExercise.cs |  4 ++--
 src/sqlite/forceSensor.cs      |  4 ++--
 4 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index ba8847e59..d994ed244 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -609,7 +609,7 @@ public class ForceSensorExercise
                                resistance == newEx.Resistance &&
                                angleDefault == newEx.AngleDefault &&
                                description == newEx.Description &&
-                               tareBeforeCapture == newEx.TareBeforeCapture &&
+                               tareBeforeCapture == newEx.TareBeforeCaptureOnExerciseEdit &&
                                forceResultant == newEx.ForceResultant &&
                                type == newEx.Type &&
                                repetitionsShow == newEx.RepetitionsShow &&
@@ -646,7 +646,22 @@ public class ForceSensorExercise
                get { return description; }
                set { description = value; }
        }
-       public bool TareBeforeCapture
+
+       /*
+          at exercise edit with forceResultant, user can select tareBeforeCapture
+          if edit again and select forceRaw, tareBeforeCapture bool is still ok on sqlite,
+          just to be shown again if user want to go to forceResultant again.
+          So this applies to TareBeforeCaptureOnExerciseEdit
+
+          But, on capture, only apply tareBeforeCapture if forceResultant is true,
+          so useTareBeforeCaptureAndForceResultant
+          */
+
+       public bool TareBeforeCaptureAndForceResultant
+       {
+               get { return (tareBeforeCapture && forceResultant); }
+       }
+       public bool TareBeforeCaptureOnExerciseEdit
        {
                get { return tareBeforeCapture; }
        }
@@ -654,6 +669,7 @@ public class ForceSensorExercise
        {
                get { return forceResultant; }
        }
+
        public Types Type
        {
                get { return type; }
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 782f10d0d..77381f0c7 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -490,7 +490,7 @@ public partial class ChronoJumpWindow
                        //textview_force_sensor_capture_comment.Buffer.Text = "";
                        textview_contacts_signal_comment.Buffer.Text = "";
 
-                       if(currentForceSensorExercise.TareBeforeCapture)
+                       if(currentForceSensorExercise.TareBeforeCaptureAndForceResultant)
                        {
                                forceSensorOtherMode = forceSensorOtherModeEnum.TARE_AND_CAPTURE_PRE;
                                //forceOtherThread = new Thread(new 
ThreadStart(forceSensorTareAndCapturePre_noGTK)); //unused see comments on that method
@@ -1077,7 +1077,7 @@ public partial class ChronoJumpWindow
                        if(! forceSensorConnect())
                                return;
 
-               if(currentForceSensorExercise.TareBeforeCapture)
+               if(currentForceSensorExercise.TareBeforeCaptureAndForceResultant)
                        forceSensorOtherMessage = Catalog.GetString ("The tare will soon begin");
                else
                        forceSensorOtherMessage = Catalog.GetString ("Please, wait …");
@@ -1312,7 +1312,7 @@ public partial class ChronoJumpWindow
                   that will affect other normal captures
                   */
                double forceTared = 0;
-               if(currentForceSensorExercise.TareBeforeCapture)
+               if(currentForceSensorExercise.TareBeforeCaptureAndForceResultant)
                {
                        forceSensorOtherMessage = Catalog.GetString ("Taring; …");
                        LogB.Information("Taring starts");
@@ -1377,7 +1377,7 @@ public partial class ChronoJumpWindow
                                        continue;
                        }
 
-                       if(currentForceSensorExercise.TareBeforeCapture && forceTared != 0)
+                       if(currentForceSensorExercise.TareBeforeCaptureAndForceResultant && forceTared != 0)
                        {
                                LogB.Information(string.Format("forceTared: {0}, force: {1}, forceFixed: {2}",
                                                        forceTared, force, force - forceTared));
@@ -1745,7 +1745,7 @@ LogB.Information(" fs F ");
                {
 LogB.Information(" fs G ");
                        //do this if we are not on tare and TareBeforeCapture
-                       if( ! (currentForceSensorExercise.TareBeforeCapture && ! forceCaptureStartMark) )
+                       if( ! (currentForceSensorExercise.TareBeforeCaptureAndForceResultant && ! 
forceCaptureStartMark) )
                        {
 
                                label_force_sensor_value_max.Text = string.Format("{0:0.##} N", 
forceSensorValues.Max);
@@ -1791,7 +1791,7 @@ LogB.Information(" fs H2 ");
                        }
 
                        //if taring at TareBeforeCapture, just show message
-                       if( currentForceSensorExercise.TareBeforeCapture && ! forceCaptureStartMark)
+                       if( currentForceSensorExercise.TareBeforeCaptureAndForceResultant && ! 
forceCaptureStartMark)
                        {
                                event_execute_label_message.Text = forceSensorOtherMessage; //"Taring ..."
                                Thread.Sleep(25);
diff --git a/src/gui/forceSensorExercise.cs b/src/gui/forceSensorExercise.cs
index 0a4f9ce14..fccd5ea8e 100644
--- a/src/gui/forceSensorExercise.cs
+++ b/src/gui/forceSensorExercise.cs
@@ -347,10 +347,10 @@ public class ForceSensorExerciseWindow
                        button_force_exerted_help.Sensitive = false;
                }
 
-               if(exercise.PercentBodyWeight > 0 && ! exercise.TareBeforeCapture)
+               if(exercise.PercentBodyWeight > 0 && ! exercise.TareBeforeCaptureOnExerciseEdit)
                        radio_mass_add.Active = true;
 
-               else if(exercise.PercentBodyWeight == 0 && exercise.TareBeforeCapture)
+               else if(exercise.PercentBodyWeight == 0 && exercise.TareBeforeCaptureOnExerciseEdit)
                        radio_mass_subtract.Active = true;
                else
                        radio_mass_nothing.Active = true;
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 59e2461b2..584e9c759 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -568,7 +568,7 @@ class SqliteForceSensorExercise : Sqlite
                        ", resistance = \"" + ex.Resistance +                                   //unused
                        "\", angleDefault = " + ex.AngleDefault +
                        ", description = \"" + ex.Description +
-                       "\", tareBeforeCapture = " + Util.BoolToInt(ex.TareBeforeCapture).ToString() +
+                       "\", tareBeforeCapture = " + 
Util.BoolToInt(ex.TareBeforeCaptureOnExerciseEdit).ToString() +
                        ", forceResultant = " + Util.BoolToInt(ex.ForceResultant).ToString() +
                        ", elastic = " + ex.TypeToInt ().ToString() +
                        ", eccReps = " + ex.RepetitionsShowToCode().ToString() +
@@ -780,7 +780,7 @@ class SqliteForceSensorExerciseImport : SqliteForceSensorExercise
                        ", resistance = \"" + ex.Resistance +                                   //unused
                        "\", angleDefault = " + ex.AngleDefault +
                        ", description = \"" + ex.Description +
-                       "\", tareBeforeCapture = " + Util.BoolToInt(ex.TareBeforeCapture).ToString() +
+                       "\", tareBeforeCapture = " + 
Util.BoolToInt(ex.TareBeforeCaptureOnExerciseEdit).ToString() +
                        ", forceResultant = " + Util.BoolToInt(ex.ForceResultant).ToString() +
                        ", elastic = " + ex.TypeToInt ().ToString() + //on this DB conversation cannot be 
both "-1"
                        " WHERE uniqueID = " + ex.UniqueID;


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