[chronojump] ForceSensor Finish/cancel done!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor Finish/cancel done!
- Date: Wed, 5 Apr 2017 11:01:54 +0000 (UTC)
commit 081a82aab4e7aad168758c91ad6fd010e865eb32
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 5 12:25:19 2017 +0200
ForceSensor Finish/cancel done!
src/gui/chronojump.cs | 4 ++--
src/gui/forceSensor.cs | 27 ++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 48460cd..0f2f09c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3417,7 +3417,7 @@ public partial class ChronoJumpWindow
{
event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked);
- if(forceThread != null && forceThread.IsAlive)
+ if(capturingForce)
{
LogB.Information("cancel clicked on force");
forceProcessCancel = true;
@@ -3453,7 +3453,7 @@ public partial class ChronoJumpWindow
//to avoid doble finish or cancel while finishing
hideButtons();
- if(forceThread != null && forceThread.IsAlive)
+ if(capturingForce)
{
LogB.Information("finish clicked on force");
forceProcessFinish = true;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index ed666cf..32204cf 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -37,6 +37,7 @@ public partial class ChronoJumpWindow
Thread forceThread;
static bool forceProcessFinish;
static bool forceProcessCancel;
+ static bool capturingForce;
private void on_button_force_sensor_ports_reload_clicked(object o, EventArgs args)
{
@@ -72,6 +73,12 @@ public partial class ChronoJumpWindow
return;
}
+ button_execute_test.Sensitive = false;
+ event_execute_button_finish.Sensitive = true;
+ event_execute_button_cancel.Sensitive = true;
+ event_execute_label_message.Text = "Capturing ...";
+
+ capturingForce = true;
forceProcessFinish = false;
forceProcessCancel = false;
@@ -105,7 +112,8 @@ public partial class ChronoJumpWindow
while(! str.StartsWith("StartedOk"));
str = "";
- TextWriter writer = File.CreateText("/tmp/force.txt"); //TODO: hardcoded
+ string fileName = "/tmp/force_" + currentPerson.Name + "_" + UtilDate.ToFile(DateTime.Now) +
".txt"; //TODO: hardcoded
+ TextWriter writer = File.CreateText(fileName);
while(! forceProcessFinish && ! forceProcessCancel)
{
str = port.ReadLine();
@@ -115,17 +123,30 @@ public partial class ChronoJumpWindow
writer.Flush();
writer.Close();
((IDisposable)writer).Dispose();
+ capturingForce = false;
port.Close();
+
+ if(forceProcessCancel)
+ Util.FileDelete(fileName);
}
private bool pulseGTKForceSensor ()
{
if(! forceThread.IsAlive || forceProcessFinish || forceProcessCancel)
{
- LogB.ThreadEnding();
- //finishPulsebar(...);
+ LogB.ThreadEnding();
+
+ button_execute_test.Sensitive = true;
+ if(forceProcessFinish)
+ event_execute_label_message.Text = "Saved.";
+ else if(forceProcessCancel)
+ event_execute_label_message.Text = "Cancelled.";
+ else
+ event_execute_label_message.Text = "";
+
LogB.ThreadEnded();
+
return false;
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]