[chronojump] Networks: Signal to know if encoder has been connected on devices window



commit e999940f1265419554f5aabb25a6f1eb79c02956
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jan 30 15:39:58 2020 +0100

    Networks: Signal to know if encoder has been connected on devices window

 glade/app1.glade             | 175 ++++++++++++++++++++++++++-----------------
 src/gui/app1/chronojump.cs   |  47 +++++++++---
 src/gui/chronopicRegister.cs |  12 ++-
 src/gui/encoder.cs           |   3 +-
 src/gui/guiTests.cs          |   2 +-
 src/gui/networks.cs          |   2 +-
 6 files changed, 158 insertions(+), 83 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 648cc1a4..5c842a3b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -33880,68 +33880,6 @@ then click this button.</property>
                       <widget class="GtkVBox" id="vbox110">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <child>
-                          <widget class="GtkHBox" id="hbox355">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <widget class="GtkButton" 
id="button_activate_chronopics_encoder_networks_problems">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="can_default">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="has_tooltip">True</property>
-                                <property name="tooltip" translatable="yes">Connect encoder</property>
-                                <property name="relief">half</property>
-                                <signal name="clicked" handler="on_chronopic_encoder_clicked" swapped="no"/>
-                                <child>
-                                  <widget class="GtkHBox" id="hbox356">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">6</property>
-                                    <child>
-                                      <widget class="GtkLabel" id="label435">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Device</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">True</property>
-                                        <property name="fill">True</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <widget class="GtkImage" id="image_chronopic_connect_encoder1">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-missing-image</property>
-                                        <property name="icon-size">2</property>
-                                      </widget>
-                                      <packing>
-                                        <property name="expand">True</property>
-                                        <property name="fill">True</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </widget>
-                                </child>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="padding">12</property>
-                                <property name="pack_type">end</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                          </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
                         <child>
                           <widget class="GtkHBox" id="hbox353">
                             <property name="visible">True</property>
@@ -33970,6 +33908,7 @@ then click this button.</property>
                                               <widget class="GtkImage" id="image_encoder_disconnected">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
+                                                <property name="yalign">0</property>
                                                 <property name="stock">gtk-no</property>
                                                 <property name="icon-size">2</property>
                                               </widget>
@@ -33980,12 +33919,100 @@ then click this button.</property>
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkLabel" id="label_chronopic_disconnected">
+                                              <widget class="GtkVBox" id="vbox171">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
-                                                <property name="xpad">5</property>
-                                                <property name="label" translatable="yes">Encoder 
disconnected.</property>
-                                                <property name="use_markup">True</property>
+                                                <property name="spacing">12</property>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label_chronopic_disconnected">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="xalign">0</property>
+                                                    <property name="label" translatable="yes">Encoder 
disconnected.</property>
+                                                    <property name="use_markup">True</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">0</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkLabel" id="label436">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="xalign">0</property>
+                                                    <property name="label" translatable="yes">Please, 
connect it and click here:</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">1</property>
+                                                  </packing>
+                                                </child>
+                                                <child>
+                                                  <widget class="GtkHBox" id="hbox356">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <child>
+                                                      <widget class="GtkButton" 
id="button_activate_chronopics_encoder_networks_problems">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property name="can_default">True</property>
+                                                        <property name="receives_default">True</property>
+                                                        <property name="has_tooltip">True</property>
+                                                        <property name="tooltip" translatable="yes">Connect 
encoder</property>
+                                                        <property name="relief">half</property>
+                                                        <signal name="clicked" 
handler="on_chronopic_encoder_clicked" swapped="no"/>
+                                                        <child>
+                                                          <widget class="GtkHBox" id="hbox357">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="border_width">6</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label435">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Device</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_chronopic_connect_encoder1">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                          </widget>
+                                                        </child>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="expand">True</property>
+                                                        <property name="fill">False</property>
+                                                        <property name="position">0</property>
+                                                      </packing>
+                                                    </child>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="padding">12</property>
+                                                    <property name="pack_type">end</property>
+                                                    <property name="position">2</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
                                                 <property name="expand">False</property>
@@ -34008,6 +34035,7 @@ then click this button.</property>
                                               <widget class="GtkImage" id="image_RFID_disconnected">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
+                                                <property name="yalign">0</property>
                                                 <property name="stock">gtk-no</property>
                                                 <property name="icon-size">2</property>
                                               </widget>
@@ -34021,13 +34049,12 @@ then click this button.</property>
                                               <widget class="GtkVBox" id="vbox168">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
