[chronojump] encoder save best_n_consecutives working for concentric
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoder save best_n_consecutives working for concentric
- Date: Tue, 29 Oct 2019 12:28:39 +0000 (UTC)
commit 9e6a6db906c2228c6c624f18bba8df3b34523d92
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Oct 29 13:28:17 2019 +0100
encoder save best_n_consecutives working for concentric
src/constants.cs | 14 +++++++++-----
src/encoder.cs | 29 +++++++++++++++++++++++++++++
src/gui/encoder.cs | 20 +++++++++++++-------
src/gui/encoderTreeviews.cs | 34 +++++++++++++++++++++++++---------
4 files changed, 76 insertions(+), 21 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index 5ab19c88..0c9ed4b7 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -1209,20 +1209,22 @@ public class Constants
public const string ForceSensorLateralityLeft = "Left";
public const string ForceSensorLateralityRight = "Right";
- public enum EncoderAutoSaveCurve { BEST, BESTN, ALL, FROM4TOPENULTIMATE, NONE }
- public static string [] EncoderAutoSaveCurvesStrings = { "Best", "Best n", "All", "All but last",
"None" };
+ public enum EncoderAutoSaveCurve { BEST, BESTN, BESTNCONSECUTIVE, ALL, FROM4TOPENULTIMATE, NONE }
+ public static string [] EncoderAutoSaveCurvesStrings = { "Best", "Best n", "Best n consecutive",
"All", "All but last", "None" };
public static string GetEncoderAutoSaveCurvesStrings (EncoderAutoSaveCurve easc)
{
if(easc == EncoderAutoSaveCurve.BEST)
return EncoderAutoSaveCurvesStrings[0];
else if(easc == EncoderAutoSaveCurve.BESTN)
return EncoderAutoSaveCurvesStrings[1];
- else if(easc == EncoderAutoSaveCurve.ALL)
+ else if(easc == EncoderAutoSaveCurve.BESTNCONSECUTIVE)
return EncoderAutoSaveCurvesStrings[2];
- else if(easc == EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
+ else if(easc == EncoderAutoSaveCurve.ALL)
return EncoderAutoSaveCurvesStrings[3];
- else //(easc == EncoderAutoSaveCurve.NONE
+ else if(easc == EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
return EncoderAutoSaveCurvesStrings[4];
+ else //(easc == EncoderAutoSaveCurve.NONE
+ return EncoderAutoSaveCurvesStrings[5];
}
public static EncoderAutoSaveCurve GetEncoderAutoSaveCurvesEnum (string str)
{
@@ -1230,6 +1232,8 @@ public class Constants
return EncoderAutoSaveCurve.BEST;
else if(str == "Best n")
return EncoderAutoSaveCurve.BESTN;
+ else if(str == "Best n consecutive")
+ return EncoderAutoSaveCurve.BESTNCONSECUTIVE;
else if(str == "All")
return EncoderAutoSaveCurve.ALL;
else if(str == "All but last")
diff --git a/src/encoder.cs b/src/encoder.cs
index ebd57f63..bab62b70 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -540,6 +540,35 @@ public class EncoderSignal
return listOfPos;
}
+ //TODO: do also for ecc-con
+ //returns the pos of the first one of the consecutive rows
+ public int FindPosOfBestNConsecutive(int start, string variable, int n)
+ {
+ //2) find the best values and fill listOfPos
+ double bestValue = 0;
+ int bestValuePos = -1;
+ int count = start;
+
+ while(count <= curves.Count - n)
+ {
+ double sum = 0;
+ for(int i = count; i < count + n; i ++)
+ {
+ sum += ((EncoderCurve) curves[i]).GetParameter(variable);
+ }
+ LogB.Information("sum: " + sum.ToString());
+ if (sum > bestValue)
+ {
+ bestValue = sum;
+ bestValuePos = count;
+ LogB.Information(string.Format("bestValue: {0}, bestValuePos: {1}",
bestValue, bestValuePos));
+ }
+
+ count ++;
+ }
+ return bestValuePos;
+ }
+
public double GetEccConMean(int eccPos, string variable)
{
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index bbd87aea..609022e3 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3868,17 +3868,20 @@ public partial class ChronoJumpWindow
//combo_encoder_capture_curves_save;
combo_encoder_capture_curves_save = ComboBox.NewText();
- //string [] comboEncoderCaptureCurvesSaveOptions = { "Best", "Best n", "All", "All but last",
"None" };
- string [] comboEncoderCaptureCurvesSaveOptionsTranslated = { Catalog.GetString("Best"),
Catalog.GetString("Best n"),
- Catalog.GetString("All"), Catalog.GetString("All but last"),
Catalog.GetString("None") };
+ string [] comboEncoderCaptureCurvesSaveOptionsTranslated = {
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[0]),
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[1]),
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[2]),
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[3]),
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[4]),
+ Catalog.GetString(Constants.EncoderAutoSaveCurvesStrings[5]) };
encoderCaptureCurvesSaveOptionsTranslation = new String
[comboEncoderCaptureCurvesSaveOptionsTranslated.Length];
- for(int j=0; j < 5 ; j++)
+ for(int j=0; j < comboEncoderCaptureCurvesSaveOptionsTranslated.Length ; j++)
encoderCaptureCurvesSaveOptionsTranslation[j] =
Constants.EncoderAutoSaveCurvesStrings[j] + ":" +
comboEncoderCaptureCurvesSaveOptionsTranslated[j];
UtilGtk.ComboUpdate(combo_encoder_capture_curves_save,
comboEncoderCaptureCurvesSaveOptionsTranslated, "");
combo_encoder_capture_curves_save.Active =
UtilGtk.ComboMakeActive(combo_encoder_capture_curves_save,
Catalog.GetString(Constants.GetEncoderAutoSaveCurvesStrings(preferences.encoderAutoSaveCurve)));
- manageVisibilityOf_spin_encoder_capture_curves_best_n ();
combo_encoder_capture_curves_save.Changed += new EventHandler
(on_combo_encoder_capture_curves_save_changed);
/* ConcentricEccentric
@@ -3928,6 +3931,7 @@ public partial class ChronoJumpWindow
hbox_encoder_capture_curves_save.PackStart(combo_encoder_capture_curves_save, true, true, 0);
hbox_encoder_capture_curves_save.ShowAll();
+ manageVisibilityOf_spin_encoder_capture_curves_best_n ();
button_combo_encoder_exercise_capture_right = UtilGtk.CreateArrowButton(ArrowType.Right,
ShadowType.In, 40, 40, UtilGtk.ArrowEnum.NONE);
button_combo_encoder_exercise_capture_right.Sensitive = true;
@@ -4205,9 +4209,10 @@ public partial class ChronoJumpWindow
void manageVisibilityOf_spin_encoder_capture_curves_best_n ()
{
- spin_encoder_capture_curves_best_n.Visible = Util.FindOnArray(
+ string englishStr = Util.FindOnArray(
':',1,0,UtilGtk.ComboGetActive(combo_encoder_capture_curves_save),
- encoderCaptureCurvesSaveOptionsTranslation) == "Best n";
+ encoderCaptureCurvesSaveOptionsTranslation);
+ spin_encoder_capture_curves_best_n.Visible = (englishStr == "Best n" || englishStr == "Best n
consecutive");
}
void on_button_encoder_capture_curves_save_clicked (object o, EventArgs args)
@@ -6503,6 +6508,7 @@ public partial class ChronoJumpWindow
(preferences.encoderAutoSaveCurve ==
Constants.EncoderAutoSaveCurve.ALL ||
preferences.encoderAutoSaveCurve ==
Constants.EncoderAutoSaveCurve.BEST ||
preferences.encoderAutoSaveCurve ==
Constants.EncoderAutoSaveCurve.BESTN ||
+ preferences.encoderAutoSaveCurve ==
Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE ||
preferences.encoderAutoSaveCurve ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE) )
needToAutoSaveCurve = true;
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index fd632720..88b2bd57 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -358,6 +358,7 @@ public partial class ChronoJumpWindow
int bestRow = 0;
int numRows = 0;
List<int> list_bestN = new List<int>();
+ int bestN = Convert.ToInt32(spin_encoder_capture_curves_best_n.Value);
int inertialStart = 0;
if( current_menuitem_mode == Constants.Menuitem_modes.POWERINERTIAL)
@@ -370,21 +371,34 @@ public partial class ChronoJumpWindow
if(saveOption == Constants.EncoderAutoSaveCurve.BEST ||
saveOption == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE ||
- saveOption == Constants.EncoderAutoSaveCurve.BESTN)
+ saveOption == Constants.EncoderAutoSaveCurve.BESTN ||
+ saveOption == Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE)
{
if(ecconLast == "c") {
//get the concentric curves
EncoderSignal encoderSignal = new
EncoderSignal(treeviewEncoderCaptureCurvesGetCurves(AllEccCon.CON));
- bestRow = encoderSignal.FindPosOfBest(inertialStart, mainVariable);
//this for BEST
- numRows = encoderSignal.CurvesNum();
//this for FROM4TOPENULTIMATE
- list_bestN = encoderSignal.FindPosOfBestN(inertialStart, mainVariable,
- Convert.ToInt32(spin_encoder_capture_curves_best_n.Value),
EncoderSignal.Contraction.C);
+
+ if(saveOption == Constants.EncoderAutoSaveCurve.BEST)
+ bestRow = encoderSignal.FindPosOfBest(inertialStart, mainVariable);
+ else if(saveOption == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
+ numRows = encoderSignal.CurvesNum();
+ else if(saveOption == Constants.EncoderAutoSaveCurve.BESTN)
+ list_bestN = encoderSignal.FindPosOfBestN(inertialStart, mainVariable,
+ bestN, EncoderSignal.Contraction.C);
+ else if(saveOption == Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE)
+ bestRow = encoderSignal.FindPosOfBestNConsecutive(inertialStart,
mainVariable,
+ bestN);
} else {
EncoderSignal encoderSignal = new
EncoderSignal(treeviewEncoderCaptureCurvesGetCurves(AllEccCon.ALL));
- bestRow = encoderSignal.FindPosOfBestEccCon(inertialStart, mainVariable);
//this for BEST //will be pos of the ecc
- numRows = encoderSignal.CurvesNum();
//this for FROM4TOPENULTIMATE
- list_bestN = encoderSignal.FindPosOfBestN(inertialStart, mainVariable,
- Convert.ToInt32(spin_encoder_capture_curves_best_n.Value),
EncoderSignal.Contraction.EC);
+ if(saveOption == Constants.EncoderAutoSaveCurve.BEST)
+ bestRow = encoderSignal.FindPosOfBestEccCon(inertialStart,
mainVariable); //will be pos of the ecc
+ else if(saveOption == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
+ numRows = encoderSignal.CurvesNum();
+ else if(saveOption == Constants.EncoderAutoSaveCurve.BESTN)
+ list_bestN = encoderSignal.FindPosOfBestN(inertialStart, mainVariable,
+ bestN, EncoderSignal.Contraction.EC);
+ //else if(saveOption == Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE)
+ //TODO
}
}
@@ -426,9 +440,11 @@ public partial class ChronoJumpWindow
(! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.ALL) ||
(! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.BEST && i == bestRow) ||
(! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.BESTN && Util.FoundInListInt(list_bestN, i)) ||
+ (! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE && i >= bestRow && i < bestRow + bestN) ||
(! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && fromValidToPenult) ||
(curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.BEST && i != bestRow)) ||
(curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.BESTN && ! Util.FoundInListInt(list_bestN, i))) ||
+ (curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE && ! (i >= bestRow && i < bestRow + bestN))) ||
(curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.NONE)) ||
(curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && ! fromValidToPenult)) )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]