[chronojump] Force sensor capture now time where force starts is always 0
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Force sensor capture now time where force starts is always 0
- Date: Mon, 8 May 2017 18:28:02 +0000 (UTC)
commit 18d72c05b6e70cc7c94f412c2d3b12178e2ad4f9
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon May 8 19:16:45 2017 +0200
Force sensor capture now time where force starts is always 0
src/gui/forceSensor.cs | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 0519b6d..211bc34 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -104,6 +104,7 @@ public partial class ChronoJumpWindow
capturingForce = forceStatus.STARTING;
forceProcessFinish = false;
forceProcessCancel = false;
+ forceSensorLast = 0;
event_execute_ButtonFinish.Clicked -= new EventHandler(on_finish_clicked);
event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
@@ -121,8 +122,8 @@ public partial class ChronoJumpWindow
//non GTK on this method
private void forceSensorCaptureDo()
{
- //lastChangedTime = 0;
- SerialPort port = new SerialPort(forceSensorPortName, 115200);
+ lastChangedTime = 0;
+ SerialPort port = new SerialPort(forceSensorPortName, 115200); //forceSensor
port.Open();
Thread.Sleep(2500); //sleep to let arduino start reading
@@ -145,12 +146,24 @@ public partial class ChronoJumpWindow
TextWriter writer = File.CreateText(fileName);
writer.WriteLine("Time (s);Force(N)");
str = "";
+ double firstTime = 0;
while(! forceProcessFinish && ! forceProcessCancel)
{
str = port.ReadLine();
+
string [] strFull = str.Split(new char[] {';'});
+ //LogB.Information("str: " + str);
+
//needed to store double in user locale
double time = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[0]));
+
+ //measurement does not start at 0 time. When we start receiving data, mark this as
firstTime
+ if(firstTime == 0)
+ firstTime = time;
+
+ //use this to have time starting at 0
+ time -= firstTime;
+
double force = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]));
writer.WriteLine(time.ToString() + ";" + force.ToString());
@@ -159,6 +172,7 @@ public partial class ChronoJumpWindow
//changeSlideIfNeeded(time, force);
}
port.WriteLine("Stop");
+
writer.Flush();
writer.Close();
((IDisposable)writer).Dispose();
@@ -225,7 +239,7 @@ public partial class ChronoJumpWindow
}
Thread.Sleep (25);
- LogB.Information(" ForceSensor:"+ forceThread.ThreadState.ToString());
+// LogB.Information(" ForceSensor:"+ forceThread.ThreadState.ToString());
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]