[chronojump] SqliteForceSensor stuff moved to new SqliteForceSensorRFD class
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] SqliteForceSensor stuff moved to new SqliteForceSensorRFD class
- Date: Mon, 3 Dec 2018 13:00:14 +0000 (UTC)
commit 22550de9d19e9713b82ed8cf46cfcf987597f5fb
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Dec 3 13:52:16 2018 +0100
SqliteForceSensor stuff moved to new SqliteForceSensorRFD class
src/gui/chronojump.cs | 4 +--
src/gui/forceSensorAnalyze.cs | 12 ++++-----
src/sqlite/forceSensor.cs | 58 ++++++++++++++++++++++++++++++++++++++++---
src/sqlite/main.cs | 10 ++++----
4 files changed, 67 insertions(+), 17 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3ad60e2c..4d3d95d5 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -621,8 +621,8 @@ public partial class ChronoJumpWindow
createTreeView_pulses (treeview_pulses);
createTreeView_multi_chronopic (false, treeview_multi_chronopic);
- rfdList = SqliteForceSensor.SelectAll(false);
- impulse = SqliteForceSensor.SelectImpulse(false);
+ rfdList = SqliteForceSensorRFD.SelectAll(false);
+ impulse = SqliteForceSensorRFD.SelectImpulse(false);
initForceSensor();
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index 2f58c890..2513551f 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -144,7 +144,7 @@ public partial class ChronoJumpWindow
{
if(rfdList[i].Changed(rfd))
{
- SqliteForceSensor.Update(true, rfd);
+ SqliteForceSensorRFD.Update(true, rfd);
rfdList[i] = rfd;
}
i ++;
@@ -153,7 +153,7 @@ public partial class ChronoJumpWindow
ForceSensorImpulse newImpulse = getImpulseValue();
if(newImpulse.Changed(impulse))
{
- SqliteForceSensor.UpdateImpulse(true, newImpulse);
+ SqliteForceSensorRFD.UpdateImpulse(true, newImpulse);
impulse = newImpulse;
}
Sqlite.Close();
@@ -440,11 +440,11 @@ public partial class ChronoJumpWindow
{
Sqlite.Open();
- SqliteForceSensor.DeleteAll(true);
- SqliteForceSensor.InsertDefaultValues(true);
+ SqliteForceSensorRFD.DeleteAll(true);
+ SqliteForceSensorRFD.InsertDefaultValues(true);
- rfdList = SqliteForceSensor.SelectAll(false);
- impulse = SqliteForceSensor.SelectImpulse(false);
+ rfdList = SqliteForceSensorRFD.SelectAll(false);
+ impulse = SqliteForceSensorRFD.SelectImpulse(false);
setRFDValues();
setImpulseValue();
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 2db220a1..b62f59f6 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -23,20 +23,70 @@ using System;
using System.Collections.Generic; //List<T>
using Mono.Data.Sqlite;
-class SqliteForceSensor : Sqlite
+class SqliteForceSensorExercise : Sqlite
+{
+ private static string table = Constants.ForceSensorExerciseTable;
+
+ public SqliteForceSensorExercise() {
+ }
+
+ ~SqliteForceSensorExercise() {}
+
+ /*
+ * create and initialize tables
+ */
+
+ protected internal static void createTable()
+ {
+ dbcmd.CommandText =
+ "CREATE TABLE " + table + " ( " +
+ "uniqueID INTEGER PRIMARY KEY, " +
+ "name TEXT, " +
+ "percentBodyWeight INT, " +
+ "ressistance TEXT, " +
+ "angle INT, " +
+ "description TEXT )";
+ dbcmd.ExecuteNonQuery();
+ }
+
+ //undefined defaultAngle will be 1000
+ //note execution can have a different angle than the default angle
+ public static void Insert (bool dbconOpened, int uniqueID, string name, int percentBodyWeight,
+ string ressistance, int angleDefault, string description)
+ {
+ if(! dbconOpened)
+ Sqlite.Open();
+
+ string uniqueIDStr = "NULL";
+ if(uniqueID != -1)
+ uniqueIDStr = uniqueID.ToString();
+
+ dbcmd.CommandText = "INSERT INTO " + table +
+ " (uniqueID, name, percentBodyWeight, ressistance, angleDefault,
description)" +
+ " VALUES (" + uniqueIDStr + ", \"" + name + "\", " + percentBodyWeight + ",
\"" +
+ ressistance + "\", " + angleDefault + ", \"" + description + "\")";
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ if(! dbconOpened)
+ Sqlite.Close();
+ }
+
+}
+
{
private static string table = Constants.ForceRFDTable;
- public SqliteForceSensor() {
+ public SqliteForceSensorRFD() {
}
- ~SqliteForceSensor() {}
+ ~SqliteForceSensorRFD() {}
/*
* create and initialize tables
*/
- protected internal static void createTableForceRFD()
+ protected internal static void createTable()
{
dbcmd.CommandText =
"CREATE TABLE " + table + " ( " +
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 70e6e0ca..8b120646 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -2172,8 +2172,8 @@ class Sqlite
{
LogB.SQL("Created and default values for ForceSensorRFD");
- SqliteForceSensor.createTableForceRFD();
- SqliteForceSensor.InsertDefaultValues(true);
+ SqliteForceSensorRFD.createTable();
+ SqliteForceSensorRFD.InsertDefaultValues(true);
currentVersion = updateVersion("1.42");
}
@@ -2222,7 +2222,7 @@ class Sqlite
{
LogB.SQL("Added ForceSensorImpulse value");
- SqliteForceSensor.InsertDefaultValueImpulse(true);
+ SqliteForceSensorRFD.InsertDefaultValueImpulse(true);
currentVersion = updateVersion("1.45");
}
@@ -2529,8 +2529,8 @@ class Sqlite
SqliteChronopicRegister.createTableChronopicRegister();
SqliteTrigger.createTableTrigger();
- SqliteForceSensor.createTableForceRFD();
- SqliteForceSensor.InsertDefaultValues(true);
+ SqliteForceSensorRFD.createTable();
+ SqliteForceSensorRFD.InsertDefaultValues(true);
creationRate ++;
SqlitePreferences.createTable();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]