[chronojump] DB:1.89. preferences: encoderCaptureFeedbackEccon. encoder feedback by phases



commit 18c917b98778ee98bb5bf423fa0ec9c8cb2a5deb
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Feb 26 20:55:39 2020 +0100

    DB:1.89. preferences: encoderCaptureFeedbackEccon. encoder feedback by phases

 glade/repetitive_conditions.glade | 91 ++++++++++++++++++++++++++++++++++++++-
 src/gui/app1/chronojump.cs        |  6 +++
 src/gui/encoderGraphObjects.cs    | 11 ++++-
 src/gui/encoderTreeviews.cs       | 40 ++++++++++++++---
 src/gui/repetitiveConditions.cs   | 36 ++++++++++++++--
 src/preferences.cs                |  2 +
 src/sqlite/main.cs                | 12 +++++-
 src/sqlite/preferences.cs         |  5 +++
 8 files changed, 190 insertions(+), 13 deletions(-)
---
diff --git a/glade/repetitive_conditions.glade b/glade/repetitive_conditions.glade
index 00ed291b..0993705c 100644
--- a/glade/repetitive_conditions.glade
+++ b/glade/repetitive_conditions.glade
@@ -1014,7 +1014,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">0.29999999329440002 0 1 
0.0099999997764800008 0.0099999997764800008 0</property>
+                                        <property name="adjustment">0.30999999307088 0 1 
0.0099999997764800008 0.0099999997764800008 0</property>
                                         <property name="climb_rate">1</property>
                                         <property name="digits">2</property>
                                         <property name="snap_to_ticks">True</property>
@@ -2107,6 +2107,95 @@
                                         <property name="position">1</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <widget class="GtkVBox" id="vbox11">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">10</property>
+                                        <child>
+                                          <widget class="GtkLabel" id="label41">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">On 
eccentric-concentric have feedback ...</property>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkAlignment" id="alignment30">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="left_padding">20</property>
+                                            <child>
+                                              <widget class="GtkHBox" id="hbox49">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="spacing">10</property>
+                                                <child>
+                                                  <widget class="GtkRadioButton" 
id="radio_encoder_eccon_both">
+                                                    <property name="label" translatable="yes">on both 
phases</property>
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">False</property>
+                                                    <property name="active">True</property>
+                                                    <property name="draw_indicator">True</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkRadioButton" 
id="radio_encoder_eccon_ecc">
+                                                    <property name="label" translatable="yes">on 
eccentric</property>
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">False</property>
+                                                    <property name="draw_indicator">True</property>
+                                                    <property 
name="group">radio_encoder_eccon_both</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkRadioButton" 
id="radio_encoder_eccon_con">
+                                                    <property name="label" translatable="yes">on 
concentric</property>
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">False</property>
+                                                    <property name="draw_indicator">True</property>
+                                                    <property 
name="group">radio_encoder_eccon_both</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="position">2</property>
+                                                  </packing>
+                                                </child>
+                                              </widget>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 8ac92d6e..442abfb7 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -6994,6 +6994,12 @@ LogB.Debug("mc finished 5");
                        if(! secondaryVariableShow)
                                secondaryVariableStr = "";
 
