[chronojump] Inertia extra weights from main GUI. More inertia stuff on encoderConfiguration



commit e09fd5689fa7f6e94d3bf11f706f030d44f8f91d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon May 25 16:01:19 2015 +0200

    Inertia extra weights from main GUI. More inertia stuff on encoderConfiguration

 glade/chronojump.glade          |  450 +++++++++++++++++++++++++++------------
 src/encoder.cs                  |   47 ++++-
 src/gui/encoder.cs              |   26 ++-
 src/gui/encoderConfiguration.cs |   69 +++---
 src/utilEncoder.cs              |   12 +
 5 files changed, 422 insertions(+), 182 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7fa1a26..43bd5d4 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7911,6 +7911,15 @@ Second Chronopic to platforms.</property>
                                                         <child>
                                                           <placeholder/>
                                                         </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
                                                       </widget>
                                                       <packing>
                                                         <property name="expand">True</property>
@@ -8854,6 +8863,15 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -10049,6 +10067,15 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -10885,6 +10912,15 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -15573,95 +15609,15 @@ on current Chronojump version.</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">8</property>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox157">
+                                                            <widget class="GtkHBox" id="hbox160">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" id="label182">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="tooltip" 
translatable="yes">Inertia moment</property>
-                                                            <property name="label" 
translatable="yes">IM</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkHBox" id="hbox158">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
                                                             <widget class="GtkLabel" id="label183">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" 
translatable="yes">Machine</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkLabel" 
id="label_encoder_im_machine">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="tooltip" 
translatable="yes">Kg*cm^2</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkHBox" id="hbox159">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label186">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" 
translatable="yes">Total</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkLabel" 
id="label_encoder_im_total">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="tooltip" 
translatable="yes">Kg*cm^2</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">2</property>
-                                                            </packing>
-                                                            </child>
+                                                            <property name="label" translatable="yes">Extra 
weights</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
@@ -15670,12 +15626,7 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox160">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="spacing">6</property>
-                                                            <child>
-                                                            <widget class="GtkSpinButton" 
id="spin_im_weights_n">
+                                                            <widget class="GtkSpinButton" 
id="spin_encoder_im_weights_n">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="invisible_char">●</property>
@@ -15683,49 +15634,37 @@ on current Chronojump version.</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">10 1 50 1 1 
0</property>
+                                                            <property name="adjustment">0 0 50 1 1 
0</property>
                                                             <property name="climb_rate">1</property>
                                                             <property name="snap_to_ticks">True</property>
                                                             <property name="numeric">True</property>
                                                             <property 
name="update_policy">if-valid</property>
+                                                            <signal name="changed" 
handler="on_spin_encoder_im_weights_n_changed" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">0</property>
+                                                            <property name="position">1</property>
                                                             </packing>
                                                             </child>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label184">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label">*</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHBox" id="hbox161">
+                                                            <widget class="GtkHBox" id="hbox157">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="spacing">2</property>
+                                                            <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkSpinButton" 
id="spin_im_weights_weight">
+                                                            <widget class="GtkLabel" id="label182">
                                                             <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="invisible_char">●</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">30 10 4000 
0.10000000000000001 10 0</property>
-                                                            <property name="climb_rate">1</property>
-                                                            <property name="snap_to_ticks">True</property>
-                                                            <property name="numeric">True</property>
-                                                            <property 
name="update_policy">if-valid</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="tooltip" 
translatable="yes">Inertia moment</property>
+                                                            <property name="label" 
translatable="yes">Inertia M.</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -15734,10 +15673,10 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkLabel" id="label185">
+                                                            <widget class="GtkLabel" 
id="label_encoder_im_total">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label">g</property>
+                                                            <property name="tooltip" 
translatable="yes">Kg*cm^2</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">True</property>
@@ -15747,15 +15686,8 @@ on current Chronojump version.</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">2</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
                                                             <property name="expand">True</property>
-                                                            <property name="fill">True</property>
+                                                            <property name="fill">False</property>
                                                             <property name="position">1</property>
                                                             </packing>
                                                             </child>
