[chronojump] On multitest do not connect first and at second button press do the capture. Now done all at once, s



commit ed7513b474db3c15b826b5a6518beacfb7e1c342
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu May 19 17:20:58 2022 +0200

    On multitest do not connect first and at second button press do the capture. Now done all at once, 
supressed having to press platform, thread, small gui.

 glade/app1.glade           | 24 +---------------
 src/chronopic.cs           | 13 +++++++--
 src/chronopic2016.cs       | 72 ++--------------------------------------------
 src/gui/app1/chronojump.cs | 33 ++-------------------
 src/gui/chronopic.cs       | 28 +++++++-----------
 5 files changed, 26 insertions(+), 144 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 454f4006b..074c5db1a 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -6141,33 +6141,11 @@ EncoderInertialCapture</property>
                                                             <property name="left_padding">2</property>
                                                             <property name="right_padding">2</property>
                                                             <child>
-                                                            <widget class="GtkVBox" id="vbox271">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" 
id="label_button_execute_connect">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" 
translatable="yes">Connect</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_button_execute">
+                                                            <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="stock">gtk-apply</property>
                                                             </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
                                                             </child>
                                                             </widget>
                                                             </child>
diff --git a/src/chronopic.cs b/src/chronopic.cs
index 011cc3de4..3df173a00 100644
--- a/src/chronopic.cs
+++ b/src/chronopic.cs
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2005  Juan Gonzalez Gomez
- * Copyright (C) 2014-2017  Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2014-2022  Xavier de Blas <xaviblas gmail com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -506,8 +506,9 @@ public class ChronopicInit
                        //-- Create chronopic object, for accessing chronopic
                        myCp = new Chronopic(mySp);
                        
-                       LogB.Information("chronopicInit-2.1");          
-                       myCp.Flush();
+                       LogB.Information("chronopicInit-2.1");
+                       if(mySp.BytesToRead > 0)
+                               myCp.Flush();
                        
                        //if myCp has been cancelled
                        if(myCp.AbortFlush) {
@@ -522,6 +523,10 @@ public class ChronopicInit
 
                                //-- Obtener el estado inicial de la plataforma
 
+                               /*
+                                  since 2.2.2 do not make connect having user to press platform.
+                                  Just directly do the jump or race
+
                                bool ok=false;
                                LogB.Information("chronopicInit-4");            
                                do {
@@ -535,6 +540,8 @@ public class ChronopicInit
                                        LogB.Error(string.Format("Error: {0}", myCp.Error));
                                        success = false;
                                }
+                               */
+                               success = true;
                        }
                } catch {
                        LogB.Error("chronopicInit-2.a catched");
diff --git a/src/chronopic2016.cs b/src/chronopic2016.cs
index 7e2432a2d..f2e5ccc5a 100644
--- a/src/chronopic2016.cs
+++ b/src/chronopic2016.cs
@@ -59,10 +59,6 @@ public class Chronopic2016
 
        // -----ConnectContactsReal START ----->
 
-       Gtk.Window chronopic_contacts_real_win;
-       Gtk.ProgressBar progressbar;
-
-       private Thread connectContactsRealThread;
        //used to pass crp to connectContactsRealThread
        private ChronopicRegisterPort crpConnectContactsRealThread;
        private ChronopicInit chronopicInit;
@@ -70,40 +66,6 @@ public class Chronopic2016
        public bool SuccededConnectContactsRealThread;
        public Gtk.Button FakeButtonContactsRealDone;
 
-       private void createGui(Gtk.Window app1, ChronopicRegisterPort crp, string labelStr)
-       {
-               chronopic_contacts_real_win = new Window ("Chronopic connection");
-               chronopic_contacts_real_win.AllowGrow = false;
-               chronopic_contacts_real_win.Modal = true;
-               chronopic_contacts_real_win.TransientFor = app1;
-               chronopic_contacts_real_win.BorderWidth= 20;
-
-               chronopic_contacts_real_win.DeleteEvent += on_delete_event;
-
-               Gtk.VBox vbox_main = new Gtk.VBox(false, 20);
-               chronopic_contacts_real_win.Add(vbox_main);
-
-               LogB.Information("Connecting real (starting connection)");
-               LogB.Information("Press test button on Chronopic");
-
-               Gtk.Label labelMessage = new Gtk.Label();
-               labelMessage.Text = labelStr + "\n" +
-                       "\n" + Catalog.GetString("Port") + ": " + crp.Port +
-                       "\n" + Catalog.GetString("Serial Number") + ": " + crp.SerialNumber;
-               vbox_main.Add(labelMessage);
-
-               progressbar = new Gtk.ProgressBar();
-               vbox_main.Add(progressbar);
-
-               Gtk.Button button_cancel = new Gtk.Button("Cancel");
-               button_cancel.Clicked += new EventHandler(on_button_cancel_clicked);
-               Gtk.HButtonBox hbox = new Gtk.HButtonBox ();
-               hbox.Add(button_cancel);
-               vbox_main.Add(hbox);
-
-               chronopic_contacts_real_win.ShowAll();
-       }
-
        private void on_button_cancel_clicked(object o, EventArgs args)
        {
                if(cpDoing == 1)
@@ -126,17 +88,11 @@ public class Chronopic2016
        public void ConnectContactsReal(Gtk.Window app1, ChronopicRegisterPort crp,
                        int cpCount, string labelStr) //cpCount 2 is for 2nd chronopic on multichronopic
        {
-               createGui(app1, crp, labelStr);
-
                crpConnectContactsRealThread = crp;
 
                cpDoing = cpCount;
 
-               connectContactsRealThread = new Thread (new ThreadStart (connectContactsRealDo));
-               GLib.Idle.Add (new GLib.IdleHandler (pulseConnectContactsReal));
-
-               LogB.ThreadStart();
-               connectContactsRealThread.Start();
+               connectContactsRealDo();
        }
 
        private void connectContactsRealDo()
@@ -169,23 +125,7 @@ public class Chronopic2016
                        assignLastConnectedVariables(crp);
 
                SuccededConnectContactsRealThread = connected;
-       }
-
-       bool pulseConnectContactsReal()
-       {
-               if(! connectContactsRealThread.IsAlive)
-               {
-                       progressbar.Fraction = 1.0;
-                       LogB.ThreadEnding();
-                       connectContactsRealEnd();
-                       LogB.ThreadEnded();
-
-                       return false;
-               }
-
-               progressbar.Pulse();
-               Thread.Sleep (50);
-               return true;
+               connectContactsRealEnd();
        }
 
        private void connectContactsRealEnd()
@@ -195,16 +135,8 @@ public class Chronopic2016
                else
                        LogB.Warning("Failure at Connecting real!");
 
-               hideAndNull();
-
                FakeButtonContactsRealDone.Click();
        }
