[chronojump] Sprint can be exported (TODO: images and select file)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Sprint can be exported (TODO: images and select file)
- Date: Wed, 24 Mar 2021 16:47:17 +0000 (UTC)
commit bc48d26a58f60a975cf6ed1bc415ad7a3079b5a5
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 24 17:46:53 2021 +0100
Sprint can be exported (TODO: images and select file)
r-scripts/sprintPhotocells.R | 64 ++++++++++++++++++++--
src/Makefile.am | 1 +
src/exportFiles/sprint.cs | 127 +++++++++++++++++++++++++++++++++++++++++--
src/gui/app1/chronojump.cs | 7 ++-
src/gui/app1/icons.cs | 4 +-
src/gui/sprint.cs | 90 +++++++++++++++++++++++++++---
src/run.cs | 1 +
src/sprint.cs | 120 ++++++++++++++++++++++++++++++++--------
8 files changed, 372 insertions(+), 42 deletions(-)
---
diff --git a/r-scripts/sprintPhotocells.R b/r-scripts/sprintPhotocells.R
index 0ef62276..23230442 100644
--- a/r-scripts/sprintPhotocells.R
+++ b/r-scripts/sprintPhotocells.R
@@ -16,7 +16,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Copyright (C) 2017 Xavier Padullés <x padulles gmail com>
-# Copyright (C) 2017 Xavier de Blas <xaviblas gmail com>
+# Copyright (C) 2017,2021 Xavier de Blas <xaviblas gmail com>
#This code uses splitTimes: accumulated time (not lap time)
@@ -264,7 +264,8 @@ drawSprintFromPhotocells <- function(sprintDynamics, splitTimes, positions, titl
paste("pmax =", round(sprintDynamics$pmax.rel.fitted, digits = 2), "W/kg")),
text.col = c("black", "black", "black", "magenta", "blue", "red"))
- exportSprintDynamics(sprintDynamics)
+ #exportSprintDynamics(sprintDynamics)
+ return (exportSprintDynamicsPrepareRow(sprintDynamics))
}
testPhotocellsCJ <- function(positions, splitTimes, mass, personHeight, tempC, personName)
@@ -278,7 +279,7 @@ testPhotocellsCJ <- function(positions, splitTimes, mass, personHeight, tempC, p
, maxTime = max(splitTimes))
print(paste("K =",sprintDynamics$K.fitted, "Vmax =", sprintDynamics$Vmax.fitted))
- drawSprintFromPhotocells(sprintDynamics = sprintDynamics, splitTimes, positions, title = personName)
+ return(drawSprintFromPhotocells(sprintDynamics = sprintDynamics, splitTimes, positions, title =
personName))
}
#----- execute code
@@ -288,7 +289,8 @@ start <- function(op)
if(op$singleOrMultiple == "TRUE")
{
prepareGraph(op$os, pngFile, op$graphWidth, op$graphHeight)
- testPhotocellsCJ(op$positions, op$splitTimes, op$mass, op$personHeight, op$tempC,
op$personName)
+ exportRow = testPhotocellsCJ(op$positions, op$splitTimes, op$mass, op$personHeight, op$tempC,
op$personName)
+ exportSprintDynamicsWriteRow (exportRow)
endGraph()
return()
}
@@ -296,9 +298,61 @@ start <- function(op)
# ------------------ op$singleOrMultiple == "FALSE" ------------------------->
#2) read the csv
- #dataFiles = read.csv(file = paste(tempPath, "/sprintInputMulti.csv", sep=""), sep=";",
stringsAsFactors=F)
+ dataFiles = read.csv(file = paste(tempPath, "/sprintInputMulti.csv", sep=""), sep=";",
stringsAsFactors=F)
+
+ #3) call testPhotocelssCJ
+ progressFolder = paste(tempPath, "/chronojump_export_progress", sep ="")
+ #tempGraphsFolder = paste(tempPath, "/chronojump_race_analyzer_export_graphs/", sep ="")
+ exportDF = NULL
+
+ for(i in 1:length(dataFiles[,1]))
+ {
+ print("splitTimes at for: ")
+ print(as.numeric(unlist(strsplit(as.character(dataFiles$splitTimes[i]), "\\_"))))
+ exportRow = testPhotocellsCJ(
+ as.numeric(unlist(strsplit(as.character(dataFiles$positions[i]),
"\\_"))),
+
as.numeric(unlist(strsplit(as.character(dataFiles$splitTimes[i]), "\\_"))),
+ dataFiles$mass[i],
+ dataFiles$personHeight[i], dataFiles$tempC[i],
dataFiles$personName[i])
+
+ if(! is.null(exportRow))
+ {
+ names = names(exportRow) #exportRow is a list, get the names
+ exportRow = unlist(exportRow) #convert to a vector
+
+ exportRowDF = data.frame(dataFiles$personName[i]) #create dataframe for this row with
some columns
+ #add exportRow data (this way we solve problems of adding strings with numbers
without converting the numbers to strings
+ #(to control if we print them as , or .)
+ for(j in 1:length(exportRow))
+ exportRowDF = cbind (exportRowDF, exportRow[j])
+# if(op$includeImagesOnExport)
+# exportRowDF = cbind(exportRowDF, paste(i, ".png", sep=""))
+
+ #write the correct names of the row dataframe
+ namesDF = c("Person",names)
+# if(op$includeImagesOnExport)
+# namesDF = c(namesDF, "Image")
+ colnames(exportRowDF) = namesDF
+
+ exportDF <- rbind (exportDF, exportRowDF) #rbind with exportDF
+ }
+
+ endGraph()
+
+ progressFilename = paste(progressFolder, "/", i, sep="")
+ file.create(progressFilename)
+ print("done")
+ }
+
+ #write the data frame
+ #na="" to not print NA on empty comments
+ if(op$decimalCharAtExport == ".")
+ write.csv(exportDF, file = paste(tempPath, "/sprintResults.csv", sep = ""), row.names =
FALSE, na="")
+ else if(op$decimalCharAtExport == ",")
+ write.csv2(exportDF, file = paste(tempPath, "/sprintResults.csv", sep = ""), row.names =
FALSE, na="")
}
+
start(op)
#Examples of use
diff --git a/src/Makefile.am b/src/Makefile.am
index b169e8a9..ad815bbd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -184,6 +184,7 @@ SOURCES = \
exportFiles/exportFiles.cs\
exportFiles/fs.cs\
exportFiles/re.cs\
+ exportFiles/sprint.cs\
AssemblyInfo.cs\
buildInfo.cs\
chronojump.cs\
diff --git a/src/exportFiles/sprint.cs b/src/exportFiles/sprint.cs
index 2cf4c129..39dcb5b9 100644
--- a/src/exportFiles/sprint.cs
+++ b/src/exportFiles/sprint.cs
@@ -23,11 +23,13 @@ using System.IO; //Directory, ...
using System.Collections; //ArrayList
using System.Collections.Generic; //List<T>
using System.Threading;
-//using Mono.Unix;
public class SprintExport : ExportFiles
{
+ private int digitsNumber;
+
private List<RunInterval> ri_l;
+ private List<object> riTypes_l; //class in sqlite/usefulObjects.cs
//constructor
public SprintExport (
@@ -39,15 +41,16 @@ public class SprintExport : ExportFiles
bool isWindows,
int personID,
int sessionID,
- char exportDecimalSeparator
+ char exportDecimalSeparator,
+ int digitsNumber
)
{
Button_done = new Gtk.Button();
assignParams(notebook, progressbar, labelResult, includeImages,
- imageWidth, imageHeight, isWindows, personID, sessionID);
+ imageWidth, imageHeight, isWindows, personID, sessionID,
exportDecimalSeparator);
- this.exportDecimalSeparator = exportDecimalSeparator;
+ this.digitsNumber = digitsNumber;
}
private string getTempGraphsDir() {
@@ -63,7 +66,123 @@ public class SprintExport : ExportFiles
protected override bool getData ()
{
ri_l = SqliteRunInterval.SelectRuns (false, sessionID, personID, "");
+ personSession_l = SqlitePersonSession.SelectCurrentSessionPersons(sessionID, true);
+ riTypes_l = SqliteRunIntervalType.SelectRunIntervalTypesNew("", false);
+
+ return ri_l.Count > 0;
+ }
+
+ //runInterval has not a file of data (like forceSensor or runEncoder)
+ //so just manage the positions and splitTimes
+ protected override bool processSets ()
+ {
+ Person p = new Person();
+ PersonSession ps = new PersonSession();
+
+ List<SprintRGraphExport> sprge_l = new List<SprintRGraphExport>();
+
+ //int element = -1; //used to sync re_l[element] with triggerListOfLists[element]
+ foreach(RunInterval ri in ri_l)
+ {
+ //element ++;
+
+ // get the person
+ bool found = false;
+ foreach(PersonAndPS paps in personSession_l)
+ {
+ if(paps.p.UniqueID == ri.PersonID)
+ {
+ p = paps.p;
+ ps = paps.ps;
+
+ found = true;
+ break;
+ }
+ }
+ if(! found)
+ continue;
+
+ /*
+ // get the type
+ found = false;
+ RunType riEx = new RunType();
+ foreach(RunType riExTemp in riEx_l)
+ if(reExTemp.UniqueID == ri.ExerciseID)
+ {
+ reEx = reExTemp;
+ found = true;
+ break;
+ }
+ if(! found)
+ continue;
+ */
+
+ // get the positions
+ string positions = RunInterval.GetSprintPositions(
+ ri.DistanceInterval, //distanceInterval. == -1 means variable
distances
+ ri.IntervalTimesString,
+ SelectRunITypes.RunIntervalTypeDistances(ri.Type, riTypes_l) //
distancesString
+ );
+ if(positions == "") //RSAs are discarded
+ continue;
+
+ //get the splitTimes
+ string splitTimes = RunInterval.GetSplitTimes(ri.IntervalTimesString, digitsNumber);
+
+ // create the export row
+ string title = Util.ChangeSpaceAndMinusForUnderscore(p.Name) + "-" +
+ Util.ChangeSpaceAndMinusForUnderscore(ri.Type);
+
+ SprintRGraphExport sprge = new SprintRGraphExport (
+ positions, splitTimes,
+ ps.Weight, //TODO: can be more if extra weight
+ ps.Height,
+ title,
+ 25);
+ sprge_l.Add(sprge);
+ }
+
+ Util.FileDelete(RunInterval.GetCSVResultsFileName());
+
+ // call the graph
+
+ if(sprge_l.Count > 0)
+ {
+ SprintRGraph s = new SprintRGraph (
+ sprge_l,
+ exportDecimalSeparator,
+ includeImages
+ );
+
+ if(! s.CallR(imageWidth, imageHeight, false))
+ {
+ failedRprocess = true;
+ return false;
+ }
+ }
+
+ LogB.Information("Waiting creation of file... ");
+ while ( ! ( Util.FileReadable(RunInterval.GetCSVResultsFileName()) || cancel ) )
+ ;
+
+ if(cancel)
+ return false;
+
+ if(includeImages)
+ {
+ //TODO
+ }
+
+ // copy the CSV
+ File.Copy(RunInterval.GetCSVResultsFileName(), exportURL, true);
+
+ return true;
+ }
+
+ protected override void setProgressBarTextAndFractionPrepare (int fileCount)
+ {
+ setProgressBarTextAndFractionDo (fileCount, ri_l.Count);
}
}
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 5f446294..5663d3b9 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -4924,14 +4924,15 @@ public partial class ChronoJumpWindow
splitTimes = Util.ChangeChars(splitTimes, ",", ".");
splitTimes = "0;" + splitTimes;
- sprint = new Sprint(positions,
+ sprintRGraph = new SprintRGraph (positions,
splitTimes,
currentPersonSession.Weight, //TODO: can be more if extra weight
currentPersonSession.Height,
+ currentPerson.Name,
25);
bool sprintRDoneOk = on_button_sprint_do ();
- string stringResultsFile = System.IO.Path.GetTempPath() + "sprintResults.csv";
+ string stringResultsFile = RunInterval.GetCSVResultsFileName();
string line = "";
if(! sprintRDoneOk || ! File.Exists(stringResultsFile))
return;
@@ -4966,7 +4967,7 @@ public partial class ChronoJumpWindow
UploadSprintDataObject usdo = new UploadSprintDataObject(
-1, //uniqueID
currentPerson.UniqueID,
- sprint.Positions, sprint.GetSplitTimesAsList(),
+ sprintRGraph.Positions, sprintRGraph.GetSplitTimesAsList(),
k, vmax, amax, fmax, pmax);
JsonCompujump js = new JsonCompujump(configChronojump.CompujumpDjango);
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index 62007d56..c57e0a67 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2017-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2017-2021 Xavier de Blas <xaviblas gmail com>
*/
@@ -119,6 +119,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_sprint_analyze_save;
[Widget] Gtk.Image image_sprint_analyze_table_save;
[Widget] Gtk.Image image_sprint_analyze_table_save_1;
+ [Widget] Gtk.Image image_sprint_export_cancel;
//encoder images
[Widget] Gtk.Image image_top_eccon;
@@ -723,6 +724,7 @@ public partial class ChronoJumpWindow
app1s_image_delete.Pixbuf = pixbuf;
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_cancel.png");
+ image_sprint_export_cancel.Pixbuf = pixbuf;
image_encoder_analyze_cancel.Pixbuf = pixbuf;
image_force_sensor_export_cancel.Pixbuf = pixbuf;
image_run_encoder_export_cancel.Pixbuf = pixbuf;
diff --git a/src/gui/sprint.cs b/src/gui/sprint.cs
index afa023ad..0b189085 100644
--- a/src/gui/sprint.cs
+++ b/src/gui/sprint.cs
@@ -35,16 +35,25 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_sprint;
[Widget] Gtk.Button button_sprint_save_image;
+ [Widget] Gtk.HBox hbox_sprint_analyze_top_modes;
+ [Widget] Gtk.RadioButton radio_sprint_analyze_individual_current_session;
+ [Widget] Gtk.RadioButton radio_sprint_analyze_groupal_current_session;
[Widget] Gtk.Image image_sprint_analyze_individual_current_set;
[Widget] Gtk.Image image_sprint_analyze_individual_current_session;
[Widget] Gtk.Image image_sprint_analyze_groupal_current_session;
[Widget] Gtk.Notebook notebook_sprint_analyze_top;
+
+ //export
+ [Widget] Gtk.Notebook notebook_sprint_export;
+ [Widget] Gtk.Label label_sprint_export_data;
[Widget] Gtk.CheckButton check_sprint_export_images;
[Widget] Gtk.HBox hbox_sprint_export_width_height;
[Widget] Gtk.SpinButton spinbutton_sprint_export_image_width;
[Widget] Gtk.SpinButton spinbutton_sprint_export_image_height;
+ [Widget] Gtk.ProgressBar progressbar_sprint_export;
+ [Widget] Gtk.Label label_sprint_export_result;
- static Sprint sprint;
+ static SprintRGraph sprintRGraph;
TreeStore storeSprint;
private void createTreeView_runs_interval_sprint (Gtk.TreeView tv)
@@ -179,11 +188,12 @@ public partial class ChronoJumpWindow
splitTimes = Util.ChangeChars(splitTimes, ",", ".");
splitTimes = "0;" + splitTimes;
- sprint = new Sprint(
+ sprintRGraph = new SprintRGraph (
positions,
splitTimes,
currentPersonSession.Weight, //TODO: can be more if extra weight
currentPersonSession.Height,
+ currentPerson.Name,
25);
return true;
}
@@ -219,11 +229,11 @@ public partial class ChronoJumpWindow
return false;
}
- if(! sprint.IsDataOk())
+ if(! sprintRGraph.IsDataOk())
{
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("This data does not seem a sprint.") + "\n\n" +
- sprint.ErrorMessage);
+ sprintRGraph.ErrorMessage);
return false;
}
@@ -231,10 +241,9 @@ public partial class ChronoJumpWindow
image_sprint.Sensitive = false;
- bool success = sprint.CallR(
+ bool success = sprintRGraph.CallR(
viewport_sprint.Allocation.Width -5,
viewport_sprint.Allocation.Height -5,
- currentPerson.Name,
true); //singleOrMultiple
if(! success)
@@ -302,6 +311,73 @@ public partial class ChronoJumpWindow
private void on_button_sprint_export_current_session_clicked (object o, EventArgs args)
{
- new DialogMessage(Constants.MessageTypes.WARNING, "TODO");
+ if(currentSession == null)
+ return;
+
+ if (radio_sprint_analyze_individual_current_session.Active)
+ {
+ if(currentPerson == null)
+ return;
+
+ button_sprint_export_session (currentPerson.UniqueID);
+ }
+ else if (radio_sprint_analyze_groupal_current_session.Active)
+ {
+ button_sprint_export_session (-1);
+ }
+ }
+
+ SprintExport sprintExport;
+ private void button_sprint_export_session (int personID)
+ {
+ //continue based on: private void button_run_encoder_export_session (int personID)
+ //TODO: sensitive stuff (false)
+ //TODO: store new width/height if changed
+ //TODO: change also spinbuttons of export sprint and forceSensor
+
+ sprintExport = new SprintExport(
+ notebook_sprint_export,
+ progressbar_sprint_export,
+ label_sprint_export_result,
+ check_sprint_export_images.Active,
+ Convert.ToInt32(spinbutton_sprint_export_image_width.Value),
+ Convert.ToInt32(spinbutton_sprint_export_image_height.Value),
+ UtilAll.IsWindows(),
+ personID,
+ currentSession.UniqueID,
+ preferences.CSVExportDecimalSeparatorChar, //decimalIsPointAtExport
(write)
+ preferences.digitsNumber);
+
+ sprintExport.Button_done.Clicked -= new EventHandler(sprint_export_done);
+ sprintExport.Button_done.Clicked += new EventHandler(sprint_export_done);
+
+ bool selectedFile = false;
+ //TODO: if(check_sprint_encoder_export_images.Active)
+ //} else {
+ //}
+
+ //restore the gui if cancelled
+ if(! selectedFile) {
+ //TODO: sensitive stuff (true)
+ }
+sprintExport.Start("/tmp/prova_sprintExport.csv");
+ }
+ private void on_button_sprint_export_file_selected (string selectedFileName)
+ {
+ //sprintExport.Start("/tmp/prova_sprintExport.csv");
+ sprintExport.Start(selectedFileName); //file or folder
+ }
+
+ private void on_button_sprint_export_cancel_clicked (object o, EventArgs args)
+ {
+ sprintExport.Cancel();
+ }
+
+ private void sprint_export_done (object o, EventArgs args)
+ {
+ sprintExport.Button_done.Clicked -= new EventHandler(sprint_export_done);
+
+// sprintButtonsSensitive(true);
+ hbox_sprint_analyze_top_modes.Sensitive = true;
}
}
diff --git a/src/run.cs b/src/run.cs
index 6804da9f..2f17a8a6 100644
--- a/src/run.cs
+++ b/src/run.cs
@@ -20,6 +20,7 @@
using System;
using System.Data;
+using System.IO; //for detect OS //TextWriter
using System.Collections.Generic; //List
using System.Threading;
using Mono.Unix;
diff --git a/src/sprint.cs b/src/sprint.cs
index 908f643c..973ff795 100644
--- a/src/sprint.cs
+++ b/src/sprint.cs
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2017 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2017-2021 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -23,49 +23,65 @@ using System.IO; //for detect OS
using System.Collections.Generic; //List<T>
using Mono.Unix;
-public class Sprint
+//to draw a graph on R
+//but also to calculate params to be uploaded on networks
+public class SprintRGraph
{
- //private List<double> positions;
- //private List<double> splitTimes;
private string positions;
private string splitTimes;
private double mass;
private double personHeight;
+ private string personName;
private double tempC;
+ private char exportDecimalSeparator;
+ private bool includeImagesOnExport;
+
private string errorMessage;
- public Sprint(string positions, string splitTimes,
- double mass, double personHeight, double tempC)
+ //constructor for 1 set
+ public SprintRGraph (string positions, string splitTimes,
+ double mass, double personHeight, string personName, double tempC)
{
this.positions = positions;
this.splitTimes = splitTimes;
this.mass = mass;
this.personHeight = personHeight;
+ this.personName = personName;
this.tempC = tempC;
+ this.exportDecimalSeparator = '.';
+ this.includeImagesOnExport = false;
+
errorMessage = "";
}
- /*
- public Sprint(List<double> positions, List<double> splitTimes,
- double mass, double personHeight, double tempC)
+ //constructor for export (many sets of possible different persons)
+ public SprintRGraph (List<SprintRGraphExport> sprge_l,
+ char exportDecimalSeparator,
+ bool includeImagesOnExport)
{
- this.positions = positions;
- this.splitTimes = splitTimes;
- this.mass = mass;
- this.personHeight = personHeight;
- this.tempC = tempC;
+ //to have Roptions.txt with data on row
+ this.positions = "-1";
+ this.splitTimes = "-1";
+ this.mass = -1;
+ this.personHeight = -1;
+ this.personName = "-1";
+ this.tempC = -1;
+
+ this.exportDecimalSeparator = exportDecimalSeparator;
+ this.includeImagesOnExport = includeImagesOnExport;
+
+ writeMultipleFilesCSV(sprge_l);
}
- */
- public bool CallR(int graphWidth, int graphHeight, string personName, bool singleOrMultiple)
+ public bool CallR(int graphWidth, int graphHeight, bool singleOrMultiple)
{
LogB.Information("\nsprint CallR ----->");
- writeOptionsFile(graphWidth, graphHeight, personName, singleOrMultiple);
+ writeOptionsFile(graphWidth, graphHeight,singleOrMultiple);
return ExecuteProcess.CallR(UtilEncoder.GetSprintPhotocellsScript());
}
- private void writeOptionsFile(int graphWidth, int graphHeight, string personName, bool
singleOrMultiple)
+ private void writeOptionsFile(int graphWidth, int graphHeight, bool singleOrMultiple)
{
/*
string scriptOptions =
@@ -79,15 +95,12 @@ public class Sprint
if(UtilAll.IsWindows())
scriptsPath = scriptsPath.Replace("\\","/");
-string exportDecimalSeparator = ".";
-bool includeImagesOnExport = false;
-
string scriptOptions =
"#scriptsPath\n" + scriptsPath + "\n" +
"#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" +
"#graphWidth\n" + graphWidth.ToString() + "\n" +
"#graphHeight\n" + graphHeight.ToString() + "\n" +
- //all the following are unused on multiple
+ //all the following (until tempC (included)) are unused on multiple
"#positions\n" + positions + "\n" +
"#splitTimes\n" + splitTimes + "\n" +
"#mass\n" + Util.ConvertToPoint(mass) + "\n" +
@@ -105,6 +118,24 @@ bool includeImagesOnExport = false;
((IDisposable)writer).Dispose();
}
+ private void writeMultipleFilesCSV(List<SprintRGraphExport> sprge_l)
+ {
+ LogB.Information("writeMultipleFilesCSV start");
+ TextWriter writer = File.CreateText(RunInterval.GetCSVInputMulti());
+
+ //write header
+ writer.WriteLine(SprintRGraphExport.PrintCSVHeaderOnExport());
+
+ //write sprge_l for
+ foreach(SprintRGraphExport sprge in sprge_l)
+ writer.WriteLine(sprge.ToCSVRowOnExport());
+
+ writer.Flush();
+ writer.Close();
+ ((IDisposable)writer).Dispose();
+ LogB.Information("writeMultipleFilesCSV end");
+ }
+
public List<double> GetSplitTimesAsList()
{
string [] splitTimesArray = splitTimes.Split(new char[] {';'});
@@ -209,3 +240,48 @@ bool includeImagesOnExport = false;
get { return errorMessage; }
}
}
+
+//this class creates the rows of each set for the csv input multi that is read by R
+public class SprintRGraphExport
+{
+ private string positions;
+ private string splitTimes;
+ private double mass;
+ private double personHeight;
+ private string personName;
+ private double tempC;
+
+ public SprintRGraphExport(
+ string positions, string splitTimes,
+ double mass, double personHeight,
+ string personName, double tempC)
+ {
+ // ; will be _ to differentiate from other ;
+ this.positions = "0_" + Util.ChangeChars(positions, ";", "_");
+ //if decimal is comma, will be converted to point for R, and also the ; will be _ to
differentiate from other ;
+ this.splitTimes = "0_" + Util.ChangeChars(
+ Util.ChangeChars(splitTimes, ",", "."), ";", "_");
+
+ this.mass = mass;
+ this.personHeight = personHeight;
+ this.personName = personName;
+ this.tempC = tempC;
+
+ }
+
+ public string ToCSVRowOnExport()
+ {
+ return positions + ";" +
+ splitTimes + ";" +
+ Util.ConvertToPoint(mass) + ";" +
+ Util.ConvertToPoint(personHeight / 100.0) + ";" + //in meters
+ personName + ";" +
+ Util.ConvertToPoint(tempC);
+ }
+
+ public static string PrintCSVHeaderOnExport()
+ {
+ return "positions;splitTimes;mass;personHeight;personName;tempC;" +
+ "comments";
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]