[chronojump] inertia-momentum calculation 85%



commit ef034a81f28a4d8e49d6fba7cf4a7d5dcebe4f10
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Feb 5 12:23:18 2014 +0100

    inertia-momentum calculation 85%

 src/gui/encoder.cs              |   80 ++++++++++++++++++++++++++------------
 src/gui/encoderConfiguration.cs |   10 +++++
 2 files changed, 65 insertions(+), 25 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 0f07ce9..d5d6b27 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -185,7 +185,8 @@ public partial class ChronoJumpWindow
        //diffrence between:
        //CALC_RECALC_CURVES: calcule and recalculate, autosaves the curve at end
        //LOAD curves does snot 
-       enum encoderActions { CAPTURE, CALC_RECALC_CURVES, LOAD, ANALYZE } 
+       //CAPTURE_CALCULE_IM records to get the inertia moment but does not calculate curves in R and not 
updates the treeview
+       enum encoderActions { CAPTURE, CALC_RECALC_CURVES, LOAD, ANALYZE, CAPTURE_CALCULE_IM } 
        enum encoderSensEnum { 
                NOSESSION, NOPERSON, YESPERSON, PROCESSINGCAPTURE, PROCESSINGR, DONENOSIGNAL, DONEYESSIGNAL, 
SELECTEDCURVE }
        encoderSensEnum encoderSensEnumStored; //tracks how was sensitive before PROCESSINGCAPTURE or 
PROCESSINGR
@@ -238,6 +239,8 @@ public partial class ChronoJumpWindow
        void on_button_encoder_select_clicked (object o, EventArgs args) {
                encoder_configuration_win = EncoderConfigurationWindow.View(encoderConfigurationCurrent);
                encoder_configuration_win.Button_accept.Clicked += new 
EventHandler(on_encoder_configuration_win_accepted);
+               encoder_configuration_win.Button_encoder_capture_inertial_do.Clicked += 
+                       new EventHandler(on_encoder_configuration_win_capture_inertial_do);
        }
 
        void on_encoder_configuration_win_accepted (object o, EventArgs args) {
@@ -247,6 +250,16 @@ public partial class ChronoJumpWindow
                label_encoder_selected.Text = encoderConfigurationCurrent.code;
        }
        
+       void on_encoder_configuration_win_capture_inertial_do (object o, EventArgs args) {
+               encoder_configuration_win.Button_encoder_capture_inertial_do.Clicked -= 
+                       new EventHandler(on_encoder_configuration_win_capture_inertial_do);
+       
+               //TODO: put a thread in order to interface be updated,
+               //maybe on start capturing this will happen because CAPTURE thread will start   
+               encoder_configuration_win.Label_im_progress_text = Catalog.GetString("Capturing");
+//             on_button_encoder_capture_calcule_inertial();
+       }
+       
        void on_button_encoder_capture_options_clicked (object o, EventArgs args) {
                encoderCaptureOptionsWin.View(repetitiveConditionsWin, volumeOn);
        }
@@ -254,15 +267,21 @@ public partial class ChronoJumpWindow
        private void on_encoder_capture_options_closed(object o, EventArgs args) {
                Log.WriteLine("closed");
        }
-
-       void on_button_encoder_capture_clicked (object o, EventArgs args) 
-       {
+       
+       private bool encoderCheckPort() {
                if(chronopicWin.GetEncoderPort() == Util.GetDefaultPort()) {
                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                        Catalog.GetString("Chronopic port is not configured."));
                        UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, 
label_connected_chronopics, false);
-                       return;
+                       return false;
                }
+               return true;
+       }
+
+       void on_button_encoder_capture_clicked (object o, EventArgs args) 
+       {
+               if(! encoderCheckPort())
+                       return;
                
                string analysisOptions = getEncoderAnalysisOptions(true);
 
@@ -366,6 +385,13 @@ public partial class ChronoJumpWindow
                }
        }
        
