[chronojump] DB:1.45 force sensor uses impulse
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB:1.45 force sensor uses impulse
- Date: Tue, 16 May 2017 19:38:41 +0000 (UTC)
commit 7e2de0d59989de6ac9807c0bc44a914d369d2b1e
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue May 16 21:38:15 2017 +0200
DB:1.45 force sensor uses impulse
glade/preferences_win.glade | 221 ++++++++++++++++++++++++++++++++++++++++++-
src/forceSensor.cs | 96 +++++++++++++++++--
src/gui/chronojump.cs | 5 +-
src/gui/forceSensor.cs | 2 +-
src/gui/preferences.cs | 112 +++++++++++++++++++++-
src/sqlite/forceSensor.cs | 74 ++++++++++++++-
src/sqlite/main.cs | 12 ++-
7 files changed, 505 insertions(+), 17 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index f6292a5..11e74b4 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -4085,6 +4085,225 @@ Other</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox_force_impulse_row">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkCheckButton" id="check_force_impulse">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_check_force_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkLabel" id="label87">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Impulse</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_force_impulse">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkComboBox" id="combo_force_impulse_function">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">1</property>
+ <property name="items"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combo_force_impulse_type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">0</property>
+ <property name="items"/>
+ <signal name="changed" handler="on_combo_force_type_changed"
swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_force_impulse_until_percent">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label_force_impulse_until_percent">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Until</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton"
id="spinbutton_force_impulse_until_percent">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">3</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">0 0 100 1 1 0</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label101">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">% maximum force</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_force_impulse_from_to">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label_force_impulse_from">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">From</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="spinbutton_force_impulse_from">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">3</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">0 0 10000 1 1 0</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_force_impulse_to">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">to</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="spinbutton_force_impulse_to">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">3</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">0 0 100000 1 1 0</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label102">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">ms</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -4108,7 +4327,7 @@ Other</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</widget>
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 8d404be..8a00c33 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -24,27 +24,31 @@ using System.Collections.Generic; //List<T>
using Mono.Unix;
public class ForceSensorRFD
-
{
//if these names change, change FunctionPrint() below
public enum Functions { RAW, FITTED } //on SQL is inserted like this
- private static string function_RAW_name = "RAW";
- private static string function_FITTED_name = "Fitted";
+ protected static string function_RAW_name = "RAW";
+ protected static string function_FITTED_name = "Fitted";
//if these names change, change TypePrint() below
- public enum Types { INSTANTANEOUS, AVERAGE, PERCENT_F_MAX, RFD_MAX } //on SQL is inserted like this
+ public enum Types { INSTANTANEOUS, AVERAGE, PERCENT_F_MAX, RFD_MAX, IMP_UNTIL_PERCENT_F_MAX,
IMP_RANGE } //on SQL is inserted like this
private static string type_INSTANTANEOUS_name = "Instantaneous";
private static string type_AVERAGE_name = "Average";
private static string type_PERCENT_F_MAX_name = "% Force max";
private static string type_RFD_MAX_name = "RFD max";
- public string code; //RFD1...4
+ public string code; //RFD1...4 //I: on impulse
public bool active;
public Functions function;
public Types type;
public int num1;
public int num2;
+ //constructor for inheritance
+ public ForceSensorRFD()
+ {
+ }
+
public ForceSensorRFD(string code, bool active, Functions function, Types type, int num1, int num2)
{
this.code = code;
@@ -101,7 +105,7 @@ public class ForceSensorRFD
return function_FITTED_name;
}
- public string TypePrint(bool translated)
+ public virtual string TypePrint(bool translated)
{
if(type == Types.INSTANTANEOUS) {
if(translated)
@@ -172,9 +176,79 @@ public class ForceSensorRFD
}
}
+public class ForceSensorImpulse : ForceSensorRFD
+{
+ //if these names change, change TypePrint() below
+ private static string type_IMP_UNTIL_PERCENT_F_MAX_name = "Until % Force max";
+ private static string type_IMP_RANGE_name = "Range";
+
+ public ForceSensorImpulse()
+ {
+ }
+
+ public ForceSensorImpulse(bool active, Functions function, Types type, int num1, int num2)
+ {
+ this.code = "I";
+ this.active = active;
+ this.function = function;
+ this.type = type;
+ this.num1 = num1;
+ this.num2 = num2;
+ }
+
+ public bool Changed(ForceSensorImpulse newImpulse)
+ {
+ if(
+ active == newImpulse.active &&
+ function == newImpulse.function && type == newImpulse.type &&
+ num1 == newImpulse.num1 && num2 == newImpulse.num2)
+ return false;
+
+ return true;
+ }
+
+ public static string [] TypesArrayImpulse(bool translated)
+ {
+ if(translated)
+ return new string [] {
+ Catalog.GetString(type_IMP_UNTIL_PERCENT_F_MAX_name),
Catalog.GetString(type_IMP_RANGE_name),
+ };
+ else
+ return new string [] {
+ type_IMP_UNTIL_PERCENT_F_MAX_name, type_IMP_RANGE_name
+ };
+ }
+
+ public override string TypePrint(bool translated)
+ {
+ if(type == Types.IMP_UNTIL_PERCENT_F_MAX) {
+ if(translated)
+ return Catalog.GetString(type_IMP_UNTIL_PERCENT_F_MAX_name);
+ else
+ return type_IMP_UNTIL_PERCENT_F_MAX_name;
+ }
+ else { // if(type == Types.IMP_RANGE)
+ if(translated)
+ return Catalog.GetString(type_IMP_RANGE_name);
+ else
+ return type_IMP_RANGE_name;
+ }
+ }
+
+ public static string Type_IMP_UNTIL_PERCENT_F_MAX_name
+ {
+ get { return type_IMP_UNTIL_PERCENT_F_MAX_name; }
+ }
+ public static string Type_IMP_RANGE_name
+ {
+ get { return type_IMP_RANGE_name; }
+ }
+}
+
public class ForceSensorGraph
{
List<ForceSensorRFD> rfdList;
+ ForceSensorImpulse impulse;
double averageLength;
double percentChange;
bool vlineT0;
@@ -183,9 +257,10 @@ public class ForceSensorGraph
bool hline50fmax_raw;
bool hline50fmax_fitted;
- public ForceSensorGraph(List<ForceSensorRFD> rfdList)
+ public ForceSensorGraph(List<ForceSensorRFD> rfdList, ForceSensorImpulse impulse)
{
this.rfdList = rfdList;
+ this.impulse = impulse;
averageLength = 0.1;
percentChange = 5;
@@ -255,6 +330,13 @@ public class ForceSensorGraph
foreach(ForceSensorRFD rfd in rfdList)
if(rfd.active)
scriptOptions += "\n" + rfd.ToR();
+ else
+ scriptOptions += "\n-1";
+
+ if(impulse.active)
+ scriptOptions += "\n" + impulse.ToR();
+ else
+ scriptOptions += "\n-1";
TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt");
writer.Write(scriptOptions);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 00fce23..f385c7f 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -381,6 +381,7 @@ public partial class ChronoJumpWindow
private Preferences preferences;
private List<ForceSensorRFD> rfdList;
+ private ForceSensorImpulse impulse;
private static Person currentPerson;
private static Session currentSession;
@@ -561,6 +562,7 @@ public partial class ChronoJumpWindow
createTreeView_multi_chronopic (false, treeview_multi_chronopic);
rfdList = SqliteForceSensor.SelectAll(false);
+ impulse = SqliteForceSensor.SelectImpulse(false);
createComboSelectJumps(true);
@@ -2713,7 +2715,7 @@ public partial class ChronoJumpWindow
private void on_preferences_activate (object o, EventArgs args)
{
- preferencesWin = PreferencesWindow.Show(preferences, rfdList, getMenuItemMode());
+ preferencesWin = PreferencesWindow.Show(preferences, rfdList, impulse, getMenuItemMode());
preferencesWin.FakeButtonImported.Clicked += new
EventHandler(on_preferences_import_configuration);
preferencesWin.FakeButtonDebugModeStart.Clicked += new
EventHandler(on_preferences_debug_mode_start);
@@ -2734,6 +2736,7 @@ public partial class ChronoJumpWindow
{
preferences = preferencesWin.GetPreferences;
rfdList = preferencesWin.GetRFDList;
+ impulse = preferencesWin.GetImpulse;
if(checkbutton_video.Active) {
videoCapturePrepare(false); //if error, show message
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 211bc34..9063c2d 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -265,7 +265,7 @@ public partial class ChronoJumpWindow
Util.FileDelete(imagePath);
image_force_sensor_graph.Sensitive = false;
- ForceSensorGraph fsg = new ForceSensorGraph(rfdList);
+ ForceSensorGraph fsg = new ForceSensorGraph(rfdList, impulse);
bool success = fsg.CallR(
viewport_force_sensor_graph.Allocation.Width -5,
viewport_force_sensor_graph.Allocation.Height -5);
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 5b3542f..b190cf5 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -133,18 +133,22 @@ public class PreferencesWindow
[Widget] Gtk.HBox hbox_force_2;
[Widget] Gtk.HBox hbox_force_3;
[Widget] Gtk.HBox hbox_force_4;
+ [Widget] Gtk.HBox hbox_force_impulse;
[Widget] Gtk.CheckButton check_force_1;
[Widget] Gtk.CheckButton check_force_2;
[Widget] Gtk.CheckButton check_force_3;
[Widget] Gtk.CheckButton check_force_4;
+ [Widget] Gtk.CheckButton check_force_impulse;
[Widget] Gtk.ComboBox combo_force_1_function;
[Widget] Gtk.ComboBox combo_force_2_function;
[Widget] Gtk.ComboBox combo_force_3_function;
[Widget] Gtk.ComboBox combo_force_4_function;
+ [Widget] Gtk.ComboBox combo_force_impulse_function;
[Widget] Gtk.ComboBox combo_force_1_type;
[Widget] Gtk.ComboBox combo_force_2_type;
[Widget] Gtk.ComboBox combo_force_3_type;
[Widget] Gtk.ComboBox combo_force_4_type;
+ [Widget] Gtk.ComboBox combo_force_impulse_type;
[Widget] Gtk.HBox hbox_force_1_at_ms;
[Widget] Gtk.HBox hbox_force_2_at_ms;
[Widget] Gtk.HBox hbox_force_3_at_ms;
@@ -153,10 +157,12 @@ public class PreferencesWindow
[Widget] Gtk.HBox hbox_force_2_at_percent;
[Widget] Gtk.HBox hbox_force_3_at_percent;
[Widget] Gtk.HBox hbox_force_4_at_percent;
+ [Widget] Gtk.HBox hbox_force_impulse_until_percent;
[Widget] Gtk.HBox hbox_force_1_from_to;
[Widget] Gtk.HBox hbox_force_2_from_to;
[Widget] Gtk.HBox hbox_force_3_from_to;
[Widget] Gtk.HBox hbox_force_4_from_to;
+ [Widget] Gtk.HBox hbox_force_impulse_from_to;
[Widget] Gtk.SpinButton spinbutton_force_1_at_ms;
[Widget] Gtk.SpinButton spinbutton_force_2_at_ms;
[Widget] Gtk.SpinButton spinbutton_force_3_at_ms;
@@ -165,14 +171,17 @@ public class PreferencesWindow
[Widget] Gtk.SpinButton spinbutton_force_2_at_percent;
[Widget] Gtk.SpinButton spinbutton_force_3_at_percent;
[Widget] Gtk.SpinButton spinbutton_force_4_at_percent;
+ [Widget] Gtk.SpinButton spinbutton_force_impulse_until_percent;
[Widget] Gtk.SpinButton spinbutton_force_1_from;
[Widget] Gtk.SpinButton spinbutton_force_2_from;
[Widget] Gtk.SpinButton spinbutton_force_3_from;
[Widget] Gtk.SpinButton spinbutton_force_4_from;
+ [Widget] Gtk.SpinButton spinbutton_force_impulse_from;
[Widget] Gtk.SpinButton spinbutton_force_1_to;
[Widget] Gtk.SpinButton spinbutton_force_2_to;
[Widget] Gtk.SpinButton spinbutton_force_3_to;
[Widget] Gtk.SpinButton spinbutton_force_4_to;
+ [Widget] Gtk.SpinButton spinbutton_force_impulse_to;
//multimedia tab
[Widget] Gtk.CheckButton checkbutton_volume;
@@ -207,6 +216,7 @@ public class PreferencesWindow
private Preferences preferences; //stored to update SQL if anything changed
private List<ForceSensorRFD> rfdList; //stored to update SQL if anything changed
+ private ForceSensorImpulse impulse;
private Thread thread;
string databaseURL;
@@ -237,7 +247,7 @@ public class PreferencesWindow
FakeButtonDebugModeStart = new Gtk.Button();
}
- static public PreferencesWindow Show (Preferences preferences, List <ForceSensorRFD> rfdList,
+ static public PreferencesWindow Show (Preferences preferences, List <ForceSensorRFD> rfdList,
ForceSensorImpulse impulse,
Constants.Menuitem_modes menu_mode)
{
if (PreferencesWindowBox == null) {
@@ -257,6 +267,7 @@ public class PreferencesWindow
PreferencesWindowBox.preferences = preferences;
PreferencesWindowBox.rfdList = rfdList;
+ PreferencesWindowBox.impulse = impulse;
PreferencesWindowBox.createComboLanguage();
@@ -546,6 +557,7 @@ public class PreferencesWindow
{
createForceCombos();
setRFDValues();
+ setImpulseValue();
}
private void check_force_visibilities()
@@ -554,6 +566,7 @@ public class PreferencesWindow
hbox_force_2.Visible = (check_force_2.Active);
hbox_force_3.Visible = (check_force_3.Active);
hbox_force_4.Visible = (check_force_4.Active);
+ hbox_force_impulse.Visible = (check_force_impulse.Active);
}
private void on_check_force_clicked (object o, EventArgs args)
@@ -567,11 +580,13 @@ public class PreferencesWindow
UtilGtk.ComboUpdate(combo_force_2_function, ForceSensorRFD.FunctionsArray(true), "");
UtilGtk.ComboUpdate(combo_force_3_function, ForceSensorRFD.FunctionsArray(true), "");
UtilGtk.ComboUpdate(combo_force_4_function, ForceSensorRFD.FunctionsArray(true), "");
+ UtilGtk.ComboUpdate(combo_force_impulse_function, ForceSensorImpulse.FunctionsArray(true),
"");
UtilGtk.ComboUpdate(combo_force_1_type, ForceSensorRFD.TypesArray(true), "");
UtilGtk.ComboUpdate(combo_force_2_type, ForceSensorRFD.TypesArray(true), "");
UtilGtk.ComboUpdate(combo_force_3_type, ForceSensorRFD.TypesArray(true), "");
UtilGtk.ComboUpdate(combo_force_4_type, ForceSensorRFD.TypesArray(true), "");
+ UtilGtk.ComboUpdate(combo_force_impulse_type, ForceSensorImpulse.TypesArrayImpulse(true), "");
}
private void on_combo_force_type_changed (object o, EventArgs args)
@@ -604,6 +619,11 @@ public class PreferencesWindow
hbox_force_4_at_ms,
hbox_force_4_at_percent,
hbox_force_4_from_to);
+ else if(combo == combo_force_impulse_type)
+ combo_force_impulse_visibility(
+ UtilGtk.ComboGetActive(combo_force_impulse_type),
+ hbox_force_impulse_until_percent,
+ hbox_force_impulse_from_to);
}
private void combo_force_visibility (string selected, Gtk.HBox at_ms, Gtk.HBox at_percent, Gtk.HBox
from_to)
@@ -613,19 +633,33 @@ public class PreferencesWindow
from_to.Visible = false;
at_percent.Visible = false;
- if(selected == Catalog.GetString("Instantaneous"))
+ if(selected == Catalog.GetString(ForceSensorRFD.Type_INSTANTANEOUS_name))
{
at_ms.Visible = true;
}
- else if(selected == Catalog.GetString("Average"))
+ else if(selected == Catalog.GetString(ForceSensorRFD.Type_AVERAGE_name))
{
from_to.Visible = true;
}
- else if(selected == Catalog.GetString("% Force max"))
+ else if(selected == Catalog.GetString(ForceSensorRFD.Type_PERCENT_F_MAX_name))
{
at_percent.Visible = true;
}
}
+ private void combo_force_impulse_visibility (string selected, Gtk.HBox until_percent, Gtk.HBox
from_to)
+ {
+ until_percent.Visible = false;
+ from_to.Visible = false;
+
+ if(selected == Catalog.GetString(ForceSensorImpulse.Type_IMP_UNTIL_PERCENT_F_MAX_name))
+ {
+ until_percent.Visible = true;
+ }
+ else if(selected == Catalog.GetString(ForceSensorImpulse.Type_IMP_RANGE_name))
+ {
+ from_to.Visible = true;
+ }
+ }
private void setRFDValues ()
{
@@ -737,6 +771,58 @@ public class PreferencesWindow
return new ForceSensorRFD(code, active, function, type, num1, num2);
}
+ private void setImpulseValue ()
+ {
+ check_force_impulse.Active = impulse.active;
+
+ combo_force_impulse_function.Active = UtilGtk.ComboMakeActive(combo_force_impulse_function,
impulse.FunctionPrint(true));
+ combo_force_impulse_type.Active = UtilGtk.ComboMakeActive(combo_force_impulse_type,
impulse.TypePrint(true));
+
+ hbox_force_impulse_until_percent.Visible = false;
+ hbox_force_impulse_from_to.Visible = false;
+
+ if(impulse.type == ForceSensorImpulse.Types.IMP_UNTIL_PERCENT_F_MAX)
+ {
+ hbox_force_impulse_until_percent.Visible = true;
+ spinbutton_force_impulse_until_percent.Value = impulse.num1;
+ }
+ else if(impulse.type == ForceSensorImpulse.Types.IMP_RANGE)
+ {
+ hbox_force_impulse_from_to.Visible = true;
+ spinbutton_force_impulse_from.Value = impulse.num1;
+ spinbutton_force_impulse_to.Value = impulse.num2;
+ }
+ }
+ private ForceSensorImpulse getImpulseValue ()
+ {
+ bool active = check_force_impulse.Active;
+ int num1 = -1;
+ int num2 = -1;
+
+ ForceSensorImpulse.Functions function;
+ if(UtilGtk.ComboGetActive(combo_force_impulse_function) ==
ForceSensorImpulse.Function_RAW_name)
+ function = ForceSensorImpulse.Functions.RAW;
+ else //(UtilGtk.ComboGetActive(combo_force_impulse_function) ==
ForceSensorImpulse.Function_FITTED_name)
+ function = ForceSensorImpulse.Functions.FITTED;
+
+ ForceSensorImpulse.Types type;
+ string typeStr = UtilGtk.ComboGetActive(combo_force_impulse_type);
+
+ if(typeStr == Catalog.GetString(ForceSensorImpulse.Type_IMP_UNTIL_PERCENT_F_MAX_name))
+ {
+ num1 = Convert.ToInt32(spinbutton_force_impulse_until_percent.Value);
+ type = ForceSensorImpulse.Types.IMP_UNTIL_PERCENT_F_MAX;
+ }
+ else // if(typeStr == Catalog.GetString(ForceSensorImpulse.Type_IMP_RANGE_name))
+ {
+ num1 = Convert.ToInt32(spinbutton_force_impulse_from.Value);
+ num2 = Convert.ToInt32(spinbutton_force_impulse_to.Value);
+ type = ForceSensorImpulse.Types.IMP_RANGE;
+ }
+
+ return new ForceSensorImpulse(active, function, type, num1, num2);
+ }
+
private void on_button_force_rfd_default_clicked (object o, EventArgs args)
{
Sqlite.Open();
@@ -744,6 +830,12 @@ public class PreferencesWindow
SqliteForceSensor.DeleteAll(true);
SqliteForceSensor.InsertDefaultValues(true);
+ rfdList = SqliteForceSensor.SelectAll(false);
+ impulse = SqliteForceSensor.SelectImpulse(false);
+
+ setRFDValues();
+ setImpulseValue();
+
Sqlite.Close();
}
@@ -1526,6 +1618,13 @@ public class PreferencesWindow
i ++;
}
+ ForceSensorImpulse newImpulse = getImpulseValue();
+ if(newImpulse.Changed(impulse))
+ {
+ SqliteForceSensor.UpdateImpulse(true, newImpulse);
+ impulse = newImpulse;
+ }
+
// end of force sensor
@@ -1633,4 +1732,9 @@ public class PreferencesWindow
{
get { return rfdList; }
}
+
+ public ForceSensorImpulse GetImpulse
+ {
+ get { return impulse; }
+ }
}
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 1285ff4..2db220a 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -40,7 +40,7 @@ class SqliteForceSensor : Sqlite
{
dbcmd.CommandText =
"CREATE TABLE " + table + " ( " +
- "code TEXT, " + //RFD1...4
+ "code TEXT, " + //RFD1...4, I (Impulse)
"active INT, " + //bool
"function TEXT, " +
"type TEXT, " +
@@ -62,6 +62,18 @@ class SqliteForceSensor : Sqlite
Insert(true, new ForceSensorRFD("RFD4", false,
ForceSensorRFD.Functions.RAW, ForceSensorRFD.Types.RFD_MAX, -1, -1));
+ InsertDefaultValueImpulse(true);
+
+ closeIfNeeded(dbconOpened);
+ }
+
+ public static void InsertDefaultValueImpulse(bool dbconOpened)
+ {
+ openIfNeeded(dbconOpened);
+
+ Insert(true, new ForceSensorImpulse(true,
+ ForceSensorImpulse.Functions.RAW, ForceSensorImpulse.Types.IMP_RANGE,
0, 500));
+
closeIfNeeded(dbconOpened);
}
@@ -77,6 +89,19 @@ class SqliteForceSensor : Sqlite
closeIfNeeded(dbconOpened);
}
+ public static void InsertImpulse(bool dbconOpened, ForceSensorImpulse impulse)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "INSERT INTO " + table +
+ " (code, active, function, type, num1, num2) VALUES (" + impulse.ToSQLInsertString()
+ ")";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ closeIfNeeded(dbconOpened);
+ }
+
public static void Update(bool dbconOpened, ForceSensorRFD rfd)
{
@@ -95,6 +120,23 @@ class SqliteForceSensor : Sqlite
closeIfNeeded(dbconOpened);
}
+ public static void UpdateImpulse(bool dbconOpened, ForceSensorImpulse impulse)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "UPDATE " + table + " SET " +
+ " active = " + Util.BoolToInt(impulse.active).ToString() + "," +
+ " function = \"" + impulse.function.ToString() + "\"" + "," +
+ " type = \"" + impulse.type.ToString() + "\"" + "," +
+ " num1 = " + impulse.num1.ToString() + "," +
+ " num2 = " + impulse.num2.ToString() +
+ " WHERE code = \"" + impulse.code + "\"";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ closeIfNeeded(dbconOpened);
+ }
//used when button_force_rfd_default is clicked
public static void DeleteAll(bool dbconOpened)
@@ -113,7 +155,7 @@ class SqliteForceSensor : Sqlite
{
openIfNeeded(dbconOpened);
- dbcmd.CommandText = "SELECT * FROM " + table;
+ dbcmd.CommandText = "SELECT * FROM " + table + " WHERE code != \"I\"";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -140,4 +182,32 @@ class SqliteForceSensor : Sqlite
return l;
}
+ public static ForceSensorImpulse SelectImpulse (bool dbconOpened)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "SELECT * FROM " + table + " WHERE code == \"I\"";
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader = dbcmd.ExecuteReader();
+
+ ForceSensorImpulse impulse = null;
+ while(reader.Read()) {
+ impulse = new ForceSensorImpulse(
+ Util.IntToBool(Convert.ToInt32(reader[1])), //active
+ (ForceSensorImpulse.Functions) Enum.Parse(
+ typeof(ForceSensorImpulse.Functions), reader[2].ToString()),
//function
+ (ForceSensorImpulse.Types) Enum.Parse(
+ typeof(ForceSensorImpulse.Types), reader[3].ToString()),
//type
+ Convert.ToInt32(reader[4]), //num1
+ Convert.ToInt32(reader[5]) //num2
+ );
+ }
+
+ reader.Close();
+ closeIfNeeded(dbconOpened);
+
+ return impulse;
+ }
}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index ef7c1da..364d6d7 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -125,7 +125,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.44";
+ static string lastChronojumpDatabaseVersion = "1.45";
public Sqlite() {
}
@@ -2219,6 +2219,15 @@ class Sqlite
currentVersion = updateVersion("1.44");
}
+ if(currentVersion == "1.44")
+ {
+ LogB.SQL("Added ForceSensorImpulse value");
+
+ SqliteForceSensor.InsertDefaultValueImpulse(true);
+
+ currentVersion = updateVersion("1.45");
+ }
+
// --- add more updates here
@@ -2399,6 +2408,7 @@ class Sqlite
SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);
//changes [from - to - desc]
+ //1.44 - 1.45 Converted DB to 1.45 Added ForceSensorImpulse value
//1.43 - 1.44 Converted DB to 1.44 Added encoderCaptureCutByTriggers to preferences
//1.42 - 1.43 Converted DB to 1.43 Added exercise params of last capture for next Chronojump
start
//1.41 - 1.42 Converted DB to 1.42 Created and default values for ForceSensorRFD
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]