+                       if(preferences.encoderCaptureFeedbackEccon != 
repetitiveConditionsWin.GetEncoderCaptureFeedbackEccon) {
+                               SqlitePreferences.Update(SqlitePreferences.EncoderCaptureFeedbackEccon,
+                                               
repetitiveConditionsWin.GetEncoderCaptureFeedbackEccon.ToString(), true);
+                               preferences.encoderCaptureFeedbackEccon = 
repetitiveConditionsWin.GetEncoderCaptureFeedbackEccon;
+                       }
+
                        if(preferences.encoderCaptureInertialEccOverloadMode != 
repetitiveConditionsWin.GetEncoderCaptureEccOverloadMode) {
                                
SqlitePreferences.Update(SqlitePreferences.EncoderCaptureInertialEccOverloadMode,
                                                
repetitiveConditionsWin.GetEncoderCaptureEccOverloadMode.ToString(), true);
diff --git a/src/gui/encoderGraphObjects.cs b/src/gui/encoderGraphObjects.cs
index a650a883..f56a3763 100644
--- a/src/gui/encoderGraphObjects.cs
+++ b/src/gui/encoderGraphObjects.cs
@@ -555,9 +555,18 @@ public class EncoderGraphDoPlot
                        if(dWidth < 1)
                                dWidth = 1;
 
+                       Preferences.EncoderPhasesEnum phaseEnum = Preferences.EncoderPhasesEnum.BOTH; // 
(eccon == "c")
+                       if (eccon == "ec" || eccon == "ecS") {
+                               bool isEven = Util.IsEven(count +1);
+                               if(isEven)
+                                       phaseEnum = Preferences.EncoderPhasesEnum.CON;
+                               else
+                                       phaseEnum = Preferences.EncoderPhasesEnum.ECC;
+                       }
+
                        //select pen color for bars and sounds
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
-                                       RepetitiveConditionsWindow.BestSetValueEnum.CAPTURE_MAIN_VARIABLE, d);
+                                       RepetitiveConditionsWindow.BestSetValueEnum.CAPTURE_MAIN_VARIABLE, d, 
phaseEnum);
 
                        bool discarded = false;
                        if(hasInertia) {
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 08f6630f..8913895b 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -1190,9 +1190,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.MeanSpeed);
+                                       curve, Constants.MeanSpeed, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1219,9 +1220,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.MaxSpeed);
+                                       curve, Constants.MaxSpeed, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1256,9 +1258,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.MeanPower);
+                                       curve, Constants.MeanPower, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1284,9 +1287,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.PeakPower);
+                                       curve, Constants.PeakPower, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1329,9 +1333,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.MeanForce);
+                                       curve, Constants.MeanForce, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1357,9 +1362,10 @@ public partial class ChronoJumpWindow
                if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
                        (cell as Gtk.CellRendererText).Foreground = null;       //will show default color
                else {
+                       Preferences.EncoderPhasesEnum phaseEnum = getEncoderCurvePhaseEnum(curve);
                        string myColor = repetitiveConditionsWin.AssignColorAutomatic(
                                        RepetitiveConditionsWindow.BestSetValueEnum.AUTOMATIC_FEEDBACK,
-                                       curve, Constants.MaxForce);
+                                       curve, Constants.MaxForce, phaseEnum);
 
                        if(myColor == "")
                                myColor = assignColor(
@@ -1416,6 +1422,28 @@ public partial class ChronoJumpWindow
                renderBoldIfNeeded(cell, curve, str);
        }
 
+       private Preferences.EncoderPhasesEnum getEncoderCurvePhaseEnum(EncoderCurve curve)
+       {
+               if (ecconLast == "ec" || ecconLast == "ecS")
+               {
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               return Preferences.EncoderPhasesEnum.CON;
+                       else
+                               return Preferences.EncoderPhasesEnum.ECC;
+               }
+               else if (ecconLast == "ce" || ecconLast == "ceS")
+               {
+                       bool isEven = Util.IsEven(Convert.ToInt32(curve.N));
+                       if(isEven)
+                               return Preferences.EncoderPhasesEnum.ECC;
+                       else
+                               return Preferences.EncoderPhasesEnum.CON;
+               }
+               else // (ecconLast == "c")
+                       return Preferences.EncoderPhasesEnum.BOTH;
+       }
+
        /* end of rendering capture and analyze cols */
 
        /* start rendering neuromuscular cols */
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index 4d978f0e..5bca8dc6 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -85,6 +85,9 @@ public class RepetitiveConditionsWindow
        [Widget] Gtk.CheckButton check_encoder_show_secondary_variable;
        [Widget] Gtk.HBox hbox_combo_encoder_secondary_variable;
        [Widget] Gtk.ComboBox combo_encoder_secondary_variable;
+       [Widget] Gtk.RadioButton radio_encoder_eccon_both;
+       [Widget] Gtk.RadioButton radio_encoder_eccon_ecc;
+       [Widget] Gtk.RadioButton radio_encoder_eccon_con;
        [Widget] Gtk.CheckButton check_encoder_inertial_ecc_overload;
        [Widget] Gtk.CheckButton check_encoder_inertial_ecc_overload_percent;
 
@@ -264,6 +267,7 @@ public class RepetitiveConditionsWindow
                                preferences.encoderCaptureMainVariableGreaterValue,
                                preferences.encoderCaptureMainVariableLowerActive,
                                preferences.encoderCaptureMainVariableLowerValue,
