[chronojump] rfd: best avg rfd in x ms implemented on gui and R (but only in raw)



commit c0a7ef7f99190282579186edd8eb91843e1df716
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 3 19:31:54 2022 +0200

    rfd: best avg rfd in x ms implemented on gui and R (but only in raw)

 glade/app1.glade                   | 261 +++++++++++++++++++++++++++++++++++--
 r-scripts/maximumIsometricForce.R  |  40 +++++-
 src/forceSensor.cs                 |  44 ++++---
 src/gui/app1/forceSensorAnalyze.cs | 111 ++++++++++------
 4 files changed, 382 insertions(+), 74 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 2a26079ed..1b648a089 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25870,6 +25870,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -27469,6 +27472,63 @@ Concentric</property>
                                                             <property name="position">4</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_force_1_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_force_1_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes" 
comments="This &quot;In&quot; means: &quot;average force in x milliseconds&quot;">In</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkSpinButton" 
id="spinbutton_force_1_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">4</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>
+                                                            <property name="adjustment">100 25 1000 1 1 
0</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label271">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">ms</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">5</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -27769,6 +27829,63 @@ Concentric</property>
                                                             <property name="position">4</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_force_2_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_force_2_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes" 
comments="This &quot;In&quot; means: &quot;average force in x milliseconds&quot;">In</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkSpinButton" 
id="spinbutton_force_2_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">4</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>
+                                                            <property name="adjustment">100 25 1000 1 1 
0</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label272">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">ms</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">5</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -28069,6 +28186,63 @@ Concentric</property>
                                                             <property name="position">4</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_force_3_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_force_3_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes" 
comments="This &quot;In&quot; means: &quot;average force in x milliseconds&quot;">In</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkSpinButton" 
id="spinbutton_force_3_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">4</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>
+                                                            <property name="adjustment">100 25 1000 1 1 
0</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label273">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">ms</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">5</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -28369,6 +28543,63 @@ Concentric</property>
                                                             <property name="position">4</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_force_4_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">6</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="label_force_4_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes" 
comments="This &quot;In&quot; means: &quot;average force in x milliseconds&quot;">In</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkSpinButton" 
id="spinbutton_force_4_in_x_ms">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">4</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>
+                                                            <property name="adjustment">100 25 1000 1 1 
0</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label274">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">ms</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">5</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -32276,18 +32507,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>
@@ -32324,6 +32543,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>
@@ -41709,6 +41940,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -49734,6 +49968,9 @@ Since Chronojump 2.1.3, backups contain the complete data.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             </widget>
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index e73642529..f9bc11909 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -587,7 +587,6 @@ drawDynamicsFromLoadCell <- function(title, exercise, datetime,
                 }
             } else if(RFDoptions$type == "RFD_MAX")
             {
-                
                 if (RFDoptions$rfdFunction == "FITTED")
                 {
                     #max is always in the initial point.
@@ -625,8 +624,39 @@ drawDynamicsFromLoadCell <- function(title, exercise, datetime,
                     
                 }
                 
-            }
-            
+            } else if(RFDoptions$type == "BEST_AVG_RFD_IN_X_MS")
+            {
+               RFD = 0
+               window = RFDoptions$start / 1000 # RFDoptions$start from ms to s
+
+               #if window does not fit in graph, discard it
+               if (dynamics$time[dynamics$startSample] + window > dynamics$time[dynamics$endSample])
+                   next
+
+               if (RFDoptions$rfdFunction == "FITTED")
+               {
+               } else if(RFDoptions$rfdFunction == "RAW")
+               {
+                       for (i in dynamics$startSample:dynamics$endSample)
+                       {
+                               forceTemp1 = dynamics$f.raw[i]
+                               forceTemp2 = interpolateXAtY(dynamics$f.raw, dynamics$time, dynamics$time[i] 
+ window)
+                               RFDtemp = (forceTemp2 - forceTemp1) / window
+
+                               if (RFDtemp > RFD)
+                               {
+                                       force1 = forceTemp1
+                                       force2 = forceTemp2
+                                       RFD = RFDtemp
+                                       time1 = dynamics$time[i]
+                                       time2 = interpolateXAtY(dynamics$time, dynamics$time, 
dynamics$time[i] + window)
+                               }
+                       }
+                       legendText = c(legendText, paste("RFD max avg in", RFDoptions$start, "ms = ", 
round(RFD, digits = 1), " N/s", sep = ""))
+                       legendColor = c(legendColor, "black")
+               }
+           }
+
             #The Y coordinate of the line when it crosses the Y axis
             intercept = force1 - RFD * time1
             
