[chronojump] DB:1.84 preferences: forceSensorMIFDuration Mode/Seconds/Percent



commit b935b9a7c47af5ab904e421f3663510a0fb19e3d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Feb 4 15:47:29 2020 +0100

    DB:1.84 preferences: forceSensorMIFDuration Mode/Seconds/Percent

 src/gui/app1/forceSensor.cs   |  1 +
 src/gui/forceSensorAnalyze.cs | 38 ++++++++++++++++++++++++++++++++++++++
 src/preferences.cs            |  4 ++++
 src/sqlite/main.cs            | 13 ++++++++++++-
 src/sqlite/preferences.cs     | 17 +++++++++++++++++
 5 files changed, 72 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 369f341f..26c9e1e9 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -129,6 +129,7 @@ public partial class ChronoJumpWindow
                createForceExerciseCombo();
                createComboForceSensorCaptureOptions();
                createForceAnalyzeCombos();
+               setForceDurationRadios();
                setRFDValues();
                setImpulseValue();
        }
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index f9a71b9d..ec736adc 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -184,6 +184,29 @@ public partial class ChronoJumpWindow
                        SqliteForceSensorRFD.UpdateImpulse(true, newImpulse);
                        impulse = newImpulse;
                }
+
+               if(preferences.forceSensorMIFDurationMode == Preferences.ForceSensorMIFDurationModes.SECONDS 
&&
+                               radio_force_rfd_duration_percent.Active)
+               {
+                       preferences.forceSensorMIFDurationMode = 
Preferences.ForceSensorMIFDurationModes.PERCENT;
+                       SqlitePreferences.Update(SqlitePreferences.ForceSensorMIFDurationMode,
+                                       preferences.forceSensorMIFDurationMode.ToString(), true);
+               }
+               else if(preferences.forceSensorMIFDurationMode == 
Preferences.ForceSensorMIFDurationModes.PERCENT &&
+                               radio_force_duration_seconds.Active)
+               {
+                       preferences.forceSensorMIFDurationMode = 
Preferences.ForceSensorMIFDurationModes.SECONDS;
+                       SqlitePreferences.Update(SqlitePreferences.ForceSensorMIFDurationMode,
+                                       preferences.forceSensorMIFDurationMode.ToString(), true);
+               }
+
+               preferences.forceSensorMIFDurationSeconds = Preferences.PreferencesChange(
+                               SqlitePreferences.ForceSensorMIFDurationSeconds,
+                               preferences.forceSensorMIFDurationSeconds, spin_force_duration_seconds.Value);
+               preferences.forceSensorMIFDurationPercent = Preferences.PreferencesChange(
+                               SqlitePreferences.ForceSensorMIFDurationPercent,
+                               preferences.forceSensorMIFDurationPercent, 
Convert.ToInt32(spin_force_rfd_duration_percent.Value));
+
                Sqlite.Close();
 
                // 2 change sensitivity of widgets
@@ -293,6 +316,21 @@ public partial class ChronoJumpWindow
                }
        }
 