+                               preferences.encoderCaptureFeedbackEccon,
                                encoderRhythm,
                                preferences.forceSensorCaptureFeedbackActive,
                                preferences.forceSensorCaptureFeedbackAt,
@@ -284,6 +288,7 @@ public class RepetitiveConditionsWindow
                        int encoderCaptureMainVariableGreaterValue,
                        bool encoderCaptureMainVariableLowerActive,
                        int encoderCaptureMainVariableLowerValue,
+                       Preferences.EncoderPhasesEnum encoderCaptureFeedbackEccon,
                        EncoderRhythm encoderRhythm,
                        bool forceSensorCaptureFeedbackActive,
                        int forceSensorCaptureFeedbackAt,
@@ -372,6 +377,13 @@ public class RepetitiveConditionsWindow
                        spinbutton_encoder_automatic_lower.Value = encoderCaptureMainVariableLowerValue;
                        update_checkbuttons_encoder_automatic = true;
 
+                       if(encoderCaptureFeedbackEccon == Preferences.EncoderPhasesEnum.ECC)
+                               radio_encoder_eccon_ecc.Active = true;
+                       else if(encoderCaptureFeedbackEccon == Preferences.EncoderPhasesEnum.CON)
+                               radio_encoder_eccon_con.Active = true;
+                       else
+                               radio_encoder_eccon_both.Active = true;
+
                        notebook_main.GetNthPage(RHYTHMPAGE).Show();
                        encoder_rhythm_set_values(encoderRhythm);
                        hbox_test_bells.Show();
@@ -755,20 +767,25 @@ public class RepetitiveConditionsWindow
                                bestSetValueCaptureMainVariable = d;
                }
        }
-               
+
        //called from gui/encoderTreeviews.cs
-       public string AssignColorAutomatic(BestSetValueEnum b, EncoderCurve curve, string variable)
+       public string AssignColorAutomatic(BestSetValueEnum b, EncoderCurve curve, string variable, 
Preferences.EncoderPhasesEnum phaseEnum)
        {
                if(GetMainVariable != variable)
                        return UtilGtk.ColorNothing;
 
                double currentValue = curve.GetParameter(variable);
 
-               return AssignColorAutomatic(b, currentValue);
+               return AssignColorAutomatic(b, currentValue, phaseEnum);
        }
        //called from previous function, gui/encoder.cs plotCurvesGraphDoPlot
-       public string AssignColorAutomatic(BestSetValueEnum b, double currentValue)
+       public string AssignColorAutomatic(BestSetValueEnum b, double currentValue, 
Preferences.EncoderPhasesEnum phaseEnum)
        {
+               if(radio_encoder_eccon_ecc.Active && phaseEnum != Preferences.EncoderPhasesEnum.ECC)
+                       return UtilGtk.ColorNothing;
+               else if(radio_encoder_eccon_con.Active && phaseEnum != Preferences.EncoderPhasesEnum.CON)
+                       return UtilGtk.ColorNothing;
+
                if(EncoderAutomaticHigherActive && currentValue > getBestSetValue(b) * 
EncoderAutomaticHigherValue / 100)
                        return UtilGtk.ColorGood;
                else if (EncoderAutomaticLowerActive && currentValue < getBestSetValue(b) * 
EncoderAutomaticLowerValue/ 100)
@@ -1039,6 +1056,17 @@ public class RepetitiveConditionsWindow
                get { return check_encoder_show_secondary_variable.Active; }
        }
 
