[chronojump] Encdoder inertial: Fixed labels ecc/con



commit a9acf5a92e422b2ca3666ceee245446d39ff8cf2
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Nov 5 11:21:49 2019 +0100

    Encdoder inertial: Fixed labels ecc/con
    
    before only changed from con to ecc at calibration point
    now it changes ok also from ecc to con

 src/encoderCaptureInertialBG.cs | 43 +++++++++++++++++++++++++++++++++++++++++
 src/gui/encoder.cs              | 18 +++++++++++++++--
 2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/src/encoderCaptureInertialBG.cs b/src/encoderCaptureInertialBG.cs
index 7a376445..f762a18f 100644
--- a/src/encoderCaptureInertialBG.cs
+++ b/src/encoderCaptureInertialBG.cs
@@ -27,7 +27,16 @@ using System.Collections.Generic; //List<T>
  */
 public class EncoderCaptureInertialBackground
 {
+       /*
+        * angleNow is useful also for showing "ecc" / "con" on gui, there needed to change  from con to ecc
+        * but for changing from ecc to con we need angleMaxAbsoluteThisPhase
+        */
        private int angleNow;
+       private int angleMaxAbsoluteThisPhase;
+
+       public enum Phases { ECC, CON, ATCALIBRATEDPOINT }      //ATCALIBRATEDPOINT: Do not diplay ecc or con 
labels
+       public Phases Phase;
+
        private bool finishBG;
        public bool StoreData;
        private SerialPort sp;
@@ -37,6 +46,7 @@ public class EncoderCaptureInertialBackground
        public EncoderCaptureInertialBackground(string port)
        {
                angleNow = 0;
+               angleMaxAbsoluteThisPhase = 0;
                finishBG = false;
                StoreData = false;
                EncoderCaptureInertialBackgroundStatic.Start();
@@ -77,6 +87,39 @@ public class EncoderCaptureInertialBackground
                        byteReaded = convertByte(byteReaded);
                        angleNow += byteReaded;
 
+                       //LogB.Information(string.Format("PRE: ANGLE: {0}, MAXABS: {1}, PHASE: {2}", 
angleNow, angleMaxAbsoluteThisPhase, Phase));
+                       if(angleNow == 0)
+                               Phase = Phases.ATCALIBRATEDPOINT;
+                       else if(angleNow == angleMaxAbsoluteThisPhase)
+                       {
+                               /*
+                                * Do not do this
+                                * Phase = Phases.NOTMOVED;
+                                * because if we are at calibration point, then move 1 mm to ecc. (but by 
threads maybe is not shown on gui/encoder.cs)
+                                * so then if phase is NOTMOVED, will continue showing the ATCALIBRATEDPOINT. 
So if speed is low maybe all the time both labels are not shown
+                                * better do not do nothing and the Phase will be the same than before, in 
that case will be ECC
+                                */
+                       }
+                       else if(angleNow > 0)
+                       {
+                               if(angleNow > angleMaxAbsoluteThisPhase)
+                               {
+                                       Phase = Phases.ECC;
+                                       angleMaxAbsoluteThisPhase = angleNow;
+                               } else //if(angleNow < angleMaxAbsoluteThisPhase)
+                                       Phase = Phases.CON;
+                       }
+                       else //if(angleNow < 0)
+                       {
+                               if(angleNow < angleMaxAbsoluteThisPhase)
+                               {
+                                       Phase = Phases.ECC;
+                                       angleMaxAbsoluteThisPhase = angleNow;
+                               } else //if(angleNow > angleMaxAbsoluteThisPhase)
+                                       Phase = Phases.CON;
+                       }
+                       //LogB.Information(string.Format("POST: ANGLE: {0}, MAXABS: {1}, PHASE: {2}", 
angleNow, angleMaxAbsoluteThisPhase, Phase));
+
                        if(StoreData)
                                EncoderCaptureInertialBackgroundStatic.ListCaptured.Add((short) byteReaded);
                        //LogB.Information("angleNow = " + angleNow.ToString());
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a660d6c9..94478f3f 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5890,13 +5890,27 @@ public partial class ChronoJumpWindow
                }
 
                int newValue = eCaptureInertialBG.AngleNow;
-               if(newValue > 0) {
+               if(eCaptureInertialBG.Phase == EncoderCaptureInertialBackground.Phases.ATCALIBRATEDPOINT)
+               {
+                       label_encoder_capture_inertial_ecc.Sensitive = false;
+                       label_encoder_capture_inertial_con.Sensitive = false;
+               }
+               else if(eCaptureInertialBG.Phase == EncoderCaptureInertialBackground.Phases.CON)
+               {
                        label_encoder_capture_inertial_ecc.Sensitive = false;
                        label_encoder_capture_inertial_con.Sensitive = true;
-               } else {
+               }
+               else if(eCaptureInertialBG.Phase == EncoderCaptureInertialBackground.Phases.ECC)
+               {
                        label_encoder_capture_inertial_ecc.Sensitive = true;
                        label_encoder_capture_inertial_con.Sensitive = false;
                }
+               /*
+               else if(eCaptureInertialBG.Phase == EncoderCaptureInertialBackground.Phases.NOTMOVED)
+               {
+                       //do not change nothing, show labels like before
+               }
+               */
 
                //resize vscale if needed
                //0 is at the graphical top. abs(+-100) is on the bottom, but is called adjustment Upper


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