+       private void setForceDurationRadios()
+       {
+               //TODO: assignar aquĆ­ lo que hi hagi de les preferencies: del radio actiu is els dos 
spinbuttons
+               if(preferences.forceSensorMIFDurationMode == Preferences.ForceSensorMIFDurationModes.SECONDS)
+                       radio_force_duration_seconds.Active = true;
+               else //(preferences.forceSensorMIFDurationMode == 
Preferences.ForceSensorMIFDurationModes.PERCENT)
+                       radio_force_rfd_duration_percent.Active = true;
+
+               //to show/hides spinbuttons
+               on_radio_force_rfd_duration_toggled (new object (), new EventArgs ());
+
+               spin_force_duration_seconds.Value = preferences.forceSensorMIFDurationSeconds;
+               spin_force_rfd_duration_percent.Value = preferences.forceSensorMIFDurationPercent;
+       }
+
        private void setRFDValues ()
        {
                setRFDValue(rfdList[0], check_force_1, combo_force_1_function, combo_force_1_type,
diff --git a/src/preferences.cs b/src/preferences.cs
index 3a24599c..154c88c3 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -141,6 +141,10 @@ public class Preferences
        public bool forceSensorCaptureFeedbackActive;
        public int forceSensorCaptureFeedbackAt;
        public int forceSensorCaptureFeedbackRange;
+       public enum ForceSensorMIFDurationModes { SECONDS, PERCENT };
+       public ForceSensorMIFDurationModes forceSensorMIFDurationMode;
+       public double forceSensorMIFDurationSeconds;
+       public int forceSensorMIFDurationPercent;
                                
        public int encoderCaptureTimeIM = 180; //hardcoded 3 minutes.
 
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index e76d1ebf..2d26cc64 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.83";
+       static string lastChronojumpDatabaseVersion = "1.84";
 
        public Sqlite() {
        }
@@ -2598,6 +2598,16 @@ class Sqlite
                                SqliteEvent.GraphLinkInsert (Constants.RunTable, "Agility-T-Test", 
"agility_t_test.png", true);
                                currentVersion = updateVersion("1.83");
                        }
+                       if(currentVersion == "1.83")
+                       {
+                               LogB.SQL("Inserted into preferences: forceSensorMIFDuration 
Mode/Seconds/Percent");
+
+                               SqlitePreferences.Insert (SqlitePreferences.ForceSensorMIFDurationMode, 
Preferences.ForceSensorMIFDurationModes.SECONDS.ToString());
+                               SqlitePreferences.Insert (SqlitePreferences.ForceSensorMIFDurationSeconds, 
"2");
+                               SqlitePreferences.Insert (SqlitePreferences.ForceSensorMIFDurationPercent, 
"5");
+
+                               currentVersion = updateVersion("1.84");
+                       }
 
 
                        /*
@@ -2811,6 +2821,7 @@ class Sqlite
                //changes [from - to - desc]
 //just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved 
stiffnessString records there
 //
+               //1.83 - 1.84 Converted DB to 1.84 Inserted into preferences: forceSensorMIFDuration 
Mode/Seconds/Percent
                //1.82 - 1.83 Converted DB to 1.83 Added missing agility_t_test image
                //1.81 - 1.82 Converted DB to 1.82 Doing alter table jump, jumpRj, tempJumpRj add datetime
                //1.80 - 1.81 Converted DB to 1.81 Inserted forceSensorCaptureFeedbackActive /At /Range
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 969e1b4c..a1f69ed7 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -70,6 +70,9 @@ class SqlitePreferences : Sqlite
        public const string ForceSensorCaptureFeedbackActive = "forceSensorCaptureFeedbackActive";
        public const string ForceSensorCaptureFeedbackAt = "forceSensorCaptureFeedbackAt";
        public const string ForceSensorCaptureFeedbackRange = "forceSensorCaptureFeedbackRange";
+       public const string ForceSensorMIFDurationMode = "forceSensorMIFDurationMode";
+       public const string ForceSensorMIFDurationSeconds = "forceSensorMIFDurationSeconds";
+       public const string ForceSensorMIFDurationPercent = "forceSensorMIFDurationPercent";
 
        protected internal static new void createTable()
        {
@@ -210,6 +213,9 @@ class SqlitePreferences : Sqlite
                                Insert (ForceSensorCalibrationDateTimeStr, "", dbcmdTr);
                                Insert (ForceSensorCalibrationWeightStr, "-1", dbcmdTr);
                                Insert (ForceSensorCalibrationFactorStr, "-1", dbcmdTr); //result value from 
sensor. Decimal is point!!
+                               Insert (ForceSensorMIFDurationMode, 
Preferences.ForceSensorMIFDurationModes.SECONDS.ToString(), dbcmdTr);
+                               Insert (ForceSensorMIFDurationSeconds, "2", dbcmdTr);
+                               Insert (ForceSensorMIFDurationPercent, "5", dbcmdTr);
 
                                //multimedia
                                Insert ("videoDevice", "", dbcmdTr); //first
@@ -517,6 +523,17 @@ class SqlitePreferences : Sqlite
                                preferences.forceSensorCalibrationFactor = Convert.ToDouble(
                                                Util.ChangeDecimalSeparator(reader[1].ToString()));
 
+                       //force sensor MIF
+                       else if(reader[0].ToString() == ForceSensorMIFDurationMode)
+                               preferences.forceSensorMIFDurationMode = 
(Preferences.ForceSensorMIFDurationModes)
+                                       Enum.Parse(typeof(Preferences.ForceSensorMIFDurationModes), 
reader[1].ToString());
+                       else if(reader[0].ToString() == ForceSensorMIFDurationSeconds)
+                               preferences.forceSensorMIFDurationSeconds = Convert.ToDouble(
+                                               Util.ChangeDecimalSeparator(reader[1].ToString()));
+                       else if(reader[0].ToString() == ForceSensorMIFDurationPercent)
+                               preferences.forceSensorMIFDurationPercent = Convert.ToInt32(
+                                               reader[1].ToString());
+
                        //advanced tab
                        else if(reader[0].ToString() == "digitsNumber")
                                preferences.digitsNumber = Convert.ToInt32(reader[1].ToString());


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