@@ -1048,9 +1078,9 @@ readRFDOptions <- function(optionsStr)
         
         return(list(
             rfdFunction     = options[1],            # raw or fitted
-            type            = options[2],            # instantaeous, average, %fmax, rfdmax
+            type            = options[2],            # instantaneous, average, %fmax, rfdmax, 
BEST_AVG_RFD_IN_X_MS
             #start and end can be in milliseconds (instant and average RFD), percentage (%fmax) or -1 if not 
needed
-            start           = as.numeric(options[3]),            # instant at which the analysis starts
+            start           = as.numeric(options[3]),            # instant at which the analysis starts (or 
time window in BEST_AVG_RFD)
             end             = as.numeric(options[4])             # instant at which the analysis ends
         ))
     } 
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 6d3b02fcb..b6cc8b2e4 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -1560,11 +1560,12 @@ public class ForceSensorRFD
        protected static string function_FITTED_name = "Fitted";
 
        //if these names change, change TypePrint() below
-       public enum Types { INSTANTANEOUS, AVERAGE, PERCENT_F_MAX, RFD_MAX, IMP_UNTIL_PERCENT_F_MAX, 
IMP_RANGE } //on SQL is inserted like this
+       public enum Types { INSTANTANEOUS, AVERAGE, PERCENT_F_MAX, RFD_MAX, BEST_AVG_RFD_IN_X_MS, 
IMP_UNTIL_PERCENT_F_MAX, IMP_RANGE } //on SQL is inserted like this
        private static string type_INSTANTANEOUS_name = "Instantaneous";
        private static string type_AVERAGE_name = "Average";
        private static string type_PERCENT_F_MAX_name = "% Force max";
        private static string type_RFD_MAX_name = "RFD max";
+       private static string type_BEST_AVG_RFD_IN_X_MS_name = "Best average RFD";
 
        public string code; //RFD1...4 //I: on impulse
        public bool active;
@@ -1611,11 +1612,14 @@ public class ForceSensorRFD
                if(translated)
                        return new string [] {
                                Catalog.GetString(type_INSTANTANEOUS_name), 
Catalog.GetString(type_AVERAGE_name),
-                               Catalog.GetString(type_PERCENT_F_MAX_name), 
Catalog.GetString(type_RFD_MAX_name)
+                                       Catalog.GetString(type_PERCENT_F_MAX_name), 
Catalog.GetString(type_RFD_MAX_name),
+                                       Catalog.GetString(type_BEST_AVG_RFD_IN_X_MS_name)
                        };
                else
                        return new string [] {
-                               type_INSTANTANEOUS_name, type_AVERAGE_name, type_PERCENT_F_MAX_name, 
type_RFD_MAX_name
+                               type_INSTANTANEOUS_name, type_AVERAGE_name,
+                                       type_PERCENT_F_MAX_name, type_RFD_MAX_name,
+                                       type_BEST_AVG_RFD_IN_X_MS_name
                        };
        }
 
