[chronojump] runEncoder with title "person-exercise" and datetime



commit 43d788c31b1a850961b939cd72a5fba62a2d380b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 22 12:58:45 2020 +0000

    runEncoder with title "person-exercise" and datetime

 r-scripts/sprintEncoder.R | 14 ++++++++++----
 src/gui/runEncoder.cs     | 15 +++++++++++++--
 src/runEncoder.cs         | 15 +++++++++++++--
 3 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 6603b6a7..a74e976e 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -43,7 +43,9 @@ assignOptions <- function(options) {
                 os             = options[7],
                 graphWidth     = as.numeric(options[8]),
                 graphHeight    = as.numeric(options[9]),
-                device         = options[10]
+                device         = options[10],
+                title          = options[11],
+                datetime       = options[12]
         ))
 }
 
@@ -192,7 +194,9 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
                     startSample = trimmingSamples$start, endSample = trimmingSamples$end, testLength = 
testLength, longEnough = longEnough, regressionDone = regression$regressionDone, timeBefore = timeBefore))
 }
 
-plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics, title = "Test graph",
+plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
+                                 title = "Test graph",
+                                 subtitle = "",
                                   plotRawMeanSpeed = TRUE,
                                   plotRawSpeed = TRUE,
                                   plotRawAccel = FALSE,
@@ -302,7 +306,7 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics, title
         {
                 barplot(height = meanSpeed, width = diff(c(0,splitTime)), space = 0,
                         ylim = ylimits,
-                        main = title, xlab = "Time (s)", ylab = "Speed (m/s)",
+                        main = title, sub = subtitle, xlab = "Time (s)", ylab = "Speed (m/s)",
                         yaxs = "i", xaxs = "i")
                 lines(sprintRawDynamics$time[sprintRawDynamics$startSample:sprintRawDynamics$endSample],
                       sprintRawDynamics$rawSpeed[sprintRawDynamics$startSample:sprintRawDynamics$endSample])
@@ -561,7 +565,9 @@ testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC)
         {
                 sprintFittedDynamics = getDynamicsFromSprint(K = sprintRawDynamics$K, Vmax = 
sprintRawDynamics$Vmax, mass, tempC, personHeight)
                 print(paste("K =",sprintFittedDynamics$K.fitted, "Vmax =", sprintFittedDynamics$Vmax.fitted))
-                plotSprintFromEncoder(sprintRawDynamic = sprintRawDynamics, sprintFittedDynamics = 
sprintFittedDynamics, title = "Testing graph",
+                plotSprintFromEncoder(sprintRawDynamic = sprintRawDynamics, sprintFittedDynamics = 
sprintFittedDynamics,
+                                     title = op$title,
+                                     subtitle = op$datetime,
                                       plotRawMeanSpeed = TRUE,
                                       plotRawSpeed = TRUE,
                                       plotRawAccel = FALSE,
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 7a86b14d..f76379d8 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -574,7 +574,7 @@ public partial class ChronoJumpWindow
                }
        }
 
-       //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint)
+               //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint)
        private List<uint> readBinaryRunEncoderValues()
         {
                //LogB.Debug("readed start mark Ok");
@@ -927,13 +927,24 @@ public partial class ChronoJumpWindow
                int imageWidth = UtilGtk.WidgetWidth(viewport_run_encoder_graph);
                int imageHeight = UtilGtk.WidgetHeight(viewport_run_encoder_graph);
 
+               string title = Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name) + "-" +
+                       
Util.ChangeSpaceAndMinusForUnderscore(UtilGtk.ComboGetActive(combo_run_encoder_exercise));
+
+               string dateTimeGraph = "";
+               if(currentRunEncoder != null)
+                       dateTimeGraph = currentRunEncoder.DateTimePublic;
+               else
+                       dateTimeGraph = UtilDate.ToFile(runEncoderTimeStartCapture);
+
                //create graph
                RunEncoderGraph reg = new RunEncoderGraph(
                                race_analyzer_distance,
                                currentPersonSession.Weight,    //TODO: can be more if extra weight
                                currentPersonSession.Height,
                                race_analyzer_temperature,
-                               race_analyzer_device);
+                               race_analyzer_device,
+                               title,
+                               dateTimeGraph);
 
                reg.CallR(imageWidth, imageHeight);
 
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index b9140bb5..bdbee1ec 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -223,6 +223,10 @@ public class RunEncoder
                get { return temperature; }
                set { temperature = value; }
        }
+       public string DateTimePublic
+       {
+               get { return dateTime; }
+       }
        public string Comments
        {
                get { return comments; }
@@ -288,14 +292,19 @@ public class RunEncoderGraph
        private double personHeight;
        private double tempC;
        private RunEncoder.Devices device;
+       private string title;
+       private string datetime;
 
-       public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC, 
RunEncoder.Devices device)
+       public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC, 
RunEncoder.Devices device,
+                       string title, string datetime)
        {
                this.testLength = testLength;
                this.mass = mass;
                this.personHeight = personHeight;
                this.tempC = tempC;
                this.device = device;
+               this.title = title;
+               this.datetime = datetime;
        }
 
        public bool CallR(int graphWidth, int graphHeight)
@@ -324,7 +333,9 @@ public class RunEncoderGraph
                        "#os\n" +                       UtilEncoder.OperatingSystemForRGraphs() + "\n" +
                        "#graphWidth\n" +               graphWidth.ToString() + "\n" +
                        "#graphHeight\n" +              graphHeight.ToString() + "\n" +
-                       "#device\n" +                   device.ToString();
+                       "#device\n" +                   device.ToString() + "\n" +
+                       "#title\n" +                    title + "\n" +
+                       "#datetime\n" +                 datetime;
 
 
                TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]