[chronojump] Run: instant images for contact/! contact with photocells



commit 9e3c638ceb2597540345ed94b460d2078e3c0ff0
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 27 10:44:12 2018 +0200

    Run: instant images for contact/! contact with photocells

 glade/app1.glade                                   |   43 ++++++++++++++++-
 .../ic_directions_run_photocell_blue_24dp_2x.png   |  Bin 0 -> 1635 bytes
 src/Makefile.am                                    |    1 +
 src/execute/event.cs                               |   16 ++++++-
 src/execute/run.cs                                 |   50 ++++++++++++++++++--
 src/execute/runObjects.cs                          |   30 ++++++++++++
 src/gui/chronojump.cs                              |    8 ++-
 src/gui/chronojumpIcons.cs                         |    9 ++++
 8 files changed, 148 insertions(+), 9 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 16ee89c..2c4ff9b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1682,6 +1682,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -8411,6 +8414,7 @@ EncoderInertialCapture</property>
                                                             <widget class="GtkLabel" 
id="event_execute_label_phases_name">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="xalign">0</property>
                                                             <property name="label" 
translatable="yes">Phases</property>
                                                             </widget>
                                                             <packing>
@@ -8448,6 +8452,7 @@ EncoderInertialCapture</property>
                                                             <widget class="GtkLabel" id="label251">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
+                                                            <property name="xalign">0</property>
                                                             <property name="label" 
translatable="yes">Time</property>
                                                             </widget>
                                                             <packing>
@@ -8484,6 +8489,39 @@ EncoderInertialCapture</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkVBox" id="vbox76">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_run_execute_running">
+                                                            <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_run_execute_photocell">
+                                                            <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="GtkVBox" id="vbox33">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -8558,7 +8596,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>
@@ -25673,6 +25711,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/images/md/ic_directions_run_photocell_blue_24dp_2x.png 
b/images/md/ic_directions_run_photocell_blue_24dp_2x.png
new file mode 100644
index 0000000..9db13dc
Binary files /dev/null and b/images/md/ic_directions_run_photocell_blue_24dp_2x.png differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b98017..bd43bfa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -428,6 +428,7 @@ RESOURCES = \
        ../images/md/ic_directions_run_blue_24dp_2x.png,run.png \
        ../images/md/ic_directions_run_simple_blue_24dp_1x.png,image_run_simple.png \
        ../images/md/ic_directions_run_multiple_blue_24dp_1x.png,image_run_multiple.png \
+       ../images/md/ic_directions_run_photocell_blue_24dp_2x.png,run_photocell.png \
        ../images/md/ic_directions_run_track_blue_24dp_1x.png,run_track_distance.png \
        ../images/md/ic_build_blue_24dp_1x.png,image_build_24.png \
        ../images/md/ic_build_blue_16dp_1x.png,image_build_16.png \
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 5167f9c..cdf4947 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -227,7 +227,11 @@ public class EventExecute
                //then thread is dead
 
                if ( ! thread.IsAlive || cancel) {
-                       LogB.ThreadEnding(); 
+                       LogB.ThreadEnding();
+
+                       //don't show any of the runChangeImage icons
+                       runChangeImageForceHide();
+
                        fakeButtonThreadDyed.Click();
 
                        LogB.ThreadEnded(); 
@@ -320,6 +324,8 @@ public class EventExecute
 
                // races specific --------------------------------->
 
+               runChangeImageIfNeeded();
+
                updateRunPhaseInfoManage();
 
                //Race track with DoubleContacts mode NONE
@@ -371,6 +377,14 @@ public class EventExecute
                return true;
        }
 
+       protected virtual void runChangeImageIfNeeded()
+       {
+       }
+
+       protected virtual void runChangeImageForceHide()
+       {
+       }
+
        protected virtual void updateRunPhaseInfoManage()
        {
        }
diff --git a/src/execute/run.cs b/src/execute/run.cs
index f291eb7..48ae54a 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -63,9 +63,13 @@ public class RunExecute : EventExecute
        //static because they are used on both threads at the same time
        protected static RunExecuteInspector runEI;
        protected static RunDoubleContact runDC;
+       protected static RunChangeImage runChangeImage;
        protected static bool success;
        protected RunExecuteInspector.Types runEIType;
 