@@ -1636,30 +1640,36 @@ public class ForceSensorRFD
 
        public virtual string TypePrint(bool translated)
        {
-               if(type == Types.INSTANTANEOUS) {
-                       if(translated)
-                               return Catalog.GetString(type_INSTANTANEOUS_name);
+               if (type == Types.INSTANTANEOUS) {
+                       if (translated)
+                               return Catalog.GetString (type_INSTANTANEOUS_name);
                        else
                                return type_INSTANTANEOUS_name;
                }
-               else if(type == Types.AVERAGE) {
-                       if(translated)
-                               return Catalog.GetString(type_AVERAGE_name);
+               else if (type == Types.AVERAGE) {
+                       if (translated)
+                               return Catalog.GetString (type_AVERAGE_name);
                        else
                                return type_AVERAGE_name;
                }
-               else if(type == Types.PERCENT_F_MAX) {
-                       if(translated)
-                               return Catalog.GetString(type_PERCENT_F_MAX_name);
+               else if (type == Types.PERCENT_F_MAX) {
+                       if (translated)
+                               return Catalog.GetString (type_PERCENT_F_MAX_name);
                        else
                                return type_PERCENT_F_MAX_name;
                }
-               else { //if(type == Types.RFD_MAX)
-                       if(translated)
-                               return Catalog.GetString(type_RFD_MAX_name);
+               else if (type == Types.RFD_MAX) {
+                       if (translated)
+                               return Catalog.GetString (type_RFD_MAX_name);
                        else
                                return type_RFD_MAX_name;
                }
+               else { //if (type == Types.BEST_AVG_RFD_IN_X_MS)
+                       if (translated)
+                               return Catalog.GetString (type_BEST_AVG_RFD_IN_X_MS_name);
+                       else
+                               return type_BEST_AVG_RFD_IN_X_MS_name;
+               }
        }
 
        public string ToSQLInsertString()
@@ -1716,6 +1726,10 @@ public class ForceSensorRFD
        {
                get { return type_RFD_MAX_name; }
        }
+       public static string Type_BEST_AVG_RFD_IN_X_MS_name
+       {
+               get { return type_BEST_AVG_RFD_IN_X_MS_name; }
+       }
 }
 
 public class ForceSensorImpulse : ForceSensorRFD
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index 9f84cee91..1a6993461 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -106,11 +106,15 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.HBox hbox_force_2_from_to;
        [Widget] Gtk.HBox hbox_force_3_from_to;
        [Widget] Gtk.HBox hbox_force_4_from_to;
-       [Widget] Gtk.HBox hbox_force_impulse_from_to;
+       [Widget] Gtk.HBox hbox_force_1_in_x_ms;
+       [Widget] Gtk.HBox hbox_force_2_in_x_ms;
+       [Widget] Gtk.HBox hbox_force_3_in_x_ms;
+       [Widget] Gtk.HBox hbox_force_4_in_x_ms;
        [Widget] Gtk.SpinButton spinbutton_force_1_at_ms;
        [Widget] Gtk.SpinButton spinbutton_force_2_at_ms;
        [Widget] Gtk.SpinButton spinbutton_force_3_at_ms;
        [Widget] Gtk.SpinButton spinbutton_force_4_at_ms;
+       [Widget] Gtk.HBox hbox_force_impulse_from_to;
        [Widget] Gtk.SpinButton spinbutton_force_1_at_percent;
        [Widget] Gtk.SpinButton spinbutton_force_2_at_percent;
        [Widget] Gtk.SpinButton spinbutton_force_3_at_percent;
@@ -126,6 +130,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.SpinButton spinbutton_force_3_to;
        [Widget] Gtk.SpinButton spinbutton_force_4_to;
        [Widget] Gtk.SpinButton spinbutton_force_impulse_to;
+       [Widget] Gtk.SpinButton spinbutton_force_1_in_x_ms;
+       [Widget] Gtk.SpinButton spinbutton_force_2_in_x_ms;
+       [Widget] Gtk.SpinButton spinbutton_force_3_in_x_ms;
+       [Widget] Gtk.SpinButton spinbutton_force_4_in_x_ms;
 
        [Widget] Gtk.Button button_hscale_force_sensor_ai_a_first;
        [Widget] Gtk.Button button_hscale_force_sensor_ai_a_pre;
@@ -348,25 +356,29 @@ public partial class ChronoJumpWindow
                                        UtilGtk.ComboGetActive(combo_force_1_type),
                                        hbox_force_1_at_ms,
                                        hbox_force_1_at_percent,
-                                       hbox_force_1_from_to);
+                                       hbox_force_1_from_to,
+                                       hbox_force_1_in_x_ms);
                else if(combo == combo_force_2_type)
                        combo_force_visibility(
                                        UtilGtk.ComboGetActive(combo_force_2_type),
                                        hbox_force_2_at_ms,
                                        hbox_force_2_at_percent,
-                                       hbox_force_2_from_to);
+                                       hbox_force_2_from_to,
+                                       hbox_force_2_in_x_ms);
                else if(combo == combo_force_3_type)
                        combo_force_visibility(
                                        UtilGtk.ComboGetActive(combo_force_3_type),
                                        hbox_force_3_at_ms,
                                        hbox_force_3_at_percent,
-                                       hbox_force_3_from_to);
+                                       hbox_force_3_from_to,
+                                       hbox_force_3_in_x_ms);
                else if(combo == combo_force_4_type)
                        combo_force_visibility(
                                        UtilGtk.ComboGetActive(combo_force_4_type),
                                        hbox_force_4_at_ms,
                                        hbox_force_4_at_percent,
-                                       hbox_force_4_from_to);
+                                       hbox_force_4_from_to,
+                                       hbox_force_4_in_x_ms);
                else if(combo == combo_force_impulse_type)
                        combo_force_impulse_visibility(
                                        UtilGtk.ComboGetActive(combo_force_impulse_type),
@@ -374,25 +386,22 @@ public partial class ChronoJumpWindow
                                        hbox_force_impulse_from_to);
        }
 
