[chronojump] Added encoder capture rhythm of 1Hz



commit 6ef75dc95de0b7bfa3d3f96a5dddffd4ff569383
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jan 16 17:50:37 2018 +0100

    Added encoder capture rhythm of 1Hz

 glade/app1.glade   |   89 +++++++++++++++++++++++++++++++++++++++++++++++++---
 src/gui/encoder.cs |   46 +++++++++++++++++++++++---
 2 files changed, 124 insertions(+), 11 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index fa16fe7..39a4ca9 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1571,6 +1571,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>
@@ -16769,7 +16772,7 @@ Concentric</property>
                                                           </packing>
                                                         </child>
                                                         <child>
-                                                          <widget class="GtkNotebook" 
id="notebook_encoder_signal_comment_and_triggers">
+                                                          <widget class="GtkNotebook" 
id="notebook_encoder_signal_comment_rhythm_and_triggers">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="show_tabs">False</property>
@@ -16839,9 +16842,82 @@ Concentric</property>
                                                             <widget class="GtkLabel" id="label283">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">page 
1</property>
+                                                            <property name="label">comment</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="tab_fill">False</property>
+                                                            <property name="type">tab</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" id="hbox243">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">12</property>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox120">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label289">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Rhythm
+1Hz</property>
+                                                            <property name="justify">center</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_encoder_rhythm">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="stock">gtk-dialog-warning</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">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkProgressBar" 
id="encoder_pulsebar_rhythm">
+                                                            <property name="width_request">30</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property 
name="pulse_step">0.050000000000000003</property>
+                                                            <property 
name="orientation">bottom-to-top</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="position">1</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" id="label287">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label">rhythm</property>
                                                             </widget>
                                                             <packing>
+                                                            <property name="position">1</property>
                                                             <property name="tab_fill">False</property>
                                                             <property name="type">tab</property>
                                                             </packing>
@@ -16880,17 +16956,17 @@ Concentric</property>
                                                             </child>
                                                             </widget>
                                                             <packing>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkLabel" id="label284">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">page 
2</property>
+                                                            <property name="label">triggers</property>
                                                             </widget>
                                                             <packing>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             <property name="tab_fill">False</property>
                                                             <property name="type">tab</property>
                                                             </packing>
@@ -22532,6 +22608,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index a96708a..ccac7f2 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -99,8 +99,10 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Viewport viewport_image_encoder_capture;
        [Widget] Gtk.Image image_encoder_capture;
        [Widget] Gtk.ProgressBar encoder_pulsebar_capture;
+       [Widget] Gtk.ProgressBar encoder_pulsebar_rhythm;
+       [Widget] Gtk.Image image_encoder_rhythm;
        [Widget] Gtk.VBox vbox_encoder_signal_comment;
-       [Widget] Gtk.Notebook notebook_encoder_signal_comment_and_triggers;
+       [Widget] Gtk.Notebook notebook_encoder_signal_comment_rhythm_and_triggers;
        [Widget] Gtk.TextView textview_encoder_signal_comment;
        [Widget] Gtk.Button button_encoder_signal_save_comment;
        [Widget] Gtk.MenuItem menuitem_export_encoder_signal;
@@ -326,6 +328,8 @@ public partial class ChronoJumpWindow
        private static bool encoderProcessFinish;
        private static bool encoderProcessFinishContMode;
 
+       private static DateTime lastRepetitionDT;
+
        EncoderConfigurationWindow encoder_configuration_win;
 
        EncoderConfiguration encoderConfigurationCurrent;
@@ -5297,10 +5301,16 @@ public partial class ChronoJumpWindow
                                                currentEncoderGI == Constants.EncoderGI.GRAVITATORY && 
eCapture.Eccon == "c")
                                {
                                        reallyCutByTriggers = preferences.encoderCaptureCutByTriggers;
-                                       notebook_encoder_signal_comment_and_triggers.Page = 1;
-                               }
+                                       notebook_encoder_signal_comment_rhythm_and_triggers.Page = 2;
+                               } else
+                                       notebook_encoder_signal_comment_rhythm_and_triggers.Page = 1;
+
                                encoderRProcCapture.CutByTriggers = reallyCutByTriggers;
 
+                               //initialize DateTime for rhythm
+                               lastRepetitionDT = DateTime.MinValue;
+                               image_encoder_rhythm.Visible = false;
+
                                encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
                                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureAndCurves));
                        }
@@ -5752,7 +5762,7 @@ public partial class ChronoJumpWindow
 
                        finishPulsebar(encoderActions.CURVES_AC);
 
-                       notebook_encoder_signal_comment_and_triggers.Page = 0;
+                       notebook_encoder_signal_comment_rhythm_and_triggers.Page = 0;
 
                        if(encoderProcessCancel) {
                                //stop video            
@@ -5765,7 +5775,7 @@ public partial class ChronoJumpWindow
                if(capturingCsharp == encoderCaptureProcess.CAPTURING) 
                {
                        updatePulsebar(encoderActions.CAPTURE); //activity on pulsebar
-                       
+
                        //capturingSendCurveToR(); //unused, done while capturing
                        readingCurveFromR();
 
@@ -5776,6 +5786,11 @@ public partial class ChronoJumpWindow
 
                        if(needToRefreshTreeviewCapture) 
                        {
+                               //TODO: is better to do this before when the curves was sent,
+                               //not when needToRefreshTreeviewCapture (because this is too later because 
it's returning from R)
+                               lastRepetitionDT = DateTime.Now;
+                               image_encoder_rhythm.Visible = false;
+
                                //LogB.Error("HERE YES");
                                //LogB.Error(encoderCaptureStringR);
 
@@ -5798,6 +5813,8 @@ public partial class ChronoJumpWindow
                                needToRefreshTreeviewCapture = false;
                        }
 
+                       updatePulsebarRhythm();
+
                        //changed trying to fix crash of nuell 27/may/2016
                        //LogB.Debug(" Cap:", encoderThread.ThreadState.ToString());
                        //LogB.Information(" Cap:" + encoderThread.ThreadState.ToString());
@@ -5996,7 +6013,24 @@ public partial class ChronoJumpWindow
                        LogB.Warning("catched at updatePulsebar");
                }
        }
-       
+
+       private void updatePulsebarRhythm()
+       {
+               //at first repetition don't show pulsebar rhythm (wait first repetition ended)
+               if(lastRepetitionDT == DateTime.MinValue)
+               {
+                       encoder_pulsebar_rhythm.Fraction = 0;
+                       return;
+               }
+
+               TimeSpan span = DateTime.Now - lastRepetitionDT;
+               double totalSeconds = span.TotalSeconds;
+
+               encoder_pulsebar_rhythm.Fraction = Util.DivideSafeFraction(totalSeconds, 1.0);
+               if(totalSeconds >= 1)
+                       image_encoder_rhythm.Visible = true;
+       }
+
 
        // -------------- drawingarea_encoder_analyze_instant
        


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