[chronojump] RunEncoder -> RaceAnalyzer, and reads/stores force column
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RunEncoder -> RaceAnalyzer, and reads/stores force column
- Date: Thu, 14 Feb 2019 12:56:00 +0000 (UTC)
commit 8fefca90136de7e56843f2a427c8024b18ed20a5
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Feb 14 13:54:50 2019 +0100
RunEncoder -> RaceAnalyzer, and reads/stores force column
r-scripts/sprintEncoder.R | 2 +-
src/chronojump.cs | 2 +-
src/gui/runEncoder.cs | 27 +++++++++++++++++----------
src/runEncoder.cs | 4 ++--
src/util.cs | 16 ++++++++--------
src/utilEncoder.cs | 10 +++++-----
6 files changed, 34 insertions(+), 27 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index bdfe6982..80008648 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -60,7 +60,7 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
Ka = 0.5*ro*Af*Cd
encoderCarrera = read.csv2(file = filename, sep = ";")
- colnames(encoderCarrera) = c("displacement", "time")
+ colnames(encoderCarrera) = c("displacement", "time", "force")
totalTime = encoderCarrera$time/1E6 #Converting microseconds to seconds
elapsedTime = diff(c(0,totalTime)) #The elapsed time between each sample
diff --git a/src/chronojump.cs b/src/chronojump.cs
index c2800414..d990e7d6 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -272,7 +272,7 @@ public class ChronoJump
//to store (encoder, force sensor, run encoder) data and graphs
UtilEncoder.CreateEncoderDirIfNeeded();
Util.CreateForceSensorDirIfNeeded();
- Util.CreateRunEncoderDirIfNeeded();
+ Util.CreateRaceAnalyzerDirIfNeeded();
//TODO: when a session is deleted, encoder data has to be deleted, also multimedia videos, I suppose. Show
message to user warning about it
//TODO: encoder weight auto written depending on person loaded, and changes if it changes person or weight
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 1364c1c6..9ec64ebc 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -266,19 +266,19 @@ public partial class ChronoJumpWindow
//forceCaptureStartMark = true;
capturingRunEncoder = arduinoCaptureStatus.CAPTURING;
- Util.CreateRunEncoderSessionDirIfNeeded (currentSession.UniqueID);
+ Util.CreateRaceAnalyzerSessionDirIfNeeded (currentSession.UniqueID);
string nameDate = currentPerson.Name + "_" + UtilDate.ToFile(DateTime.Now);
//fileName to save the csv
- string fileName = Util.GetRunEncoderSessionDir(currentSession.UniqueID) +
Path.DirectorySeparatorChar + nameDate + ".csv";
+ string fileName = Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) +
Path.DirectorySeparatorChar + nameDate + ".csv";
//lastRunEncoderFile to save the images
lastRunEncoderFile = nameDate;
TextWriter writer = File.CreateText(fileName);
- writer.WriteLine("Pulses;Time(useconds)");
+ writer.WriteLine("Pulses;Time(useconds);Force(N)");
str = "";
int firstTime = 0;
@@ -302,11 +302,13 @@ public partial class ChronoJumpWindow
continue;
//check if there is one and only one ';'
- if( ! (str.Contains(";") && str.IndexOf(";") == str.LastIndexOf(";")) )
- continue;
+ //if( ! (str.Contains(";") && str.IndexOf(";") == str.LastIndexOf(";")) )
string [] strFull = str.Split(new char[] {';'});
- //LogB.Information("str: " + str);
+ LogB.Information("captured str: " + str);
+
+ if(strFull.Length != 3)
+ continue;
LogB.Information("pulses: " + strFull[0]);
if(! Util.IsNumber(strFull[0], false))
@@ -316,6 +318,10 @@ public partial class ChronoJumpWindow
if(! Util.IsNumber(strFull[1], false))
continue;
+ LogB.Information("force avg (N): " + strFull[1]);
+ if(! Util.IsNumber(strFull[2], false))
+ continue;
+
/*
int time = Convert.ToInt32(strFull[0]);
@@ -330,7 +336,8 @@ public partial class ChronoJumpWindow
*/
int pulse = Convert.ToInt32(strFull[0]);
int time = Convert.ToInt32(strFull[1]);
- writer.WriteLine(pulse.ToString() + ";" + time.ToString());
+ int force = Convert.ToInt32(strFull[2]);
+ writer.WriteLine(pulse.ToString() + ";" + time.ToString() + ";" + force.ToString());
}
LogB.Information(string.Format("FINISHED WITH conditions: {0}-{1}-{2}",
runEncoderProcessFinish, runEncoderProcessCancel,
runEncoderProcessError));
@@ -367,7 +374,7 @@ public partial class ChronoJumpWindow
Util.FileDelete(fileName);
else {
//call graph. Prepare data
- File.Copy(fileName, UtilEncoder.GetRunEncoderCSVFileName(), true); //can be
overwritten
+ File.Copy(fileName, UtilEncoder.GetRaceAnalyzerCSVFileName(), true); //can be
overwritten
lastRunEncoderFullPath = fileName;
//create graph
@@ -389,7 +396,7 @@ public partial class ChronoJumpWindow
LogB.Information("File exists on png, trying to copy");
try {
File.Copy(UtilEncoder.GetSprintEncoderImage(),
- Util.GetRunEncoderSessionDir(currentSession.UniqueID)
+ Path.DirectorySeparatorChar +
+
Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) + Path.DirectorySeparatorChar +
lastRunEncoderFile + //nameDate
".png",
true); //can be overwritten
@@ -412,7 +419,7 @@ public partial class ChronoJumpWindow
string str = "";
if (portRE.BytesToRead > 0)
str = portRE.ReadLine();
- //LogB.Information("PRE_get_calibrationfactor bytes: " + portFS.ReadExisting());
+ //LogB.Information("PRE_get_calibrationfactor bytes: " + portRE.ReadExisting());
return str;
}
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index e215c924..4b7e3b52 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -41,7 +41,7 @@ public class RunEncoderGraph
{
LogB.Information("\nrunEncoder CallR ----->");
writeOptionsFile(graphWidth, graphHeight);
- return ExecuteProcess.CallR(UtilEncoder.GetRunEncoderScript());
+ return ExecuteProcess.CallR(UtilEncoder.GetRaceAnalyzerScript());
}
private void writeOptionsFile(int graphWidth, int graphHeight)
@@ -55,7 +55,7 @@ public class RunEncoderGraph
string scriptOptions =
"#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n" +
- "#filename\n" + UtilEncoder.GetRunEncoderCSVFileName() + "\n" +
+ "#filename\n" + UtilEncoder.GetRaceAnalyzerCSVFileName() + "\n" +
"#mass\n" + Util.ConvertToPoint(mass) + "\n" +
"#personHeight\n" + Util.ConvertToPoint(personHeight / 100.0) + "\n" +
//send it in meters
"#tempC\n" + tempC + "\n" +
diff --git a/src/util.cs b/src/util.cs
index b4157609..faa6036a 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -980,15 +980,15 @@ public class Util
*/
//to store run encoder data and graphs
- public static string GetRunEncoderDir()
+ public static string GetRaceAnalyzerDir()
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
- "Chronojump" + Path.DirectorySeparatorChar + "runEncoder");
+ "Chronojump" + Path.DirectorySeparatorChar + "raceAnalyzer");
}
- public static void CreateRunEncoderDirIfNeeded ()
+ public static void CreateRaceAnalyzerDirIfNeeded ()
{
- string dir = GetRunEncoderDir();
+ string dir = GetRaceAnalyzerDir();
if( ! Directory.Exists(dir)) {
Directory.CreateDirectory (dir);
LogB.Information ("created dir:", dir);
@@ -996,13 +996,13 @@ public class Util
}
//runEncoder organized by sessions.
- public static string GetRunEncoderSessionDir (int sessionID)
+ public static string GetRaceAnalyzerSessionDir (int sessionID)
{
- return GetRunEncoderDir() + Path.DirectorySeparatorChar + sessionID.ToString();
+ return GetRaceAnalyzerDir() + Path.DirectorySeparatorChar + sessionID.ToString();
}
- public static void CreateRunEncoderSessionDirIfNeeded (int sessionID)
+ public static void CreateRaceAnalyzerSessionDirIfNeeded (int sessionID)
{
- string dir = GetRunEncoderSessionDir(sessionID);
+ string dir = GetRaceAnalyzerSessionDir(sessionID);
if( ! Directory.Exists(dir)) {
Directory.CreateDirectory (dir);
LogB.Information ("created dir:", dir);
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index cfd1517a..17f1bea8 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -254,14 +254,14 @@ public class UtilEncoder
return System.IO.Path.Combine(Util.GetDataDir(), "r-scripts");
}
- public static string GetRunEncoderScript() {
+ public static string GetRaceAnalyzerScript() {
return System.IO.Path.Combine(GetSprintPath(), "sprintEncoder.R");
}
- public static string GetRunEncoderCSVFileName() {
- return Path.Combine(Path.GetTempPath(), "cj_run_encoder_data.csv");
+ public static string GetRaceAnalyzerCSVFileName() {
+ return Path.Combine(Path.GetTempPath(), "cj_race_analyzer_data.csv");
}
- public static string GetRunEncoderTempFileName() {
- return Path.Combine(Path.GetTempPath(), "cj_run_encoder_graph.png");
+ public static string GetRaceAnalyzerTempFileName() {
+ return Path.Combine(Path.GetTempPath(), "cj_race_analyzer_graph.png");
}
public static string GetmifScript() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]