@@ -21998,6 +21930,15 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -22742,6 +22683,15 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23978,6 +23928,15 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -24271,6 +24230,15 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -27139,6 +27107,7 @@ comments</property>
                                   <widget class="GtkLabel" id="label5">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
+                                    <property name="tooltip" translatable="yes">Inertia momentum without 
extra weight</property>
                                     <property name="xalign">0</property>
                                     <property name="label" translatable="yes">Inertia M.</property>
                                   </widget>
@@ -27149,11 +27118,11 @@ comments</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkSpinButton" id="spin_inertia">
+                                  <widget class="GtkSpinButton" id="spin_inertia_machine">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="has_tooltip">True</property>
-                                    <property name="tooltip">Inertia Momentum</property>
+                                    <property name="tooltip">Inertia momentum without extra weight</property>
                                     <property name="invisible_char">●</property>
                                     <property name="invisible_char_set">True</property>
                                     <property name="primary_icon_activatable">False</property>
@@ -27191,7 +27160,125 @@ comments</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkHBox" id="hbox_inertia2">
+                              <widget class="GtkHBox" id="hbox_inertia_mass">
+                                <property name="can_focus">False</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <widget class="GtkLabel" id="label31">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Mass of each extra 
load</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="spin_inertia_mass">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="has_tooltip">True</property>
+                                    <property name="invisible_char">●</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">30 0 4000 1 10 0</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <property name="numeric">True</property>
+                                    <property name="update_policy">if-valid</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label32">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label">g</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</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>
+                            <child>
+                              <widget class="GtkHBox" id="hbox_inertia_length">
+                                <property name="can_focus">False</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <widget class="GtkLabel" id="label20">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Length of each load</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="spin_inertia_length">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="has_tooltip">True</property>
+                                    <property name="invisible_char">●</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">15 1 200 0.10000000000000001 10 0</property>
+                                    <property name="climb_rate">1</property>
+                                    <property name="digits">1</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <property name="numeric">True</property>
+                                    <property name="update_policy">if-valid</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="label29">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label">cm</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">6</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkHBox" id="hbox_inertia_calcule">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <child>
@@ -27259,7 +27346,7 @@ comments</property>
                               <packing>
                                 <property name="expand">True</property>
                                 <property name="fill">True</property>
-                                <property name="position">5</property>
+                                <property name="position">7</property>
                               </packing>
                             </child>
                           </widget>
@@ -27438,7 +27525,7 @@ comments</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkSpinButton" id="spin_im_weight">
+                      <widget class="GtkSpinButton" id="spin_im_weight_calcule">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="invisible_char">●</property>
@@ -27446,7 +27533,7 @@ comments</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 10 4000 1 10 0</property>
+                        <property name="adjustment">30 10 4000 1 10 0</property>
                         <property name="climb_rate">1</property>
                         <property name="snap_to_ticks">True</property>
                         <property name="numeric">True</property>
@@ -27459,7 +27546,7 @@ comments</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkSpinButton" id="spin_im_length">
+                      <widget class="GtkSpinButton" id="spin_im_length_calcule">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="invisible_char">●</property>
@@ -27483,7 +27570,7 @@ comments</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkSpinButton" id="spin_im_duration">
+                      <widget class="GtkSpinButton" id="spin_im_duration_calcule">
                         <property name="can_focus">True</property>
                         <property name="invisible_char">●</property>
                         <property name="primary_icon_activatable">False</property>
@@ -27697,7 +27784,6 @@ comments</property>
                 </child>
                 <child>
                   <widget class="GtkAlignment" id="alignment4">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="top_padding">10</property>
                     <child>
@@ -27743,7 +27829,7 @@ comments</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkSpinButton" id="spin_im_weights_n">
+                              <widget class="GtkSpinButton" id="spin_im_weights_n_calcule">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="invisible_char">●</property>
@@ -27783,7 +27869,7 @@ comments</property>
                               <placeholder/>
                             </child>
                             <child>
-                              <widget class="GtkSpinButton" id="spin_im_weights_weight">
+                              <widget class="GtkSpinButton" id="spin_im_weights_weight_calcule">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="invisible_char">●</property>
@@ -27837,7 +27923,6 @@ comments</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
                                 <property name="has_tooltip">True</property>
