[chronojump] ForceSensor export plots also a simple AB Force/time graph
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor export plots also a simple AB Force/time graph
- Date: Fri, 19 Feb 2021 16:46:34 +0000 (UTC)
commit ff21a05aa8b2f92e66fd6456aefab0991bbaa963
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Feb 19 17:44:54 2021 +0100
ForceSensor export plots also a simple AB Force/time graph
r-scripts/maximumIsometricForce.R | 34 +++++++++++++++++++++++++++++++++-
src/forceSensor.cs | 1 +
src/util.cs | 5 ++++-
3 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index 7435b60c..281a289e 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -1101,6 +1101,32 @@ doProcess <- function(pngFile, dataFile, decimalChar, title, exercise, datetime,
return(exportedValues)
}
+plotABGraph <- function(pngFile, dataFile, decimalChar, title, exercise, datetime, captureOptions,
startSample, endSample)
+{
+ title = fixTitleAndOtherStrings(title)
+ exercise = fixTitleAndOtherStrings(exercise)
+
+ print("Going to enter prepareGraph")
+ prepareGraph(op$os, pngFile, op$graphWidth, op$graphHeight)
+
+ originalTest = read.csv(dataFile, header = F, dec = decimalChar, sep = ";", skip = 2)
+ colnames(originalTest) <- c("time", "force")
+ x = as.numeric(originalTest$time / 1000000) # Time is converted from microseconds to seconds
+ y = originalTest$force
+
+ if(captureOptions == "ABS")
+ y = abs(y)
+ else if(captureOptions == "INVERTED")
+ y = -1 * y
+
+ plot(y ~ x, type="l")
+
+ #mark max point
+ points(x[which(y == max(y))], max(y), col="red", cex=2)
+
+ endGraph()
+}
+
start <- function(op)
{
if(op$singleOrMultiple == "TRUE")
@@ -1150,7 +1176,8 @@ start <- function(op)
#3) call doProcess
progressFolder = paste(tempPath, "/chronojump_mif_progress", sep ="")
- tempGraphsFolder = paste(tempPath, "/chronojump_mif_graphs/", sep ="")
+ tempGraphsFolder = paste(tempPath, "/chronojump_mif_graphs_rfd/", sep ="")
+ tempGraphsABFolder = paste(tempPath, "/chronojump_mif_graphs_ab/", sep ="")
#countGraph = 1
for(i in 1:length(dataFiles[,1]))
@@ -1173,6 +1200,11 @@ start <- function(op)
endGraph() #close graph that is being done to not receive error: too many
open devices
})
+ pngFile <- paste(tempGraphsABFolder, i, ".png", sep="") #but remember to graph also
when model fails
+ plotABGraph(pngFile, as.vector(dataFiles$fullURL[i]),
+ dataFiles$decimalChar[i], dataFiles$title[i], dataFiles$exercise[i],
paste(dataFiles$date[i], dataFiles$time[i], sep=" "),
+ dataFiles$captureOptions[i], dataFiles$startSample[i],
dataFiles$endSample[i])
+
if(! modelOk)
exportModelVector = exportModelVectorOnFail #done here and not on the catch,
because it didn't worked there
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 9a8f9aaf..2183fa94 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -2633,6 +2633,7 @@ public class ForceSensorExport
//create progressbar and graph files dirs or delete their contents
createOrEmptyDir(Util.GetForceSensorTempProgressDir());
createOrEmptyDir(Util.GetForceSensorTempGraphsDir());
+ createOrEmptyDir(Util.GetForceSensorTempGraphsABDir());
thread = new Thread (new ThreadStart (forceSensorExportDo));
GLib.Idle.Add (new GLib.IdleHandler (pulseForceSensorExportGTK));
diff --git a/src/util.cs b/src/util.cs
index 4cc16c57..79d3ff1f 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1071,7 +1071,10 @@ public class Util
return Path.Combine(Path.GetTempPath(), "chronojump_mif_progress");
}
public static string GetForceSensorTempGraphsDir() {
- return Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs");
+ return Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs_rfd");
+ }
+ public static string GetForceSensorTempGraphsABDir() {
+ return Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs_ab");
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]