[chronojump] DB: 1.87 ALTER TABLE forceSensorExercise adding eccReps, eccMin, conMin
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB: 1.87 ALTER TABLE forceSensorExercise adding eccReps, eccMin, conMin
- Date: Mon, 17 Feb 2020 18:22:03 +0000 (UTC)
commit 87cfe3ab88c2bbc54a37420d2e602e3fd05c606b
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 17 19:21:27 2020 +0100
DB: 1.87 ALTER TABLE forceSensorExercise adding eccReps, eccMin, conMin
src/forceSensor.cs | 46 +++++++++++++++++++++++--
src/gui/forceSensorExercise.cs | 3 +-
src/sqlite/forceSensor.cs | 78 ++++++++++++++++++++++++++++++++++--------
src/sqlite/main.cs | 22 +++++++++++-
4 files changed, 129 insertions(+), 20 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 5a2c0f95..07a91d35 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -345,6 +345,9 @@ public class ForceSensorExercise
private bool tareBeforeCapture;
private bool forceResultant;
private bool elastic;
+ private bool eccReps;
+ private double eccMin;
+ private double conMin;
/*
* note percentBodyWeight and tareBeforeCapture will not be true at the same time, so there are three
modes on total mass management (see diagrams/processes/forceSensorExerciseParameters)
@@ -369,6 +372,25 @@ public class ForceSensorExercise
this.elastic = false;
}
+ public ForceSensorExercise(int uniqueID, string name, int percentBodyWeight, string resistance, int
angleDefault,
+ string description, bool tareBeforeCapture, bool forceResultant, bool elastic,
+ bool eccReps, double eccMin, double conMin)
+ {
+ this.uniqueID = uniqueID;
+ this.name = name;
+ this.percentBodyWeight = percentBodyWeight;
+ this.resistance = resistance;
+ this.angleDefault = angleDefault;
+ this.description = description;
+ this.tareBeforeCapture = tareBeforeCapture;
+ this.forceResultant = forceResultant;
+ this.elastic = elastic;
+ this.eccReps = eccReps;
+ this.eccMin = eccMin;
+ this.conMin = conMin;
+ }
+
+ //constructor at DB: 1.86
public ForceSensorExercise(int uniqueID, string name, int percentBodyWeight, string resistance, int
angleDefault,
string description, bool tareBeforeCapture, bool forceResultant, bool elastic)
{
@@ -387,7 +409,8 @@ public class ForceSensorExercise
{
return uniqueID.ToString() + ":" + name + ":" + percentBodyWeight.ToString() + ":" +
resistance + ":" + angleDefault.ToString() + ":" + description + ":" +
- tareBeforeCapture.ToString() + ":" + forceResultant.ToString() + ":" +
elastic.ToString();
+ tareBeforeCapture.ToString() + ":" + forceResultant.ToString() + ":" +
elastic.ToString() + ":" +
+ eccReps.ToString() + ":" + eccMin.ToString() + ":" + conMin.ToString();
}
public string ToSQLInsertString()
@@ -401,7 +424,9 @@ public class ForceSensorExercise
resistance + "\", " + angleDefault + ", \"" + description + "\", " +
Util.BoolToInt(tareBeforeCapture).ToString() + ", " +
Util.BoolToInt(forceResultant).ToString() + ", " +
- Util.BoolToInt(elastic).ToString();
+ Util.BoolToInt(elastic).ToString() + ", " +
+ Util.BoolToInt(eccReps).ToString() + ", " +
+ Util.ConvertToPoint(eccMin) + ", " + Util.ConvertToPoint(conMin);
}
// to be able to import
@@ -427,7 +452,10 @@ public class ForceSensorExercise
description == newEx.Description &&
tareBeforeCapture == newEx.TareBeforeCapture &&
forceResultant == newEx.ForceResultant &&
- elastic == newEx.Elastic)
+ elastic == newEx.Elastic &&
+ eccReps == newEx.EccReps &&
+ eccMin == newEx.EccMin &&
+ conMin == newEx.ConMin)
return false;
return true;
@@ -471,6 +499,18 @@ public class ForceSensorExercise
{
get { return elastic; }
}
+ public bool EccReps
+ {
+ get { return eccReps; }
+ }
+ public double EccMin
+ {
+ get { return eccMin; }
+ }
+ public double ConMin
+ {
+ get { return conMin; }
+ }
public bool ComputeAsElastic
{
diff --git a/src/gui/forceSensorExercise.cs b/src/gui/forceSensorExercise.cs
index 48e78dfa..72061929 100644
--- a/src/gui/forceSensorExercise.cs
+++ b/src/gui/forceSensorExercise.cs
@@ -494,7 +494,8 @@ public class ForceSensorExerciseWindow
entry_description.Text,
radio_mass_subtract.Active, //tareBeforeCapture
radio_force_resultant.Active,
- radio_fixation_elastic.Active);
+ radio_fixation_elastic.Active,
+ false, -1, -1); //TODO: read this from the gui
if(modeEnum == modesEnum.ADD)
{
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index d4b290d8..0e9efd4c 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -448,7 +448,10 @@ class SqliteForceSensorExercise : Sqlite
"description TEXT, " +
"tareBeforeCapture INT, " +
"forceResultant INT NOT NULL, " +
- "elastic INT NOT NULL)";
+ "elastic INT NOT NULL, " +
+ "eccReps INT DEFAULT 0, " +
+ "eccMin FLOAT DEFAULT -1, " + //can be displacement or N
+ "conMin FLOAT DEFAULT -1)"; //can be displacement or N
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
}
@@ -462,7 +465,8 @@ class SqliteForceSensorExercise : Sqlite
dbcmd.CommandText = "INSERT INTO " + table +
" (uniqueID, name, percentBodyWeight, resistance, angleDefault, " +
- " description, tareBeforeCapture, forceResultant, elastic)" +
+ " description, tareBeforeCapture, forceResultant, elastic, " +
+ " eccReps, eccMin, conMin)" +
" VALUES (" + ex.ToSQLInsertString() + ")";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -491,6 +495,9 @@ class SqliteForceSensorExercise : Sqlite
"\", tareBeforeCapture = " + Util.BoolToInt(ex.TareBeforeCapture).ToString() +
", forceResultant = " + Util.BoolToInt(ex.ForceResultant).ToString() +
", elastic = " + Util.BoolToInt(ex.Elastic).ToString() +
+ ", eccReps = " + Util.BoolToInt(ex.EccReps).ToString() +
+ ", eccMin = " + Util.ConvertToPoint(ex.EccMin) +
+ ", conMin = " + Util.ConvertToPoint(ex.ConMin) +
" WHERE uniqueID = " + ex.UniqueID;
LogB.SQL(dbcmd.CommandText.ToString());
@@ -542,18 +549,35 @@ class SqliteForceSensorExercise : Sqlite
array.Add(ex);
}
} else {
- while(reader.Read()) {
- ex = new ForceSensorExercise (
- Convert.ToInt32(reader[0].ToString()), //uniqueID
- reader[1].ToString(), //name
- Convert.ToInt32(reader[2].ToString()), //percentBodyWeight
- reader[3].ToString(), //resistance (unused)
- Convert.ToInt32(reader[4].ToString()), //angleDefault
- reader[5].ToString(), //description
- Util.IntToBool(Convert.ToInt32(reader[6].ToString())),
//tareBeforeCapture
- Util.IntToBool(Convert.ToInt32(reader[7].ToString())),
//forceResultant
- Util.IntToBool(Convert.ToInt32(reader[8].ToString()))
//elastic
- );
+ while(reader.Read())
+ {
+ if(reader.FieldCount == 9) //DB 1.73
+ ex = new ForceSensorExercise (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ Convert.ToInt32(reader[2].ToString()),
//percentBodyWeight
+ reader[3].ToString(), //resistance
(unused)
+ Convert.ToInt32(reader[4].ToString()), //angleDefault
+ reader[5].ToString(), //description
+
Util.IntToBool(Convert.ToInt32(reader[6].ToString())), //tareBeforeCapture
+
Util.IntToBool(Convert.ToInt32(reader[7].ToString())), //forceResultant
+ Util.IntToBool(Convert.ToInt32(reader[8].ToString()))
//elastic
+ );
+ else //if(reader.FieldCount == 12) DB: 1.87
+ ex = new ForceSensorExercise (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ Convert.ToInt32(reader[2].ToString()),
//percentBodyWeight
+ reader[3].ToString(), //resistance
(unused)
+ Convert.ToInt32(reader[4].ToString()), //angleDefault
+ reader[5].ToString(), //description
+
Util.IntToBool(Convert.ToInt32(reader[6].ToString())), //tareBeforeCapture
+
Util.IntToBool(Convert.ToInt32(reader[7].ToString())), //forceResultant
+
Util.IntToBool(Convert.ToInt32(reader[8].ToString())), //elastic
+
Util.IntToBool(Convert.ToInt32(reader[9].ToString())), //eccReps
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[10].ToString())), //eccMin
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[11].ToString())) //conMin
+ );
array.Add(ex);
}
}
@@ -627,9 +651,33 @@ class SqliteForceSensorExerciseImport : SqliteForceSensorExercise
ex.Resistance = "";
- Update(true, ex);
+ Update_1_73_to_1_74(true, ex);
}
}
+
+ public static void Update_1_73_to_1_74 (bool dbconOpened, ForceSensorExercise ex)
+ {
+ if(! dbconOpened)
+ Sqlite.Open();
+
+ dbcmd.CommandText = "UPDATE " + table + " SET " +
+ " name = \"" + ex.Name +
+ "\", percentBodyWeight = " + ex.PercentBodyWeight +
+ ", resistance = \"" + ex.Resistance + //unused
+ "\", angleDefault = " + ex.AngleDefault +
+ ", description = \"" + ex.Description +
+ "\", tareBeforeCapture = " + Util.BoolToInt(ex.TareBeforeCapture).ToString() +
+ ", forceResultant = " + Util.BoolToInt(ex.ForceResultant).ToString() +
+ ", elastic = " + Util.BoolToInt(ex.Elastic).ToString() +
+ " WHERE uniqueID = " + ex.UniqueID;
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ if(! dbconOpened)
+ Sqlite.Close();
+ }
+
}
class SqliteForceSensorElasticBand : Sqlite
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 2c4cd6e1..89e9bfb6 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.86";
+ static string lastChronojumpDatabaseVersion = "1.87";
public Sqlite() {
}
@@ -610,6 +610,7 @@ class Sqlite
LogB.SQL("User database newer than program, need to update software");
returnSoftwareIsNew = false;
} else {
+ //LogB.PrintAllThreads = true; //comment this
LogB.Warning("Old database, need to convert");
LogB.Warning("db version: " + currentVersion);
@@ -2628,6 +2629,22 @@ class Sqlite
currentVersion = updateVersion("1.86");
}
+ if(currentVersion == "1.86")
+ {
+ LogB.SQL("Doing alter table forceSensorExercise adding eccReps, eccMin,
conMin");
+ try {
+ //sqlite does not have drop column
+ executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + "
ADD COLUMN eccReps INT DEFAULT 0;");
+ executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + "
ADD COLUMN eccMin FLOAT DEFAULT -1;");
+ executeSQL("ALTER TABLE " + Constants.ForceSensorExerciseTable + "
ADD COLUMN conMin FLOAT DEFAULT -1;");
+ } catch {
+ LogB.SQL("Catched. ");
+
+ }
+ LogB.SQL("Done!");
+
+ currentVersion = updateVersion("1.87");
+ }
/*
if(currentVersion == "1.79")
@@ -2654,6 +2671,8 @@ class Sqlite
LogB.SQL("Closing Sqlite after DB updates");
Sqlite.Close(); //------------------------------------------------
+
+ //LogB.PrintAllThreads = false; //comment this
}
//if changes are made here, remember to change also in CreateTables()
@@ -2840,6 +2859,7 @@ class Sqlite
//changes [from - to - desc]
//just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved
stiffnessString records there
//
+ //1.86 - 1.87 Converted DB to 1.87 Doing alter table forceSensorExercise adding eccReps,
eccMin, conMin.
//1.85 - 1.86 Converted DB to 1.86 Inserted into preferences: RunEncoderMinAccel
//1.84 - 1.85 Converted DB to 1.85 Inserted 5 vars into preferences:
EncoderCaptureMainVariable...
//1.83 - 1.84 Converted DB to 1.84 Inserted into preferences: forceSensorMIFDuration
Mode/Seconds/Percent
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]