[chronojump] encoderTreeviews inertial cannot selected discarded rows by buttons
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoderTreeviews inertial cannot selected discarded rows by buttons
- Date: Wed, 15 May 2019 16:35:12 +0000 (UTC)
commit f4e0e953ac33e92bc7ada4d9f2b85fb1c5091ff8
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed May 15 17:58:15 2019 +0200
encoderTreeviews inertial cannot selected discarded rows by buttons
src/constants.cs | 2 +-
src/encoder.cs | 14 ++++++++------
src/gui/encoderTreeviews.cs | 46 ++++++++++++++++++++++++++++++++-------------
src/json.cs | 4 ++--
4 files changed, 44 insertions(+), 22 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index 88d54a65..eade2775 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -939,7 +939,7 @@ public class Constants
public enum Encoder1RMMethod { NONWEIGHTED, WEIGHTED, WEIGHTED2, WEIGHTED3 }
public enum ContextMenu { NONE, EDITDELETE, DELETE }
- public enum EncoderAutoSaveCurve { ALL, NONE, BEST, FROM4TOPENULTIMATE }
+ public enum EncoderAutoSaveCurve { ALL, NONE, BEST, FROM4TOPENULTIMATE } //note last mode not need to
be 4 because DB 1.63 introduces the config of this value
//BIGGEST_TC will be the default mode.
// - at END of each track: track ends before the biggest TC (just before the trunk arrives)
diff --git a/src/encoder.cs b/src/encoder.cs
index 0e300811..40dea2c6 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -424,14 +424,15 @@ public class EncoderSignal
}
//this can be an eccentric or concentric curve
- public int FindPosOfBest(string variable) {
+ public int FindPosOfBest(int start, string variable)
+ {
double bestValue = 0;
- int bestValuePos = 0;
+ int bestValuePos = start;
int i = 0;
foreach(EncoderCurve curve in curves)
{
- if(curve.GetParameter(variable) > bestValue) {
+ if(i >= start && curve.GetParameter(variable) > bestValue) {
bestValue = curve.GetParameter(variable);
bestValuePos = i;
}
@@ -442,13 +443,14 @@ public class EncoderSignal
}
//this is an ecc-con curve
- public int FindPosOfBestEccCon(string variable)
+ //start is a counter of phases not of repetitions
+ public int FindPosOfBestEccCon(int start, string variable)
{
double eccValue = 0;
double conValue = 0;
double bestValue = 0; //will be ecc-con average
- int bestValuePos = 0; //will be the position of the ecc
+ int bestValuePos = start; //will be the position of the ecc
int i = 0;
bool ecc = true;
@@ -458,7 +460,7 @@ public class EncoderSignal
eccValue = curve.GetParameter(variable);
} else {
conValue = curve.GetParameter(variable);
- if( ( (eccValue + conValue) / 2 ) > bestValue) {
+ if( i >= start && ( (eccValue + conValue) / 2 ) > bestValue) {
bestValue = (eccValue + conValue) / 2;
bestValuePos = i -1;
}
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 13349449..345b28d3 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -343,15 +343,25 @@ public partial class ChronoJumpWindow
{
int bestRow = 0;
int numRows = 0;
+
+ int inertialStart = 0;
+ if( current_menuitem_mode == Constants.Menuitem_modes.POWERINERTIAL)
+ {
+ if(ecconLast == "c")
+ inertialStart = preferences.encoderCaptureInertialDiscardFirstN;
+ else
+ inertialStart = 2 * preferences.encoderCaptureInertialDiscardFirstN;
+ }
+
if(saveOption == Constants.EncoderAutoSaveCurve.BEST || saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE) {
if(ecconLast == "c") {
//get the concentric curves
EncoderSignal encoderSignal = new
EncoderSignal(treeviewEncoderCaptureCurvesGetCurves(AllEccCon.CON));
- bestRow = encoderSignal.FindPosOfBest(mainVariable);
+ bestRow = encoderSignal.FindPosOfBest(inertialStart, mainVariable);
numRows = encoderSignal.CurvesNum();
} else {
EncoderSignal encoderSignal = new
EncoderSignal(treeviewEncoderCaptureCurvesGetCurves(AllEccCon.ALL));
- bestRow = encoderSignal.FindPosOfBestEccCon(mainVariable); //will be pos of
the ecc
+ bestRow = encoderSignal.FindPosOfBestEccCon(inertialStart, mainVariable);
//will be pos of the ecc
numRows = encoderSignal.CurvesNum();
}
}
@@ -371,23 +381,33 @@ public partial class ChronoJumpWindow
Sqlite.Open();
bool changeTo;
- while(iterOk) {
+ while(iterOk)
+ {
TreePath path = encoderCaptureListStore.GetPath(iter);
- bool from4ToPenult = false;
+ //discard first rows
+ bool thisRowDiscarded = false;
+ if( current_menuitem_mode == Constants.Menuitem_modes.POWERINERTIAL &&
+ ( (ecconLast == "c" && i <
preferences.encoderCaptureInertialDiscardFirstN) ||
+ (ecconLast != "c" && i < 2 *
preferences.encoderCaptureInertialDiscardFirstN) ) )
+ {
+ thisRowDiscarded = true;
+ }
+
+ bool fromValidToPenult = false;
if( saveOption == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE &&
- ( (ecconLast == "c" && i > 2 && i < numRows -1) ||
- (ecconLast != "c" && i > 4 && i < numRows -2) ) )
- from4ToPenult = true;
+ ( (ecconLast == "c" && i < numRows -1) ||
+ (ecconLast != "c" && i < numRows -2) ) )
+ fromValidToPenult = true;
EncoderCurve curve = (EncoderCurve) encoderCaptureListStore.GetValue (iter, 0);
if(
- (! curve.Record && saveOption == Constants.EncoderAutoSaveCurve.ALL)
||
- (! curve.Record && saveOption == Constants.EncoderAutoSaveCurve.BEST
&& i == bestRow) ||
- (! curve.Record && saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && from4ToPenult) ||
- (curve.Record && saveOption == Constants.EncoderAutoSaveCurve.BEST &&
i != bestRow) ||
- (curve.Record && saveOption == Constants.EncoderAutoSaveCurve.NONE) ||
- (curve.Record && saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && ! from4ToPenult) )
+ (! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.ALL) ||
+ (! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.BEST && i == bestRow) ||
+ (! curve.Record && ! thisRowDiscarded && saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && fromValidToPenult) ||
+ (curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.BEST && i != bestRow)) ||
+ (curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.NONE)) ||
+ (curve.Record && (thisRowDiscarded || saveOption ==
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE && ! fromValidToPenult)) )
{
changeTo = ! curve.Record;
diff --git a/src/json.cs b/src/json.cs
index 03ef97f9..ac25d531 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -1199,8 +1199,8 @@ public class UploadEncoderDataObject
EncoderSignal eSignal = new EncoderSignal(curves);
//this n is the n of the ecc curve
- int nSpeed = eSignal.FindPosOfBestEccCon(Constants.MeanSpeed);
- int nPower = eSignal.FindPosOfBestEccCon(Constants.MeanPower);
+ int nSpeed = eSignal.FindPosOfBestEccCon(0, Constants.MeanSpeed);
+ int nPower = eSignal.FindPosOfBestEccCon(0, Constants.MeanPower);
rangeBySpeed = Util.ConvertToPoint( eSignal.GetEccConMax(nSpeed, Constants.Range) );
rangeByPower = Util.ConvertToPoint( eSignal.GetEccConMax(nPower, Constants.Range) );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]