-       private void hideAndNull()
-       {
-               chronopic_contacts_real_win.Hide();
-               chronopic_contacts_real_win = null;
-       }
-
 
        public bool IsLastConnectedReal(ChronopicRegisterPort crp, int cpCount)
        {
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index f8859f607..3471a7c15 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -3607,7 +3607,8 @@ public partial class ChronoJumpWindow
 
                if(m == Constants.Modes.JUMPSSIMPLE || m == Constants.Modes.JUMPSREACTIVE)
                {
-                       button_execute_test_show_connect_or_execute(! 
cp2016.SuccededConnectContactsRealThread);
+                       button_contacts_detect.Visible = true;
+                       hbox_contacts_detect_and_execute.Visible = false;
 
                        notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.CONTACTS);
                        //notebook_capture_analyze.ShowTabs = true;
@@ -3681,12 +3682,6 @@ public partial class ChronoJumpWindow
                        LogB.Information(string.Format("wireless conditions B: {0}, {1}",
                                cp2016.StoredWireless, chronopicRegister != null));
 
-                       if(cp2016.StoredWireless ||
-                                       (chronopicRegister != null && 
chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.RUN_WIRELESS) == 1) )
-                               button_execute_test_show_connect_or_execute(false);
-                       else
-                               button_execute_test_show_connect_or_execute(! 
cp2016.SuccededConnectContactsRealThread);
-
                        button_contacts_detect.Visible = true;
                        hbox_contacts_detect_and_execute.Visible = false;
 
@@ -3874,7 +3869,6 @@ public partial class ChronoJumpWindow
                } 
                else if(m == Constants.Modes.FORCESENSOR)
                {
-                       button_execute_test_show_connect_or_execute(false);
                        button_contacts_detect.Visible = true;
                        hbox_contacts_detect_and_execute.Visible = false;
 
@@ -3924,7 +3918,6 @@ public partial class ChronoJumpWindow
                }
                else if(m == Constants.Modes.RUNSENCODER)
                {
-                       button_execute_test_show_connect_or_execute(false);
                        button_contacts_detect.Visible = true;
                        hbox_contacts_detect_and_execute.Visible = false;
 
@@ -3971,7 +3964,6 @@ public partial class ChronoJumpWindow
                else if(m == Constants.Modes.RT)
                {
                        event_execute_drawingarea.Visible = true;
-                       button_execute_test_show_connect_or_execute(! 
cp2016.SuccededConnectContactsRealThread);
 
                        notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.CONTACTS);
                        notebooks_change(m);
@@ -3991,7 +3983,6 @@ public partial class ChronoJumpWindow
                }
                else {  //m == Constants.Modes.OTHER (contacts / other)
                        event_execute_drawingarea.Visible = true;
-                       button_execute_test_show_connect_or_execute(! 
cp2016.SuccededConnectContactsRealThread);
 
                        notebook_sup.CurrentPage = Convert.ToInt32(notebook_sup_pages.CONTACTS);
                        hbox_other.Visible = true;
@@ -4413,25 +4404,6 @@ public partial class ChronoJumpWindow
                        checkFile(Constants.CheckFileOp.RUNS_INTERVALLIC_CAPTURE_SAVE_IMAGE);
        }
 