+       protected Gtk.Image image_run_execute_running;
+       protected Gtk.Image image_run_execute_photocell;
+
 //     protected bool firstTrackDone;
 
        public RunExecute() {
@@ -78,7 +82,8 @@ public class RunExecute : EventExecute
                        bool volumeOn, Preferences.GstreamerTypes gstreamer,
                        double progressbarLimit, ExecutingGraphData egd,
                        Constants.DoubleContact checkDoubleContactMode, int checkDoubleContactTime, 
-                       bool speedStartArrival, bool measureReactionTime
+                       bool speedStartArrival, bool measureReactionTime,
+                       Gtk.Image image_run_execute_running, Gtk.Image image_run_execute_photocell
                        )
        {
                this.personID = personID;
@@ -100,6 +105,8 @@ public class RunExecute : EventExecute
                this.checkDoubleContactTime = checkDoubleContactTime;
                this.speedStartArrival = speedStartArrival;     
                this.measureReactionTime = measureReactionTime;
+               this.image_run_execute_running = image_run_execute_running;
+               this.image_run_execute_photocell = image_run_execute_photocell;
 
                reactionTimeMS = 0;
 
@@ -147,6 +154,7 @@ public class RunExecute : EventExecute
                        platformState = chronopicInitialValue(cp);
                
                LogB.Debug("MANAGE(b)!!!!");
+               runChangeImage = new RunChangeImage();
 
                //you can start ON or OFF the platform, 
                //we record always de TF (or time between we abandonate the platform since we arrive)
@@ -158,6 +166,7 @@ public class RunExecute : EventExecute
                        loggedState = States.ON;
                        startIn = true;
                        runPhase = runPhases.PLATFORM_INI_NO_TIME;
+                       runChangeImage.Current = RunChangeImage.Types.PHOTOCELL;
                } else if (platformState==Chronopic.Plataforma.OFF) {
                        feedbackMessage = Catalog.GetString("You are OUT, RUN when prepared!");
                        needShowFeedbackMessage = true; 
@@ -166,6 +175,7 @@ public class RunExecute : EventExecute
                        loggedState = States.OFF;
                        startIn = false;
                        runPhase = runPhases.PRE_RUNNING;
+                       runChangeImage.Current = RunChangeImage.Types.RUNNING;
                }
                else { //UNKNOW (Chronopic disconnected, port changed, ...)
                        chronopicHasBeenDisconnected();
@@ -270,6 +280,7 @@ public class RunExecute : EventExecute
                                if (has_arrived()) // timestamp is tf
                                {
                                        loggedState = States.ON;
+                                       runChangeImage.Current = RunChangeImage.Types.PHOTOCELL;
 
                                        onlyInterval_NeedShowCountDownFalse();
 
@@ -323,6 +334,7 @@ public class RunExecute : EventExecute
                                else if (has_lifted()) // timestamp is tc
                                {
                                        loggedState = States.OFF;
+                                       runChangeImage.Current = RunChangeImage.Types.RUNNING;
 
                                        lastTc = 0;
 
@@ -382,12 +394,11 @@ public class RunExecute : EventExecute
                        if(success || cancel || finish)
                        {
                                exitWaitEventBucle = waitToExitWaitEventBucle();
+                               runChangeImage.Current = RunChangeImage.Types.NONE;
                        }
 
                } while ( ! exitWaitEventBucle );
 
-               runEI.ChangePhase(RunExecuteInspector.Phases.END);
-
                onlyInterval_FinishWaitEventWrite();
        }
 
@@ -436,6 +447,33 @@ public class RunExecute : EventExecute
                        return true;
        }
 
