[chronojump] forceSensor do not use chronopicRegister, discover works with useThis on already discovered
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] forceSensor do not use chronopicRegister, discover works with useThis on already discovered
- Date: Thu, 19 May 2022 11:52:41 +0000 (UTC)
commit bba5cc5442769e9f8498cb918b99cd58884c7d96
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 19 13:52:01 2022 +0200
forceSensor do not use chronopicRegister, discover works with useThis on already discovered
src/gui/app1/chronojump.cs | 56 ++++++++++++++++++++++++++++++++++++++++-----
src/gui/app1/forceSensor.cs | 23 ++++++++-----------
2 files changed, 60 insertions(+), 19 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 0010ac589..44b0f25c3 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -4556,9 +4556,13 @@ public partial class ChronoJumpWindow
----------------- discover / detect devices --------->
*/
+ //TODO instead of 4 lists, have List<microDiscoveGui>
List<Gtk.ProgressBar> progressbar_microNotDiscovered_l;
List<Gtk.Button> button_microNotDiscovered_l;
+ List<string> portAlreadyDiscovered_l;
+ List<Gtk.Button> button_microAlreadyDiscovered_l;
+
private void setup_table_micro_discover_l (
List<ChronopicRegisterPort> alreadyDiscovered_l,
List<ChronopicRegisterPort> notDiscovered_l)
@@ -4573,6 +4577,8 @@ public partial class ChronoJumpWindow
// 2) create the lists of widgets to be able to access later
progressbar_microNotDiscovered_l = new List<Gtk.ProgressBar> ();
button_microNotDiscovered_l = new List<Gtk.Button> ();
+ portAlreadyDiscovered_l = new List<string>();
+ button_microAlreadyDiscovered_l = new List<Gtk.Button> ();
// 3) create widgets, lists, attach to table and show all
for (int i = 0; i < alreadyDiscovered_l.Count; i ++)
@@ -4609,9 +4615,16 @@ public partial class ChronoJumpWindow
Gtk.Button b = new Gtk.Button("Use this");
- b.Sensitive = false;
- if (! alreadyDiscovered)
+ if (alreadyDiscovered)
+ {
+ b.Sensitive = discoverMatchCurrentMode (crp.Type);
+ button_microAlreadyDiscovered_l.Add (b);
+ portAlreadyDiscovered_l.Add (crp.Port);
+ b.Clicked += new EventHandler(on_discover_button_clicked);
+ } else {
+ b.Sensitive = false;
button_microNotDiscovered_l.Add (b);
+ }
table_micro_discover.Attach (b, (uint) 2, (uint) 3, (uint) i, (uint) i+1,
AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
@@ -4788,24 +4801,55 @@ public partial class ChronoJumpWindow
{
Button bPress = (Button) o;
+ // 1) test the discovered by MicroDiscover
//loop the list to know which button was
for (int i = 0 ; i < button_microNotDiscovered_l.Count; i ++)
if(button_microNotDiscovered_l[i] == bPress)
{
- forceSensorPortName = microDiscover.ToDiscover_l[i].Port;
- LogB.Information(forceSensorPortName);
-
SqliteChronopicRegister.Update(false,
microDiscover.ToDiscover_l[i], microDiscover.Discovered_l[i]);
chronopicRegister.SetType (microDiscover.ToDiscover_l[i].SerialNumber,
microDiscover.Discovered_l[i]);
+ portSelectedForceSensor = microDiscover.ToDiscover_l[i].Port;
+
+ button_contacts_detect.Visible = false;
+ hbox_contacts_detect_and_execute.Visible = true;
+ on_button_micro_discover_cancel_close_clicked (new object (), new EventArgs
());
+
+ return;
+ }
+
+ // 2) test the already discovered
+ for (int i = 0 ; i < button_microAlreadyDiscovered_l.Count; i ++)
+ if(button_microAlreadyDiscovered_l[i] == bPress)
+ {
+ portSelectedForceSensor = portAlreadyDiscovered_l[i];
button_contacts_detect.Visible = false;
- vbox_contacts_detect_and_execute.Visible = true;
+ hbox_contacts_detect_and_execute.Visible = true;
on_button_micro_discover_cancel_close_clicked (new object (), new EventArgs
());
return;
}
+
+ //TODO: note the on_button_micro_discover_cancel_close_clicked will emit a cancel if the
thread is active
+ //so when thread ends, it should close the window
+ //so manage that on pulse
+ }
+
+ private bool pulseDiscoverConnectGTK ()
+ {
+ if(! discoverThread.IsAlive)
+ {
+ // 3) end this pulse
+ LogB.Information("pulseDiscoverConnectGTK ending here");
+ LogB.ThreadEnded();
+
+ return false;
+ }
+
+ Thread.Sleep (200);
+ return true;
}
private void on_button_micro_discover_cancel_close_clicked (object o, EventArgs args)
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 5d16507b2..9a871e1de 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -113,7 +113,6 @@ public partial class ChronoJumpWindow
static bool forceCaptureStartMark; //Just needed to display Capturing message (with seconds)
static ForceSensorValues forceSensorValues;
- string forceSensorPortName;
SerialPort portFS; //Attention!! Don't reopen port because arduino makes reset and tare,
calibration... is lost
bool portFSOpened;
bool forceSensorBinaryCapture;
@@ -249,30 +248,28 @@ public partial class ChronoJumpWindow
layout_force_text.FontDescription = Pango.FontDescription.FromString
(preferences.GetFontTypeWithSize(10));
}
+ private string portSelectedForceSensor; //in future can be another port to detect two
//Attention: no GTK here!!
private bool forceSensorConnect()
{
LogB.Information(" FS connect 0 ");
- if(chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ARDUINO_FORCE) == null)
+ if(portSelectedForceSensor == "")
{
forceSensorOtherMessage = forceSensorNotConnectedString;
return false;
}
- LogB.Information(" FS connect 1 ");
- forceSensorPortName =
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ARDUINO_FORCE).Port;
- LogB.Information(" FS connect 2 ");
- if(forceSensorPortName == null || forceSensorPortName == "")
- {
- forceSensorOtherMessage = "Please, select port!";
- return false;
- }
LogB.Information(" FS connect 3 ");
+
+ return forceSensorConnectDo ();
+ }
+
+ private bool forceSensorConnectDo()
+ {
forceSensorOtherMessage = "Connecting ...";
- portFS = new SerialPort(forceSensorPortName, 115200); //forceSensor
- //portFS = new SerialPort(forceSensorPortName, 1000000); //forceSensor
+ portFS = new SerialPort(portSelectedForceSensor, 115200); //forceSensor
LogB.Information(" FS connect 4: opening port...");
try {
@@ -456,7 +453,7 @@ public partial class ChronoJumpWindow
}
}
- if(chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.ARDUINO_FORCE) == 0)
+ if(portSelectedForceSensor == "")
{
event_execute_label_message.Text = forceSensorNotConnectedString;
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]