[chronojump] RaceAnalyzer export can manage fixed/variable segments on same export (and produce all needed spread
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RaceAnalyzer export can manage fixed/variable segments on same export (and produce all needed spread
- Date: Fri, 18 Feb 2022 10:08:25 +0000 (UTC)
commit 603658b72818ea61579e06ad8c8633301cb24d85
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 18 11:07:23 2022 +0100
RaceAnalyzer export can manage fixed/variable segments on same export (and produce all needed spreadsheet
columns)
r-scripts/sprintEncoder.R | 26 ++++++++++++++++++++++--
src/runEncoder.cs | 51 +++++++++++++++++++++++++++++++++--------------
2 files changed, 60 insertions(+), 17 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index d1b3c8fdb..64a46e8bc 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -920,8 +920,26 @@ start <- function(op)
splitPositionAll = NULL
for(i in 1:length(dataFiles[,1]))
{
- splitPositionAll = c(splitPositionAll, seq(from=dataFiles$splitLength[i],
to=dataFiles$testLength[i], by=dataFiles$splitLength[i])) #TODO
+ if(dataFiles$splitLength[i] > 0)
+ {
+ splitPositionAll = c(splitPositionAll, seq(from=dataFiles$splitLength[i],
to=dataFiles$testLength[i], by=dataFiles$splitLength[i]))
+ } else
+ {
+ #as.character() because -1 (no triggers) is readed as a number and then the strsplit
fails
+ splitsVariable =
as.numeric(unlist(strsplit(as.character(dataFiles$splitVariableCm[i]), "\\,")))
+ splitsVariableCumSum = 0
+ for(j in 1:length(splitsVariable))
+ {
+ if(splitsVariableCumSum + splitsVariable[j]/100 < dataFiles$testLength[i])
+ {
+ splitsVariableCumSum = splitsVariableCumSum + splitsVariable[j]/100
+ splitPositionAll = c(splitPositionAll, splitsVariableCumSum)
+ }
+ }
+ splitPositionAll = c(splitPositionAll, dataFiles$testLength[i])
+ }
}
+
splitPositionAll = sort(unique(splitPositionAll))
#print("splitPositionAll")
#print(splitPositionAll)
@@ -935,13 +953,17 @@ start <- function(op)
prepareGraph(op$os, pngFile, op$graphWidth, op$graphHeight)
exportRow = testEncoderCJ(
as.vector(dataFiles$fullURL[i]), paste(tempInstantFolder, i, ".csv", sep =
""),
- dataFiles$testLength[i], dataFiles$splitLength[i], splitPositionAll, #TODO
+ dataFiles$testLength[i], dataFiles$splitLength[i],
+ as.numeric(unlist(strsplit(as.character(dataFiles$splitVariableCm[i]),
"\\,"))), #as.character() because -1 (no triggers) is readed as a number and then the strsplit fails
+ splitPositionAll,
dataFiles$mass[i], dataFiles$personHeight[i], dataFiles$tempC[i],
dataFiles$device[i], dataFiles$title[i], dataFiles$datetime[i], op$startAccel,
as.numeric(unlist(strsplit(as.character(dataFiles$triggersOn[i]), "\\,"))),
#as.character() because -1 (no triggers) is readed as a number and then the strsplit fails
as.numeric(unlist(strsplit(as.character(dataFiles$triggersOff[i]), "\\,")))
)
+ #print("exportRow:")
+ #print(exportRow)
if(! is.null(exportRow))
{
names = names(exportRow) #exportRow is a list, get the names
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 48867973c..6bf4804f6 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -470,14 +470,12 @@ public class RunEncoderExercise
get { return Util.ListIntToSQLString (segmentVariableCm, ";"); }
}
//same as above but return -1 if empty
- public string SegmentVariableCmToR
+ public string SegmentVariableCmToR (string sep)
{
- get {
- string str = SegmentVariableCmToSQL;
- if(str == "")
- str = "-1";
- return str;
- }
+ string str = Util.ListIntToSQLString (segmentVariableCm, sep);
+ if(str == "")
+ str = "-1";
+ return str;
}
public bool IsSprint
{
@@ -599,7 +597,7 @@ public class RunEncoderGraphExport
private RunEncoder.Devices device;
private double tempC;
private int testLength;
- private RunEncoderExercise rex;
+ private RunEncoderExercise exercise;
private string title;
private string datetime;
private TriggerList triggerList;
@@ -611,7 +609,7 @@ public class RunEncoderGraphExport
double mass, double personHeight,
RunEncoder.Devices device,
double tempC, int testLength,
- RunEncoderExercise rex, string title, string datetime,
+ RunEncoderExercise exercise, string title, string datetime,
TriggerList triggerList,
string comments)
{
@@ -622,7 +620,7 @@ public class RunEncoderGraphExport
this.device = device;
this.tempC = tempC;
this.testLength = testLength;
- this.rex = rex;
+ this.exercise = exercise;
this.title = title;
this.datetime = datetime;
this.comments = comments;
@@ -635,13 +633,24 @@ public class RunEncoderGraphExport
if(isWindows)
url = url.Replace("\\","/");
+ string segmentM = "-1"; //variable segments
+ string segmentVariableCm = "-1"; //fixed segments
+ if(exercise.SegmentCm > 0)
+ segmentM = Util.ConvertToPoint(exercise.SegmentCm / 100.0); //fixed segment
+ else
+ {
+ //it is a row separated by ; so we need , here
+ segmentVariableCm = exercise.SegmentVariableCmToR(",");
+ }
+
return url + ";" +
Util.ConvertToPoint(mass) + ";" +
Util.ConvertToPoint(personHeight / 100.0) + ";" + //in meters
device.ToString() + ";" +
Util.ConvertToPoint(tempC) + ";" +
testLength.ToString() + ";" +
- Util.ConvertToPoint(rex.SegmentCm / 100.0) + ";" + //in meters
+ segmentM + ";" + //fixed segments (m)
+ segmentVariableCm + ";" + //variable segments (cm)
title + ";" +
datetime + ";" +
printTriggers(TriggerList.Type3.ON) + ";" +
@@ -658,8 +667,14 @@ public class RunEncoderGraphExport
{
return "fullURL;mass;personHeight;device;tempC;testLength;" +
"splitLength;" + //segmentCm on C#, splitLength on R
+ "splitVariableCm;" +
"title;datetime;triggersOn;triggersOff;comments";
}
+
+ public RunEncoderExercise Exercise
+ {
+ get { return exercise; }
+ }
}
public class RunEncoderGraph
@@ -781,8 +796,14 @@ public class RunEncoderGraph
localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo;
string segmentM = "-1"; //variable segments
- if(rex.SegmentCm > 0)
- segmentM = Util.ConvertToPoint(rex.SegmentCm / 100.0); //fixed segment
+ string segmentVariableCm = "-1"; //fixed segments
+ if(singleOrMultiple) //only on single
+ {
+ if(rex.SegmentCm > 0)
+ segmentM = Util.ConvertToPoint(rex.SegmentCm / 100.0); //fixed segment
+ else
+ segmentVariableCm = rex.SegmentVariableCmToR(";");
+ }
string scriptOptions =
"#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n" +
@@ -795,8 +816,8 @@ public class RunEncoderGraph
"#graphWidth\n" + graphWidth.ToString() + "\n" +
"#graphHeight\n" + graphHeight.ToString() + "\n" +
"#device\n" + device.ToString() + "\n" + //unused on multiple
- "#segmentM\n" + segmentM + "\n" + //unused on multiple
- "#segmentVariableCm\n" + rex.SegmentVariableCmToR + "\n" + //unused on multiple
+ "#segmentM\n" + segmentM + "\n" + //unused on multiple
+ "#segmentVariableCm\n" + segmentVariableCm + "\n" + //unused on
multiple
"#title\n" + title + "\n" + //unused on multiple
"#datetime\n" + datetime + "\n" + //unused on multiple
"#startAccel\n" + Util.ConvertToPoint(startAccel) + "\n" +
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]