[chronojump] Force sensor: binary detect from firmware, remove from gui. added webcam



commit 908f72ed84b3e2b31167737d45a89ca091e4797d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 18 17:29:55 2019 +0100

    Force sensor: binary detect from firmware, remove from gui. added webcam

 glade/app1.glade       | 42 +++++++++++++++++++--------------------
 src/gui/chronojump.cs  | 15 +-------------
 src/gui/forceSensor.cs | 53 ++++++++++++++++++++++++++++++++++++--------------
 3 files changed, 59 insertions(+), 51 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 3836d02f..374bc26a 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -5960,19 +5960,6 @@ EncoderInertialCapture</property>
                                                             <property name="position">2</property>
                                                             </packing>
                                                             </child>
-                                                            <child>
-                                                            <widget class="GtkCheckButton" 
id="check_force_sensor_capture_binary">
-                                                            <property name="label">Binary</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property 
name="receives_default">False</property>
-                                                            <property name="draw_indicator">True</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">3</property>
-                                                            </packing>
-                                                            </child>
                                                           </widget>
                                                         </child>
                                                       </widget>
@@ -9078,7 +9065,7 @@ EncoderInertialCapture</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkHBox" 
id="hbox_capture_phases_time_record">
+                                                            <widget class="GtkHBox" 
id="hbox_capture_phases_time">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">10</property>
@@ -9241,8 +9228,26 @@ EncoderInertialCapture</property>
                                                             <property name="position">2</property>
                                                             </packing>
                                                             </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkVSeparator" 
id="vseparator_force_sensor_camera_space">
+                                                            <property name="can_focus">False</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="padding">30</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
                                                             <child>
-                                                            <widget class="GtkVBox" id="vbox33">
+                                                            <widget class="GtkVBox" 
id="vbox_contacts_camera">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -9394,13 +9399,6 @@ EncoderInertialCapture</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
-                                                            <packing>
-                                                            <property name="expand">True</property>
-                                                            <property name="fill">True</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkLabel" id="label20">
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 90a642b6..b419c04b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -301,7 +301,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_video_no;
 
        //force sensor
-       [Widget] Gtk.HBox hbox_capture_phases_time_record;
+       [Widget] Gtk.HBox hbox_capture_phases_time;
 
        //multiChronopic        
        [Widget] Gtk.Button button_edit_selected_multi_chronopic;
@@ -343,7 +343,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_activate_chronopics;
        [Widget] Gtk.Button button_threshold;
        [Widget] Gtk.Button button_force_sensor_adjust;
-       [Widget] Gtk.CheckButton check_force_sensor_capture_binary;
 
        //non standard icons    
        [Widget] Gtk.Image image_jump_reactive_bell;
@@ -3199,7 +3198,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = true;
                        button_force_sensor_adjust.Visible = false;
-                       check_force_sensor_capture_binary.Visible = false;
                        if(m == Constants.Menuitem_modes.JUMPSSIMPLE) 
                        {
                                notebooks_change(m);
@@ -3230,7 +3228,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = true;
                        button_force_sensor_adjust.Visible = false;
-                       check_force_sensor_capture_binary.Visible = false;
                        button_inspect_last_test.Visible = true;
 
                        if(m == Constants.Menuitem_modes.RUNSSIMPLE) 
@@ -3371,7 +3368,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = false;
                        button_force_sensor_adjust.Visible = true;
-                       check_force_sensor_capture_binary.Visible = true;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                        hbox_results_legend.Visible = false;
 
@@ -3390,7 +3386,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = false;
                        button_threshold.Visible = false;
                        button_force_sensor_adjust.Visible = false;
-                       check_force_sensor_capture_binary.Visible = false;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                        hbox_results_legend.Visible = false;
 
@@ -3412,7 +3407,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = false;
                        button_threshold.Visible = true;
                        button_force_sensor_adjust.Visible = false;
-                       check_force_sensor_capture_binary.Visible = false;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                }
                else {  //m == Constants.Menuitem_modes.OTHER (contacts / other)
@@ -3426,7 +3420,6 @@ public partial class ChronoJumpWindow
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = false;
                        button_threshold.Visible = true;
                        button_force_sensor_adjust.Visible = false;
-                       check_force_sensor_capture_binary.Visible = false;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                }
 
@@ -7555,7 +7548,6 @@ LogB.Debug("mc finished 5");
                vbox_execute_test.Sensitive = false;
                button_execute_test.Sensitive = false;
                button_force_sensor_adjust.Sensitive = false;
-               check_force_sensor_capture_binary.Sensitive = false;
 
                encoderButtonsSensitive(encoderSensEnum.NOSESSION);
                
@@ -7576,7 +7568,6 @@ LogB.Debug("mc finished 5");
                button_contacts_person_change.Sensitive = true;
                button_encoder_person_change.Sensitive = true;
                button_force_sensor_adjust.Sensitive = false;
-               check_force_sensor_capture_binary.Sensitive = false;
                
                menuSessionSensitive(true);
                vbox_stats.Sensitive = true;
@@ -7604,7 +7595,6 @@ LogB.Debug("mc finished 5");
                menuPersonSelectedSensitive(false);
                vbox_execute_test.Sensitive = false;
                button_force_sensor_adjust.Sensitive = false;
-               check_force_sensor_capture_binary.Sensitive = false;
 
                label_top_person_name.Text = "";
                label_top_encoder_person_name.Text = "";
@@ -7640,7 +7630,6 @@ LogB.Debug("mc finished 5");
                combo_result_runs_interval.Sensitive = true;
                combo_pulses.Sensitive = true;
                button_force_sensor_adjust.Sensitive = true;
-               check_force_sensor_capture_binary.Sensitive = true;
                
                vbox_execute_test.Sensitive = true;
        }
