[chronojump] EncoderRhythm rest not for first repetition in cluster



commit ba18051f9ac9aacd989ba20a50a14a4672c7d8e4
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jan 19 12:35:32 2018 +0100

    EncoderRhythm rest not for first repetition in cluster

 src/encoder.cs |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index dcc9467..f90b4a7 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -2122,6 +2122,11 @@ public class EncoderRhythmObject
                RepsCluster = 5;
                RestClustersSeconds = 6;
        }
+
+       public bool UseClusters()
+       {
+               return (RepsCluster > 0);
+       }
 }
 public class EncoderRhythm
 {
@@ -2154,6 +2159,11 @@ public class EncoderRhythm
                return (lastRepetitionDT > DateTime.MinValue);
        }
 
+       private bool firstInCluster()
+       {
+               return (nreps % ero.RepsCluster == 0);
+       }
+
        public void SetLastRepetitionDT()
        {
                lastRepetitionDT = DateTime.Now;
@@ -2198,28 +2208,33 @@ public class EncoderRhythm
        //reptition has an initial rest phase
        private void calculateRepetitionFraction(double totalSeconds)
        {
-               if(totalSeconds < ero.RestRepsSeconds)
+               //first repetition in cluster will not have rest
+               double restRepsSeconds = ero.RestRepsSeconds;
+               if(ero.UseClusters() && firstInCluster())
+                       restRepsSeconds = 0;
+
+               if(totalSeconds < restRepsSeconds)
                {
                        TextRepetition = "";
                        TextRest = "Resting " +
-                               Util.TrimDecimals((ero.RestRepsSeconds - totalSeconds),1) +
+                               Util.TrimDecimals((restRepsSeconds - totalSeconds),1) +
                                " s";
                        fractionRepetition = 0;
-                       fractionRest = totalSeconds / ero.RestRepsSeconds;
+                       fractionRest = totalSeconds / restRepsSeconds;
                        return;
                }
-               else if((totalSeconds - ero.RestRepsSeconds) < ero.EccSeconds)
+               else if((totalSeconds - restRepsSeconds) < ero.EccSeconds)
                {
                        TextRepetition = "Excentric";
                        TextRest = "";
-                       fractionRepetition = 1 - ((totalSeconds - ero.RestRepsSeconds) / ero.EccSeconds);
+                       fractionRepetition = 1 - ((totalSeconds - restRepsSeconds) / ero.EccSeconds);
                        fractionRest = 0;
                        return;
                }
                else {
                        TextRepetition = "Concentric";
                        TextRest = "";
-                       fractionRepetition = (totalSeconds - (ero.RestRepsSeconds + ero.EccSeconds)) / 
ero.ConSeconds;
+                       fractionRepetition = (totalSeconds - (restRepsSeconds + ero.EccSeconds)) / 
ero.ConSeconds;
                        fractionRest = 0;
                        return;
                }


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