[chronojump] Fixed bug from last commit and nicer code
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed bug from last commit and nicer code
- Date: Tue, 26 May 2015 12:02:40 +0000 (UTC)
commit de0b646b3df6c2400aca8cd69a288bb05062355e
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue May 26 14:00:53 2015 +0200
Fixed bug from last commit and nicer code
src/encoder.cs | 45 ++++++++++++++++++++++++++++++---------------
src/gui/encoder.cs | 2 +-
src/sqlite/encoder.cs | 4 ++--
src/sqlite/main.cs | 2 +-
4 files changed, 34 insertions(+), 19 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index 37b9f2d..942531d 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -102,7 +102,7 @@ public class EncoderParams
"#analysis\n" + analysis + "\n" +
"#analysisVariables\n" + analysisVariables + "\n" +
"#analysisOptions\n" + analysisOptions + "\n" +
- encoderConfiguration.ToString("\n", true, true) + "\n" + //last bool is: forROptions
+ encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.ROPTIONS) + "\n" +
"#smoothCon\n" + smoothCon + "\n" +
"#curve\n" + curve + "\n" +
"#width\n" + width + "\n" +
@@ -1251,20 +1251,19 @@ public class EncoderConfiguration {
this.extraWeightLength = 1;
}
}
+
+ public enum Outputs { ROPTIONS, RCSV, SQL}
- //decimalPointForR: ensure decimal is point in order to work in R
- public string ToString(string sep, bool decimalPointForR, bool forROptions) {
- string str_d = "";
- string str_D = "";
- if(decimalPointForR) {
- str_d = Util.ConvertToPoint(d);
- str_D = Util.ConvertToPoint(D);
- } else {
- str_d = d.ToString();
- str_D = D.ToString();
- }
+ public string ToStringOutput(Outputs o)
+ {
+ //for R and SQL
+ string str_d = Util.ConvertToPoint(d);
+ string str_D = Util.ConvertToPoint(D);
+
+ string sep = "";
- if(forROptions)
+ if(o == Outputs.ROPTIONS) {
+ sep = "\n";
return
"#name" + sep + name + sep +
"#str_d" + sep + str_d + sep +
@@ -1274,7 +1273,22 @@ public class EncoderConfiguration {
"#inertiaTotal" + sep + inertiaTotal.ToString() + sep +
"#gearedDown" + sep + gearedDown.ToString()
;
- else //for SQL
+ }
+ else if (o == Outputs.RCSV) { //not single curve
+ sep = ",";
+ //do not need inertiaMachine, extraWeightN, extraWeightGrams, extraWeightLength
(unneded for the R calculations)
+ return
+ name + sep +
+ str_d + sep +
+ str_D + sep +
+ anglePush.ToString() + sep +
+ angleWeight.ToString() + sep +
+ inertiaTotal.ToString() + sep +
+ gearedDown.ToString()
+ ;
+ }
+ else { //(o == Outputs.SQL)
+ sep = ":";
return
name + sep +
str_d + sep +
@@ -1288,8 +1302,9 @@ public class EncoderConfiguration {
extraWeightGrams.ToString() + sep +
extraWeightLength.ToString()
;
+ }
}
-
+
//just to show on a treeview
public string ToStringPretty() {
string sep = "; ";
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e8a5f10..ebc6397 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2674,7 +2674,7 @@ public partial class ChronoJumpWindow
fullURL + "," +
eSQL.eccon + "," + //this is the eccon of every curve
ex.percentBodyWeight.ToString() + "," +
- eSQL.encoderConfiguration.ToString(",",true,false) + "," +
//last bool is: forROptions
+
eSQL.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.RCSV) + "," +
eSQL.LateralityToEnglish()
);
countSeries ++;
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 99953a5..6c39b0a 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -89,7 +89,7 @@ class SqliteEncoder : Sqlite
es.time + ", " + es.minHeight + ", '" + es.description +
"', '" + es.status + "', '" +
removeURLpath(es.videoURL) + "', '" +
- es.encoderConfiguration.ToString(":",true,false) + "', '" + //last bool is:
forROptions
+ es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "', '" +
Util.ConvertToPoint(es.future1) + "', '" + es.future2 + "', '" + es.future3 + "')";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -139,7 +139,7 @@ class SqliteEncoder : Sqlite
", description = '" + es.description +
"', status = '" + es.status +
"', videoURL = '" + removeURLpath(es.videoURL) +
- "', encoderConfiguration = '" +
es.encoderConfiguration.ToString(":",true,false) + //last bool is: forROptions
+ "', encoderConfiguration = '" +
es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) +
"', future1 = '" + Util.ConvertToPoint(es.future1) +
"', future2 = '" + es.future2 +
"', future3 = '" + es.future3 +
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index cb17e17..3b416ae 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1479,7 +1479,7 @@ class Sqlite
es.signalOrCurve + "', '" + es.filename + "', '" +
es.url + "', " + es.time + ", " + es.minHeight + ", '" +
es.description + "', '" +
es.status + "', '" + es.videoURL + "', '" +
- econf.ToString(":",true,false) + "', '" + //in this
conversion put this as default for all SQL rows. last bool is: forROptions
+ econf.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "',
'" + //in this conversion put this as default for all SQL rows.
es.future1 + "', '" + es.future2 + "', '" + es.future3 + "')";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]