-                                                <property name="spacing">8</property>
+                                                <property name="spacing">20</property>
                                                 <child>
                                                   <widget class="GtkLabel" id="label_RFID_disconnected">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
                                                     <property name="xalign">0</property>
-                                                    <property name="xpad">5</property>
                                                     <property name="label" translatable="yes">RFID has been 
disconnected!</property>
                                                     <property name="use_markup">True</property>
                                                   </widget>
@@ -34042,7 +34069,6 @@ then click this button.</property>
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
                                                     <property name="xalign">0</property>
-                                                    <property name="xpad">5</property>
                                                     <property name="label" translatable="yes">Please, 
connect it and restart Chronojump.</property>
                                                     <property name="use_markup">True</property>
                                                   </widget>
@@ -34092,6 +34118,17 @@ then click this button.</property>
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkHBox" id="hbox355">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index e10a15c8..1600cfa1 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -715,7 +715,7 @@ public partial class ChronoJumpWindow
                if(needToShowChronopicRegisterWindow)
                {
                        LogB.Information("Show chronopic resgister win");
-                       chronopicRegisterWin.Show();
+                       chronopicRegisterWin.Show(false);
                }
                LogB.Information("Chronojump window started");
        }
@@ -3428,7 +3428,7 @@ public partial class ChronoJumpWindow
 
                last_menuitem_mode_defined = true;
 
-               chronopicRegisterUpdate(false);
+               chronopicRegisterUpdate(false, false);
 
                chronojumpWindowTestsNext();
 
@@ -3798,7 +3798,7 @@ public partial class ChronoJumpWindow
                if(current_menuitem_mode == Constants.Menuitem_modes.RUNSINTERVALLIC && compujumpAutologout 
!= null)
                        compujumpAutologout.StartCapturingRunInterval();
 
-               chronopicRegisterUpdate(false);
+               chronopicRegisterUpdate(false, false);
 
                int numContacts = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
                LogB.Information("numContacts: " + numContacts);
@@ -3830,7 +3830,7 @@ public partial class ChronoJumpWindow
                                //new DialogMessage(Constants.MessageTypes.WARNING, 
Constants.SimulatedTestsNotAllowed);
                                //UtilGtk.DeviceColors(viewport_chronopics, false);
                                //open device window
-                               chronopicRegisterUpdate(true);
+                               chronopicRegisterUpdate(true, false);
 
                                return;
                        }
@@ -5285,7 +5285,7 @@ public partial class ChronoJumpWindow
                */
 
                //TODO: on Windows need to close the sp if it's open, and maybe the cp
-               chronopicRegisterUpdate(true);
+               chronopicRegisterUpdate(true, false);
        }
 
        private void on_chronopic_encoder_clicked (object o, EventArgs args) {
@@ -5296,7 +5296,11 @@ public partial class ChronoJumpWindow
                */
 
                //TODO: on Windows need to close the sp if it's open, and maybe the cp
-               chronopicRegisterUpdate(true);
+
+               if(o == (object) button_activate_chronopics_encoder_networks_problems)
+                       chronopicRegisterUpdate(true, true);
+               else
+                       chronopicRegisterUpdate(true, false);
        }
 
        
@@ -7500,7 +7504,7 @@ LogB.Debug("mc finished 5");
         * sensitive GUI on executeAuto methods 
         */
 
-       private void chronopicRegisterUpdate(bool openWindow)
+       private void chronopicRegisterUpdate(bool openWindow, bool networksNeedCheckEncoder)
        {
                //on Windows need to close the port before reading with FTDI dll
                if(UtilAll.IsWindows())
@@ -7538,15 +7542,40 @@ LogB.Debug("mc finished 5");
                if(openWindow)
                {
                        chronopicRegisterWin = new ChronopicRegisterWindow(app1, chronopicRegister.Crpl.L);
+
                        cp2016.WindowOpened = true;
 
                        if(app1Shown)
-                               chronopicRegisterWin.Show();
-                       else
+                       {
+                               chronopicRegisterWin.Show(networksNeedCheckEncoder);
+
+                               if (networksNeedCheckEncoder)
+                                       chronopicRegisterWin.FakeButtonNetworksCheckSensors.Clicked +=
+                                               new 
EventHandler(on_chronopic_register_win_close_networks_check_encoder);
+                       } else
                                needToShowChronopicRegisterWindow = true;
                }
        }
 