+       void on_button_encoder_capture_calcule_inertial () 
+       {
+               if(! encoderCheckPort())
+                       return;
+               
+               encoderThreadStart(encoderActions.CAPTURE_CALCULE_IM);
+       }
 
 
        void on_combo_encoder_exercise_changed (object o, EventArgs args) {
@@ -4124,18 +4150,20 @@ Log.WriteLine(str);
        private void encoderThreadStart(encoderActions action) {
                encoderProcessCancel = false;
                encoderProcessFinish = false;
-               if(action == encoderActions.CAPTURE) {
+               if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_CALCULE_IM) {
                        //encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
                        Log.WriteLine("CCCCCCCCCCCCCCC");
                        if( runEncoderCaptureCsharpCheckPort(chronopicWin.GetEncoderPort()) ) {
                                
-                               bool ok = runEncoderCaptureCsharpInitializeR();
-                               if(! ok) {
-                                       new DialogMessage(Constants.MessageTypes.WARNING,
-                                                       Catalog.GetString("Sorry. Error doing graph.") +
-                                                       "\n" + Catalog.GetString("Maybe R or EMD are not 
installed.") +
-                                                       "\n\nhttp://www.r-project.org/";);
-                                       return;
+                               if(action == encoderActions.CAPTURE) {
+                                       bool ok = runEncoderCaptureCsharpInitializeR();
+                                       if(! ok) {
+                                               new DialogMessage(Constants.MessageTypes.WARNING,
+                                                               Catalog.GetString("Sorry. Error doing 
graph.") +
+                                                               "\n" + Catalog.GetString("Maybe R or EMD are 
not installed.") +
+                                                               "\n\nhttp://www.r-project.org/";);
+                                               return;
+                                       }
                                }
 
                                UtilGtk.ErasePaint(encoder_capture_drawingarea, encoder_capture_pixmap);
@@ -4155,18 +4183,20 @@ Log.WriteLine(str);
 
                                encoderStartVideoRecord();
 
-                               //remove treeview columns
-                               treeviewEncoderCaptureRemoveColumns();
-                               encoderCaptureStringR = 
",series,exercise,mass,start,width,height,meanSpeed,maxSpeed,maxSpeedT,meanPower,peakPower,peakPowerT,pp_ppt,NA,NA,NA";
-                               
-                               capturingCsharp = true;
-                               eccaCreated = false;
-                       
-                               //TODO: add demult and angle    
-                               massDisplacedEncoder = 
UtilEncoder.GetMassByEncoderConfiguration(encoderConfigurationCurrent, 
-                                       findMass(Constants.MassType.BODY), findMass(Constants.MassType.EXTRA),
-                                       getExercisePercentBodyWeightFromCombo(), 1, 90
-                                       );
+                               if(action == encoderActions.CAPTURE) {
+                                       //remove treeview columns
+                                       treeviewEncoderCaptureRemoveColumns();
+                                       encoderCaptureStringR = 
",series,exercise,mass,start,width,height,meanSpeed,maxSpeed,maxSpeedT,meanPower,peakPower,peakPowerT,pp_ppt,NA,NA,NA";
+
+                                       capturingCsharp = true;
+                                       eccaCreated = false;
+
+                                       //TODO: add demult and angle    
+                                       massDisplacedEncoder = 
UtilEncoder.GetMassByEncoderConfiguration(encoderConfigurationCurrent, 
+                                                       findMass(Constants.MassType.BODY), 
findMass(Constants.MassType.EXTRA),
+                                                       getExercisePercentBodyWeightFromCombo(), 1, 90
+                                                       );
+                               }
 
                                encoderThreadCapture = new Thread(new ThreadStart(captureCsharp));
                                GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCapture));
diff --git a/src/gui/encoderConfiguration.cs b/src/gui/encoderConfiguration.cs
index ed1dfd1..62a8b3a 100644
--- a/src/gui/encoderConfiguration.cs
+++ b/src/gui/encoderConfiguration.cs
@@ -53,6 +53,8 @@ public class EncoderConfigurationWindow {
        [Widget] Gtk.Box vbox_calcule_im;
        [Widget] Gtk.SpinButton spin_im_weight;
        [Widget] Gtk.SpinButton spin_im_length;
+       [Widget] Gtk.Label label_im_progress;
+       [Widget] Gtk.Button button_encoder_capture_inertial_do;
 
        [Widget] Gtk.Button button_accept;
 
@@ -227,5 +229,13 @@ public class EncoderConfigurationWindow {
        public Button Button_accept {
                get { return button_accept; }
        }
+       
+       public Button Button_encoder_capture_inertial_do {
+               get { return button_encoder_capture_inertial_do; }
+       }
+       
+       public string Label_im_progress_text {
+               set { label_im_progress.Text = value; }
+       }
                
 }


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