[chronojump] forceSensor shows real time data
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] forceSensor shows real time data
- Date: Wed, 5 Apr 2017 11:50:46 +0000 (UTC)
commit 4d13c4ef94b1d8c941135ed135229b89b06fb7e6
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 5 13:50:27 2017 +0200
forceSensor shows real time data
glade/app1.glade | 69 ++++++++++++++++++++++++++++++++++++++++++++++++
src/gui/chronojump.cs | 5 ++-
src/gui/forceSensor.cs | 65 +++++++++++++++++++++++++++++++++++++++------
3 files changed, 128 insertions(+), 11 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 82c79a0..26b1667 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -10872,9 +10872,35 @@ after time</property>
<property name="border_width">20</property>
<property name="spacing">10</property>
<child>
+ <widget class="GtkHBox" id="hbox207">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkVScale"
id="vscale_force_sensor">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">0 -100 100 1 10
10</property>
+ <property name="inverted">True</property>
+ <property name="round_digits">1</property>
+ <property name="draw_value">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox72">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">10</property>
+ <child>
<widget class="GtkLabel" id="label262">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="xalign">0</property>
<property name="label">Force sensor</property>
</widget>
<packing>
@@ -10884,9 +10910,28 @@ after time</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox208">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
<widget class="GtkLabel"
id="label_force_sensor_value">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label254">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">N</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -10896,6 +10941,27 @@ after time</property>
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
<property name="position">7</property>
</packing>
</child>
@@ -19845,6 +19911,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 0f2f09c..8b94019 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -68,6 +68,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Notebook notebook_sup;
[Widget] Gtk.HBox hbox_other;
[Widget] Gtk.Notebook notebook_capture_analyze; //not encoder
+ [Widget] Gtk.Notebook notebook_capture_graph_table;
[Widget] Gtk.HBox hbox_contacts_sup_capture_analyze_two_buttons;
[Widget] Gtk.RadioButton radio_mode_contacts_capture;
@@ -3417,7 +3418,7 @@ public partial class ChronoJumpWindow
{
event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked);
- if(capturingForce)
+ if(capturingForce != forceStatus.STOP)
{
LogB.Information("cancel clicked on force");
forceProcessCancel = true;
@@ -3453,7 +3454,7 @@ public partial class ChronoJumpWindow
//to avoid doble finish or cancel while finishing
hideButtons();
- if(capturingForce)
+ if(capturingForce != forceStatus.STOP)
{
LogB.Information("finish clicked on force");
forceProcessFinish = true;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 794f49f..1dd44e3 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -31,13 +31,25 @@ public partial class ChronoJumpWindow
[Widget] Gtk.HBox hbox_combo_force_sensor_ports;
[Widget] Gtk.ComboBox combo_force_sensor_ports;
[Widget] Gtk.Label label_force_sensor_value;
+ [Widget] Gtk.VScale vscale_force_sensor;
CjComboForceSensorPorts comboForceSensorPorts;
Thread forceThread;
static bool forceProcessFinish;
static bool forceProcessCancel;
- static bool capturingForce;
+
+ /*
+ * forceStatus:
+ * STOP is when is not used
+ * STARTING is while is waiting forceSensor to start capturing
+ * CAPTURING is when data is arriving
+ */
+ enum forceStatus { STOP, STARTING, CAPTURING }
+ static forceStatus capturingForce = forceStatus.STOP;
+
+ static bool forceCaptureStartMark; //Just needed to display "Capturing message"
+ static double forceSensorLast; //Needed to display value and move vscale
private void on_button_force_sensor_ports_reload_clicked(object o, EventArgs args)
{
@@ -76,9 +88,12 @@ public partial class ChronoJumpWindow
button_execute_test.Sensitive = false;
event_execute_button_finish.Sensitive = true;
event_execute_button_cancel.Sensitive = true;
- event_execute_label_message.Text = "Capturing ...";
+ event_execute_label_message.Text = "Please, wait ...";
+ forceCaptureStartMark = false;
+ vscale_force_sensor.Value = 0;
+ notebook_capture_graph_table.CurrentPage = 1; //"Show table"
- capturingForce = true;
+ capturingForce = forceStatus.STARTING;
forceProcessFinish = false;
forceProcessCancel = false;
@@ -111,6 +126,9 @@ public partial class ChronoJumpWindow
}
while(! str.StartsWith("StartedOk"));
+ forceCaptureStartMark = true;
+ capturingForce = forceStatus.CAPTURING;
+
Util.CreateForceSensorSessionDirIfNeeded (currentSession.UniqueID);
string fileName = Util.GetForceSensorSessionDir(currentSession.UniqueID) +
Path.DirectorySeparatorChar +
currentPerson.Name + "_" + UtilDate.ToFile(DateTime.Now) + ".txt";
@@ -121,12 +139,14 @@ public partial class ChronoJumpWindow
{
str = port.ReadLine();
writer.WriteLine(str);
+ string [] strFull = str.Split(new char[] {';'});
+ forceSensorLast = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]));
}
port.WriteLine("Stop");
writer.Flush();
writer.Close();
((IDisposable)writer).Dispose();
- capturingForce = false;
+ capturingForce = forceStatus.STOP;
port.Close();
@@ -152,12 +172,39 @@ public partial class ChronoJumpWindow
return false;
}
- /*
- updatePulsebar(...); //activity on pulsebar
- update graph or vscale
- */
- Thread.Sleep (50);
+ if(forceCaptureStartMark)
+ {
+ event_execute_label_message.Text = "Capturing ...";
+ forceCaptureStartMark = false;
+ }
+
+ if(capturingForce == forceStatus.CAPTURING)
+ {
+ //A) resize vscale if needed
+ int upper = Convert.ToInt32(vscale_force_sensor.Adjustment.Upper);
+ int lower = Convert.ToInt32(vscale_force_sensor.Adjustment.Lower);
+ bool changed = false;
+
+ if(forceSensorLast > upper)
+ {
+ upper = Convert.ToInt32(forceSensorLast * 2);
+ changed = true;
+ }
+ if(forceSensorLast < lower)
+ {
+ lower = Convert.ToInt32(forceSensorLast * 2); //good for negative values
+ changed = true;
+ }
+ if(changed)
+ vscale_force_sensor.SetRange(lower, upper);
+
+ //B) change the value
+ vscale_force_sensor.Value = forceSensorLast;
+ label_force_sensor_value.Text = forceSensorLast.ToString();
+ }
+
+ Thread.Sleep (25);
LogB.Information(" ForceSensor:"+ forceThread.ThreadState.ToString());
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]