[chronojump] Jump, JumpRj shows icons for air/land while capturing



commit 2bcfac5af22be02e91af3715923a13ddef73faca
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 25 13:54:53 2022 +0200

    Jump, JumpRj shows icons for air/land while capturing

 glade/app1.glade                          | 68 ++++++++++++++++++++-----
 src/Makefile.am                           |  2 +-
 src/execute/event.cs                      | 16 +++++-
 src/execute/jump.cs                       | 83 ++++++++++++++++++++++++++++---
 src/execute/{runObjects.cs => objects.cs} | 43 ++++++++++++++++
 src/gui/app1/chronojump.cs                |  2 +
 src/gui/app1/icons.cs                     |  8 +++
 7 files changed, 201 insertions(+), 21 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index c885b90da..28d6b2a8c 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -6432,6 +6432,39 @@ EncoderInertialCapture</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkVBox" id="vbox102">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_jump_execute_air">
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</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_jump_execute_land">
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-missing-image</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">2</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" id="hbox94">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -6495,7 +6528,7 @@ EncoderInertialCapture</property>
                                                             <packing>
                                                             <property name="expand">True</property>
                                                             <property name="fill">True</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
@@ -26328,6 +26361,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -33127,18 +33163,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -33175,6 +33199,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -42616,6 +42652,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -50689,6 +50728,9 @@ Since Chronojump 2.1.3, backups contain the complete data.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             </widget>
diff --git a/src/Makefile.am b/src/Makefile.am
index ceb81b4ce..539bcd61d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -180,7 +180,7 @@ SOURCES = \
        execute/event.cs\
        execute/jump.cs\
        execute/run.cs\
-       execute/runObjects.cs\
+       execute/objects.cs\
        execute/pulse.cs\
        execute/reactionTime.cs\
        execute/multiChronopic.cs\
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 54b867a33..654861944 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -233,6 +233,11 @@ public class EventExecute
                if ( ! thread.IsAlive || cancel) {
                        LogB.ThreadEnding();
 
+                       //TODO: only for mode jump
+                       //don't show any of the jumpChangeImage icons
+                       jumpChangeImageForceHide();
+
+                       //TODO: only for mode run
                        //don't show any of the runChangeImage icons
                        runChangeImageForceHide();
 
@@ -336,7 +341,10 @@ public class EventExecute
 
                // races specific --------------------------------->
 
-               runChangeImageIfNeeded();
+               //TODO: pass mode and only do what related to mode
+
+               jumpChangeImageIfNeeded ();
+               runChangeImageIfNeeded ();
 
                updateRunPhaseInfoManage();
 
@@ -401,10 +409,16 @@ public class EventExecute
                return true;
        }
 
+       protected virtual void jumpChangeImageIfNeeded()
+       {
+       }
        protected virtual void runChangeImageIfNeeded()
        {
        }
 
+       protected virtual void jumpChangeImageForceHide()
+       {
+       }
        protected virtual void runChangeImageForceHide()
        {
        }
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index a4fbccd53..cd9fbd335 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -47,11 +47,14 @@ public class JumpExecute : EventExecute
                PRE_OR_DOING, PLATFORM_END
        }
        protected static jumpPhases jumpPhase;
+       protected static JumpChangeImage jumpChangeImage;
 
        private int angle = -1;
        private bool avoidGraph;
        private bool heightPreferred;
        protected bool metersSecondsPreferred;
+       protected Gtk.Image image_jump_execute_air;
+       protected Gtk.Image image_jump_execute_land;
        protected bool upload;
        protected int uploadStationId;
        protected bool django;
@@ -69,6 +72,7 @@ public class JumpExecute : EventExecute
                        bool avoidGraph, //on configChronojump.Exhibition do not show graph because it gets 
too slow with big database
                        bool heightPreferred, bool metersSecondsPreferred,
                        int graphLimit, bool graphAllTypes, bool graphAllPersons,
+                       Gtk.Image image_jump_execute_air, Gtk.Image image_jump_execute_land,
                        bool upload, int uploadStationId, bool django //upload: configChronojump.Compujump && 
