[chronojump] Encoder auto save curve best n working also for ec
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder auto save curve best n working also for ec
- Date: Tue, 29 Oct 2019 13:03:07 +0000 (UTC)
commit a1fa79ef20a37aa9634a8471e025f287478b248f
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Oct 29 14:02:49 2019 +0100
Encoder auto save curve best n working also for ec
src/encoder.cs | 32 +++++++++++++++++++++++++++++++-
src/gui/encoderTreeviews.cs | 11 +++++++----
2 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index bab62b70..8aacc55f 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -462,7 +462,7 @@ public class EncoderSignal
{
bestValue = curve.GetParameter(variable);
bestValuePos = i;
- LogB.Information(string.Format("bestValue: {0}; bestValuePos: {1}",
bestValue, bestValuePos));
+ //LogB.Information(string.Format("bestValue: {0}; bestValuePos: {1}",
bestValue, bestValuePos));
}
i++;
@@ -568,6 +568,36 @@ public class EncoderSignal
}
return bestValuePos;
}
+ public int FindPosOfBestNConsecutiveEccCon(int start, string variable, int n)
+ {
+ //2) find the best values and fill listOfPos
+ double bestValue = 0;
+ int bestValuePos = -1;
+ int count = start;
+
+ n *= 2;
+ while(count <= curves.Count - n)
+ {
+ double sum = 0;
+ for(int i = count; i < count + n; i += 2)
+ {
+ double eccValue = ((EncoderCurve) curves[i]).GetParameter(variable);
+ double conValue = ((EncoderCurve) curves[i+1]).GetParameter(variable);
+ sum += (eccValue + conValue) / 2;
+ LogB.Information(string.Format("eccValue: {0}, conValue: {1}, accumulated
sum: {2}", eccValue, conValue, sum));
+ }
+ LogB.Information("total sum: " + sum.ToString());
+ if (sum > bestValue)
+ {
+ bestValue = sum;
+ bestValuePos = count;
+ LogB.Information(string.Format("bestValue: {0}, bestValuePos: {1}",
bestValue, bestValuePos));
+ }
+
+ count += 2;
+ }
+ return bestValuePos;
+ }
public double GetEccConMean(int eccPos, string variable)
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 88b2bd57..07babf24 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -397,8 +397,9 @@ public partial class ChronoJumpWindow
else if(saveOption == Constants.EncoderAutoSaveCurve.BESTN)
list_bestN = encoderSignal.FindPosOfBestN(inertialStart, mainVariable,
bestN, EncoderSignal.Contraction.EC);
- //else if(saveOption == Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE)
- //TODO
+ else if(saveOption == Constants.EncoderAutoSaveCurve.BESTNCONSECUTIVE)
+ bestRow =
encoderSignal.FindPosOfBestNConsecutiveEccCon(inertialStart, mainVariable,
+ bestN);
}
}
@@ -440,11 +441,13 @@ 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.BESTNCONSECUTIVE &&
+ i >= bestRow && ( (ecconLast == "c" && i < bestRow + bestN) ||
(ecconLast != "c" && i < bestRow + 2*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.BESTNCONSECUTIVE && //! (i >= bestRow && i < bestRow + bestN))) ||
+ ! (i >= bestRow && ( (ecconLast == "c" && i < bestRow + bestN) ||
(ecconLast != "c" && i < bestRow + 2*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]