Commit f4e0e953 authored by Xavier de Blas's avatar Xavier de Blas

encoderTreeviews inertial cannot selected discarded rows by buttons

parent 42a96b9d
......@@ -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)
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment