[chronojump] DB:1.56 EncoderRhythm gravitatory restAfterEcc boolean
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB:1.56 EncoderRhythm gravitatory restAfterEcc boolean
- Date: Tue, 13 Feb 2018 12:35:14 +0000 (UTC)
commit a1a15ca1fbb485bb4b0e2fc61ce2deb0b382351c
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Feb 13 13:34:42 2018 +0100
DB:1.56 EncoderRhythm gravitatory restAfterEcc boolean
glade/repetitive_conditions.glade | 81 +++++++++++++++++++++++++++++++++++-
src/encoderRhythm.cs | 37 +++++++++++++----
src/gui/chronojump.cs | 2 +-
src/gui/repetitiveConditions.cs | 18 ++++++--
src/preferences.cs | 9 ++++
src/sqlite/main.cs | 12 +++++-
src/sqlite/preferences.cs | 4 ++
7 files changed, 145 insertions(+), 18 deletions(-)
---
diff --git a/glade/repetitive_conditions.glade b/glade/repetitive_conditions.glade
index d305e73..5fa28e9 100644
--- a/glade/repetitive_conditions.glade
+++ b/glade/repetitive_conditions.glade
@@ -3947,6 +3947,81 @@
</packing>
</child>
<child>
+ <widget class="GtkAlignment" id="alignment26">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">30</property>
+ <child>
+ <widget class="GtkVBox" id="vbox_rhythm_rest_after">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label54">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">On encoder gravitatory
rest is done ...</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="hbox_rhythm_rest_after">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkRadioButton" id="radio_rest_after_ecc">
+ <property name="label" translatable="yes">after
eccentric</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_rest_after_con">
+ <property name="label" translatable="yes">after
concentric</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radio_rest_after_ecc</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</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>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkAlignment" id="alignment23">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -3965,7 +4040,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -4101,7 +4176,7 @@ when there's no change in the encoder during this time:
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -4135,7 +4210,7 @@ when there's no change in the encoder during this time:
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="position">6</property>
</packing>
</child>
</widget>
diff --git a/src/encoderRhythm.cs b/src/encoderRhythm.cs
index 30412b6..1f2c620 100644
--- a/src/encoderRhythm.cs
+++ b/src/encoderRhythm.cs
@@ -29,6 +29,7 @@ public class EncoderRhythm
public double EccSeconds;
public double ConSeconds;
public double RestRepsSeconds; //rest between repetitions
+ public bool RestAfterEcc; //rest after eccentric or concentric. Only applies to gravitatory
//cluster stuff
public int RepsCluster;
@@ -45,13 +46,15 @@ public class EncoderRhythm
ConSeconds = 1;
RestRepsSeconds = 0;
+ RestAfterEcc = true;
RepsCluster = 1; //1 is default, minimum value and means "no use clusters"
RestClustersSeconds = 6;
}
public EncoderRhythm(bool active, bool repsOrPhases,
- double repSeconds, double eccSeconds, double conSeconds, double restRepsSeconds,
+ double repSeconds, double eccSeconds, double conSeconds,
+ double restRepsSeconds, bool restAfterEcc,
int repsCluster, double restClustersSeconds)
{
Active = active;
@@ -59,7 +62,9 @@ public class EncoderRhythm
RepSeconds = repSeconds;
EccSeconds = eccSeconds;
ConSeconds = conSeconds;
+
RestRepsSeconds = restRepsSeconds;
+ RestAfterEcc = restAfterEcc;
RepsCluster = repsCluster;
RestClustersSeconds = restClustersSeconds;
@@ -110,14 +115,20 @@ public class EncoderRhythmExecute
private double fractionRest;
//true is for con or ecc-con (gravitatory, always end on "con"), false is for con-ecc (inertial)
- private bool eccon_ec = true;
+ //private bool eccon_ec = true;
+ private bool gravitatory = true;
+ /*
+ * on inertial rest is after ecc.
+ * on gravitatory rest can be after ecc or con (see RestAfterEcc)
+ */
//constructor
- public EncoderRhythmExecute(EncoderRhythm encoderRhythm, bool eccon_ec)
+ public EncoderRhythmExecute(EncoderRhythm encoderRhythm, bool gravitatory)
{
this.encoderRhythm = encoderRhythm;
- this.eccon_ec = eccon_ec;
+ //this.eccon_ec = eccon_ec;
+ this.gravitatory = gravitatory;
initialize();
}
@@ -155,6 +166,13 @@ public class EncoderRhythmExecute
lastIsUp = up;
}
+ private bool restBetweenRepetitions()
+ {
+ return
+ ( gravitatory && lastIsUp != encoderRhythm.RestAfterEcc ) ||
+ ( ! gravitatory && ! lastIsUp );
+ }
+
private bool checkIfRestingBetweenClusters(double totalSeconds)
{
if(restClusterTimeEndedFlag)
@@ -165,7 +183,8 @@ public class EncoderRhythmExecute
* mod of repetitions by RepsCluster == 0 AND
* if repetition ends on c, whe have done c (or if it ends on e, we have done e)
*/
- if(nreps > 0 && nreps % encoderRhythm.RepsCluster == 0 && lastIsUp == eccon_ec)
+ //if(nreps > 0 && nreps % encoderRhythm.RepsCluster == 0 && lastIsUp == eccon_ec)
+ if(nreps > 0 && nreps % encoderRhythm.RepsCluster == 0 && restBetweenRepetitions())
{
if(totalSeconds < encoderRhythm.RestClustersSeconds)
return true;
@@ -206,7 +225,8 @@ public class EncoderRhythmExecute
* we ended excentric and it's con-ecc) && totalSeconds < restRepsSeconds)
* then there's a rest between repetitions
*/
- if(lastIsUp == eccon_ec && totalSeconds < restRepsSeconds)
+ //if(lastIsUp == eccon_ec && totalSeconds < restRepsSeconds)
+ if (totalSeconds < restRepsSeconds && restBetweenRepetitions())
{
TextRepetition = "";
TextRest = "Resting " +
@@ -222,9 +242,10 @@ public class EncoderRhythmExecute
/*
* if we ended con and repetition ends at con, then substract restRepsSeconds to totalSeconds
to calculate fraction
- * als when we done ecc and repetition ends at ecc
+ * also when we done ecc and repetition ends at ecc
*/
- if(restRepsSeconds > 0 && lastIsUp == eccon_ec)
+ //if(restRepsSeconds > 0 && lastIsUp == eccon_ec)
+ if( restRepsSeconds > 0 && restBetweenRepetitions())
totalSeconds -= restRepsSeconds;
if(encoderRhythm.RepsOrPhases)
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index c8400e2..f824bd6 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -805,7 +805,7 @@ public partial class ChronoJumpWindow
preferences.encoderRhythmActive, preferences.encoderRhythmRepsOrPhases,
preferences.encoderRhythmRepSeconds,
preferences.encoderRhythmEccSeconds, preferences.encoderRhythmConSeconds,
- preferences.encoderRhythmRestRepsSeconds,
+ preferences.encoderRhythmRestRepsSeconds,
preferences.encoderRhythmRestAfterEcc,
preferences.encoderRhythmRepsCluster,
preferences.encoderRhythmRestClustersSeconds);
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index 8a05211..b0f1a98 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -165,6 +165,8 @@ public class RepetitiveConditionsWindow
[Widget] Gtk.SpinButton spin_rhythm_ecc;
[Widget] Gtk.SpinButton spin_rhythm_con;
[Widget] Gtk.SpinButton spin_rhythm_rest_reps;
+ [Widget] Gtk.VBox vbox_rhythm_rest_after;
+ [Widget] Gtk.RadioButton radio_rest_after_ecc;
[Widget] Gtk.SpinButton spin_rhythm_reps_cluster;
[Widget] Gtk.SpinButton spin_rhythm_rest_clusters;
@@ -610,10 +612,13 @@ public class RepetitiveConditionsWindow
private void on_radio_rhythm_together_toggled (object o, EventArgs args)
{
- if(radio_rhythm_together.Active)
+ if(radio_rhythm_together.Active) {
notebook_duration_repetition.CurrentPage = 0;
- else
+ vbox_rhythm_rest_after.Visible = false;
+ } else {
notebook_duration_repetition.CurrentPage = 1;
+ vbox_rhythm_rest_after.Visible = true;
+ }
}
private void on_check_rhythm_use_clusters_toggled (object o, EventArgs args)
@@ -636,10 +641,13 @@ public class RepetitiveConditionsWindow
{
check_rhythm_active.Active = encoderRhythm.Active;
- if(encoderRhythm.RepsOrPhases)
+ if(encoderRhythm.RepsOrPhases) {
radio_rhythm_together.Active = true;
- else
+ vbox_rhythm_rest_after.Visible = false;
+ } else {
radio_rhythm_separated.Active = true;
+ vbox_rhythm_rest_after.Visible = true;
+ }
spin_rhythm_rep.Value = encoderRhythm.RepSeconds;
spin_rhythm_ecc.Value = encoderRhythm.EccSeconds;
@@ -673,7 +681,7 @@ public class RepetitiveConditionsWindow
return new EncoderRhythm(
check_rhythm_active.Active, radio_rhythm_together.Active,
spin_rhythm_rep.Value, spin_rhythm_ecc.Value, spin_rhythm_con.Value,
- spin_rhythm_rest_reps.Value,
+ spin_rhythm_rest_reps.Value, radio_rest_after_ecc.Active,
reps_cluster, spin_rhythm_rest_clusters.Value);
}
diff --git a/src/preferences.cs b/src/preferences.cs
index 69e209f..f1f5daf 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -105,6 +105,7 @@ public class Preferences
public double encoderRhythmEccSeconds;
public double encoderRhythmConSeconds;
public double encoderRhythmRestRepsSeconds;
+ public bool encoderRhythmRestAfterEcc;
public int encoderRhythmRepsCluster;
public double encoderRhythmRestClustersSeconds;
@@ -175,6 +176,7 @@ public class Preferences
encoderRhythmEccSeconds != er.EccSeconds ||
encoderRhythmConSeconds != er.ConSeconds ||
encoderRhythmRestRepsSeconds != er.RestRepsSeconds ||
+ encoderRhythmRestAfterEcc != er.RestAfterEcc ||
encoderRhythmRepsCluster != er.RepsCluster ||
encoderRhythmRestClustersSeconds != er.RestClustersSeconds
)
@@ -224,6 +226,13 @@ public class Preferences
Util.ConvertToPoint(er.RestRepsSeconds), true); //double to point
}
+ if(encoderRhythmRestAfterEcc != er.RestAfterEcc)
+ {
+ encoderRhythmRestAfterEcc = er.RestAfterEcc;
+ SqlitePreferences.Update(SqlitePreferences.EncoderRhythmRestAfterEccStr,
+ er.RestAfterEcc.ToString(), true); //bool
+ }
+
if(encoderRhythmRepsCluster != er.RepsCluster)
{
encoderRhythmRepsCluster = er.RepsCluster;
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index aa7c5b6..31bb8e2 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -125,7 +125,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.55";
+ static string lastChronojumpDatabaseVersion = "1.56";
public Sqlite() {
}
@@ -2329,6 +2329,15 @@ class Sqlite
currentVersion = updateVersion("1.55");
}
+ if(currentVersion == "1.55")
+ {
+ LogB.SQL("Added encoder rhythm restAfterEcc");
+
+ SqlitePreferences.Insert (SqlitePreferences.EncoderRhythmRestAfterEccStr,
"True");
+
+ currentVersion = updateVersion("1.56");
+ }
+
@@ -2512,6 +2521,7 @@ class Sqlite
SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);
//changes [from - to - desc]
+ //1.55 - 1.56 Converted DB to 1.56 Added encoder rhythm restAfterEcc
//1.54 - 1.55 Converted DB to 1.55 Added preferences: personPhoto
//1.53 - 1.54 Converted DB to 1.54 Added encoderRhythm variables: repOrPhases, repSeconds
//1.52 - 1.53 Converted DB to 1.53 Added encoderRhtyhm active variable
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 0ee3add..de31405 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -48,6 +48,7 @@ class SqlitePreferences : Sqlite
public const string EncoderRhythmEccSecondsStr = "encoderRhythmEccSeconds";
public const string EncoderRhythmConSecondsStr = "encoderRhythmConSeconds";
public const string EncoderRhythmRestRepsSecondsStr = "encoderRhythmRestRepsSeconds";
+ public const string EncoderRhythmRestAfterEccStr = "encoderRhythmRestAfterEcc";
public const string EncoderRhythmRepsClusterStr = "encoderRhythmRepsCluster";
public const string EncoderRhythmRestClustersSecondsStr = "encoderRhythmRestClustersSeconds";
@@ -163,6 +164,7 @@ class SqlitePreferences : Sqlite
Insert (EncoderRhythmEccSecondsStr, Util.ConvertToPoint(er.EccSeconds),
dbcmdTr);
Insert (EncoderRhythmConSecondsStr, Util.ConvertToPoint(er.ConSeconds),
dbcmdTr);
Insert (EncoderRhythmRestRepsSecondsStr,
Util.ConvertToPoint(er.RestRepsSeconds), dbcmdTr);
+ Insert (EncoderRhythmRestAfterEccStr, er.RestAfterEcc.ToString(), dbcmdTr);
Insert (EncoderRhythmRepsClusterStr, Util.ConvertToPoint(er.RepsCluster),
dbcmdTr);
Insert (EncoderRhythmRestClustersSecondsStr,
Util.ConvertToPoint(er.RestClustersSeconds), dbcmdTr);
@@ -353,6 +355,8 @@ class SqlitePreferences : Sqlite
else if(reader[0].ToString() == EncoderRhythmRestRepsSecondsStr)
preferences.encoderRhythmRestRepsSeconds = Convert.ToDouble(
Util.ChangeDecimalSeparator(reader[1].ToString()));
+ else if(reader[0].ToString() == EncoderRhythmRestAfterEccStr)
+ preferences.encoderRhythmRestAfterEcc = reader[1].ToString() == "True"; //bool
else if(reader[0].ToString() == EncoderRhythmRepsClusterStr)
preferences.encoderRhythmRepsCluster = Convert.ToInt32(reader[1].ToString());
//int
else if(reader[0].ToString() == EncoderRhythmRestClustersSecondsStr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]