[chronojump/FS-TFT-Menu] DB: 2.39 RunEncoderExercise ALTER TABLE added angleDefault. RunEncoder ALTER TABLE added angle
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/FS-TFT-Menu] DB: 2.39 RunEncoderExercise ALTER TABLE added angleDefault. RunEncoder ALTER TABLE added angle
- Date: Wed, 11 May 2022 08:25:11 +0000 (UTC)
commit ef393a2c71bc2cf3f258da860dbc876c0a888512
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri May 6 18:16:42 2022 +0200
DB: 2.39 RunEncoderExercise ALTER TABLE added angleDefault. RunEncoder ALTER TABLE added angle
src/runEncoder.cs | 31 ++++++++++++++++++++++++-------
src/sqlite/main.cs | 20 +++++++++++++++++++-
src/sqlite/runEncoder.cs | 23 ++++++++++++++---------
3 files changed, 57 insertions(+), 17 deletions(-)
---
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index d938b86a3..02aec94f3 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -44,6 +44,7 @@ public class RunEncoder
private string dateTime;
private string comments;
private string videoURL;
+ private int angle;
private string exerciseName;
@@ -58,7 +59,7 @@ public class RunEncoder
//constructor
public RunEncoder(int uniqueID, int personID, int sessionID, int exerciseID, Devices device,
int distance, int temperature, string filename, string url,
- string dateTime, string comments, string videoURL, string exerciseName)
+ string dateTime, string comments, string videoURL, int angle, string exerciseName)
{
this.uniqueID = uniqueID;
this.personID = personID;
@@ -72,6 +73,7 @@ public class RunEncoder
this.dateTime = dateTime;
this.comments = comments;
this.videoURL = videoURL;
+ this.angle = angle;
this.exerciseName = exerciseName;
}
@@ -91,7 +93,7 @@ public class RunEncoder
return
"(" + uniqueIDStr + ", " + personID + ", " + sessionID + ", " + exerciseID + ", \"" +
device.ToString() + "\", " +
distance + ", " + temperature + ", \"" + filename + "\", \"" + url + "\", \"" +
dateTime + "\", \"" +
- comments + "\", \"" + videoURL + "\")";
+ comments + "\", \"" + videoURL + "\", " + angle + ")";
}
public void UpdateSQL(bool dbconOpened)
@@ -113,7 +115,8 @@ public class RunEncoder
"\", dateTime = \"" + dateTime +
"\", comments = \"" + comments +
"\", videoURL = \"" + Util.MakeURLrelative(videoURL) +
- "\" WHERE uniqueID = " + uniqueID;
+ "\", angle = " + angle +
+ " WHERE uniqueID = " + uniqueID;
}
public void UpdateSQLJustComments(bool dbconOpened)
@@ -259,6 +262,11 @@ public class RunEncoder
get { return videoURL; }
set { videoURL = value; }
}
+ public int Angle
+ {
+ get { return angle; }
+ set { angle = value; }
+ }
public string ExerciseName
{
get { return exerciseName; }
@@ -401,6 +409,7 @@ public class RunEncoderExercise
public static int SegmentCmDefault = 500;
private List<int> segmentVariableCm; //if segmentCm == -1 then this is used
private bool isSprint;
+ private int angleDefault;
public RunEncoderExercise()
{
@@ -411,7 +420,8 @@ public class RunEncoderExercise
this.name = name;
}
- public RunEncoderExercise(int uniqueID, string name, string description, int segmentCm, List<int>
segmentVariableCm, bool isSprint)
+ public RunEncoderExercise(int uniqueID, string name, string description,
+ int segmentCm, List<int> segmentVariableCm, bool isSprint, int angleDefault)
{
this.uniqueID = uniqueID;
this.name = name;
@@ -419,13 +429,15 @@ public class RunEncoderExercise
this.segmentCm = segmentCm;
this.segmentVariableCm = segmentVariableCm;
this.isSprint = isSprint;
+ this.angleDefault = angleDefault;
}
public override string ToString()
{
- return string.Format("{0}:{1}:{2}:{3}:{4}:{5}",
+ return string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}",
uniqueID, name, description, segmentCm,
- Util.ListIntToSQLString (segmentVariableCm, ";"), isSprint);
+ Util.ListIntToSQLString (segmentVariableCm, ";"),
+ isSprint, angleDefault);
}
public void InsertSQL (bool dbconOpened)
@@ -441,7 +453,8 @@ public class RunEncoderExercise
return
"(" + uniqueIDStr + ", \"" + name + "\", \"" + description + "\", " +
- segmentCm + ", \"" + SegmentVariableCmToSQL + "\", " + Util.BoolToInt(isSprint) + ")";
+ segmentCm + ", \"" + SegmentVariableCmToSQL + "\", " +
+ Util.BoolToInt(isSprint) + ", " + angleDefault + ")";
}
public int UniqueID
@@ -481,6 +494,10 @@ public class RunEncoderExercise
{
get { return isSprint; }
}
+ public int AngleDefault
+ {
+ get { return angleDefault; }
+ }
}
//results coming from analyze (load) using R. To be published on exportable table
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index e5c989145..d1d0614ee 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -131,7 +131,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "2.38";
+ static string lastChronojumpDatabaseVersion = "2.39";
public Sqlite()
{
@@ -3254,6 +3254,23 @@ class Sqlite
currentVersion = updateVersion("2.38");
}
+ if(currentVersion == "2.38")
+ {
+ LogB.SQL("RunEncoderExercise ALTER TABLE added angleDefault. RunEncoder ALTER
TABLE added angle.");
+ try {
+ executeSQL("ALTER TABLE " + Constants.RunEncoderExerciseTable + " ADD
COLUMN angleDefault INT NOT NULL DEFAULT 0;");
+ } catch {
+ LogB.SQL("Catched at Doing ALTER TABLE RunEncoderExercise added
angleDefault.");
+ }
+
+ try {
+ executeSQL("ALTER TABLE " + Constants.RunEncoderTable + " ADD COLUMN
angle INT NOT NULL DEFAULT 0;");
+ } catch {
+ LogB.SQL("Catched at Doing ALTER TABLE RunEncoder added angle.");
+ }
+
+ currentVersion = updateVersion("2.39");
+ }
/*
if(currentVersion == "1.79")
@@ -3475,6 +3492,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
+ //2.38 - 2.39 Converted DB to 2.39 RunEncoderExercise ALTER TABLE added angleDefault.
RunEncoder ALTER TABLE added angle
//2.37 - 2.38 Converted DB to 2.38 Doing alter table runInterval, tempRunInterval add
photocellStr
//2.36 - 2.37 Converted DB to 2.37 Doing ALTER TABLE encoder add repCriteria.
//2.35 - 2.36 Converted DB to 2.36 Inserted into preferences:
encoderRepetitionCriteriaGravitatory, encoderRepetitionCriteriaInertial
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index 76aa65aa4..ac6816d8f 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -54,7 +54,8 @@ class SqliteRunEncoder : Sqlite
"url TEXT, " + //URL of data files. stored as relative
"datetime TEXT, " + //2019-07-11_15-01-44
"comments TEXT, " +
- "videoURL TEXT)"; //URL of video of signals. stored as relative
+ "videoURL TEXT, " + //URL of video of signals. stored as relative
+ "angle INT)"; //capture can be or not at angleDefault
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
}
@@ -64,7 +65,7 @@ class SqliteRunEncoder : Sqlite
openIfNeeded(dbconOpened);
dbcmd.CommandText = "INSERT INTO " + table +
- " (uniqueID, personID, sessionID, exerciseID, device, distance, temperature,
filename, url, dateTime, comments, videoURL)" +
+ " (uniqueID, personID, sessionID, exerciseID, device, distance, temperature,
filename, url, dateTime, comments, videoURL, angle)" +
" VALUES " + insertString;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -173,7 +174,8 @@ class SqliteRunEncoder : Sqlite
reader[9].ToString(), //datetime
reader[10].ToString(), //comments
reader[11].ToString(), //videoURL
- reader[12].ToString() //exerciseName
+ Convert.ToInt32(reader[12].ToString()), //angle
+ reader[13].ToString() //exerciseName
);
list.Add(re);
}
@@ -320,7 +322,7 @@ class SqliteRunEncoder : Sqlite
myFilename,
Util.MakeURLrelative(Util.GetRunEncoderSessionDir(Convert.ToInt32(session.Name))),
parsedDate, relt.Comment,
- "", ""); //import without video and without name on comment
+ "", 0, ""); //import without video and without name on comment
runEncoder.InsertSQL(true);
importedSomething = true;
@@ -330,7 +332,7 @@ class SqliteRunEncoder : Sqlite
//need to create an exercise to assign to the imported files
if(importedSomething)
{
- RunEncoderExercise ex = new RunEncoderExercise(0, "Sprint", "",
RunEncoderExercise.SegmentCmDefault, new List<int>(), true);
+ RunEncoderExercise ex = new RunEncoderExercise(0, "Sprint", "",
RunEncoderExercise.SegmentCmDefault, new List<int>(), true, 0);
ex.InsertSQL(true);
}
@@ -362,7 +364,8 @@ class SqliteRunEncoderExercise : Sqlite
"description TEXT, " +
"segmentMeters INT, " + //changed to cm in DB 2.33
"segmentVariableCm TEXT, " + //separator is ;
- "isSprint INT NOT NULL DEFAULT 1)"; //bool
+ "isSprint INT NOT NULL DEFAULT 1, " + //bool
+ "angleDefault INT NOT NULL DEFAULT 0)"; //0 horiz, -90 vert go down, 90 vert go up.
Technically can be from -180 to 180
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
}
@@ -375,7 +378,7 @@ class SqliteRunEncoderExercise : Sqlite
Sqlite.Open();
dbcmd.CommandText = "INSERT INTO " + table +
- " (uniqueID, name, description, segmentMeters, segmentVariableCm, isSprint)" +
+ " (uniqueID, name, description, segmentMeters, segmentVariableCm, isSprint,
angleDefault)" +
" VALUES " + insertString;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -393,7 +396,7 @@ class SqliteRunEncoderExercise : Sqlite
//Default exercise for users without exercises (empty database creation or never used raceAnalyzer)
protected internal static void insertDefault ()
{
- RunEncoderExercise re = new RunEncoderExercise (-1, "Sprint", "",
RunEncoderExercise.SegmentCmDefault, new List<int>(), true);
+ RunEncoderExercise re = new RunEncoderExercise (-1, "Sprint", "",
RunEncoderExercise.SegmentCmDefault, new List<int>(), true, 0);
re.InsertSQL(true);
}
@@ -414,6 +417,7 @@ class SqliteRunEncoderExercise : Sqlite
"\", segmentMeters = " + ex.SegmentCm + //cm since DB 2.33
", segmentVariableCm = \"" + ex.SegmentVariableCmToSQL +
"\", isSprint = " + Util.BoolToInt(ex.IsSprint) +
+ ", angleDefault = " + ex.AngleDefault +
" WHERE uniqueID = " + ex.UniqueID;
LogB.SQL(dbcmd.CommandText.ToString());
@@ -463,7 +467,8 @@ class SqliteRunEncoderExercise : Sqlite
reader[2].ToString(), //description
Convert.ToInt32(reader[3].ToString()), //segmentCm (cm since DB 2.33)
Util.SQLStringToListInt(reader[4].ToString(), ";"),
//segmentVariableCm
- Util.IntToBool(Convert.ToInt32(reader[5].ToString()))
+ Util.IntToBool(Convert.ToInt32(reader[5].ToString())),
+ Convert.ToInt32(reader[6].ToString()) //angleDefault
);
list.Add(ex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]