+       /*
+        * on networks when there's no encoder, hbox_encoder_disconnected is shown
+        * it has button_activate_chronopics_encoder_networks_problems
+        * this calls chronopicRegisterUpdate(true, true);
+        * second true is the networksNeedCheckEncoder
+        * so check here if encodee is configured
+        * when ChronopicRegisterWindow is close or destroyed (delete_event)
+        */
+       private void on_chronopic_register_win_close_networks_check_encoder (object o, EventArgs args)
+       {
+               chronopicRegisterWin.FakeButtonNetworksCheckSensors.Clicked -=
+                       new EventHandler(on_chronopic_register_win_close_networks_check_encoder);
+
+               List<ChronopicRegisterPort> l = SqliteChronopicRegister.SelectAll (false);
+               foreach(ChronopicRegisterPort crp in l)
+                       if(crp.Type == ChronopicRegisterPort.Types.ENCODER)
+                               notebook_start.CurrentPage = 1;
+       }
+
        //trying to fix when an OSX disconnects and reconnects same chronopic (and it has captured)
        private void closeSerialPort (object o, EventArgs args)
        {
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index 6ec7dea8..753e6afc 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -101,7 +101,8 @@ public class ChronopicRegisterWindow
        Gtk.Window chronopic_register_win;
        Gtk.VBox vbox_main;
        private List<ChronopicRegisterPort> listConnected;
-
+       private bool networksNeedCheckEncoder;
+       public Gtk.Button FakeButtonNetworksCheckSensors;
        public Gtk.Button FakeButtonCloseSerialPort;
 
        public ChronopicRegisterWindow(Gtk.Window app1, List<ChronopicRegisterPort> listAll)
@@ -131,10 +132,14 @@ public class ChronopicRegisterWindow
                createButtons();
        }
 
-       public void Show()
+       public void Show(bool networksNeedCheckEncoder)
        {
                chronopic_register_win.ShowAll();
                list_labels_selected_show(); //hide some label_selected if they are UNKNOWN
+
+               this.networksNeedCheckEncoder = networksNeedCheckEncoder;
+               if(networksNeedCheckEncoder)
+                       FakeButtonNetworksCheckSensors = new Gtk.Button();
        }
 
        private void createWindow(Gtk.Window app1)
@@ -445,6 +450,9 @@ public class ChronopicRegisterWindow
 
        private void on_button_close_clicked(object o, EventArgs args)
        {
+               if(networksNeedCheckEncoder && FakeButtonNetworksCheckSensors != null)
+                       FakeButtonNetworksCheckSensors.Click();
+
                chronopic_register_win.Hide();
                chronopic_register_win = null;
        }
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e6c5f90c..df9d8d46 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -115,6 +115,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.VPaned vpaned_encoder_main;
        [Widget] Gtk.VPaned vpaned_encoder_capture_video_and_set_graph;
        [Widget] Gtk.Button button_activate_chronopics_encoder;
+       [Widget] Gtk.Button button_activate_chronopics_encoder_networks_problems;
 
        [Widget] Gtk.Notebook notebook_encoder_sup;
        [Widget] Gtk.Notebook notebook_encoder_capture;
@@ -685,7 +686,7 @@ public partial class ChronoJumpWindow
                if(currentSession.Name == Constants.SessionSimulatedName && testsActive)
                        return true;
 
-               chronopicRegisterUpdate(false);
+               chronopicRegisterUpdate(false, false);
                int numEncoders = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.ENCODER);
                LogB.Information("numEncoders: " + numEncoders);
                if(numEncoders == 0)
diff --git a/src/gui/guiTests.cs b/src/gui/guiTests.cs
index 042adc9b..2b7730be 100644
--- a/src/gui/guiTests.cs
+++ b/src/gui/guiTests.cs
@@ -467,7 +467,7 @@ public partial class ChronoJumpWindow
        {
                LogB.TestStart("chronojumpWindowTestsChronopicContactReal");
 
-               chronopicRegisterUpdate(false);
+               chronopicRegisterUpdate(false, false);
                if(chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.CONTACTS) != 1)
                {
                        testsActive = false;
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 7eac0160..5c0edc41 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -201,7 +201,7 @@ public partial class ChronoJumpWindow
                        rfidProcessCancel = false;
                        networksRunIntervalCanChangePersonSQLReady = true;
 
-                       chronopicRegisterUpdate(false);
+                       chronopicRegisterUpdate(false, false);
                        if(chronopicRegister != null && chronopicRegister.GetRfidPortName() != "")
                        {
                                networksShowDeviceMissingRFID (false);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]