-       [Widget] Gtk.Label label_button_execute_connect;
-
-       private void button_execute_test_show_connect_or_execute (bool connect_or_execute)
-       {
-               string space = Catalog.GetString("Space");
-
-               if(connect_or_execute)
-               {
-                       label_button_execute_connect.Visible = true;
-                       image_button_execute.Visible = false;
-                       button_execute_test.TooltipText = Catalog.GetString("Connect") + string.Format(" 
({0}+{1})", kCtrl, space);
-               } else
-               {
-                       label_button_execute_connect.Visible = false;
-                       image_button_execute.Visible = true;
-                       button_execute_test.TooltipText = Catalog.GetString("Execute test") + string.Format(" 
({0}+{1})", kCtrl, space);
-               }
-       }
-
        /*
         * end of menu test selectors
         */
@@ -4930,7 +4902,6 @@ public partial class ChronoJumpWindow
                {
                        //cp2016.StoredCanCaptureContacts = true;
                        cp2016.StoredWireless = true;
-                       button_execute_test_show_connect_or_execute(false); //to not show "connect"
 
                        on_button_execute_test_acceptedPre_start_camera(WebcamStartedTestStart.CHRONOPIC);
                        return;
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 7b3af1306..7b56ac455 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2017   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2022   Xavier de Blas <xaviblas gmail com>
  */
 
 
@@ -126,13 +126,6 @@ public partial class ChronoJumpWindow
                        message = Catalog.GetString("Please, cut photocell barrier or click Chronopic TEST 
button.");
 
                cp2016.ConnectContactsReal(app1, crp, numCP, message);
-
-               //manage show threshold stuff
-               threshold.ChronopicFirmwareReconnected(numCP);  //t_stored_on_chronopic will be 50, and later 
firmware will be changed
-               label_threshold.Text = //Catalog.GetString("Threshold") + " " +
-                       threshold.GetLabel() + " ms";
-               if(threshold.GetT == 50)
-                       label_threshold.Text += " (" + Catalog.GetString("Applied") + ")";
        }
 
        private void on_connection_contacts_real_done (object o, EventArgs args)
@@ -144,17 +137,19 @@ public partial class ChronoJumpWindow
                {
                        LogB.Information("Success at Connecting real! (main GUI)");
 
-                       //new on 2.0.3 do not continue with sequence, exit, and execute test will be another 
press button
-                       /*
-                       connectingSequence = connectingSequenceEnum.FIRMWAREIFNEEDED;
-                       chronopicConnectionSequenceDo();
-                       */
-
-                       //change appearance of execute test button
-                       button_execute_test_show_connect_or_execute(false);
+                       //manage show threshold stuff
+                       threshold.ChronopicFirmwareReconnected(1);      //t_stored_on_chronopic will be 50, 
and later firmware will be changed. TODO: may this work for Chronopic 2
+                       label_threshold.Text = //Catalog.GetString("Threshold") + " " +
+                               threshold.GetLabel() + " ms";
+                       if(threshold.GetT == 50)
+                               label_threshold.Text += " (" + Catalog.GetString("Applied") + ")";
 
                        UtilGtk.PrintLabelWithTooltip(event_execute_label_message,
                                        Catalog.GetString("Connected to Chronopic"));
+
+                       //2.2.2 At end of connection change firmware (because connection, change firmware, 
execute is on the same first button_press)
+                       connectingSequence = connectingSequenceEnum.FIRMWAREIFNEEDED;
+                       chronopicConnectionSequenceDo();
                } else
                        LogB.Warning("Failure at Connecting real! (main GUI)");
        }
@@ -173,7 +168,6 @@ public partial class ChronoJumpWindow
                                label_threshold.Text += " (" + Catalog.GetString("Failed") + ")";
                }
 
-
                connectingSequence = connectingSequenceEnum.END;
                chronopicConnectionSequenceDo();
        }


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