+       public Preferences.EncoderPhasesEnum GetEncoderCaptureFeedbackEccon {
+               get {
+                       if(radio_encoder_eccon_ecc.Active)
+                               return Preferences.EncoderPhasesEnum.ECC;
+                       else if(radio_encoder_eccon_con.Active)
+                               return Preferences.EncoderPhasesEnum.CON;
+                       else
+                               return Preferences.EncoderPhasesEnum.BOTH;
+               }
+       }
+
        public Preferences.encoderCaptureEccOverloadModes GetEncoderCaptureEccOverloadMode {
                get {
                        if(check_encoder_inertial_ecc_overload_percent.Active)
diff --git a/src/preferences.cs b/src/preferences.cs
index 833b93f0..f18a22fd 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -142,6 +142,8 @@ public class Preferences
        public int encoderCaptureMainVariableGreaterValue;
        public bool encoderCaptureMainVariableLowerActive;
        public int encoderCaptureMainVariableLowerValue;
+       public enum EncoderPhasesEnum { BOTH, ECC, CON}
+       public EncoderPhasesEnum encoderCaptureFeedbackEccon;
 
        //forceSensor
        public string forceSensorTareDateTime;
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index c7792b44..4d6758b0 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.88";
+       static string lastChronojumpDatabaseVersion = "1.89";
 
        public Sqlite() {
        }
@@ -2654,6 +2654,15 @@ class Sqlite
 
                                currentVersion = updateVersion("1.88");
                        }
+                       if(currentVersion == "1.88")
+                       {
+                               LogB.SQL("Inserted into preferences: encoderCaptureFeedbackEccon");
+
+                               SqlitePreferences.Insert (SqlitePreferences.EncoderCaptureFeedbackEccon,
+                                               Preferences.EncoderPhasesEnum.BOTH.ToString());
+
+                               currentVersion = updateVersion("1.89");
+                       }
 
                        /*
                        if(currentVersion == "1.79")
@@ -2868,6 +2877,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.88 - 1.89 Converted DB to 1.89 Inserted into preferences: encoderCaptureFeedbackEccon
                //1.87 - 1.88 Converted DB to 1.88 Inserted into preferences: 
encoderCaptureInertialEccOverloadMode
                //1.86 - 1.87 Converted DB to 1.87 Doing alter table forceSensorExercise adding eccReps, 
eccMin, conMin.
                //1.85 - 1.86 Converted DB to 1.86 Inserted into preferences: RunEncoderMinAccel
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 30249708..11461768 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -57,6 +57,7 @@ class SqlitePreferences : Sqlite
        public const string EncoderCaptureMainVariableGreaterValue = "encoderCaptureMainVariableGreaterValue";
        public const string EncoderCaptureMainVariableLowerActive = "encoderCaptureMainVariableLowerActive";
        public const string EncoderCaptureMainVariableLowerValue = "encoderCaptureMainVariableLowerValue";
+       public const string EncoderCaptureFeedbackEccon = "encoderCaptureFeedbackEccon";
        public const string EncoderCaptureInertialEccOverloadMode = "encoderCaptureInertialEccOverloadMode";
 
        //forceSensor
@@ -160,6 +161,7 @@ class SqlitePreferences : Sqlite
                                Insert ("encoderCaptureMainVariable", 
Constants.EncoderVariablesCapture.MeanPower.ToString(), dbcmdTr);
                                Insert ("encoderCaptureSecondaryVariable", 
Constants.EncoderVariablesCapture.RangeAbsolute.ToString(), dbcmdTr);
                                Insert ("encoderCaptureSecondaryVariableShow", "True", dbcmdTr);
+                               Insert (EncoderCaptureFeedbackEccon, 
Preferences.EncoderPhasesEnum.BOTH.ToString(), dbcmdTr);
                                Insert (EncoderCaptureInertialEccOverloadMode, 
Preferences.encoderCaptureEccOverloadModes.SHOW_LINE.ToString(), dbcmdTr);
                                Insert (EncoderCaptureMainVariableThisSetOrHistorical, "True", dbcmdTr);
                                Insert (EncoderCaptureMainVariableGreaterActive, "False", dbcmdTr);
@@ -389,6 +391,9 @@ class SqlitePreferences : Sqlite
                                        Enum.Parse(typeof(Constants.EncoderVariablesCapture), 
reader[1].ToString());
                        else if(reader[0].ToString() == "encoderCaptureSecondaryVariableShow")
                                preferences.encoderCaptureSecondaryVariableShow = reader[1].ToString() == 
"True";
+                       else if(reader[0].ToString() == EncoderCaptureFeedbackEccon)
+                               preferences.encoderCaptureFeedbackEccon = (Preferences.EncoderPhasesEnum)
+                                       Enum.Parse(typeof(Preferences.EncoderPhasesEnum), 
reader[1].ToString());
                        else if(reader[0].ToString() == EncoderCaptureInertialEccOverloadMode)
                                preferences.encoderCaptureInertialEccOverloadMode = 
(Preferences.encoderCaptureEccOverloadModes)
                                        Enum.Parse(typeof(Preferences.encoderCaptureEccOverloadModes), 
reader[1].ToString());


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