-                                <signal name="clicked" 
handler="on_button_encoder_calcule_inertial_weights_clicked" swapped="no"/>
                               </widget>
                               <packing>
                                 <property name="expand">True</property>
@@ -34685,6 +34770,60 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -36809,6 +36948,15 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                 <child>
                                   <placeholder/>
                                 </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -37591,6 +37739,15 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -40339,6 +40496,15 @@ show elevation as:</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -40747,6 +40913,15 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -41170,6 +41345,15 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 286a4b3..37b9f2d 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -909,8 +909,16 @@ public class EncoderConfiguration {
        public double D;        //external disc or pulley
        public int anglePush;
        public int angleWeight;
-       public int inertia;
+       
+       public int inertiaMachine; //this is the inertia without the disc
+       
        public int gearedDown;  //demultiplication
+       
+       public int inertiaTotal; //this is the inertia used by R
+       public int extraWeightN; //how much extra weights
+       public int extraWeightGrams; //weight of each extra weight
+       public double extraWeightLength; //length from center to center (cm)
+
 
        public string textDefault = Catalog.GetString("Linear encoder attached to a barbell.") + "\n" + 
                Catalog.GetString("Also common gym tests like jumps or chin-ups.");
@@ -932,8 +940,12 @@ public class EncoderConfiguration {
                D = -1;
                anglePush = -1;
                angleWeight = -1;
-               inertia = -1;
+               inertiaMachine = -1;
                gearedDown = 1;
+               inertiaTotal = -1;
+               extraWeightN = 0;
+               extraWeightGrams = 0;
+               extraWeightLength = 1;
        }
 
        // note: if this changes, change also in:
@@ -1223,8 +1235,21 @@ public class EncoderConfiguration {
                this.D =           Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[2]));
                this.anglePush =   Convert.ToInt32(strFull[3]);
                this.angleWeight = Convert.ToInt32(strFull[4]);
-               this.inertia =     Convert.ToInt32(strFull[5]);
+               this.inertiaMachine =   Convert.ToInt32(strFull[5]);
                this.gearedDown =  Convert.ToInt32(strFull[6]);
+       
+               //this params started at 1.5.1
+               if(strFull.Length > 7) {
+                       this.inertiaTotal =     Convert.ToInt32(strFull[7]);
+                       this.extraWeightN =     Convert.ToInt32(strFull[8]);
+                       this.extraWeightGrams = Convert.ToInt32(strFull[9]);
+                       this.extraWeightLength = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[10]));
+               } else {
+                       this.inertiaTotal =     inertiaMachine;
+                       this.extraWeightN =     0;
+                       this.extraWeightGrams = 0;
+                       this.extraWeightLength = 1;
+               }
        }
        
        //decimalPointForR: ensure decimal is point in order to work in R
@@ -1246,18 +1271,22 @@ public class EncoderConfiguration {
                                "#str_D" + sep +        str_D + sep + 
                                "#anglePush" + sep +    anglePush.ToString() + sep + 
                                "#angleWeight" + sep +  angleWeight.ToString() + sep +
-                               "#inertia" + sep +      inertia.ToString() + sep + 
+                               "#inertiaTotal" + sep + inertiaTotal.ToString() + sep + 
                                "#gearedDown" + sep +   gearedDown.ToString()
                                ;
-               else
+               else    //for SQL
                        return 
                                name + sep + 
                                str_d + sep + 
                                str_D + sep + 
                                anglePush.ToString() + sep + 
                                angleWeight.ToString() + sep +
-                               inertia.ToString() + sep + 
-                               gearedDown.ToString()
+                               inertiaMachine.ToString() + sep + 
+                               gearedDown.ToString() + sep + 
+                               inertiaTotal.ToString() + sep + 
+                               extraWeightN.ToString() + sep + 
+                               extraWeightGrams.ToString() + sep +
+                               extraWeightLength.ToString()
                                ;
        }
 
@@ -1282,8 +1311,8 @@ public class EncoderConfiguration {
                        str_angleWeight = sep + "weight angle=" + angleWeight.ToString();
 
                string str_inertia = "";
-               if(inertia != -1)
-                       str_inertia = sep + "inertia=" + inertia.ToString();
+               if(has_inertia && inertiaTotal != -1)
+                       str_inertia = sep + "inertia total=" + inertiaTotal.ToString();
 
                string str_gearedDown = "";
                if(gearedDown != 1)     //1 is the default
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 7f84d2c..ada111a 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -39,8 +39,8 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.SpinButton spin_encoder_extra_weight;
        [Widget] Gtk.Label label_encoder_displaced_weight;
        [Widget] Gtk.Label label_encoder_1RM_percent;
-       [Widget] Gtk.Label label_encoder_im_machine;
        [Widget] Gtk.Label label_encoder_im_total;
+       [Widget] Gtk.SpinButton spin_encoder_im_weights_n;
 
        [Widget] Gtk.Label label_encoder_selected;      
        
@@ -372,14 +372,26 @@ public partial class ChronoJumpWindow
                
                encoderConfigurationCurrent = encoder_configuration_win.GetAcceptedValues();
                                
-               if(encoderConfigurationCurrent.has_inertia)
+               if(encoderConfigurationCurrent.has_inertia) {
                        notebook_encoder_capture_load.CurrentPage = 1;
-               else
+
+                       encoderConfigurationCurrent.extraWeightN = (int) spin_encoder_im_weights_n.Value; 
+                       encoderConfigurationCurrent.inertiaTotal = 
UtilEncoder.CalculeInertiaTotal(encoderConfigurationCurrent);
+                       label_encoder_im_total.Text = encoderConfigurationCurrent.inertiaTotal.ToString();
+               } else
                        notebook_encoder_capture_load.CurrentPage = 0;
 
                label_encoder_selected.Text = encoderConfigurationCurrent.code;
        }
        
+       void on_spin_encoder_im_weights_n_changed (object o, EventArgs args) {
+               encoderConfigurationCurrent.extraWeightN = (int) spin_encoder_im_weights_n.Value; 
+               encoderConfigurationCurrent.inertiaTotal = 
UtilEncoder.CalculeInertiaTotal(encoderConfigurationCurrent);
+               label_encoder_im_total.Text = encoderConfigurationCurrent.inertiaTotal.ToString();
+       }
+       
+
+       
        void on_encoder_configuration_win_capture_inertial_do (object o, EventArgs args) 
        {
                on_button_encoder_capture_calcule_im();
@@ -1274,8 +1286,12 @@ public partial class ChronoJumpWindow
                        
                                encoderConfigurationCurrent = eSQL.encoderConfiguration;
                        
-                               if(encoderConfigurationCurrent.has_inertia)
+                               if(encoderConfigurationCurrent.has_inertia) {
                                        notebook_encoder_capture_load.CurrentPage = 1;
+
+                                       spin_encoder_im_weights_n.Value = 
encoderConfigurationCurrent.extraWeightN;
+                                       label_encoder_im_total.Text = 
encoderConfigurationCurrent.inertiaTotal.ToString();
+                               }
                                else
                                        notebook_encoder_capture_load.CurrentPage = 0;
 
@@ -1299,7 +1315,7 @@ public partial class ChronoJumpWindow
                        encoderButtonsSensitive(encoderSensEnumStored);
                }
        }
