[chronojump] RunEncoder sends analyze accel, force, power options to R
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RunEncoder sends analyze accel, force, power options to R
- Date: Fri, 24 Apr 2020 10:14:05 +0000 (UTC)
commit 7149e9d781a649138e104f43fc7524a6cef822f9
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Apr 24 12:12:23 2020 +0200
RunEncoder sends analyze accel, force, power options to R
glade/app1.glade | 2 ++
r-scripts/sprintEncoder.R | 39 +++++++++++++++++++++++-------------
src/gui/app1/runEncoder.cs | 39 ++++++++++++++++++++++++++++++++++++
src/gui/app1/runEncoderAnalyze.cs | 42 +++++++++++++++++++++++++++++----------
src/runEncoder.cs | 24 +++++++++++++++++++++-
5 files changed, 120 insertions(+), 26 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 2622ecdc..f4301aec 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25434,6 +25434,7 @@ Concentric</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_button_run_encoder_analyze_analyze_clicked" swapped="no"/>
<child>
<widget class="GtkHBox" id="hbox410">
<property name="visible">True</property>
@@ -25827,6 +25828,7 @@ Concentric</property>
<property name="receives_default">True</property>
<property name="tooltip"
translatable="yes">Close</property>
<property name="relief">half</property>
+ <signal name="clicked"
handler="on_button_run_encoder_analyze_options_close_and_analyze_clicked" swapped="no"/>
<accelerator key="Escape" signal="clicked"/>
<child>
<widget class="GtkHBox" id="hbox413">
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 71583857..25be1dc3 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -16,6 +16,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Copyright (C) 2018-2020 Xavier Padullés <x padulles gmail com>
+# Copyright (C) 2020 Xavier de Blas <xaviblas gmail com>
+
#-------------- get params -------------
args <- commandArgs(TRUE)
@@ -47,8 +49,14 @@ assignOptions <- function(options) {
title = options[11],
datetime = options[12],
startAccel = options[13],
- triggersOnList = as.numeric(unlist(strsplit(options[14], "\\;"))),
- triggersOffList = as.numeric(unlist(strsplit(options[15], "\\;")))
+ plotRawAccel = as.logical(options[14]),
+ plotFittedAccel = as.logical(options[15]),
+ plotRawForce = as.logical(options[16]),
+ plotFittedForce = as.logical(options[17]),
+ plotRawPower = as.logical(options[18]),
+ plotFittedPower = as.logical(options[19]),
+ triggersOnList = as.numeric(unlist(strsplit(options[20], "\\;"))),
+ triggersOffList = as.numeric(unlist(strsplit(options[21], "\\;")))
))
}
@@ -232,15 +240,15 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
triggersOff = "",
plotRawMeanSpeed = TRUE,
plotRawSpeed = TRUE,
- plotRawAccel = FALSE,
- plotRawForce = FALSE,
+ plotRawAccel = op$plotRawAccel,
+ plotRawForce = op$plotRawForce,
plotMeanRawForce = TRUE,
- plotRawPower = FALSE,
+ plotRawPower = op$plotRawPower,
plotMeanRawPower = TRUE,
plotFittedSpeed = TRUE,
- plotFittedAccel = FALSE,
- plotFittedForce = FALSE,
- plotFittedPower = FALSE,
+ plotFittedAccel = op$plotFittedAccel,
+ plotFittedForce = op$plotFittedForce,
+ plotFittedPower = op$plotFittedPower,
startAccel,
plotStartDetection = TRUE)
{
@@ -256,6 +264,9 @@ plotSprintFromEncoder <- function(sprintRawDynamics, sprintFittedDynamics,
print("#######Entering plotSprintFromEncoder###########")
par(mar = c(7, 4, 5, 6.5))
+ print("plotRawAccel")
+ print(plotRawAccel)
+ print(typeof(plotRawAccel))
#Checking that the position reaches at least testLength
if(max(sprintRawDynamics$rawPosition) < sprintRawDynamics$testLength)
@@ -639,15 +650,15 @@ testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC, start
triggersOff = op$triggersOffList,
plotRawMeanSpeed = TRUE,
plotRawSpeed = TRUE,
- plotRawAccel = FALSE,
- plotRawForce = FALSE,
+ plotRawAccel = op$plotRawAccel,
+ plotRawForce = op$plotRawForce,
plotMeanRawForce = FALSE,
- plotRawPower = FALSE,
+ plotRawPower = op$plotRawPower,
plotMeanRawPower = FALSE,
plotFittedSpeed = TRUE,
- plotFittedAccel = FALSE,
- plotFittedForce = FALSE,
- plotFittedPower = TRUE,
+ plotFittedAccel = op$plotFittedAccel,
+ plotFittedForce = op$plotFittedForce,
+ plotFittedPower = op$plotFittedPower,
startAccel,
plotStartDetection = TRUE)
exportSprintDynamics(sprintFittedDynamics)
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 7dfe7367..5a51a117 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -272,6 +272,8 @@ public partial class ChronoJumpWindow
textview_contacts_signal_comment.Buffer.Text = "";
image_run_encoder_graph.Sensitive = false;
+ button_run_encoder_analyze_options.Sensitive = false;
+ button_run_encoder_analyze_analyze.Sensitive = false;
button_delete_last_test.Sensitive = false;
}
@@ -760,6 +762,7 @@ public partial class ChronoJumpWindow
sensitiveLastTestButtons(true);
event_execute_label_message.Text = "Loaded: " + Util.GetLastPartOfPath(re.Filename);
+ button_run_encoder_analyze_options.Sensitive = true;
}
protected void on_run_encoder_load_signal_row_play (object o, EventArgs args)
@@ -930,6 +933,7 @@ public partial class ChronoJumpWindow
runEncoderAnalyzeOpenImage();
notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.RACEENCODER);
radio_mode_contacts_analyze.Active = true;
+ button_run_encoder_analyze_analyze.Sensitive = true;
}
private void raceEncoderCaptureGraphDo()
@@ -949,6 +953,25 @@ public partial class ChronoJumpWindow
else
dateTimeGraph = UtilDate.ToFile(runEncoderTimeStartCapture);
+ bool plotRawAccel = ( check_run_encoder_analyze_accel.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_accel) ==
Catalog.GetString(runEncoderAnalyzeRawName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_accel) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+ bool plotFittedAccel = ( check_run_encoder_analyze_accel.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_accel) ==
Catalog.GetString(runEncoderAnalyzeFittedName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_accel) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+ bool plotRawForce = ( check_run_encoder_analyze_force.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_force) ==
Catalog.GetString(runEncoderAnalyzeRawName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_force) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+ bool plotFittedForce = ( check_run_encoder_analyze_force.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_force) ==
Catalog.GetString(runEncoderAnalyzeFittedName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_force) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+ bool plotRawPower = ( check_run_encoder_analyze_power.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_power) ==
Catalog.GetString(runEncoderAnalyzeRawName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_power) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+ bool plotFittedPower = ( check_run_encoder_analyze_power.Active && (
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_power) ==
Catalog.GetString(runEncoderAnalyzeFittedName) ||
+ UtilGtk.ComboGetActive(combo_run_encoder_analyze_power) ==
Catalog.GetString(runEncoderAnalyzeBothName) ) );
+
//create graph
RunEncoderGraph reg = new RunEncoderGraph(
race_analyzer_distance,
@@ -959,6 +982,9 @@ public partial class ChronoJumpWindow
title,
dateTimeGraph,
preferences.runEncoderMinAccel,
+ plotRawAccel, plotFittedAccel,
+ plotRawForce, plotFittedForce,
+ plotRawPower, plotFittedPower,
triggerListRunEncoder);
reg.CallR(imageWidth, imageHeight);
@@ -1092,6 +1118,8 @@ public partial class ChronoJumpWindow
notebook_analyze.CurrentPage =
Convert.ToInt32(notebook_analyze_pages.RACEENCODER);
radio_mode_contacts_analyze.Active = true;
button_contacts_exercise_close_and_recalculate.Sensitive = true;
+ button_run_encoder_analyze_options.Sensitive = true;
+ button_run_encoder_analyze_analyze.Sensitive = true;
button_delete_last_test.Sensitive = true;
/*
@@ -1112,6 +1140,8 @@ public partial class ChronoJumpWindow
webcamEnd (Constants.TestTypes.RACEANALYZER, -1);
sensitiveLastTestButtons(false);
contactsShowCaptureDoingButtons(false);
+ button_run_encoder_analyze_options.Sensitive = false;
+ button_run_encoder_analyze_analyze.Sensitive = false;
button_delete_last_test.Sensitive = false;
if(runEncoderProcessCancel)
@@ -1204,6 +1234,8 @@ public partial class ChronoJumpWindow
triggerListRunEncoder.SQLInsert(signalID);
}
+ private bool button_run_encoder_analyze_analyze_was_sensitive; //needed this temp variable
+
void runEncoderButtonsSensitive(bool sensitive)
{
//runEncoder related buttons
@@ -1212,6 +1244,13 @@ public partial class ChronoJumpWindow
button_contacts_exercise.Sensitive = sensitive;
button_execute_test.Sensitive = sensitive;
+ if(sensitive)
+ button_run_encoder_analyze_analyze.Sensitive =
button_run_encoder_analyze_analyze_was_sensitive;
+ else {
+ button_run_encoder_analyze_analyze_was_sensitive =
button_run_encoder_analyze_analyze.Sensitive;
+ button_run_encoder_analyze_analyze.Sensitive = false;
+ }
+
hbox_contacts_camera.Sensitive = sensitive;
//other gui buttons
diff --git a/src/gui/app1/runEncoderAnalyze.cs b/src/gui/app1/runEncoderAnalyze.cs
index 8ed463d9..ec978aa1 100644
--- a/src/gui/app1/runEncoderAnalyze.cs
+++ b/src/gui/app1/runEncoderAnalyze.cs
@@ -33,19 +33,10 @@ public partial class ChronoJumpWindow
[Widget] Gtk.ComboBox combo_run_encoder_analyze_accel;
[Widget] Gtk.ComboBox combo_run_encoder_analyze_force;
[Widget] Gtk.ComboBox combo_run_encoder_analyze_power;
+ [Widget] Gtk.Button button_run_encoder_analyze_options;
+ [Widget] Gtk.Button button_run_encoder_analyze_analyze;
- private void on_button_run_encoder_analyze_options_clicked (object o, EventArgs args)
- {
- notebook_run_encoder_analyze_or_options.CurrentPage = 1;
- runEncoderButtonsSensitive(false); //TODO: add this new buttons if needed
- }
- private void on_button_run_encoder_analyze_options_close_clicked (object o, EventArgs args)
- {
- notebook_run_encoder_analyze_or_options.CurrentPage = 0;
- runEncoderButtonsSensitive(true); //TODO: add this new buttons if needed
- }
-
private string runEncoderAnalyzeRawName = "RAW";
private string runEncoderAnalyzeFittedName = "Fitted";
private string runEncoderAnalyzeBothName = "Both";
@@ -98,4 +89,33 @@ public partial class ChronoJumpWindow
combo_run_encoder_analyze_power.Visible = (check_run_encoder_analyze_power.Active);
}
+ private void on_button_run_encoder_analyze_options_clicked (object o, EventArgs args)
+ {
+ notebook_run_encoder_analyze_or_options.CurrentPage = 1;
+ runEncoderButtonsSensitive(false); //TODO: add this new buttons if needed
+ }
+ private void on_button_run_encoder_analyze_options_close_clicked (object o, EventArgs args)
+ {
+ notebook_run_encoder_analyze_or_options.CurrentPage = 0;
+ runEncoderButtonsSensitive(true); //TODO: add this new buttons if needed
+ }
+
+ private void on_button_run_encoder_analyze_options_close_and_analyze_clicked (object o, EventArgs
args)
+ {
+ on_button_run_encoder_analyze_options_close_clicked (o, args);
+ on_button_run_encoder_analyze_analyze_clicked (o, args);
+ }
+
+ private void on_button_run_encoder_analyze_analyze_clicked (object o, EventArgs args)
+ {
+ if(! Util.FileExists(lastRunEncoderFullPath))
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileNotFoundStr());
+ return;
+ }
+
+ if(lastRunEncoderFullPath != null && lastRunEncoderFullPath != "")
+ raceEncoderCopyTempAndDoGraphs();
+ }
+
}
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 53b8e4b0..2feb13a0 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -295,10 +295,20 @@ public class RunEncoderGraph
private string title;
private string datetime;
private double startAccel;
+ private bool plotRawAccel;
+ private bool plotFittedAccel;
+ private bool plotRawForce;
+ private bool plotFittedForce;
+ private bool plotRawPower;
+ private bool plotFittedPower;
private TriggerList triggerList;
public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC,
RunEncoder.Devices device,
- string title, string datetime, double startAccel, TriggerList triggerList)
+ string title, string datetime, double startAccel,
+ bool plotRawAccel, bool plotFittedAccel,
+ bool plotRawForce, bool plotFittedForce,
+ bool plotRawPower, bool plotFittedPower,
+ TriggerList triggerList)
{
this.testLength = testLength;
this.mass = mass;
@@ -308,6 +318,12 @@ public class RunEncoderGraph
this.title = title;
this.datetime = datetime;
this.startAccel = startAccel;
+ this.plotRawAccel = plotRawAccel;
+ this.plotFittedAccel = plotFittedAccel;
+ this.plotRawForce = plotRawForce;
+ this.plotFittedForce = plotFittedForce;
+ this.plotRawPower = plotRawPower;
+ this.plotFittedPower = plotFittedPower;
this.triggerList = triggerList;
}
@@ -341,6 +357,12 @@ public class RunEncoderGraph
"#title\n" + title + "\n" +
"#datetime\n" + datetime + "\n" +
"#startAccel\n" + Util.ConvertToPoint(startAccel) + "\n" +
+ "#plotRawAccel\n" + Util.BoolToRBool(plotRawAccel) + "\n" +
+ "#plotFittedAccel\n" + Util.BoolToRBool(plotFittedAccel) + "\n" +
+ "#plotRawForce\n" + Util.BoolToRBool(plotRawForce) + "\n" +
+ "#plotFittedForce\n" + Util.BoolToRBool(plotFittedForce) + "\n" +
+ "#plotRawPower\n" + Util.BoolToRBool(plotRawPower) + "\n" +
+ "#plotFittedPower\n" + Util.BoolToRBool(plotFittedPower) + "\n" +
printTriggers(TriggerList.Type3.ON) + "\n" +
printTriggers(TriggerList.Type3.OFF);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]