[chronojump] Fixed last two commits: main variable on feedback, extra weight with decimals
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed last two commits: main variable on feedback, extra weight with decimals
- Date: Tue, 6 Mar 2018 15:10:43 +0000 (UTC)
commit ab89cd442dd433dc9df3ff83efe8282897c5e751
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Mar 6 16:09:26 2018 +0100
Fixed last two commits: main variable on feedback, extra weight with decimals
src/gui/chronojump.cs | 4 ++--
src/gui/encoder.cs | 7 +++++--
src/sqlite/encoder.cs | 10 +++++-----
src/util.cs | 12 ++++++++++++
4 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 84ac157..b90e588 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -6876,10 +6876,10 @@ LogB.Debug("X");
Constants.EncoderVariablesCapture mainVariable = Constants.SetEncoderVariablesCapture(
repetitiveConditionsWin.GetMainVariable);
if( preferences.encoderCaptureMainVariable != mainVariable ) {
- SqlitePreferences.Update("encoderCaptureMainVariable",
mainVariable.ToString(), false);
+ SqlitePreferences.Update("encoderCaptureMainVariable",
Constants.GetEncoderVariablesCapture(mainVariable), false);
preferences.encoderCaptureMainVariable = mainVariable;
}
- string mainVariableStr = mainVariable.ToString();
+ string mainVariableStr = Constants.GetEncoderVariablesCapture(mainVariable);
//treeview_encoder should be updated (to colorize some cells)
//only if there was data
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index d829339..5e82fef 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -661,9 +661,11 @@ public partial class ChronoJumpWindow
{
//TODO: do a regression to find maxPower with a value of extraWeight unused
double extraWeight = Convert.ToDouble(spin_encoder_extra_weight.Value);
- foreach(EncoderSQL es in arrayTemp)
- if(Convert.ToDouble(es.extraWeight) == extraWeight &&
Convert.ToDouble(es.future1) > maxPower)
+ foreach(EncoderSQL es in arrayTemp) {
+
if(Util.SimilarDouble(Convert.ToDouble(Util.ChangeDecimalSeparator(es.extraWeight)), extraWeight) &&
+ Convert.ToDouble(es.future1) > maxPower)
maxPower = Convert.ToDouble(es.future1);
+ }
}
else if(encGI == Constants.EncoderGI.INERTIAL)
{
@@ -6364,6 +6366,7 @@ public partial class ChronoJumpWindow
maxPowerIntersession = findMaxPowerIntersession();
+
plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower,
captureCurvesBarsData,
repetitiveConditionsWin.EncoderInertialDiscardFirstThree,
false); //not capturing
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index dded99c..ee93c05 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -48,7 +48,7 @@ class SqliteEncoder : Sqlite
"exerciseID INT, " +
"eccon TEXT, " + //"c" or "ec"
"laterality TEXT, " + //"RL" "R" "L". stored in english
- "extraWeight TEXT, " + //string because can contain "33%" or "50Kg"
+ "extraWeight TEXT, " + //string
"signalOrCurve TEXT, " + //"signal" or "curve"
"filename TEXT, " +
"url TEXT, " + //URL of data of signals and curves. stored as relative
@@ -84,7 +84,7 @@ class SqliteEncoder : Sqlite
" VALUES (" + es.uniqueID + ", " +
es.personID + ", " + es.sessionID + ", " +
es.exerciseID + ", \"" + es.eccon + "\", \"" +
- es.LateralityToEnglish() + "\", \"" + es.extraWeight + "\", \"" +
+ es.LateralityToEnglish() + "\", \"" + Util.ConvertToPoint(es.extraWeight) + "\", \"" +
es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
removeURLpath(es.url) + "\", " +
es.time + ", " + es.minHeight + ", \"" + es.description +
@@ -131,7 +131,7 @@ class SqliteEncoder : Sqlite
", exerciseID = " + es.exerciseID +
", eccon = \"" + es.eccon +
"\", laterality = \"" + es.LateralityToEnglish() +
- "\", extraWeight = \"" + es.extraWeight +
+ "\", extraWeight = \"" + Util.ConvertToPoint(es.extraWeight) +
"\", signalOrCurve = \"" + es.signalOrCurve +
"\", filename = \"" + es.filename +
"\", url = \"" + removeURLpath(es.url) +
@@ -300,7 +300,7 @@ class SqliteEncoder : Sqlite
Convert.ToInt32(reader[3].ToString()), //exerciseID
reader[4].ToString(), //eccon
Catalog.GetString(reader[5].ToString()),//laterality
- reader[6].ToString(), //extraWeight
+ Util.ChangeDecimalSeparator(reader[6].ToString()), //extraWeight
reader[7].ToString(), //signalOrCurve
reader[8].ToString(), //filename
addURLpath(fixOSpath(reader[9].ToString())), //url
@@ -565,7 +565,7 @@ class SqliteEncoder : Sqlite
reader[0].ToString(), //person name
reader[1].ToString(), //person sex
reader[3].ToString(), //encoder exercise name
- reader[4].ToString(), //extra mass
+ Util.ChangeDecimalSeparator(reader[4].ToString()), //extra mass
reader[5].ToString() //power
};
array.Add (s);
diff --git a/src/util.cs b/src/util.cs
index 59cbb63..9bfb008 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -30,6 +30,18 @@ using System.Globalization; //Unicode
//this class tries to be a space for methods that are used in different classes
public class Util
{
+ /*
+ * sometimes two doubles are similar "human eye" but different when they are compared with equal
+ * just return true if the difference between them is lower than 0.1
+ */
+ public static bool SimilarDouble (double a, double b)
+ {
+ if(Math.Abs(a - b) < 0.1)
+ return true;
+
+ return false;
+ }
+
//all numbers are saved in database with '.' as decimal separator (method for numbers)
public static string ConvertToPoint (double myDouble)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]