-       
+
        protected void on_encoder_load_signal_row_edit (object o, EventArgs args) {
                LogB.Information("row edit at load signal");
                LogB.Information(genericWin.TreeviewSelectedUniqueID.ToString());
diff --git a/src/gui/encoderConfiguration.cs b/src/gui/encoderConfiguration.cs
index c76518e..16ae2a5 100644
--- a/src/gui/encoderConfiguration.cs
+++ b/src/gui/encoderConfiguration.cs
@@ -43,27 +43,29 @@ public class EncoderConfigurationWindow {
        [Widget] Gtk.Box hbox_angle_push;
        [Widget] Gtk.Box hbox_angle_weight;
        [Widget] Gtk.Box hbox_inertia;
-       [Widget] Gtk.Box hbox_inertia2;
+       [Widget] Gtk.Box hbox_inertia_mass;
+       [Widget] Gtk.Box hbox_inertia_length;
+       [Widget] Gtk.Box hbox_inertia_calcule;
 
        [Widget] Gtk.SpinButton spin_d;
        [Widget] Gtk.SpinButton spin_D;
        [Widget] Gtk.SpinButton spin_angle_push;
        [Widget] Gtk.SpinButton spin_angle_weight;
-       [Widget] Gtk.SpinButton spin_inertia;
+       [Widget] Gtk.SpinButton spin_inertia_machine;
+       [Widget] Gtk.SpinButton spin_inertia_mass; //mass of each of the extra load (weights)
+       [Widget] Gtk.SpinButton spin_inertia_length;
                
        [Widget] Gtk.Box vbox_select_encoder;
        [Widget] Gtk.VSeparator vseparator_im;
        [Widget] Gtk.Box vbox_calcule_im;
-       [Widget] Gtk.SpinButton spin_im_weight;
-       [Widget] Gtk.SpinButton spin_im_length;
-       //[Widget] Gtk.SpinButton spin_im_duration;
+       [Widget] Gtk.SpinButton spin_im_weight_calcule;
+       [Widget] Gtk.SpinButton spin_im_length_calcule;
+       //[Widget] Gtk.SpinButton spin_im_duration_calcule;
        [Widget] Gtk.Label label_im_result_disc;
        [Widget] Gtk.Label label_im_result_weights;
        [Widget] Gtk.Label label_im_result_total;
        [Widget] Gtk.Table table_im_machine_result;
        [Widget] Gtk.Box vbox_im_weights_and_total;
-       [Widget] Gtk.SpinButton spin_im_weights_n;
-       [Widget] Gtk.SpinButton spin_im_weights_weight;
        [Widget] Gtk.Table table_im_weights_and_total_result;
        [Widget] Gtk.Label label_im_feedback;
        [Widget] Gtk.Button button_encoder_capture_inertial_do;
@@ -117,7 +119,9 @@ public class EncoderConfigurationWindow {
 
                EncoderConfigurationWindowBox.initializeList(ec.type, ec.position);
                
-               EncoderConfigurationWindowBox.putValuesStoredPreviously(ec.d, ec.D, ec.anglePush, 
ec.angleWeight, ec.inertia);
+               EncoderConfigurationWindowBox.putValuesStoredPreviously(
+                               ec.d, ec.D, ec.anglePush, ec.angleWeight, 
+                               ec.inertiaMachine, ec.extraWeightGrams, ec.extraWeightLength);
        
                EncoderConfigurationWindowBox.encoder_configuration.Show ();
                return EncoderConfigurationWindowBox;
@@ -174,7 +178,9 @@ public class EncoderConfigurationWindow {
                hbox_angle_push.Visible = ec.has_angle_push;
                hbox_angle_weight.Visible = ec.has_angle_weight;
                hbox_inertia.Visible = ec.has_inertia;
-               hbox_inertia2.Visible = ec.has_inertia;
+               hbox_inertia_mass.Visible = ec.has_inertia;
+               hbox_inertia_length.Visible = ec.has_inertia;
+               hbox_inertia_calcule.Visible = ec.has_inertia;
                
                label_count.Text = (listCurrent + 1).ToString() + " / " + list.Count.ToString();
        
@@ -183,7 +189,9 @@ public class EncoderConfigurationWindow {
                        on_button_encoder_capture_inertial_show_clicked (new object(), new EventArgs());
        }
        
-       private void putValuesStoredPreviously(double d, double D, int anglePush, int angleWeight, int 
inertia) {
+       private void putValuesStoredPreviously(double d, double D, int anglePush, int angleWeight, 
+                       int inertia, int extraWeightGrams, double extraWeightLength) 
+       {
                if(d != -1)
                        spin_d.Value = d;
                if(D != -1)
@@ -193,7 +201,10 @@ public class EncoderConfigurationWindow {
                if(angleWeight != -1)
                        spin_angle_weight.Value = angleWeight;
                if(inertia != -1)
-                       spin_inertia.Value = inertia;
+                       spin_inertia_machine.Value = inertia;
+                       
+               spin_inertia_mass.Value = extraWeightGrams;
+               spin_inertia_length.Value = extraWeightLength;
        }
        
        /*
@@ -210,7 +221,7 @@ public class EncoderConfigurationWindow {
                ec.D = -1;
                ec.anglePush = -1;
                ec.angleWeight = -1;
-               ec.inertia = -1;
+               ec.inertiaMachine = -1;
                
                if(ec.has_d)
                        ec.d = (double) spin_d.Value; 
@@ -224,8 +235,12 @@ public class EncoderConfigurationWindow {
                if(ec.has_angle_weight)
                        ec.angleWeight = (int) spin_angle_weight.Value; 
 
-               if(ec.has_inertia)
-                       ec.inertia = (int) spin_inertia.Value; 
+               if(ec.has_inertia) {
+                       ec.inertiaMachine = (int) spin_inertia_machine.Value; 
+                       ec.inertiaTotal = (int) spin_inertia_machine.Value; 
+                       ec.extraWeightGrams = (int) spin_inertia_mass.Value;
+                       ec.extraWeightLength = (double) spin_inertia_length.Value;
+               }
 
                return ec;
        }
@@ -285,12 +300,12 @@ public class EncoderConfigurationWindow {
                if(imResult == 0) {
                        label_im_feedback.Text = "<b>" + message + "</b>";
                        label_im_feedback.UseMarkup = true; 
-                       spin_inertia.Value = imResult;
+                       spin_inertia_machine.Value = imResult;
                } else {
                        //label_im_result_disc.Text = Util.TrimDecimals(imResult, 2);
                        //as int now
                        label_im_result_disc.Text = Convert.ToInt32(imResult).ToString();
-                       spin_inertia.Value = imResult;
+                       spin_inertia_machine.Value = imResult;
                        label_im_feedback.Text = "";
 
                        table_im_machine_result.Visible = true;
@@ -311,22 +326,6 @@ public class EncoderConfigurationWindow {
        }
        */
        
-       void on_button_encoder_calcule_inertial_weights_clicked (object o, EventArgs args) {
-               int n = Convert.ToInt32(spin_im_weights_n.Value);
-               double weightInKg = spin_im_weights_weight.Value / 1000.0;
-               double length = spin_im_length.Value;
-
-               //IM of all the weights = n * (weight * length^2) Kg*cm^2
-               double im_weights = n * ( weightInKg * Math.Pow(length,2) );
-               
-               label_im_result_weights.Text = Util.TrimDecimals(im_weights, 2);
-               double im_total = Convert.ToDouble(label_im_result_disc.Text) + im_weights;
-               label_im_result_total.Text = Util.TrimDecimals(im_total, 2);
-               spin_inertia.Value = im_total;
-               
-               table_im_weights_and_total_result.Visible = true;
-       }
-               
        private void on_button_cancel_clicked (object o, EventArgs args)
        {
                EncoderConfigurationWindowBox.encoder_configuration.Hide();
@@ -365,15 +364,15 @@ public class EncoderConfigurationWindow {
        
        
        public double Spin_im_weight {
-               get { return spin_im_weight.Value; }
+               get { return spin_im_weight_calcule.Value; }
        }
        
        public double Spin_im_length {
-               get { return spin_im_length.Value; }
+               get { return spin_im_length_calcule.Value; }
        }
        
        public int Spin_im_duration {
-               //get { return (int) spin_im_duration.Value; }
+               //get { return (int) spin_im_duration_calcule.Value; }
                //
                //do 60 seconds and it will end automatically when ended
                get { return 60; }
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 8cee3fe..35d67b3 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -755,5 +755,17 @@ public class UtilEncoder
                return list;
        }
 
+       public static int CalculeInertiaTotal (EncoderConfiguration econf) {
+               //LogB.Debug(econf.ToString(":",false,false));
+               int n = econf.extraWeightN;
+               double weightInKg = econf.extraWeightGrams / 1000.0;
+               double length = econf.extraWeightLength;
+
+               //IM of all the weights = n * (weight * length^2) Kg*cm^2
+               int im_weights = Convert.ToInt32(n * ( weightInKg * Math.Pow(length,2) ));
+
+               return econf.inertiaMachine + im_weights;
+       }
+               
 
 }


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