-       private void combo_force_visibility (string selected, Gtk.HBox at_ms, Gtk.HBox at_percent, Gtk.HBox 
from_to)
+       private void combo_force_visibility (string selected, Gtk.HBox at_ms, Gtk.HBox at_percent, Gtk.HBox 
from_to, Gtk.HBox in_x_ms)
        {
                //valid for active == "" and active == "RFD max"
                at_ms.Visible = false;
                from_to.Visible = false;
                at_percent.Visible = false;
+               in_x_ms.Visible = false;
 
                if(selected == Catalog.GetString(ForceSensorRFD.Type_INSTANTANEOUS_name))
-               {
                        at_ms.Visible = true;
-               }
                else if(selected == Catalog.GetString(ForceSensorRFD.Type_AVERAGE_name))
-               {
                        from_to.Visible = true;
-               }
                else if(selected == Catalog.GetString(ForceSensorRFD.Type_PERCENT_F_MAX_name))
-               {
                        at_percent.Visible = true;
-               }
+               else if(selected == Catalog.GetString(ForceSensorRFD.Type_BEST_AVG_RFD_IN_X_MS_name))
+                       in_x_ms.Visible = true;
        }
        private void combo_force_impulse_visibility (string selected, Gtk.HBox until_percent, Gtk.HBox 
from_to)
        {
@@ -400,13 +409,9 @@ public partial class ChronoJumpWindow
                from_to.Visible = false;
 
                if(selected == Catalog.GetString(ForceSensorImpulse.Type_IMP_UNTIL_PERCENT_F_MAX_name))
-               {
                        until_percent.Visible = true;
-               }
                else if(selected == Catalog.GetString(ForceSensorImpulse.Type_IMP_RANGE_name))
-               {
                        from_to.Visible = true;
-               }
        }
 
        private void setForceDurationRadios()
@@ -434,31 +439,36 @@ public partial class ChronoJumpWindow
 
        private void setRFDValues ()
        {
-               setRFDValue(rfdList[0], check_force_1, combo_force_1_function, combo_force_1_type,
+               setRFDValue (rfdList[0], check_force_1, combo_force_1_function, combo_force_1_type,
                                hbox_force_1_at_ms, spinbutton_force_1_at_ms,
                                hbox_force_1_at_percent, spinbutton_force_1_at_percent,
-                               hbox_force_1_from_to, spinbutton_force_1_from, spinbutton_force_1_to);
+                               hbox_force_1_from_to, spinbutton_force_1_from, spinbutton_force_1_to,
+                               hbox_force_1_in_x_ms, spinbutton_force_1_in_x_ms);
 
-               setRFDValue(rfdList[1], check_force_2, combo_force_2_function, combo_force_2_type,
+               setRFDValue (rfdList[1], check_force_2, combo_force_2_function, combo_force_2_type,
                                hbox_force_2_at_ms, spinbutton_force_2_at_ms,
                                hbox_force_2_at_percent, spinbutton_force_2_at_percent,
-                               hbox_force_2_from_to, spinbutton_force_2_from, spinbutton_force_2_to);
+                               hbox_force_2_from_to, spinbutton_force_2_from, spinbutton_force_2_to,
+                               hbox_force_2_in_x_ms, spinbutton_force_2_in_x_ms);
 
-               setRFDValue(rfdList[2], check_force_3, combo_force_3_function, combo_force_3_type,
+               setRFDValue (rfdList[2], check_force_3, combo_force_3_function, combo_force_3_type,
                                hbox_force_3_at_ms, spinbutton_force_3_at_ms,
                                hbox_force_3_at_percent, spinbutton_force_3_at_percent,
-                               hbox_force_3_from_to, spinbutton_force_3_from, spinbutton_force_3_to);
+                               hbox_force_3_from_to, spinbutton_force_3_from, spinbutton_force_3_to,
+                               hbox_force_3_in_x_ms, spinbutton_force_3_in_x_ms);
 
-               setRFDValue(rfdList[3], check_force_4, combo_force_4_function, combo_force_4_type,
+               setRFDValue (rfdList[3], check_force_4, combo_force_4_function, combo_force_4_type,
                                hbox_force_4_at_ms, spinbutton_force_4_at_ms,
                                hbox_force_4_at_percent, spinbutton_force_4_at_percent,
-                               hbox_force_4_from_to, spinbutton_force_4_from, spinbutton_force_4_to);
+                               hbox_force_4_from_to, spinbutton_force_4_from, spinbutton_force_4_to,
+                               hbox_force_4_in_x_ms, spinbutton_force_4_in_x_ms);
        }
 
