[chronojump] Code for autograph after force sensor capture. Untested yet!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Code for autograph after force sensor capture. Untested yet!
- Date: Wed, 17 May 2017 10:56:01 +0000 (UTC)
commit fce909f317ddc464c094326d428c235150537b2f
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed May 17 12:55:32 2017 +0200
Code for autograph after force sensor capture. Untested yet!
src/gui/chronojump.cs | 4 +-
src/gui/forceSensor.cs | 72 ++++++++++++++++++++++++++++++++----------------
2 files changed, 50 insertions(+), 26 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index dbbad4c..6d49049 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3496,7 +3496,7 @@ public partial class ChronoJumpWindow
{
event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked);
- if(capturingForce != forceStatus.STOP)
+ if(capturingForce == forceStatus.STARTING || capturingForce == forceStatus.CAPTURING)
{
LogB.Information("cancel clicked on force");
forceProcessCancel = true;
@@ -3532,7 +3532,7 @@ public partial class ChronoJumpWindow
//to avoid doble finish or cancel while finishing
hideButtons();
- if(capturingForce != forceStatus.STOP)
+ if(capturingForce == forceStatus.STARTING || capturingForce == forceStatus.CAPTURING)
{
LogB.Information("finish clicked on force");
forceProcessFinish = true;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 9063c2d..19d2287 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -49,8 +49,9 @@ public partial class ChronoJumpWindow
* STOP is when is not used
* STARTING is while is waiting forceSensor to start capturing
* CAPTURING is when data is arriving
+ * COPIED_TO_TMP means data is on tmp and graph can be called
*/
- enum forceStatus { STOP, STARTING, CAPTURING }
+ enum forceStatus { STOP, STARTING, CAPTURING, COPIED_TO_TMP }
static forceStatus capturingForce = forceStatus.STOP;
static bool forceCaptureStartMark; //Just needed to display "Capturing message"
@@ -182,6 +183,13 @@ public partial class ChronoJumpWindow
if(forceProcessCancel)
Util.FileDelete(fileName);
+ else {
+ //call graph
+ File.Copy(fileName,
+ Path.GetTempPath() + Path.DirectorySeparatorChar + "cj_mif_Data.csv",
+ true); //can be overwritten
+ capturingForce = forceStatus.COPIED_TO_TMP;
+ }
}
private bool pulseGTKForceSensor ()
@@ -190,16 +198,28 @@ public partial class ChronoJumpWindow
{
LogB.ThreadEnding();
- button_execute_test.Sensitive = true;
if(forceProcessFinish)
- event_execute_label_message.Text = "Saved.";
- else if(forceProcessCancel)
+ {
+ if(capturingForce == forceStatus.STOP)
+ {
+ Thread.Sleep (25); //Wait file is copied
+ return true;
+ }
+ else if(capturingForce == forceStatus.COPIED_TO_TMP)
+ {
+ event_execute_label_message.Text = "Saved.";
+ Thread.Sleep (250); //Wait a bit to ensure is copied
+ forceSensorDoGraph();
+ }
+ } else if(forceProcessCancel)
event_execute_label_message.Text = "Cancelled.";
else
event_execute_label_message.Text = "";
LogB.ThreadEnded();
+ button_execute_test.Sensitive = true;
+
return false;
}
@@ -261,30 +281,34 @@ public partial class ChronoJumpWindow
Path.GetTempPath() + Path.DirectorySeparatorChar + "cj_mif_Data.csv",
true); //can be overwritten
- string imagePath = Path.GetTempPath() + Path.DirectorySeparatorChar +
"cj_mif_Graph.png";
- Util.FileDelete(imagePath);
- image_force_sensor_graph.Sensitive = false;
-
- ForceSensorGraph fsg = new ForceSensorGraph(rfdList, impulse);
- bool success = fsg.CallR(
- viewport_force_sensor_graph.Allocation.Width -5,
- viewport_force_sensor_graph.Allocation.Height -5);
+ forceSensorDoGraph();
+ }
+ filechooser.Destroy ();
+ }
- if(! success)
- {
- new DialogMessage(Constants.MessageTypes.WARNING, "Error doing graph.");
- filechooser.Destroy ();
- return;
- }
+ void forceSensorDoGraph()
+ {
+ string imagePath = Path.GetTempPath() + Path.DirectorySeparatorChar + "cj_mif_Graph.png";
+ Util.FileDelete(imagePath);
+ image_force_sensor_graph.Sensitive = false;
- while ( ! Util.FileReadable(imagePath));
+ ForceSensorGraph fsg = new ForceSensorGraph(rfdList, impulse);
+ bool success = fsg.CallR(
+ viewport_force_sensor_graph.Allocation.Width -5,
+ viewport_force_sensor_graph.Allocation.Height -5);
- image_force_sensor_graph = UtilGtk.OpenImageSafe(
- imagePath,
- image_force_sensor_graph);
- image_force_sensor_graph.Sensitive = true;
+ if(! success)
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING, "Error doing graph.");
+ return;
}
- filechooser.Destroy ();
+
+ while ( ! Util.FileReadable(imagePath));
+
+ image_force_sensor_graph = UtilGtk.OpenImageSafe(
+ imagePath,
+ image_force_sensor_graph);
+ image_force_sensor_graph.Sensitive = true;
}
private void on_button_force_sensor_data_folder_clicked (object o, EventArgs args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]