[chronojump] Added check_version for force sensor
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added check_version for force sensor
- Date: Mon, 16 Oct 2017 17:08:07 +0000 (UTC)
commit f7937dacac581f629da53806320957f1525684d2
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Oct 16 19:06:42 2017 +0200
Added check_version for force sensor
arduino/ForceSensor/ForceSensor.ino | 2 +-
glade/app1.glade | 21 ++++++++++++++
src/gui/chronojump.cs | 1 +
src/gui/forceSensor.cs | 51 +++++++++++++++++++++++++++-------
4 files changed, 63 insertions(+), 12 deletions(-)
---
diff --git a/arduino/ForceSensor/ForceSensor.ino b/arduino/ForceSensor/ForceSensor.ino
index 6c304de..c1a9048 100644
--- a/arduino/ForceSensor/ForceSensor.ino
+++ b/arduino/ForceSensor/ForceSensor.ino
@@ -37,7 +37,7 @@
#define DOUT 3
#define CLK 2
-//Version number
+//Version number //it always need to start with: "Force_Sensor-"
String version = "Force_Sensor-0.1";
HX711 scale(DOUT, CLK);
diff --git a/glade/app1.glade b/glade/app1.glade
index 209d264..16a5b7f 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1384,6 +1384,9 @@
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkLabel"
id="label_start_selector_jumps">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -6360,6 +6363,21 @@ after time</property>
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkButton"
id="button_force_sensor_check_version">
+ <property name="label" translatable="yes">Check
version</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="on_buttons_force_sensor_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">20</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
@@ -21488,6 +21506,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 4e59e49..5aee332 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -6388,6 +6388,7 @@ LogB.Debug("X");
notebook_options_top.CurrentPage = 4;
notebook_results.CurrentPage = 4;
changeTestImage("", "", "FORCESENSOR");
+ event_execute_button_finish.Sensitive = false;
} else if(mode == Constants.Menuitem_modes.RT)
{
notebook_execute.CurrentPage = 5;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 267bcc0..6f64f5f 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -31,6 +31,7 @@ public partial class ChronoJumpWindow
{
[Widget] Gtk.Button button_force_sensor_tare;
[Widget] Gtk.Button button_force_sensor_calibrate;
+ [Widget] Gtk.Button button_force_sensor_check_version;
[Widget] Gtk.Label label_force_sensor_value_max;
[Widget] Gtk.Label label_force_sensor_value;
[Widget] Gtk.Label label_force_sensor_value_min;
@@ -133,7 +134,7 @@ public partial class ChronoJumpWindow
return true;
}
- enum forceSensorOtherModeEnum { TARE, CALIBRATE, CAPTURE_PRE }
+ enum forceSensorOtherModeEnum { TARE, CALIBRATE, CAPTURE_PRE, CHECK_VERSION }
static forceSensorOtherModeEnum forceSensorOtherMode;
private void on_buttons_force_sensor_clicked(object o, EventArgs args)
@@ -153,10 +154,15 @@ public partial class ChronoJumpWindow
forceSensorOtherMode = forceSensorOtherModeEnum.CALIBRATE;
forceOtherThread = new Thread(new ThreadStart(forceSensorCalibrate));
}
- else { //if (o == (object) button_execute_test)
+ else if (o == (object) button_execute_test)
+ {
forceSensorOtherMode = forceSensorOtherModeEnum.CAPTURE_PRE;
forceOtherThread = new Thread(new ThreadStart(forceSensorCapturePre));
}
+ else { //if (o == (object) button_check_version)
+ forceSensorOtherMode = forceSensorOtherModeEnum.CHECK_VERSION;
+ forceOtherThread = new Thread(new ThreadStart(forceSensorCheckVersion));
+ }
GLib.Idle.Add (new GLib.IdleHandler (pulseGTKForceSensorOther));
@@ -168,6 +174,7 @@ public partial class ChronoJumpWindow
{
button_force_sensor_tare.Sensitive = sensitive;
button_force_sensor_calibrate.Sensitive = sensitive;
+ button_force_sensor_check_version.Sensitive = sensitive;
button_execute_test.Sensitive = sensitive;
}
@@ -190,7 +197,10 @@ public partial class ChronoJumpWindow
{
LogB.ThreadEnding();
- if(forceSensorOtherMode == forceSensorOtherModeEnum.TARE || forceSensorOtherMode ==
forceSensorOtherModeEnum.CALIBRATE)
+ if(
+ forceSensorOtherMode == forceSensorOtherModeEnum.TARE ||
+ forceSensorOtherMode == forceSensorOtherModeEnum.CALIBRATE ||
+ forceSensorOtherMode == forceSensorOtherModeEnum.CHECK_VERSION)
forceSensorButtonsSensitive(true);
else //if(forceSensorOtherMode == forceSensorOtherModeEnum.CAPTURE_PRE)
forceSensorCapturePre2();
@@ -207,10 +217,8 @@ public partial class ChronoJumpWindow
private void forceSensorTare()
{
if(! portFSOpened)
- {
if(! forceSensorConnect())
return;
- }
if(! forceSensorSendCommand("tare:", "Taring ...", "Catched force taring"))
return;
@@ -231,13 +239,11 @@ public partial class ChronoJumpWindow
private void forceSensorCalibrate()
{
if(! portFSOpened)
- {
if(! forceSensorConnect())
return;
- }
if(! forceSensorSendCommand("calibrate:" +
spin_force_sensor_calibration_kg_value.Value.ToString() + ";",
- "Calibrating ...", "Catched force calibrating"))
+ "Calibrating ...", "Catched force calibrating"))
return;
string str = "";
@@ -253,13 +259,33 @@ public partial class ChronoJumpWindow
}
//Attention: no GTK here!!
- private void forceSensorCapturePre()
+ private void forceSensorCheckVersion()
{
if(! portFSOpened)
- {
if(! forceSensorConnect())
return;
+
+ if(! forceSensorSendCommand("get_version:", "Checking version ...", "Catched checking
version"))
+ return;
+
+ string str = "";
+ do {
+ Thread.Sleep(100); //sleep to let arduino start reading
+ str = portFS.ReadLine().Trim();
+ LogB.Information("init string: " + str);
}
+ while(! str.Contains("Force_Sensor-"));
+
+ forceSensorOtherMessageShowSeconds = false;
+ forceSensorOtherMessage = str;
+ }
+
+ //Attention: no GTK here!!
+ private void forceSensorCapturePre()
+ {
+ if(! portFSOpened)
+ if(! forceSensorConnect())
+ return;
forceSensorOtherMessage = "Please, wait ...";
capturingForce = forceStatus.STARTING;
@@ -378,7 +404,7 @@ public partial class ChronoJumpWindow
capturingForce = forceStatus.COPIED_TO_TMP;
}
}
-
+
private bool pulseGTKForceSensorCapture ()
{
//LogB.Information(capturingForce.ToString())
@@ -408,6 +434,9 @@ public partial class ChronoJumpWindow
forceSensorButtonsSensitive(true);
+ //finish, cancel: sensitive = false
+ hideButtons();
+
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]