[chronojump] encoderRhythm with two pulsebars
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoderRhythm with two pulsebars
- Date: Fri, 19 Jan 2018 11:22:26 +0000 (UTC)
commit ff92e247166c10b111a00fe45c980d044224dcf7
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jan 19 12:21:53 2018 +0100
encoderRhythm with two pulsebars
glade/app1.glade | 1 +
src/encoder.cs | 92 ++++++++++++++++++++++++++++++++--------------------
src/gui/encoder.cs | 16 +++------
3 files changed, 64 insertions(+), 45 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 9af2004..1a8d6ab 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -16917,6 +16917,7 @@ Concentric</property>
<child>
<widget class="GtkProgressBar"
id="encoder_pulsebar_rhythm_wait">
<property name="width_request">120</property>
+ <property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="pulse_step">0.050000000000000003</property>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index e4535f8..dcc9467 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -2114,7 +2114,7 @@ public class EncoderRhythmObject
public EncoderRhythmObject()
{
- //default 0.5 seconds ecc, 0.5 con, 5 repetitions and rest 3 seconds
+ //default values
EccSeconds = 0.5;
ConSeconds = 0.5;
RestRepsSeconds = 1;
@@ -2125,21 +2125,23 @@ public class EncoderRhythmObject
}
public class EncoderRhythm
{
- public string Text;
- public bool ShowRestingSpinner;
+ public string TextRepetition;
+ public string TextRest;
private DateTime lastRepetitionDT;
private EncoderRhythmObject ero;
private int nreps;
- //private bool restingBetweenClustersFlag; //to manage lastRepetitionDT when rest finished
private bool restClusterTimeEndedFlag;
+ private double fractionRepetition;
+ private double fractionRest;
+
//constructor
public EncoderRhythm()
{
- Text = "";
- ShowRestingSpinner = false;
+ TextRepetition = "";
+ TextRest = "";
lastRepetitionDT = DateTime.MinValue;
ero = new EncoderRhythmObject();
@@ -2181,56 +2183,76 @@ public class EncoderRhythm
}
//useful for fraction of the repetition and the rest time
- public double GetFraction()
+ public void CalculateFractionsAndText()
{
- double fraction = 0;
+ //double fraction = 0;
TimeSpan span = DateTime.Now - lastRepetitionDT;
double totalSeconds = span.TotalSeconds;
if(checkIfRestingBetweenClusters(totalSeconds))
- fraction = GetRestingFraction(totalSeconds);
+ calculateClusterRestingFraction(totalSeconds);
else
- fraction = GetRepetitionFraction(totalSeconds);
-
- if(fraction < 0)
- fraction = 0;
- else if(fraction > 1)
- fraction = 1;
-
- return fraction;
+ calculateRepetitionFraction(totalSeconds);
}
- public double GetRepetitionFraction(double totalSeconds)
+ //reptition has an initial rest phase
+ private void calculateRepetitionFraction(double totalSeconds)
{
if(totalSeconds < ero.RestRepsSeconds)
{
- Text = "Resting " +
+ TextRepetition = "";
+ TextRest = "Resting " +
Util.TrimDecimals((ero.RestRepsSeconds - totalSeconds),1) +
" s";
- ShowRestingSpinner = true;
- return 0;
- //return totalSeconds / ero.RestRepsSeconds;
+ fractionRepetition = 0;
+ fractionRest = totalSeconds / ero.RestRepsSeconds;
+ return;
}
else if((totalSeconds - ero.RestRepsSeconds) < ero.EccSeconds)
{
- Text = "Excentric";
- ShowRestingSpinner = false;
- return 1 - ((totalSeconds - ero.RestRepsSeconds) / ero.EccSeconds);
+ TextRepetition = "Excentric";
+ TextRest = "";
+ fractionRepetition = 1 - ((totalSeconds - ero.RestRepsSeconds) / ero.EccSeconds);
+ fractionRest = 0;
+ return;
}
else {
- Text = "Concentric";
- ShowRestingSpinner = false;
- return (totalSeconds - (ero.RestRepsSeconds + ero.EccSeconds)) / ero.ConSeconds;
+ TextRepetition = "Concentric";
+ TextRest = "";
+ fractionRepetition = (totalSeconds - (ero.RestRepsSeconds + ero.EccSeconds)) /
ero.ConSeconds;
+ fractionRest = 0;
+ return;
}
}
- public double GetRestingFraction(double totalSeconds)
+ private void calculateClusterRestingFraction(double totalSeconds)
{
- ShowRestingSpinner = true;
- Text = "Resting " +
- Convert.ToInt32((ero.RestClustersSeconds - totalSeconds)).ToString() +
- " s";
- //return totalSeconds / ero.RestClustersSeconds;
- return 0;
+ TextRepetition = "";
+ TextRest = "Resting " + Convert.ToInt32((ero.RestClustersSeconds - totalSeconds)).ToString()
+ " s";
+ fractionRepetition = 0;
+ fractionRest = totalSeconds / ero.RestClustersSeconds;
+ return;
+ }
+
+ public double FractionRepetition
+ {
+ get {
+ if(fractionRepetition < 0)
+ return 0;
+ else if(fractionRepetition > 1)
+ return 1;
+ return fractionRepetition;
+ }
+ }
+
+ public double FractionRest
+ {
+ get {
+ if(fractionRest < 0)
+ return 0;
+ else if(fractionRest > 1)
+ return 1;
+ return fractionRest;
+ }
}
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c70564a..2abfeef 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -6025,17 +6025,13 @@ public partial class ChronoJumpWindow
return;
}
- double fraction = encoderRhythm.GetFraction();
- encoder_pulsebar_rhythm_eccon.Fraction = fraction;
- encoder_pulsebar_rhythm_eccon.Text = encoderRhythm.Text;
+ encoderRhythm.CalculateFractionsAndText();
+ encoder_pulsebar_rhythm_eccon.Fraction = encoderRhythm.FractionRepetition;
+ encoder_pulsebar_rhythm_eccon.Text = encoderRhythm.TextRepetition;
+ encoder_pulsebar_rhythm_wait.Fraction = encoderRhythm.FractionRest;
+ encoder_pulsebar_rhythm_wait.Text = encoderRhythm.TextRest;
- //image_encoder_rhythm_wait.Visible = encoderRhythm.ShowRestingSpinner;
- /*
- if(encoderRhythm.ShowRestingSpinner)
- spinner_encoder_rhythm_wait.Spin();
- */
-
- if(fraction >= 1)
+ if(encoderRhythm.FractionRepetition >= 1)
image_encoder_rhythm_alert.Visible = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]