+       protected override void runChangeImageIfNeeded()
+       {
+               if(! runChangeImage.ShouldBeChanged())
+                       return;
+
+               if(runChangeImage.Current == RunChangeImage.Types.RUNNING)
+               {
+                       image_run_execute_running.Visible = true;
+                       image_run_execute_photocell.Visible = false;
+               }
+               else if(runChangeImage.Current == RunChangeImage.Types.PHOTOCELL)
+               {
+                       image_run_execute_running.Visible = false;
+                       image_run_execute_photocell.Visible = true;
+               } else
+               {
+                       image_run_execute_running.Visible = false;
+                       image_run_execute_photocell.Visible = false;
+               }
+       }
+
+       protected override void runChangeImageForceHide()
+       {
+               image_run_execute_running.Visible = false;
+               image_run_execute_photocell.Visible = false;
+       }
+
        protected override void updateRunPhaseInfoManage()
        {
                //check if it's defined at beginning of race
@@ -448,7 +486,6 @@ public class RunExecute : EventExecute
                //LogB.Information("In lastTfCheckTimeEnded()");
                TimeSpan span = DateTime.Now - timerLastTf;
                if(span.TotalMilliseconds > checkDoubleContactTime * 1.5)
-//             if(span.TotalMilliseconds > checkDoubleContactTime * 1.1) //TODO: try different values
                {
                        timerLastTf = DateTime.Now;
                        LogB.Information("lastTfCheckTimeEnded: success");
@@ -735,7 +772,8 @@ public class RunIntervalExecute : RunExecute
                        RepetitiveConditionsWindow repetitiveConditionsWin,
                        double progressbarLimit, ExecutingGraphData egd ,
                        Constants.DoubleContact checkDoubleContactMode, int checkDoubleContactTime, 
-                       bool speedStartArrival, bool measureReactionTime
+                       bool speedStartArrival, bool measureReactionTime,
+                       Gtk.Image image_run_execute_running, Gtk.Image image_run_execute_photocell
                        )
        {
                this.personID = personID;
@@ -776,6 +814,8 @@ public class RunIntervalExecute : RunExecute
                this.checkDoubleContactTime = checkDoubleContactTime;
                this.speedStartArrival = speedStartArrival;     
                this.measureReactionTime = measureReactionTime;
+               this.image_run_execute_running = image_run_execute_running;
+               this.image_run_execute_photocell = image_run_execute_photocell;
 
                reactionTimeMS = 0;
                reactionTimeIncludedStr = Catalog.GetString("Included on race time of first track");
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index 0c8d3bf..5b64591 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -789,3 +789,33 @@ public class RunExecuteInspector
                return report;
        }
 }
+
+public class RunChangeImage
+{
+       public enum Types { NONE, RUNNING, PHOTOCELL }
+       private Types last;
+       private Types current;
+
+       //constructor, don't show any image
+       public RunChangeImage()
+       {
+               last = Types.NONE;
+               current = Types.NONE;
+       }
+
+       public bool ShouldBeChanged()
+       {
+               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/chronojump.cs b/src/gui/chronojump.cs
index e0b4844..88c5986 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4619,7 +4619,9 @@ public partial class ChronoJumpWindow
                                preferences.runDoubleContactsMode,
                                preferences.runDoubleContactsMS,
                                preferences.runSpeedStartArrival,
-                               check_run_simple_with_reaction_time.Active
+                               check_run_simple_with_reaction_time.Active,
+                               image_run_execute_running,
+                               image_run_execute_photocell
                                );
                
                if (! canCaptureC)
@@ -4744,7 +4746,9 @@ public partial class ChronoJumpWindow
                                preferences.runIDoubleContactsMode,
                                preferences.runIDoubleContactsMS,
                                preferences.runSpeedStartArrival,
-                               check_run_interval_with_reaction_time.Active
+                               check_run_interval_with_reaction_time.Active,
+                               image_run_execute_running,
+                               image_run_execute_photocell
                                );
 
                //suitable for limited by tracks and time
diff --git a/src/gui/chronojumpIcons.cs b/src/gui/chronojumpIcons.cs
index eae9cb4..aae7d7e 100644
--- a/src/gui/chronojumpIcons.cs
+++ b/src/gui/chronojumpIcons.cs
@@ -84,6 +84,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_selector_start_other;
        [Widget] Gtk.Image image_selector_start_cancel;
 
+       //run
+       [Widget] Gtk.Image image_run_execute_running;
+       [Widget] Gtk.Image image_run_execute_photocell;
+
        //encoder images
        [Widget] Gtk.Image image_top_eccon;
        [Widget] Gtk.Image image_encoder_eccon_concentric;
@@ -375,6 +379,11 @@ public partial class ChronoJumpWindow
                image_mode_runs_small.Pixbuf = pixbuf;
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_run_multiple.png");
                image_mode_runs_intervallic_small.Pixbuf = pixbuf;
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run.png");
+               image_run_execute_running.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "run_photocell.png");
+               image_run_execute_photocell.Pixbuf = pixbuf;
                
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNamePulse);
                image_mode_pulses_small.Pixbuf = pixbuf;


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