-       private void setRFDValue(ForceSensorRFD rfd, Gtk.CheckButton check, Gtk.ComboBox 
combo_force_function, Gtk.ComboBox combo_force_type,
+       private void setRFDValue (ForceSensorRFD rfd, Gtk.CheckButton check, Gtk.ComboBox 
combo_force_function, Gtk.ComboBox combo_force_type,
                        Gtk.HBox hbox_force_at_ms, Gtk.SpinButton spinbutton_force_at_ms,
                        Gtk.HBox hbox_force_at_percent, Gtk.SpinButton spinbutton_force_at_percent,
-                       Gtk.HBox hbox_force_from_to, Gtk.SpinButton spinbutton_force_from, Gtk.SpinButton 
spinbutton_force_to)
+                       Gtk.HBox hbox_force_from_to, Gtk.SpinButton spinbutton_force_from, Gtk.SpinButton 
spinbutton_force_to,
+                       Gtk.HBox hbox_force_in_x_ms, Gtk.SpinButton spinbutton_force_in_x_ms)
        {
                check.Active = rfd.active;
 
@@ -468,6 +478,7 @@ public partial class ChronoJumpWindow
                hbox_force_at_ms.Visible = false;
                hbox_force_at_percent.Visible = false;
                hbox_force_from_to.Visible = false;
+               hbox_force_in_x_ms.Visible = false;
 
                if(rfd.type == ForceSensorRFD.Types.INSTANTANEOUS)
                {
@@ -485,28 +496,39 @@ public partial class ChronoJumpWindow
                        hbox_force_at_percent.Visible = true;
                        spinbutton_force_at_percent.Value = rfd.num1;
                }
+               else if(rfd.type == ForceSensorRFD.Types.BEST_AVG_RFD_IN_X_MS)
+               {
+                       hbox_force_in_x_ms.Visible = true;
+                       spinbutton_force_in_x_ms.Value = rfd.num1;
+               }
        }
 
-       private List<ForceSensorRFD> getRFDValues()
+       private List<ForceSensorRFD> getRFDValues ()
        {
                List<ForceSensorRFD> l = new List<ForceSensorRFD>();
                l.Add(getRFDValue("RFD1", check_force_1, combo_force_1_function, combo_force_1_type,
                                        spinbutton_force_1_at_ms, spinbutton_force_1_at_percent,
-                                       spinbutton_force_1_from, spinbutton_force_1_to));
+                                       spinbutton_force_1_from, spinbutton_force_1_to,
+                                       spinbutton_force_1_in_x_ms));
                l.Add(getRFDValue("RFD2", check_force_2, combo_force_2_function, combo_force_2_type,
                                        spinbutton_force_2_at_ms, spinbutton_force_2_at_percent,
-                                       spinbutton_force_2_from, spinbutton_force_2_to));
+                                       spinbutton_force_2_from, spinbutton_force_2_to,
+                                       spinbutton_force_2_in_x_ms));
                l.Add(getRFDValue("RFD3", check_force_3, combo_force_3_function, combo_force_3_type,
                                        spinbutton_force_3_at_ms, spinbutton_force_3_at_percent,
-                                       spinbutton_force_3_from, spinbutton_force_3_to));
+                                       spinbutton_force_3_from, spinbutton_force_3_to,
+                                       spinbutton_force_3_in_x_ms));
                l.Add(getRFDValue("RFD4", check_force_4, combo_force_4_function, combo_force_4_type,
                                        spinbutton_force_4_at_ms, spinbutton_force_4_at_percent,
-                                       spinbutton_force_4_from, spinbutton_force_4_to));
+                                       spinbutton_force_4_from, spinbutton_force_4_to,
+                                       spinbutton_force_4_in_x_ms));
                return l;
        }
