[chronojump] Encoder Roptions with comments for each line
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder Roptions with comments for each line
- Date: Mon, 27 Apr 2015 15:14:24 +0000 (UTC)
commit 4f2f98e968cc573c8a6ba0ce1f32c2db66d9f1cc
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Apr 27 17:13:34 2015 +0200
Encoder Roptions with comments for each line
encoder/call_capture.R | 11 +------
encoder/call_graph.R | 18 +-----------
src/encoder.cs | 70 +++++++++++++++++++++++++++++++++++------------
src/gui/encoder.cs | 2 +-
src/sqlite/encoder.cs | 4 +-
src/sqlite/main.cs | 2 +-
src/util.cs | 8 +++++
src/utilEncoder.cs | 1 +
8 files changed, 69 insertions(+), 47 deletions(-)
---
diff --git a/encoder/call_capture.R b/encoder/call_capture.R
index 522e005..ea581ce 100644
--- a/encoder/call_capture.R
+++ b/encoder/call_capture.R
@@ -9,18 +9,11 @@
args <- commandArgs(TRUE)
+
optionsFile <- args[1]
-#print(optionsFile)
-#--- user commands ---
-getOptionsFromFile <- function(optionsFile, lines) {
- optionsCon <- file(optionsFile, 'r')
- options=readLines(optionsCon, n=lines)
- close(optionsCon)
- return (options)
-}
+options <- scan(optionsFile, comment.char="#", what=character(), sep="\n")
-options <- getOptionsFromFile(optionsFile, 32)
scriptUtilR = options[28]
source(scriptUtilR)
diff --git a/encoder/call_graph.R b/encoder/call_graph.R
index 3d17dd7..594a174 100644
--- a/encoder/call_graph.R
+++ b/encoder/call_graph.R
@@ -8,25 +8,11 @@
args <- commandArgs(TRUE)
-optionsFile <- args[1]
-print(optionsFile)
-
-#--- user commands ---
-getOptionsFromFile <- function(optionsFile, lines) {
- optionsCon <- file(optionsFile, 'r')
- options=readLines(optionsCon, n=lines)
- close(optionsCon)
- return (options)
-}
-#way A. passing options to a file
-options <- getOptionsFromFile(optionsFile, 32)
+optionsFile <- args[1]
-#way B. put options as arguments
-#unused because maybe command line gets too long
-#options <- commandArgs(TRUE)
+options <- scan(optionsFile, comment.char="#", what=character(), sep="\n")
-#print(options)
#---------------------------------------------------------------------
# Attention
diff --git a/src/encoder.cs b/src/encoder.cs
index 748d9c7..fafdfd6 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -91,12 +91,24 @@ public class EncoderParams
this.decimalSeparator = decimalSeparator;
}
- public string ToString2 (string sep)
+ public string ToStringROptions ()
{
- return minHeight + sep + exercisePercentBodyWeight + sep + massBody + sep + massExtra +
- sep + eccon + sep + analysis + sep + analysisVariables + sep + analysisOptions +
- sep + encoderConfiguration.ToString(sep, true) +
- sep + smoothCon + sep + curve + sep + width + sep + height + sep + decimalSeparator;
+ return
+ "#minHeight\n" + minHeight + "\n" +
+ "#exercisePercentBodyWeight\n" + exercisePercentBodyWeight + "\n" +
+ "#massBody\n" + massBody + "\n" +
+ "#massExtra\n" + massExtra + "\n" +
+ "#eccon\n" + eccon + "\n" +
+ "#analysis\n" + analysis + "\n" +
+ "#analysisVariables\n" + analysisVariables + "\n" +
+ "#analysisOptions\n" + analysisOptions + "\n" +
+ encoderConfiguration.ToString("\n", true, true) + "\n" + //last bool is: forROptions
+ "#smoothCon\n" + smoothCon + "\n" +
+ "#curve\n" + curve + "\n" +
+ "#width\n" + width + "\n" +
+ "#height\n" + height + "\n" +
+ "#decimalSeparator\n" + decimalSeparator
+ ;
}
public string Analysis {
@@ -177,14 +189,20 @@ public class EncoderGraphROptions
}
public override string ToString() {
- return inputData + "\n" +
- outputGraph + "\n" + outputData1 + "\n" +
- outputData2 + "\n" + specialData + "\n" +
- ep.ToString2("\n") + "\n" + title + "\n" + operatingSystem + "\n" +
- scriptUtilR + "\n" + scriptNeuromuscularProfile + "\n" +
- englishWords + "\n" +
- translatedWords + "\n" +
- scriptGraphR + "\n";
+ return
+ "#inputdata\n" + inputData + "\n" +
+ "#outputgraph\n" + outputGraph + "\n" +
+ "#outputdata1\n" + outputData1 + "\n" +
+ "#outputdata2\n" + outputData2 + "\n" +
+ "#specialdata\n" + specialData + "\n" +
+ ep.ToStringROptions() + "\n" +
+ "#title\n" + title + "\n" +
+ "#operatingsystem\n" + operatingSystem + "\n" +
+ "#scriptUtilR\n" + scriptUtilR + "\n" +
+ "#scriptNeuromuscularProfile\n" + scriptNeuromuscularProfile + "\n" +
+ "#englishWords\n" + englishWords + "\n" +
+ "#translatedWords\n" + translatedWords + "\n" +
+ "#scriptGraphR\n" + scriptGraphR + "\n";
}
~EncoderGraphROptions() {}
@@ -1126,7 +1144,7 @@ public class EncoderConfiguration {
}
//decimalPointForR: ensure decimal is point in order to work in R
- public string ToString(string sep, bool decimalPointForR) {
+ public string ToString(string sep, bool decimalPointForR, bool forROptions) {
string str_d = "";
string str_D = "";
if(decimalPointForR) {
@@ -1137,10 +1155,26 @@ public class EncoderConfiguration {
str_D = D.ToString();
}
- return
- name + sep + str_d + sep + str_D + sep +
- anglePush.ToString() + sep + angleWeight.ToString() + sep +
- inertia.ToString() + sep + gearedDown.ToString();
+ if(forROptions)
+ return
+ "#name" + sep + name + sep +
+ "#str_d" + sep + str_d + sep +
+ "#str_D" + sep + str_D + sep +
+ "#anglePush" + sep + anglePush.ToString() + sep +
+ "#angleWeight" + sep + angleWeight.ToString() + sep +
+ "#inertia" + sep + inertia.ToString() + sep +
+ "#gearedDown" + sep + gearedDown.ToString()
+ ;
+ else
+ return
+ name + sep +
+ str_d + sep +
+ str_D + sep +
+ anglePush.ToString() + sep +
+ angleWeight.ToString() + sep +
+ inertia.ToString() + sep +
+ gearedDown.ToString()
+ ;
}
//just to show on a treeview
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 54eb899..4af9399 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2625,7 +2625,7 @@ public partial class ChronoJumpWindow
fullURL + "," +
eSQL.eccon + "," + //this is the eccon of every curve
ex.percentBodyWeight.ToString() + "," +
- eSQL.encoderConfiguration.ToString(",",true) + "," +
+ eSQL.encoderConfiguration.ToString(",",true,false) + "," +
//last bool is: forROptions
eSQL.LateralityToEnglish()
);
countSeries ++;
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 5f48548..99953a5 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) + "', '" +
+ es.encoderConfiguration.ToString(":",true,false) + "', '" + //last bool is:
forROptions
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) +
+ "', encoderConfiguration = '" +
es.encoderConfiguration.ToString(":",true,false) + //last bool is: forROptions
"', future1 = '" + Util.ConvertToPoint(es.future1) +
"', future2 = '" + es.future2 +
"', future3 = '" + es.future3 +
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index da9cac4..cb17e17 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) + "', '" + //in this conversion put
this as default for all SQL rows
+ econf.ToString(":",true,false) + "', '" + //in this
conversion put this as default for all SQL rows. last bool is: forROptions
es.future1 + "', '" + es.future2 + "', '" + es.future3 + "')";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
diff --git a/src/util.cs b/src/util.cs
index 7828bbf..1f03b2f 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -319,6 +319,14 @@ public class Util
return myStringBuilder.ToString();
}
+ //use this!!!
+ public static string RemoveChar(string s, char c)
+ {
+ StringBuilder myStringBuilder = new StringBuilder(s);
+ myStringBuilder.Replace(c,' ');
+ return myStringBuilder.ToString();
+ }
+
public static string RemoveZeroOrMinus(string myString)
{
if(myString == "0" || myString == "-")
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 4934873..bc52bc6 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -314,6 +314,7 @@ public class UtilEncoder
foreach(string etw in Constants.EncoderTranslatedWords) {
temp = Util.ChangeChars(Catalog.GetString(etw), ";", ",");
temp = Util.RemoveNewLine(temp, true);
+ temp = Util.RemoveChar(temp, '#'); //needed to distinguish comments '#' than
normal lines like the EncoderTranslatedWords
encoderTranslatedWordsOK[count++] = temp;
}
} else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]