[chronojump] Race encoder can change device type. UNTESTED!



commit 4e8cc12f3a0478885b8789fcb687d45e663f58f3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Aug 30 06:49:14 2019 +0200

    Race encoder can change device type. UNTESTED!

 glade/app1.glade          | 75 +++++++++++++++++++++++++++++++++++++++--------
 r-scripts/sprintEncoder.R | 15 +++++++---
 src/gui/chronojump.cs     |  8 ++---
 src/gui/runEncoder.cs     | 12 +++++++-
 src/runEncoder.cs         |  9 ++++--
 5 files changed, 94 insertions(+), 25 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 620f4a9e..aa548856 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -7077,7 +7077,7 @@ EncoderInertialCapture</property>
                                                             <widget class="GtkLabel" id="label368">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
-                                                            <property name="label">race analyzer stuff 
EXPERIMENTAL</property>
+                                                            <property name="label">Races with encoder - SOON 
AVAILABLE</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -7523,6 +7523,49 @@ EncoderInertialCapture</property>
                                                             <property name="position">3</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkHBox" 
id="hbox_race_analyzer_device">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="spacing">4</property>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="race_analyzer_radio_device_fishing">
+                                                            <property name="label">Fishing device</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <widget class="GtkRadioButton" 
id="race_analyzer_radio_device_other">
+                                                            <property name="label">Other device</property>
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property 
name="receives_default">False</property>
+                                                            <property name="active">True</property>
+                                                            <property name="draw_indicator">True</property>
+                                                            <property 
name="group">race_analyzer_radio_device_fishing</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">True</property>
+                                                            <property name="position">4</property>
+                                                            </packing>
+                                                            </child>
                                                           </widget>
                                                         </child>
                                                       </widget>
@@ -21683,6 +21726,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23643,6 +23689,18 @@ 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>
@@ -23679,18 +23737,6 @@ 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>
@@ -30544,6 +30590,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 7ea49488..9a1a8aa0 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -42,14 +42,15 @@ assignOptions <- function(options) {
                 testLength = as.numeric(options[6]),
                 os             = options[7],
                 graphWidth     = as.numeric(options[8]),
-                graphHeight    = as.numeric(options[9])
+                graphHeight    = as.numeric(options[9]),
+                device         = options[10]
         ))
 }
 
 #-------------- assign options -------------
 op <- assignOptions(options)
 
-getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, Height , Vw = 0)
+getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, Height , Vw = 0, device)
 {
         print("#####Entering in getSprintFromEncoder###############")
         # Constants for the air friction modeling
@@ -74,7 +75,13 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
         #raceAnalyzer$displacement = raceAnalyzer$displacement * 2 * pi * diameter / 200
         #In 30m there are 12267 pulses.
         #TODO: measure this several times to have an accurate value
-        raceAnalyzer$displacement = 4 * raceAnalyzer$displacement * 30 / 12267
+       pulsesIn30m = NULL
+       if(device == "FISHING")
+               pulsesIn30m = 12267
+       else
+               pulsesIn30m = 12267 #TODO: change value
+
+        raceAnalyzer$displacement = 4 * raceAnalyzer$displacement * 30 / pulsesIn30m
         position = cumsum(raceAnalyzer$displacement)
         speed = raceAnalyzer$displacement / elapsedTime
         accel = (speed[3] - speed[1]) / (totalTime[3] - totalTime[1])
@@ -500,7 +507,7 @@ tryNLS <- function(data){
 
 testEncoderCJ <- function(filename, testLength, mass, personHeight, tempC)
 {
-        sprintRawDynamics = getSprintFromEncoder(filename, testLength, op$mass, op$tempC, op$personHeight)
+        sprintRawDynamics = getSprintFromEncoder(filename, testLength, op$mass, op$tempC, op$personHeight, 
op$device)
         # print("sprintRawDynamics:")
         # print(sprintRawDynamics)
         if (sprintRawDynamics$longEnough & sprintRawDynamics$regressionDone)
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7681e689..18bd474e 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3206,6 +3206,8 @@ public partial class ChronoJumpWindow
                notebook_analyze.CurrentPage = Convert.ToInt32(notebook_analyze_pages.STATISTICS);
                button_inspect_last_test.Visible = false;
                vbox_force_capture_feedback.Visible = false;
+               button_force_sensor_adjust.Visible = false;
+               hbox_race_analyzer_device.Visible = false;
 
                //on OSX R is not installed by default. Check if it's installed. Needed for encoder and force 
sensor
                if(
@@ -3231,7 +3233,6 @@ public partial class ChronoJumpWindow
                        //notebook_capture_analyze.ShowTabs = true;
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = true;
-                       button_force_sensor_adjust.Visible = false;
                        if(m == Constants.Menuitem_modes.JUMPSSIMPLE) 
                        {
                                notebooks_change(m);
@@ -3261,7 +3262,6 @@ public partial class ChronoJumpWindow
                        //notebook_capture_analyze.ShowTabs = true;
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = true;
-                       button_force_sensor_adjust.Visible = false;
                        button_inspect_last_test.Visible = true;
 
                        if(m == Constants.Menuitem_modes.RUNSSIMPLE) 
@@ -3418,7 +3418,7 @@ public partial class ChronoJumpWindow
                        //notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid 
for "OTHER" tests)
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = true;
                        button_threshold.Visible = false;
-                       button_force_sensor_adjust.Visible = false;
+                       hbox_race_analyzer_device.Visible = true;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                        hbox_results_legend.Visible = false;
 
@@ -3438,7 +3438,6 @@ public partial class ChronoJumpWindow
                        //notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid 
for "OTHER" tests)
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = false;
                        button_threshold.Visible = true;
-                       button_force_sensor_adjust.Visible = false;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                }
                else {  //m == Constants.Menuitem_modes.OTHER (contacts / other)
@@ -3451,7 +3450,6 @@ public partial class ChronoJumpWindow
                        //notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid 
for "OTHER" tests)
                        hbox_contacts_sup_capture_analyze_two_buttons.Visible = false;
                        button_threshold.Visible = true;
-                       button_force_sensor_adjust.Visible = false;
                        //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
                }
 
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 862a1660..342a12bc 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -37,12 +37,16 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.SpinButton race_analyzer_spinbutton_temperature;
        [Widget] Gtk.SpinButton race_analyzer_spinbutton_graph_width;
        [Widget] Gtk.SpinButton race_analyzer_spinbutton_graph_height;
+       [Widget] Gtk.HBox hbox_race_analyzer_device;
+       [Widget] Gtk.RadioButton race_analyzer_radio_device_fishing;
        [Widget] Gtk.Image image_race_encoder_graph;
 
        int race_analyzer_distance;
        int race_analyzer_temperature;
        int race_analyzer_graph_width;
        int race_analyzer_graph_height;
+       RunEncoderGraph.Devices race_analyzer_device;
+
 
        Thread runEncoderCaptureThread;
        static bool runEncoderProcessFinish;
@@ -207,6 +211,11 @@ public partial class ChronoJumpWindow
                race_analyzer_temperature = Convert.ToInt32(race_analyzer_spinbutton_temperature.Value);
                race_analyzer_graph_width = Convert.ToInt32(race_analyzer_spinbutton_graph_width.Value);
                race_analyzer_graph_height = Convert.ToInt32(race_analyzer_spinbutton_graph_height.Value);
+
+               if(race_analyzer_radio_device_fishing.Active)
+                       race_analyzer_device = RunEncoderGraph.Devices.FISHING;
+               else
+                       race_analyzer_device = RunEncoderGraph.Devices.OTHER;
        }
 
        //TODO: do all this with an "other" thread like in force sensor to allow connecting messages to be 
displayed
@@ -419,7 +428,8 @@ public partial class ChronoJumpWindow
                                race_analyzer_distance,
                                currentPersonSession.Weight,    //TODO: can be more if extra weight
                                currentPersonSession.Height,
-                               race_analyzer_temperature);
+                               race_analyzer_temperature,
+                               race_analyzer_device);
 
                reg.CallR(race_analyzer_graph_width, race_analyzer_graph_height);
 
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index ba0105d3..bcc7a99e 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -24,17 +24,21 @@ using System.Collections.Generic; //List<T>
 
 public class RunEncoderGraph
 {
+       public enum Devices { FISHING, OTHER }
+
        private int testLength;
        private double mass;
        private double personHeight;
        private double tempC;
+       private Devices device;
 
-       public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC)
+       public RunEncoderGraph(int testLength, double mass, double personHeight, double tempC, Devices device)
        {
                this.testLength = testLength;
                this.mass = mass;
                this.personHeight = personHeight;
                this.tempC = tempC;
+               this.device = device;
        }
 
        public bool CallR(int graphWidth, int graphHeight)
@@ -62,7 +66,8 @@ public class RunEncoderGraph
                        "#testLength\n" +               testLength.ToString() + "\n" +
                        "#os\n" +                       UtilEncoder.OperatingSystemForRGraphs() + "\n" +
                        "#graphWidth\n" +               graphWidth.ToString() + "\n" +
-                       "#graphHeight\n" +              graphHeight.ToString();
+                       "#graphHeight\n" +              graphHeight.ToString() + "\n" +
+                       "#device\n" +                   device.ToString();
 
 
                TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt");


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