upload (contacts) button active
                        )
        {
@@ -95,6 +99,8 @@ public class JumpExecute : EventExecute
                this.graphLimit = graphLimit;
                this.graphAllTypes = graphAllTypes;
                this.graphAllPersons = graphAllPersons;
+               this.image_jump_execute_air = image_jump_execute_air;
+               this.image_jump_execute_land = image_jump_execute_land;
                this.upload = upload;
                this.uploadStationId = uploadStationId;
                this.django = django;
@@ -146,6 +152,7 @@ public class JumpExecute : EventExecute
                LogB.Information("Jumps Manage!");
                //boolean to know if chronopic has been disconnected    
                chronopicDisconnected = false;
+               jumpChangeImage = new JumpChangeImage();
 
                if (simulated) 
                        platformState = Chronopic.Plataforma.ON;
@@ -153,7 +160,10 @@ public class JumpExecute : EventExecute
                        platformState = chronopicInitialValue(cp);
                
                
-               if (platformState==Chronopic.Plataforma.ON) {
+               if (platformState==Chronopic.Plataforma.ON)
+               {
+                       jumpChangeImageDo (platformState); //done here before thread starts
+
                        feedbackMessage = Catalog.GetString("You are IN, JUMP when prepared!");
                        needShowFeedbackMessage = true; 
                        Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn, gstreamer);
@@ -177,7 +187,10 @@ public class JumpExecute : EventExecute
                        LogB.ThreadStart(); 
                        thread.Start(); 
                } 
-               else if (platformState==Chronopic.Plataforma.OFF) {
+               else if (platformState==Chronopic.Plataforma.OFF)
+               {
+                       jumpChangeImageDo (platformState);
+
                        ConfirmWindow confirmWin;               
                        confirmWin = ConfirmWindow.Show(Catalog.GetString(
                                                "You are OUT, please enter the platform, prepare for jump and 
press the 'accept' button"),
@@ -192,6 +205,8 @@ public class JumpExecute : EventExecute
                        confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
                }
                else { //UNKNOW (Chronopic disconnected, port changed, ...)
+                       jumpChangeImageDo (platformState);
+
                        chronopicHasBeenDisconnected();
                }
        }
@@ -202,6 +217,7 @@ public class JumpExecute : EventExecute
 
                //boolean to know if chronopic has been disconnected    
                chronopicDisconnected = false;
+               jumpChangeImage = new JumpChangeImage();
 
                if (simulated) {
                        if(fall != -1)
@@ -218,6 +234,8 @@ public class JumpExecute : EventExecute
                                platformState != Chronopic.Plataforma.ON) 
                {
                        //UNKNOW (Chronopic disconnected, port changed, ...)
+                       jumpChangeImageDo (platformState);
+
                        chronopicHasBeenDisconnected();
                        return;
                }
@@ -256,7 +274,8 @@ public class JumpExecute : EventExecute
                                else
                                        platformState = Chronopic.Plataforma.OFF; //mark now that we have 
jumped
                        }
-                       
+                       jumpChangeImageDo (platformState);
+
                        //start thread
                        thread = new Thread(new ThreadStart(waitEvent));
                        GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
@@ -266,6 +285,8 @@ public class JumpExecute : EventExecute
                } 
                else  
                {
+                       jumpChangeImageDo (platformState);
+
                        ConfirmWindow confirmWin;
 
                        string message = Catalog.GetString("You are IN, please leave the platform, and press 
the 'accept' button");
@@ -290,8 +311,46 @@ public class JumpExecute : EventExecute
        private void callAgainManageFall(object o, EventArgs args) {
                ManageFall();
        }
-       
-       
+
+       //before thread start, to set the image
+       protected void jumpChangeImageDo (Chronopic.Plataforma plat)
+       {
+               if (plat == Chronopic.Plataforma.OFF)
+                       jumpChangeImage.Current = JumpChangeImage.Types.AIR;
+               else if (plat == Chronopic.Plataforma.ON)
+                       jumpChangeImage.Current = JumpChangeImage.Types.LAND;
+               else
+                       jumpChangeImage.Current = JumpChangeImage.Types.NONE;
+
+               jumpChangeImageIfNeeded ();
+       }
+
+       protected override void jumpChangeImageIfNeeded ()
+       {
+               if(! jumpChangeImage.ShouldBeChanged())
+                       return;
+
+               if (jumpChangeImage.Current == JumpChangeImage.Types.AIR)
+               {
+                       image_jump_execute_air.Visible = true;
+                       image_jump_execute_land.Visible = false;
+               } else if (jumpChangeImage.Current == JumpChangeImage.Types.LAND)
+               {
+                       image_jump_execute_air.Visible = false;
+                       image_jump_execute_land.Visible = true;
+               } else
+               { //UNKNOW (Chronopic disconnected, port changed, ...)
+                       image_jump_execute_air.Visible = false;
+                       image_jump_execute_land.Visible = false;
+               }
+       }
+
+       protected override void jumpChangeImageForceHide()
+       {
+               image_jump_execute_air.Visible = false;
+               image_jump_execute_land.Visible = false;
+       }
+
        protected override void waitEvent ()
        {
                double timestamp = 0;
@@ -338,6 +397,8 @@ public class JumpExecute : EventExecute
                                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) 
                                {
                                        //has landed
+                                       jumpChangeImage.Current = JumpChangeImage.Types.LAND;
+
                                        if(hasFall && tc == 0) 
                                        {
                                                //**** graphC **** 
@@ -396,6 +457,7 @@ public class JumpExecute : EventExecute
                                else if (platformState == Chronopic.Plataforma.OFF && loggedState == 
States.ON) 
                                {
                                        //it's out, was inside (= has jumped)
+                                       jumpChangeImage.Current = JumpChangeImage.Types.AIR;
                                
                                        //fall != -1 because if it was == -1, it will change once touching 
floor for the first time     
                                        if(hasFall && fall != -1) {
@@ -606,6 +668,7 @@ public class JumpRjExecute : JumpExecute
                        bool volumeOn, Preferences.GstreamerTypes gstreamer,
                        bool metersSecondsPreferred, FeedbackWindow feedbackWin,
                        double progressbarLimit, ExecutingGraphData egd,
+                       Gtk.Image image_jump_execute_air, Gtk.Image image_jump_execute_land,
                        bool upload, int uploadStationId, bool django //upload: configChronojump.Compujump && 
upload (contacts) button active
                        )
        {
@@ -643,6 +706,8 @@ public class JumpRjExecute : JumpExecute
                if(TypeHasFall) { hasFall = true; } 
                else { hasFall = false; }
 
+               this.image_jump_execute_air = image_jump_execute_air;
+               this.image_jump_execute_land = image_jump_execute_land;
                this.upload = upload;
                this.uploadStationId = uploadStationId;
                this.django = django;
@@ -665,6 +730,7 @@ public class JumpRjExecute : JumpExecute
        {
                //boolean to know if chronopic has been disconnected    
                chronopicDisconnected = false;
+               jumpChangeImage = new JumpChangeImage();
 
                if (simulated)
                        if(hasFall) 
@@ -683,7 +749,8 @@ public class JumpRjExecute : JumpExecute
                        return;
                }
 
-               
+               jumpChangeImageDo (platformState);
+
                bool success = false;
 
                if (platformState==Chronopic.Plataforma.OFF && hasFall ) {
@@ -773,6 +840,10 @@ public class JumpRjExecute : JumpExecute
                        else
                                ok = cp.Read_event(out timestamp, out platformState);
                        
+                       if (platformState == Chronopic.Plataforma.OFF)
+                               jumpChangeImage.Current = JumpChangeImage.Types.AIR;
+                       else if (platformState == Chronopic.Plataforma.ON)
+                               jumpChangeImage.Current = JumpChangeImage.Types.LAND;
                        
                        //if chronopic signal is Ok and state has changed
                        if (ok && (
diff --git a/src/execute/runObjects.cs b/src/execute/objects.cs
similarity index 97%
rename from src/execute/runObjects.cs
rename to src/execute/objects.cs
index 7ceca3101..0dce35e35 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/objects.cs
@@ -22,6 +22,10 @@ using System;
 using System.Data;
 using System.Collections.Generic; //List
 
+/*
+   RUN OBJECTS
+ */
+
 //contains for each phase: isContact? startMSInSequence duration
 public class RunPhaseInfo
 {
@@ -891,3 +895,42 @@ public class RunChangeImage
        }
 
 }
+
+/*
+   JUMP OBJECTS
+ */
+
+/*
+   This is written by capture thread and readed by GTK thread.
+   Manages the icon shown on jumping.
+   */
+
+public class JumpChangeImage
+{
+       public enum Types { NONE, AIR, LAND }
+       private Types last;
+       private Types current;
+
+       //constructor, don't show any image
+       public JumpChangeImage()
+       {
+               last = Types.NONE;
+               current = Types.NONE;
+       }
+
+       public bool ShouldBeChanged()
+       {
+               //LogB.Information (string.Format ("ShouldBeChanged, current: {0}, last: {1}", current, 
last));
+               if(current == last)
+                       return false;
+
+               last = current;
+               return true;
+       }
+
+       //accesssor: get/change current image
+       public Types Current {
+               get { return current; }
+               set { current = value; }
+       }
+}
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 7571015a9..14a856650 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -5206,6 +5206,7 @@ public partial class ChronoJumpWindow
                                preferences.heightPreferred, preferences.metersSecondsPreferred,
                                Convert.ToInt32(spin_contacts_graph_last_limit.Value),
                                radio_contacts_graph_allTests.Active, radio_contacts_graph_allPersons.Active,
+                               image_jump_execute_air, image_jump_execute_land,
                                (configChronojump.Compujump && check_contacts_networks_upload.Active),
                                configChronojump.CompujumpStationID, configChronojump.CompujumpDjango);
 
@@ -5501,6 +5502,7 @@ public partial class ChronoJumpWindow
                                preferences.volumeOn, preferences.gstreamer,
                                preferences.metersSecondsPreferred,
                                feedbackWin, progressbarLimit, egd,
+                               image_jump_execute_air, image_jump_execute_land,
                                (configChronojump.Compujump && check_contacts_networks_upload.Active),
                                configChronojump.CompujumpStationID, configChronojump.CompujumpDjango);
                
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index 224983207..90742f98c 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -121,6 +121,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_button_contacts_capture_save_image_chart;
        [Widget] Gtk.Image image_button_contacts_capture_save_image_disk;
 
+       //jump
+       [Widget] Gtk.Image image_jump_execute_air;
+       [Widget] Gtk.Image image_jump_execute_land;
+
        //run
        [Widget] Gtk.Image image_run_simple_show_time;
        [Widget] Gtk.Image image_run_execute_running;
@@ -668,6 +672,10 @@ public partial class ChronoJumpWindow
                image_mode_race_encoder_small1.Pixbuf = pixbuf;
                image_change_modes_contacts_runs_encoder.Pixbuf = pixbuf;
 
+               //TODO: change them
+               image_jump_execute_air.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run_2x.png");
+               image_jump_execute_land.Pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
"run_photocell.png");
+
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run_2x.png");
                image_run_execute_running.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run_photocell.png");


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