[chronojump] DB: 1.82. Jump, JumpRj have datetime
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB: 1.82. Jump, JumpRj have datetime
- Date: Wed, 8 Jan 2020 12:23:42 +0000 (UTC)
commit 2c37d34beac4d04862396cd06596694ea90be1f3
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jan 8 11:22:52 2020 +0100
DB: 1.82. Jump, JumpRj have datetime
src/execute/jump.cs | 17 ++++++++++-------
src/jump.cs | 13 +++++++++----
src/sqlite/jump.cs | 22 +++++++++++++---------
src/sqlite/jumpRj.cs | 14 ++++++++------
src/sqlite/main.cs | 19 ++++++++++++++++++-
src/treeview/jump.cs | 4 ++--
6 files changed, 60 insertions(+), 29 deletions(-)
---
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index b6367002..89010ee6 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -467,14 +467,16 @@ public class JumpExecute : EventExecute
needShowFeedbackMessage = true;
string table = Constants.JumpTable;
+ string datetime = UtilDate.ToFile(DateTime.Now);
uniqueID = SqliteJump.Insert(false, table, "NULL", personID, sessionID,
type, tv, tc, fall, //type, tv, tc, fall
- weight, description, angle, Util.BoolToNegativeInt(simulated));
+ weight, description, angle, Util.BoolToNegativeInt(simulated),
+ datetime);
//define the created object
eventDone = new Jump(uniqueID, personID, sessionID, type, tv, tc, fall,
- weight, description, angle, Util.BoolToNegativeInt(simulated));
+ weight, description, angle, Util.BoolToNegativeInt(simulated), datetime);
if(! avoidGraph)
{
@@ -1033,6 +1035,7 @@ public class JumpRjExecute : JumpExecute
*/
}
+ string datetime = UtilDate.ToFile(DateTime.Now);
if(tempTable)
SqliteJumpRj.Insert(false, Constants.TempJumpRjTable, "NULL", personID, sessionID,
@@ -1040,19 +1043,19 @@ public class JumpRjExecute : JumpExecute
fall, weight, description,
Util.GetAverage(tvString), Util.GetAverage(tcString),
tvString, tcString,
- jumps, Util.GetTotalTime(tcString, tvString), limitString,
angleString, Util.BoolToNegativeInt(simulated)
- );
+ jumps, Util.GetTotalTime(tcString, tvString), limitString,
angleString, Util.BoolToNegativeInt(simulated),
+ datetime);
else {
uniqueID = SqliteJumpRj.Insert(false, Constants.JumpRjTable, "NULL", personID,
sessionID,
type, Util.GetMax(tvString), Util.GetMax(tcString),
fall, weight, description,
Util.GetAverage(tvString), Util.GetAverage(tcString),
tvString, tcString,
- jumps, Util.GetTotalTime(tcString, tvString), limitString,
angleString, Util.BoolToNegativeInt(simulated)
- );
+ jumps, Util.GetTotalTime(tcString, tvString), limitString,
angleString, Util.BoolToNegativeInt(simulated),
+ datetime);
//define the created object
- eventDone = new JumpRj(uniqueID, personID, sessionID, type, tvString, tcString, fall,
weight, description, jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString,
Util.BoolToNegativeInt(simulated));
+ eventDone = new JumpRj(uniqueID, personID, sessionID, type, tvString, tcString, fall,
weight, description, jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString,
Util.BoolToNegativeInt(simulated), datetime);
//event will be raised, and managed in chronojump.cs
diff --git a/src/jump.cs b/src/jump.cs
index 5209a26b..9c447481 100644
--- a/src/jump.cs
+++ b/src/jump.cs
@@ -35,12 +35,13 @@ public class Jump : Event
//for not checking always in database
protected bool hasFall;
private double angle;
+ protected string datetime;
public Jump() {
}
//after inserting database (SQL)
- public Jump(int uniqueID, int personID, int sessionID, string type, double tv, double tc, double
fall, double weight, string description, double angle, int simulated)
+ public Jump(int uniqueID, int personID, int sessionID, string type, double tv, double tc, double
fall, double weight, string description, double angle, int simulated, string datetime)
{
this.uniqueID = uniqueID;
this.personID = personID;
@@ -53,6 +54,7 @@ public class Jump : Event
this.description = description;
this.angle = angle;
this.simulated = simulated;
+ this.datetime = datetime;
}
//used to select a jump at SqliteJump.SelectJumpData and at Sqlite.converTables
@@ -69,6 +71,7 @@ public class Jump : Event
this.description = eventString[8].ToString();
this.angle = Convert.ToDouble(Util.ChangeDecimalSeparator(eventString[9]));
this.simulated = Convert.ToInt32(eventString[10]);
+ this.datetime = eventString[11];
}
@@ -78,7 +81,7 @@ public class Jump : Event
personID, sessionID,
type, tv, tc, fall,
weight, description,
- angle, simulated);
+ angle, simulated, datetime);
}
public virtual double Stiffness(double personMassInKg, double extraMass)
@@ -144,7 +147,7 @@ public class JumpRj : Jump
//after inserting database (SQL)
public JumpRj(int uniqueID, int personID, int sessionID, string type,
string tvString, string tcString, double fall, double weight,
- string description, int jumps, double time, string limited, string angleString, int
simulated)
+ string description, int jumps, double time, string limited, string angleString, int
simulated, string datetime)
{
this.uniqueID = uniqueID;
this.personID = personID;
@@ -160,6 +163,7 @@ public class JumpRj : Jump
this.limited = limited;
this.angleString = angleString;
this.simulated = simulated;
+ this.datetime = datetime;
}
//used to select a jump at SqliteJump.SelectRjJumpData and at Sqlite.convertTables
@@ -182,6 +186,7 @@ public class JumpRj : Jump
this.limited = eventString[15];
this.angleString = eventString[16];
this.simulated = Convert.ToInt32(eventString[17]);
+ this.datetime = eventString[18];
}
@@ -193,7 +198,7 @@ public class JumpRj : Jump
type, TvMax, TcMax, fall, weight,
description, TvAvg, TcAvg, tvString, tcString,
jumps, time, limited,
- angleString, simulated);
+ angleString, simulated, datetime);
}
diff --git a/src/sqlite/jump.cs b/src/sqlite/jump.cs
index 83ef081b..83311b3e 100644
--- a/src/sqlite/jump.cs
+++ b/src/sqlite/jump.cs
@@ -52,10 +52,11 @@ class SqliteJump : Sqlite
"weight TEXT, " + //string because can contain "33%" or "50Kg"
"description TEXT, " +
"angle FLOAT, " + //-1.0 if undef
- "simulated INT )"; //since db: 0.60 (cj 0.8.1.2) simulated = -1, real test (not
uploaded to server) = 0,
+ "simulated INT, " + //since db: 0.60 (cj 0.8.1.2) simulated = -1, real test (not
uploaded to server) = 0,
//positive numbers represent the serverUniqueID
//the simulated has two purposes, but it's logical because
//only real tests can be uploaded
+ "datetime TEXT )";
dbcmd.ExecuteNonQuery();
}
@@ -65,7 +66,7 @@ class SqliteJump : Sqlite
*/
//public static int Insert(int personID, int sessionID, string type, double tv, double tc, int fall,
double weight, string limited, string description, int simulated)
- public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double tv, double tc, double fall, double weight, string description, double angle,
int simulated)
+ public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double tv, double tc, double fall, double weight, string description, double angle,
int simulated, string datetime)
{
if(! dbconOpened)
Sqlite.Open();
@@ -74,12 +75,12 @@ class SqliteJump : Sqlite
uniqueID = "NULL";
dbcmd.CommandText = "INSERT INTO " + tableName +
- " (uniqueID, personID, sessionID, type, tv, tc, fall, weight, description,
angle, simulated)" +
+ " (uniqueID, personID, sessionID, type, tv, tc, fall, weight, description,
angle, simulated, datetime)" +
" VALUES (" + uniqueID + ", "
+ personID + ", " + sessionID + ", \"" + type + "\", "
+ Util.ConvertToPoint(tv) + ", " + Util.ConvertToPoint(tc) + ", " +
Util.ConvertToPoint(fall) + ", \""
+ Util.ConvertToPoint(weight) + "\", \"" + description + "\", "
- + Util.ConvertToPoint(angle) + ", " + simulated +")" ;
+ + Util.ConvertToPoint(angle) + ", " + simulated + ", \"" + datetime + "\")" ;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -155,8 +156,8 @@ class SqliteJump : Sqlite
int count = new int();
count = 0;
- while(reader.Read()) {
-
+ while(reader.Read())
+ {
myArray.Add (reader[0].ToString() + ":" + //person.name
reader[1].ToString() + ":" + //jump.uniqueID
reader[2].ToString() + ":" + //jump.personID
@@ -169,7 +170,8 @@ class SqliteJump : Sqlite
reader[9].ToString() + ":" + //description
Util.ChangeDecimalSeparator(reader[10].ToString()) + ":" +
//angle
reader[11].ToString() + ":" + //simulated
- reader[12].ToString() //person.weight
+ reader[12].ToString() + ":" + //datetime
+ reader[13].ToString() //person.weight
);
count ++;
}
@@ -203,7 +205,7 @@ class SqliteJump : Sqlite
reader = dbcmd.ExecuteReader();
reader.Read();
- Jump myJump = new Jump(DataReaderToStringArray(reader, 11));
+ Jump myJump = new Jump(DataReaderToStringArray(reader, 12));
reader.Close();
@@ -325,7 +327,9 @@ class SqliteJump : Sqlite
reader[8].ToString(), // description
Convert.ToDouble(Util.ChangeDecimalSeparator(
reader[9].ToString())), //angle
- Convert.ToInt32(reader[10].ToString())); //simulated
+ Convert.ToInt32(reader[10].ToString()), //simulated
+ reader[11].ToString() //datetime
+ );
jmp_l.Add(jmp);
LogB.Information(jmp.ToString());
diff --git a/src/sqlite/jumpRj.cs b/src/sqlite/jumpRj.cs
index 90120a10..cd27abd8 100644
--- a/src/sqlite/jumpRj.cs
+++ b/src/sqlite/jumpRj.cs
@@ -54,11 +54,12 @@ class SqliteJumpRj : SqliteJump
"time FLOAT, " + //if limit it's 'n' jumps, we probably waste 7.371 seconds
"limited TEXT, " + //for RJ, "11J" or "11S" (11 Jumps, 11 seconds)
"angleString TEXT, " + //"-1" if undef
- "simulated INT )";
+ "simulated INT, " +
+ "datetime TEXT )";
dbcmd.ExecuteNonQuery();
}
- public static int Insert (bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double tvMax, double tcMax, double fall, double weight, string description, double
tvAvg, double tcAvg, string tvString, string tcString, int jumps, double time, string limited, string
angleString, int simulated )
+ public static int Insert (bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double tvMax, double tcMax, double fall, double weight, string description, double
tvAvg, double tcAvg, string tvString, string tcString, int jumps, double time, string limited, string
angleString, int simulated, string datetime )
{
Console.WriteLine("At SQL insert RJ");
@@ -70,14 +71,14 @@ class SqliteJumpRj : SqliteJump
dbcmd.CommandText = "INSERT INTO " + tableName +
" (uniqueID, personID, sessionID, type, tvMax, tcMax, fall, weight,
description, " +
- "tvAvg, tcAvg, tvString, tcString, jumps, time, limited, angleString,
simulated )" +
+ "tvAvg, tcAvg, tvString, tcString, jumps, time, limited, angleString,
simulated, datetime )" +
"VALUES (" + uniqueID + ", " +
personID + ", " + sessionID + ", \"" + type + "\", " +
Util.ConvertToPoint(tvMax) + ", " + Util.ConvertToPoint(tcMax) + ", \"" +
Util.ConvertToPoint(fall) + "\", \"" + Util.ConvertToPoint(weight) + "\", \""
+ description + "\", " +
Util.ConvertToPoint(tvAvg) + ", " + Util.ConvertToPoint(tcAvg) + ", \"" +
Util.ConvertToPoint(tvString) + "\", \"" + Util.ConvertToPoint(tcString) +
"\", " +
- jumps + ", " + Util.ConvertToPoint(time) + ", \"" + limited + "\", \"" +
angleString + "\", " + simulated +")" ;
+ jumps + ", " + Util.ConvertToPoint(time) + ", \"" + limited + "\", \"" +
angleString + "\", " + simulated + ", \"" + datetime + "\")" ;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -159,7 +160,8 @@ class SqliteJumpRj : SqliteJump
reader[16].ToString() + ":" + //limited
reader[17].ToString() + ":" + //angleString
reader[18].ToString() + ":" + //simulated
- reader[19].ToString() //person.weight
+ reader[19].ToString() + ":" + //datetime
+ reader[20].ToString() //person.weight
);
count ++;
}
@@ -194,7 +196,7 @@ class SqliteJumpRj : SqliteJump
reader = dbcmd.ExecuteReader();
reader.Read();
- JumpRj myJump = new JumpRj(DataReaderToStringArray(reader, 18));
+ JumpRj myJump = new JumpRj(DataReaderToStringArray(reader, 19));
reader.Close();
if(!dbconOpened)
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index f78b1661..a24ab813 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.81";
+ static string lastChronojumpDatabaseVersion = "1.82";
public Sqlite() {
}
@@ -2576,6 +2576,22 @@ class Sqlite
currentVersion = updateVersion("1.81");
}
+ if(currentVersion == "1.81")
+ {
+ LogB.SQL("Doing alter table jump, jumpRj, tempJumpRj add datetime");
+ try {
+ //sqlite does not have drop column
+ executeSQL("ALTER TABLE " + Constants.JumpTable + " ADD COLUMN
datetime TEXT;");
+ executeSQL("ALTER TABLE " + Constants.JumpRjTable + " ADD COLUMN
datetime TEXT;");
+ executeSQL("ALTER TABLE " + Constants.TempJumpRjTable + " ADD COLUMN
datetime TEXT;");
+ } catch {
+ LogB.SQL("Catched. forceSensor stiffness/stiffnessString already
exists.");
+
+ }
+ LogB.SQL("Done!");
+
+ currentVersion = updateVersion("1.82");
+ }
/*
@@ -2789,6 +2805,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.81 - 1.82 Converted DB to 1.82 Doing alter table jump, jumpRj, tempJumpRj add datetime
//1.80 - 1.81 Converted DB to 1.81 Inserted forceSensorCaptureFeedbackActive /At /Range
//1.79 - 1.80 Converted DB to 1.80 Inserted forceSensorElasticEccMinDispl, ...
//1.78 - 1.79 Converted DB to 1.79 Inserted into preferences: encoderWorkKcal
diff --git a/src/treeview/jump.cs b/src/treeview/jump.cs
index 945b0b75..df720a6b 100644
--- a/src/treeview/jump.cs
+++ b/src/treeview/jump.cs
@@ -163,7 +163,7 @@ public class TreeViewJumps : TreeViewEvent
myJump.Weight = Convert.ToDouble(myStringOfData[8].ToString());
//to calculate potency
- personWeight = Convert.ToDouble(myStringOfData[12]);
+ personWeight = Convert.ToDouble(myStringOfData[13]);
weightInKg = Util.WeightFromPercentToKg(myJump.Weight, personWeight);
return myJump;
@@ -289,7 +289,7 @@ public class TreeViewJumpsRj : TreeViewJumps
myJumpRj.Weight = Convert.ToDouble(myStringOfData[8].ToString());
- personWeight = Convert.ToDouble(myStringOfData[19]);
+ personWeight = Convert.ToDouble(myStringOfData[20]);
weightInKg = Util.WeightFromPercentToKg(myJumpRj.Weight, personWeight);
return myJumpRj;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]