[chronojump] ChronopicWizard done. Need integration with chronopicWin, and cj start window
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ChronopicWizard done. Need integration with chronopicWin, and cj start window
- Date: Wed, 7 Sep 2016 22:41:53 +0000 (UTC)
commit ac23ccadd28860519217c79c180792559622e92d
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Sep 8 00:35:41 2016 +0200
ChronopicWizard done. Need integration with chronopicWin, and cj start window
diagrams/classes/chronopicConnection.dia | Bin 4483 -> 4536 bytes
src/constants.cs | 5 ++
src/gui/chronojump.cs | 55 ++++++++++++++++++---
src/gui/chronopicWizard.cs | 76 +++++++++++++++++++----------
4 files changed, 102 insertions(+), 34 deletions(-)
---
diff --git a/diagrams/classes/chronopicConnection.dia b/diagrams/classes/chronopicConnection.dia
index 13e6ff9..2de3d02 100644
Binary files a/diagrams/classes/chronopicConnection.dia and b/diagrams/classes/chronopicConnection.dia differ
diff --git a/src/constants.cs b/src/constants.cs
index 7c9af88..42ff536 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -692,6 +692,11 @@ public class Constants
}
public enum Menuitem_modes { JUMPSSIMPLE, JUMPSREACTIVE, RUNSSIMPLE, RUNSINTERVALLIC,
POWERGRAVITATORY, POWERINERTIAL, OTHER }
+ public static bool Menuitem_mode_IsContacts (Menuitem_modes m) {
+ if(m == Menuitem_modes.POWERGRAVITATORY || m == Menuitem_modes.POWERINERTIAL)
+ return false;
+ return true;
+ }
public static string All = "All";
public static string None = "None";
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 6c84ad4..ce6374c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -477,6 +477,8 @@ public partial class ChronoJumpWindow
ChronopicWindow chronopicWin;
ChronopicWizardWindow chronopicWizardWin;
+ string wizardPortContacts;
+ string wizardPortEncoder;
/*
* useful to not check for Chronopic if changing select_menuitem_mode_toggled from a 50 to a 50
@@ -611,6 +613,8 @@ public partial class ChronoJumpWindow
repetitiveConditionsWin.FakeButtonClose.Clicked += new
EventHandler(on_repetitive_conditions_closed);
createChronopicWindow(false, "");
+ wizardPortContacts = "";
+ wizardPortEncoder = "";
on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
on_extra_window_pulses_test_changed(new object(), new EventArgs());
@@ -3244,13 +3248,29 @@ public partial class ChronoJumpWindow
//it's not visible at startup
main_menu.Visible = true;
- //do not perform autoDetect if we are on contacts and already detected
- if( chronopicWin.Connected && m != Constants.Menuitem_modes.POWERGRAVITATORY && m !=
Constants.Menuitem_modes.POWERINERTIAL )
- change_multitest_firmware(m);
- else
- autoDetectChronopic(m); //will perform change_multitest_firmware at the end (except
on POWERs)
-
-
+ /*
+ if(Constants.Menuitem_mode_IsContacts(m) && wizardPortContacts != "")
+ chronopicWin.Connected = true;
+ else if (! Constants.Menuitem_mode_IsContacts(m) && wizardPortEncoder != "")
+ chronopicWin.Connected = true;
+ */
+
+//mySp = new SerialPort(myPort);
+//myCp = new Chronopic(mySp);
+//pensar en duplicats de chronopic i serial port
+//connectar amb chronopicInit.Do ?
+
+
+ if(Constants.Menuitem_mode_IsContacts(m))
+ {
+ if(chronopicWin.Connected)
+ change_multitest_firmware(m);
+ else
+ autoDetectChronopic(m); //on contacts will perform change_multitest_firmware
at the end
+ }
+ else if(wizardPortEncoder == "")
+ autoDetectChronopic(m);
+
chronojumpWindowTestsNext();
}
@@ -6946,8 +6966,27 @@ LogB.Debug("X");
);
}
- private void on_button_chronopic_wizard_clicked (object o, EventArgs args) {
+ private void on_button_chronopic_wizard_clicked (object o, EventArgs args)
+ {
chronopicWizardWin = ChronopicWizardWindow.Show();
+
+ chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -=
+ new EventHandler(chronopic_wizard_finished);
+ chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked += new
+ EventHandler(chronopic_wizard_finished);
+ }
+ private void chronopic_wizard_finished (object o, EventArgs args)
+ {
+ chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -=
+ new EventHandler(chronopic_wizard_finished);
+
+ wizardPortContacts = chronopicWizardWin.PortContacts;
+ wizardPortEncoder = chronopicWizardWin.PortEncoder;
+
+ LogB.Information("wizardPortContacts: " + wizardPortContacts);
+ LogB.Information("wizardPortEncoder: " + wizardPortEncoder);
+
+ chronopicWizardWin.HideAndNull();
}
//start/end auto mode
diff --git a/src/gui/chronopicWizard.cs b/src/gui/chronopicWizard.cs
index e0f3502..c47e55b 100644
--- a/src/gui/chronopicWizard.cs
+++ b/src/gui/chronopicWizard.cs
@@ -72,8 +72,9 @@ public class ChronopicWizardWindow
static ChronopicWizardWindow ChronopicWizardWindowBox;
- public string portContacts;
- public string portEncoder;
+ public Gtk.Button FakeButtonChronopicWizardFinished;
+ public string PortContacts;
+ public string PortEncoder;
private ArrayList portsAlreadyDetected;
@@ -100,6 +101,10 @@ public class ChronopicWizardWindow
void initialize()
{
+ FakeButtonChronopicWizardFinished = new Gtk.Button();
+ PortContacts = "";
+ PortEncoder = "";
+
portsAlreadyDetected = new ArrayList(0);
notebook_main.CurrentPage = 0;
@@ -134,11 +139,7 @@ public class ChronopicWizardWindow
ArrayList detectPorts()
{
//detect ports
- string [] ports = {""};
- if(UtilAll.IsWindows())
- ports = SerialPort.GetPortNames();
- else
- ports = Directory.GetFiles("/dev/", "ttyUSB*");
+ string [] ports = ChronopicPorts.GetPorts();
//get only new ports
ArrayList portsNew = new ArrayList(0);
@@ -236,6 +237,7 @@ public class ChronopicWizardWindow
return true;
}
+ //gui for contacts detection ----
void on_button_done_unplugged_clicked (object o, EventArgs args)
{
@@ -282,6 +284,8 @@ public class ChronopicWizardWindow
button_done_contacts.Sensitive = true;
}
+ //gui for encoder detection ----
+
void on_button_done_encoder_clicked (object o, EventArgs args)
{
button_done_encoder.Sensitive = false;
@@ -347,7 +351,7 @@ public class ChronopicWizardWindow
//from page 2 to page 3 detect encoder
//exit if there's no encoder
if(radio_start_contacts.Active)
- on_button_cancel_clicked(o, args); //TODO
+ finishWizard();
else {
button_next.Sensitive = false; //unsensitive until click on Done
@@ -356,37 +360,57 @@ public class ChronopicWizardWindow
}
}
else if(notebook_main.CurrentPage == 3) {
- //exiting form encoder page
- on_button_cancel_clicked(o, args); //TODO
+ finishWizard();
}
//change the page
notebook_main.CurrentPage += advancePages;
}
+
+ private void finishWizard()
+ {
+ if(radio_start_contacts.Active || radio_start_both.Active)
+ PortContacts = readSelectedRadioButton(radio_contacts1, radio_contacts2,
+ radio_contacts3, radio_contacts4, radio_contacts5);
+
+ if(radio_start_encoder.Active || radio_start_both.Active)
+ PortEncoder = readSelectedRadioButton(radio_encoder1, radio_encoder2,
+ radio_encoder3, radio_encoder4, radio_encoder5);
+
+ //exiting using finish (next) button
+ FakeButtonChronopicWizardFinished.Click();
+ }
+
+ private string readSelectedRadioButton(Gtk.RadioButton radio1, Gtk.RadioButton radio2,
+ Gtk.RadioButton radio3, Gtk.RadioButton radio4, Gtk.RadioButton radio5)
+ {
+ if(radio1.Active)
+ return radio1.Label;
+ else if(radio2.Active)
+ return radio2.Label;
+ else if(radio3.Active)
+ return radio3.Label;
+ else if(radio4.Active)
+ return radio4.Label;
+ else //if(radio5.Active)
+ return radio5.Label;
+ }
- void on_button_cancel_clicked (object o, EventArgs args)
+ public void HideAndNull ()
{
ChronopicWizardWindowBox.chronopic_wizard_win.Hide();
ChronopicWizardWindowBox = null;
}
+
+ void on_button_cancel_clicked (object o, EventArgs args)
+ {
+ HideAndNull();
+ }
void on_delete_event (object o, DeleteEventArgs args)
{
- /*
- * copied from preferences
- *
- //do not hide/exit if copyiing
- if (thread != null && thread.IsAlive)
- args.RetVal = true;
- else {
- */
- ChronopicWizardWindowBox.chronopic_wizard_win.Hide();
- ChronopicWizardWindowBox = null;
- /*
- }
- */
+ progressbarContinue = false;
+ HideAndNull();
}
-
-
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]