-       private ForceSensorRFD getRFDValue(string code, Gtk.CheckButton check, Gtk.ComboBox 
combo_force_function, Gtk.ComboBox combo_force_type,
+       private ForceSensorRFD getRFDValue (string code, Gtk.CheckButton check, Gtk.ComboBox 
combo_force_function, Gtk.ComboBox combo_force_type,
                        Gtk.SpinButton spinbutton_force_at_ms, Gtk.SpinButton spinbutton_force_at_percent,
-                       Gtk.SpinButton spinbutton_force_from, Gtk.SpinButton spinbutton_force_to)
+                       Gtk.SpinButton spinbutton_force_from, Gtk.SpinButton spinbutton_force_to,
+                       Gtk.SpinButton spinbutton_force_in_x_ms)
+
        {
                bool active = check.Active;
                int num1 = -1;
@@ -520,26 +542,31 @@ public partial class ChronoJumpWindow
 
                ForceSensorRFD.Types type;
                string typeStr = UtilGtk.ComboGetActive(combo_force_type);
-               if(typeStr == Catalog.GetString(ForceSensorRFD.Type_INSTANTANEOUS_name))
+               if (typeStr == Catalog.GetString (ForceSensorRFD.Type_INSTANTANEOUS_name))
                {
-                       num1 = Convert.ToInt32(spinbutton_force_at_ms.Value);
+                       num1 = Convert.ToInt32 (spinbutton_force_at_ms.Value);
                        type = ForceSensorRFD.Types.INSTANTANEOUS;
                }
-               else if(typeStr == Catalog.GetString(ForceSensorRFD.Type_AVERAGE_name))
+               else if (typeStr == Catalog.GetString (ForceSensorRFD.Type_AVERAGE_name))
                {
-                       num1 = Convert.ToInt32(spinbutton_force_from.Value);
-                       num2 = Convert.ToInt32(spinbutton_force_to.Value);
+                       num1 = Convert.ToInt32 (spinbutton_force_from.Value);
+                       num2 = Convert.ToInt32 (spinbutton_force_to.Value);
                        type = ForceSensorRFD.Types.AVERAGE;
                }
-               else if(typeStr == Catalog.GetString(ForceSensorRFD.Type_PERCENT_F_MAX_name))
+               else if (typeStr == Catalog.GetString (ForceSensorRFD.Type_PERCENT_F_MAX_name))
                {
-                       num1 = Convert.ToInt32(spinbutton_force_at_percent.Value);
+                       num1 = Convert.ToInt32 (spinbutton_force_at_percent.Value);
                        type = ForceSensorRFD.Types.PERCENT_F_MAX;
                }
-               else // (typeStr == Catalog.GetString(ForceSensorRFD.Type_RFD_MAX_name))
+               else if (typeStr == Catalog.GetString (ForceSensorRFD.Type_RFD_MAX_name))
                        type = ForceSensorRFD.Types.RFD_MAX;
+               else //if (typeStr == Catalog.GetString (ForceSensorRFD.Type_BEST_AVG_RFD_IN_X_MS_name))
+               {
+                       num1 = Convert.ToInt32 (spinbutton_force_in_x_ms.Value);
+                       type = ForceSensorRFD.Types.BEST_AVG_RFD_IN_X_MS;
+               }
 
-               return new ForceSensorRFD(code, active, function, type, num1, num2);
+               return new ForceSensorRFD (code, active, function, type, num1, num2);
        }
 
        private void setImpulseValue ()


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