[chronojump] EncoderRhythm also for inertial



commit c27ad0556ce91a776767d51dfa43aa9d78abb951
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 30 12:02:53 2018 +0100

    EncoderRhythm also for inertial

 src/encoderCapture.cs |   23 +++++++++++------------
 src/encoderRhythm.cs  |    4 +++-
 src/gui/encoder.cs    |   18 +++++++++---------
 3 files changed, 23 insertions(+), 22 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index c98c199..1d16a9c 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -47,6 +47,8 @@ public abstract class EncoderCapture
        public bool RhythmEcconUp;
        private Gtk.Button fakeButtonRhythm;
 
+       protected bool gravitatoryOrInertial; //currently only used for encoderRhythm
+
        // ---- protected stuff ----
        protected int widthG;
        protected int heightG;
@@ -586,22 +588,15 @@ public abstract class EncoderCapture
                                                 */
                                                if( useRhythm && (shouldSendCurveBool || (eccon == "c" && ! 
ecc.up)) )
                                                {
-                                                       LogB.Information("SSC: " + ecc.up.ToString());
                                                        RhythmEcconUp = ecc.up;
 
-                                                       if(rhythmRepsOrPhases)
-                                                       {
-                                                               if(eccon == "c" && ecc.up)
-                                                               {
-                                                                       RhythmNRep ++;
-                                                                       fakeButtonRhythm.Click();
-                                                               }
-                                                       } else {
-                                                               if( (eccon == "c" && ecc.up) || (eccon != "c" 
&& ! ecc.up))
-                                                                       RhythmNRep ++;
+                                                       //on gravitatory phase ends at up, on inertial the 
opposite
+                                                       if(gravitatoryOrInertial == ecc.up)
+                                                               RhythmNRep ++;
 
+                                                       //if phases always send the phase. On reps only when 
change rep
+                                                       if(! rhythmRepsOrPhases || gravitatoryOrInertial == 
ecc.up)
                                                                fakeButtonRhythm.Click();
-                                                       }
                                                }
                                        }
 
@@ -916,6 +911,8 @@ public class EncoderCaptureGravitatory : EncoderCapture
                
                //just a default value, unused until a curve has been accepted
                lastDirectionStoredIsUp = true;
+
+               gravitatoryOrInertial = true;
        }
 }
 
@@ -929,6 +926,8 @@ public class EncoderCaptureInertial : EncoderCapture
        protected override void initSpecific()
        {
                realHeightG = 2 * 5000 ; //5 meters up / 5 meters down
+
+               gravitatoryOrInertial = false;
        }
 
        public override void InitCalibrated(int angleNow)
diff --git a/src/encoderRhythm.cs b/src/encoderRhythm.cs
index c55619c..30412b6 100644
--- a/src/encoderRhythm.cs
+++ b/src/encoderRhythm.cs
@@ -114,9 +114,11 @@ public class EncoderRhythmExecute
 
 
        //constructor
-       public EncoderRhythmExecute(EncoderRhythm encoderRhythm)
+       public EncoderRhythmExecute(EncoderRhythm encoderRhythm, bool eccon_ec)
        {
                this.encoderRhythm = encoderRhythm;
+               this.eccon_ec = eccon_ec;
+
                initialize();
        }
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index faaa7d5..7c7fa18 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5289,7 +5289,7 @@ public partial class ChronoJumpWindow
                                                (encoderConfigurationCurrent.has_inertia && 
eCaptureInertialBG != null),
                                                configChronojump.EncoderCaptureShowOnlyBars,
                                                currentSession.Name == Constants.SessionSimulatedName && 
testsActive,
-                                               (encoderRhythm.Active && ! 
encoderConfigurationCurrent.has_inertia), //rhythm only on gravitory now
+                                               (encoderRhythm.Active),
                                                encoderRhythm.RepsOrPhases
                                                );
 
@@ -5302,8 +5302,11 @@ public partial class ChronoJumpWindow
                                                eCaptureInertialBG.SimulatedReset();
                                }
 
-                               //initialize DateTime for rhythm
-                               encoderRhythmExecute = new EncoderRhythmExecute(encoderRhythm);
+                               /*
+                                * initialize DateTime for rhythm
+                                * also variable eccon_ec gravitatory mode is e -> c, inertial is c -> e
+                                */
+                               encoderRhythmExecute = new EncoderRhythmExecute(encoderRhythm, ! 
encoderConfigurationCurrent.has_inertia);
                                image_encoder_rhythm_alert.Visible = false;
 
                                //triggers only work on gravitatory, concentric
@@ -5314,16 +5317,13 @@ public partial class ChronoJumpWindow
                                {
                                        reallyCutByTriggers = preferences.encoderCaptureCutByTriggers;
                                        notebook_encoder_signal_comment_rhythm_and_triggers.Page = 2;
-                               } else if(encoderRhythm.Active && ! encoderConfigurationCurrent.has_inertia) 
//rhythm only on gravitory now
+                               } else if(encoderRhythm.Active)
                                {
                                        notebook_encoder_signal_comment_rhythm_and_triggers.Page = 1;
                                        image_encoder_rhythm_rest.Visible = encoderRhythm.UseRest();
 
-                                       if(encoderRhythm.Active)
-                                       {
-                                               eCapture.FakeButtonRhythm.Clicked -= new 
EventHandler(on_encoder_rhythm_changed);
-                                               eCapture.FakeButtonRhythm.Clicked += new 
EventHandler(on_encoder_rhythm_changed);
-                                       }
+                                       eCapture.FakeButtonRhythm.Clicked -= new 
EventHandler(on_encoder_rhythm_changed);
+                                       eCapture.FakeButtonRhythm.Clicked += new 
EventHandler(on_encoder_rhythm_changed);
                                }
 
                                encoderRProcCapture.CutByTriggers = reallyCutByTriggers;


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