@@ -7703,7 +7692,6 @@ LogB.Debug("mc finished 5");
                button_activate_chronopics.Sensitive = false;
                button_threshold.Sensitive = false;
                button_force_sensor_adjust.Sensitive = false;
-               check_force_sensor_capture_binary.Sensitive = false;
                button_auto_start.Sensitive = false;
                notebook_options_top.Sensitive = false;
                event_execute_button_update.Sensitive = false;
@@ -7769,7 +7757,6 @@ LogB.Debug("mc finished 5");
                button_activate_chronopics.Sensitive = true;
                button_threshold.Sensitive = true;
                button_force_sensor_adjust.Sensitive = true;
-               check_force_sensor_capture_binary.Sensitive = true;
                button_auto_start.Sensitive = true;
                notebook_options_top.Sensitive = true;
                event_execute_button_update.Sensitive = true;
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index cb4cdba2..26c30301 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -75,6 +75,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.TextView textview_force_sensor_capture_comment;
        [Widget] Gtk.HBox hbox_force_sensor_lat_and_comments;
        [Widget] Gtk.Alignment alignment_force_sensor_adjust;
+       [Widget] Gtk.VSeparator vseparator_force_sensor_camera_space;
        [Widget] Gtk.Button button_force_sensor_tare;
        [Widget] Gtk.Button button_force_sensor_calibrate;
        [Widget] Gtk.Label label_force_sensor_value_max;
@@ -120,6 +121,7 @@ public partial class ChronoJumpWindow
        string forceSensorPortName;
        SerialPort portFS; //Attention!! Don't reopen port because arduino makes reset and tare, 
calibration... is lost
        bool portFSOpened;
+       bool forceSensorBinaryCapture;
 
 
        Gdk.GC pen_black_force_capture;
@@ -211,13 +213,6 @@ public partial class ChronoJumpWindow
 
                Thread.Sleep(3000); //sleep to let arduino start reading serial event
 
-               //At the moment, binary code do not check version, tare, calibrate
-               if(forceSensorBinaryCapture())
-               {
-                       portFSOpened = true;
-                       return true;
-               }
-
                LogB.Information(" FS connect 6: get version");
 
                string version = forceSensorCheckVersionDo();
@@ -247,6 +242,13 @@ public partial class ChronoJumpWindow
                                return false;
                }
 
+               bool forceSensorBinaryCapture = false;
+                double versionDouble = Convert.ToDouble(Util.ChangeDecimalSeparator(version));
+               if(versionDouble >= Convert.ToDouble(Util.ChangeDecimalSeparator("0.3"))) //from 0.3 versions 
can be binary
+                       forceSensorBinaryCapture = forceSensorCheckBinaryCapture();
+
+               LogB.Information("forceSensorBinaryCapture = " + forceSensorBinaryCapture.ToString());
+
                portFSOpened = true;
                forceSensorOtherMessage = "Connected!";
                LogB.Information(" FS connect 7: connected and adjusted!");
@@ -528,6 +530,31 @@ public partial class ChronoJumpWindow
                return(str.Remove(0,13));
        }
 
+       //Attention: no GTK here!!
+       private bool forceSensorCheckBinaryCapture()
+       {
+               if(! forceSensorSendCommand("get_transmission_format:", "Checking transmission format ...", 
"Catched checking transmission format"))
+                       return false;
+
+               string str = "";
+               do {
+                       Thread.Sleep(100); //sleep to let arduino start reading
+                       try {
+                               str = portFS.ReadLine().Trim();
+                       } catch {
+                               forceSensorOtherMessage = "Disconnected";
+                               return false;
+                       }
+                       LogB.Information("init string: " + str);
+               }
+               while(! (str.Contains("binary") || str.Contains("text")) );
+
+               forceSensorOtherMessageShowSeconds = false;
+               forceSensorOtherMessage = str;
+
+               return (str == "binary");
+       }
+
        //Attention: no GTK here!!
        private void forceSensorCapturePre()
        {
@@ -586,11 +613,6 @@ public partial class ChronoJumpWindow
                forceCaptureThread.Start();
        }
 
-       private bool forceSensorBinaryCapture()
-       {
-               return check_force_sensor_capture_binary.Active;
-       }
-
        private bool readBinaryRowMark()
        {
                if(portFS.ReadByte() != 255)
@@ -687,7 +709,7 @@ public partial class ChronoJumpWindow
                writer.WriteLine("Time (micros);Force(N)");
                str = "";
                int firstTime = 0;
-               bool forceSensorBinary = forceSensorBinaryCapture();
+//             bool forceSensorBinary = forceSensorBinaryCapture();
 
                //LogB.Information("pre bucle");
                //LogB.Information(string.Format("forceProcessFinish: {0}, forceProcessCancel: {1}, 
forceProcessError: {2}", forceProcessFinish, forceProcessCancel, forceProcessError));
@@ -697,7 +719,7 @@ public partial class ChronoJumpWindow
                        int time = 0;
                        double force = 0;
 
-                       if(forceSensorBinary)
+                       if(forceSensorBinaryCapture)
                        {
                                if(! readBinaryRowMark())
                                        continue;
@@ -1461,7 +1483,8 @@ LogB.Information(" re R ");
 
        private void showHideForceSensorControls(bool modeForceSensor)
        {
-               hbox_capture_phases_time_record.Visible = ! modeForceSensor;
+               hbox_capture_phases_time.Visible = ! modeForceSensor;
+               vseparator_force_sensor_camera_space.Visible = modeForceSensor; //extra space before camera 
on force sensor
                menuitem_force_sensor_open_folder.Visible = modeForceSensor;
                menuitem_force_sensor_check_version.Visible = modeForceSensor;
        }


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