[chronojump] All Encoder.Select differentiate gravitatory/inertial. (Need check code)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] All Encoder.Select differentiate gravitatory/inertial. (Need check code)
- Date: Thu, 26 May 2016 16:56:12 +0000 (UTC)
commit 20639996590705a56d15e239878ce5587d41b59c
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 26 18:52:13 2016 +0200
All Encoder.Select differentiate gravitatory/inertial. (Need check code)
src/constants.cs | 1 +
src/gui/chronojump.cs | 14 +++++++-
src/gui/encoder.cs | 56 +++++++++++++++++++++++------------
src/gui/encoderSelectRepetitions.cs | 22 +++++++------
src/gui/encoderTreeviews.cs | 4 +-
src/sqlite/encoder.cs | 27 ++++++++++++++--
src/sqlite/main.cs | 6 ++-
src/sqlite/personSession.cs | 8 ++--
src/sqlite/session.cs | 8 ++--
9 files changed, 99 insertions(+), 47 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index e7445c5..92ebc42 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -736,6 +736,7 @@ public class Constants
public static string EccentricConcentric = "Eccentric-concentric";
//public static string ConcentricEccentric = "Concentric-eccentric";
+ public enum EncoderGI {ALL, GRAVITATORY, INERTIAL}
public enum EncoderCheckFileOp { CAPTURE_EXPORT_ALL, ANALYZE_SAVE_IMAGE, ANALYZE_SAVE_AB,
ANALYZE_SAVE_TABLE}
public static double EncoderErrorCode = -1;
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 2f9792d..7045f69 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3045,14 +3045,18 @@ public partial class ChronoJumpWindow
}
notebook_sup.CurrentPage = 1;
+
+ bool changed = false;
if(m == menuitem_modes.POWERGRAVITATORY) {
menuitem_mode_selected_power_gravitatory.Visible = true;
//change encoderConfigurationCurrent if needed
if(encoderConfigurationCurrent.has_inertia) {
encoderConfigurationCurrent = new EncoderConfiguration(); //LINEAR,
not INERTIAL
- label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ changed = true;
}
+
+ currentEncoderGI = Constants.EncoderGI.GRAVITATORY;
} else {
menuitem_mode_selected_power_inertial.Visible = true;
@@ -3060,8 +3064,14 @@ public partial class ChronoJumpWindow
if(! encoderConfigurationCurrent.has_inertia) {
encoderConfigurationCurrent = new EncoderConfiguration(
Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL);
- label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ changed = true;
}
+
+ currentEncoderGI = Constants.EncoderGI.INERTIAL;
+ }
+ if(changed) {
+ label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ prepareAnalyzeRepetitions ();
}
} else { //m == menuitem_modes.OTHER (contacts / other)
notebook_sup.CurrentPage = 0;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 96aac15..2c49bc3 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -286,6 +286,7 @@ public partial class ChronoJumpWindow
EncoderConfigurationWindow encoder_configuration_win;
EncoderConfiguration encoderConfigurationCurrent;
+ Constants.EncoderGI currentEncoderGI; //store here to not have to check the GUI and have thread
problems
/*
* this contains last EncoderSQL captured, recalculated or loaded
@@ -1020,7 +1021,7 @@ public partial class ChronoJumpWindow
else
return; //error
- encSelReps.PassVariables(currentPerson, currentSession,
+ encSelReps.PassVariables(currentPerson, currentSession, currentEncoderGI,
genericWin, button_encoder_analyze,
getExerciseIDFromCombo(exerciseCombos.ANALYZE),
preferences.askDeletion);
@@ -1045,7 +1046,8 @@ public partial class ChronoJumpWindow
EncoderSQL eSQL = new EncoderSQL();
try {
- eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0, -1, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+ eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0,
Constants.EncoderGI.ALL,
+ -1, "", EncoderSQL.Eccons.ALL, false, true)[0];
} catch {
eSQLfound = false;
LogB.Warning("Catched! seems it's already deleted");
@@ -1073,12 +1075,22 @@ public partial class ChronoJumpWindow
//TODO: change encSelReps and this will change labels
updateUserCurvesLabelsAndCombo(dbconOpened);
}
+
+ private Constants.EncoderGI getEncoderGI() {
+ /*
+ if(radio_menuitem_mode_power_gravitatory.Active)
+ return = Constants.EncoderGI.GRAVITATORY;
+ else //if(radio_menuitem_mode_power_inertial.Active)
+ return = Constants.EncoderGI.INERTIAL;
+ */
+ return currentEncoderGI;
+ }
void on_button_encoder_load_signal_clicked (object o, EventArgs args)
{
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
- "signal", EncoderSQL.Eccons.ALL,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
+ -1, "signal", EncoderSQL.Eccons.ALL,
false, true);
ArrayList dataPrint = new ArrayList();
@@ -1155,8 +1167,8 @@ public partial class ChronoJumpWindow
genericWin.HideAndNull();
ArrayList data = SqliteEncoder.Select(
- false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID, -1,
- "signal", EncoderSQL.Eccons.ALL,
+ false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID,
Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL,
false, true);
bool success = false;
@@ -1216,7 +1228,8 @@ public partial class ChronoJumpWindow
LogB.Information("row edit apply at load signal");
int curveID = genericWin.TreeviewSelectedUniqueID;
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, -1, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0,
Constants.EncoderGI.ALL,
+ -1, "", EncoderSQL.Eccons.ALL, false, true)[0];
//if changed comment, update SQL, and update treeview
//first remove conflictive characters
@@ -1262,7 +1275,8 @@ public partial class ChronoJumpWindow
on_button_encoder_delete_signal_accepted (o, args);
else {
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
- false, signalID, 0, 0, -1, "signal", EncoderSQL.Eccons.ALL, false,
true)[0];
+ false, signalID, 0, 0, Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL, false, true)[0];
//delete signal and related curves (both from SQL and files)
encoderSignalDelete(eSQL.GetFullURL(false), signalID); //don't convertPathToR
@@ -1315,7 +1329,8 @@ public partial class ChronoJumpWindow
{
//select related curves to find URL
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
- false, esc.curveID, -1, -1, -1, "curve", EncoderSQL.Eccons.ALL,
false, true)[0];
+ false, esc.curveID, -1, -1, Constants.EncoderGI.ALL,
+ -1, "curve", EncoderSQL.Eccons.ALL, false, true)[0];
//delete file
Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
@@ -1579,7 +1594,8 @@ public partial class ChronoJumpWindow
void on_button_encoder_delete_signal_accepted (object o, EventArgs args)
{
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
- false, Convert.ToInt32(encoderSignalUniqueID), 0, 0, -1, "signal",
EncoderSQL.Eccons.ALL, false, true)[0];
+ false, Convert.ToInt32(encoderSignalUniqueID), 0, 0, Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL, false, true)[0];
//delete signal and related curves (both from SQL and files)
encoderSignalDelete(eSQL.GetFullURL(false), Convert.ToInt32(encoderSignalUniqueID));
@@ -1616,7 +1632,7 @@ public partial class ChronoJumpWindow
else if(radio_encoder_analyze_individual_current_session.Active)
{
ArrayList data = SqliteEncoder.Select(
- dbconOpened, -1, currentPerson.UniqueID, currentSession.UniqueID,
+ dbconOpened, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
getExerciseIDFromCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL,
false, true);
@@ -1856,8 +1872,8 @@ public partial class ChronoJumpWindow
if( ! radio_encoder_analyze_individual_current_set.Active)
{
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
- "curve", EncoderSQL.Eccons.ALL,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
+ -1, "curve", EncoderSQL.Eccons.ALL,
false, true);
if(data.Count == 0) {
@@ -2120,7 +2136,7 @@ public partial class ChronoJumpWindow
//onlyActive is false to have all the curves
//this is a need for "single" to select on display correct curve
data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID,
getEncoderGI(),
getExerciseIDFromCombo(exerciseCombos.ANALYZE),
"curve", ecconSelect,
false, true);
@@ -2131,7 +2147,8 @@ public partial class ChronoJumpWindow
ArrayList dataPre = SqliteEncoder.Select(
false, -1,
Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
- currentSession.UniqueID,
+ currentSession.UniqueID,
+ getEncoderGI(),
getExerciseIDFromCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL,
false, //onlyActive=false. Means: all saved
repetitions
@@ -2151,6 +2168,7 @@ public partial class ChronoJumpWindow
false, -1,
currentPerson.UniqueID,
Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()),
+ getEncoderGI(),
getExerciseIDFromCombo(exerciseCombos.ANALYZE),
"curve", EncoderSQL.Eccons.ALL,
false, //onlyActive=false. Means: all saved
repetitions
@@ -5226,14 +5244,14 @@ public partial class ChronoJumpWindow
bool deletedUserCurves = false;
EncoderSQL currentSignalSQL = (EncoderSQL) SqliteEncoder.Select(
- true, Convert.ToInt32(encoderSignalUniqueID), 0, 0,
-1,
- "", EncoderSQL.Eccons.ALL,
+ true, Convert.ToInt32(encoderSignalUniqueID), 0, 0,
getEncoderGI(),
+ -1, "", EncoderSQL.Eccons.ALL,
false, true)[0];
ArrayList data = SqliteEncoder.Select(
- true, -1, currentPerson.UniqueID,
currentSession.UniqueID, -1,
- "curve", EncoderSQL.Eccons.ALL,
+ true, -1, currentPerson.UniqueID,
currentSession.UniqueID, getEncoderGI(),
+ -1, "curve", EncoderSQL.Eccons.ALL,
false, true);
foreach(EncoderSQL eSQL in data)
{
diff --git a/src/gui/encoderSelectRepetitions.cs b/src/gui/encoderSelectRepetitions.cs
index e1f11c5..20f642c 100644
--- a/src/gui/encoderSelectRepetitions.cs
+++ b/src/gui/encoderSelectRepetitions.cs
@@ -36,6 +36,7 @@ public class EncoderSelectRepetitions
protected Person currentPerson;
protected Session currentSession;
+ protected Constants.EncoderGI encoderGI;
protected GenericWindow genericWin;
protected Gtk.Button button_encoder_analyze;
protected int exerciseID; //can be -1 (all)
@@ -76,7 +77,7 @@ public class EncoderSelectRepetitions
Type = Types.UNDEFINED;
}
- public void PassVariables(Person currentP, Session currentS,
+ public void PassVariables(Person currentP, Session currentS, Constants.EncoderGI eGI,
GenericWindow gw, Gtk.Button button_e_a, int exID, bool askDel)
{
RepsActive = 0;
@@ -85,6 +86,7 @@ public class EncoderSelectRepetitions
currentPerson = currentP;
currentSession = currentS;
+ encoderGI = eGI;
genericWin = gw;
button_encoder_analyze = button_e_a;
@@ -173,8 +175,8 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
protected override void getData()
{
data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, exerciseID,
- "curve", EncoderSQL.Eccons.ALL,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, encoderGI,
+ exerciseID, "curve", EncoderSQL.Eccons.ALL,
false, true);
}
@@ -294,8 +296,8 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
checkboxes = genericWin.GetColumn(1, false);
ArrayList data = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, exerciseID,
- "curve", EncoderSQL.Eccons.ALL,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID, encoderGI,
+ exerciseID, "curve", EncoderSQL.Eccons.ALL,
false, true);
//update on database the curves that have been selected/deselected
@@ -320,8 +322,8 @@ public class EncoderSelectRepetitionsIndividualCurrentSession : EncoderSelectRep
int curveID = genericWin.TreeviewSelectedUniqueID;
EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(
- false, curveID, 0, 0, -1,
- "", EncoderSQL.Eccons.ALL,
+ false, curveID, 0, 0, encoderGI,
+ -1, "", EncoderSQL.Eccons.ALL,
false, true)[0];
//if changed comment, update SQL, and update treeview
@@ -403,7 +405,7 @@ public class EncoderSelectRepetitionsIndividualAllSessions : EncoderSelectRepeti
protected override void getData()
{
- data = SqliteEncoder.SelectCompareIntersession(false, exerciseID, currentPerson.UniqueID);
+ data = SqliteEncoder.SelectCompareIntersession(false, encoderGI, exerciseID,
currentPerson.UniqueID);
}
protected override void createBigArray()
@@ -549,8 +551,8 @@ public class EncoderSelectRepetitionsGroupalCurrentSession : EncoderSelectRepeti
int j = 0; //list of added persons
foreach(Person p in dataPre) {
ArrayList eSQLarray = SqliteEncoder.Select(
- false, -1, p.UniqueID, currentSession.UniqueID, exerciseID,
- "curve", EncoderSQL.Eccons.ALL,
+ false, -1, p.UniqueID, currentSession.UniqueID, encoderGI,
+ exerciseID, "curve", EncoderSQL.Eccons.ALL,
false, true);
int activeCurves = UtilEncoder.GetActiveCurvesNum(eSQLarray);
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 70aac49..20a00cc 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -515,8 +515,8 @@ public partial class ChronoJumpWindow
} else { //not current set
//TODO:
curvesData = SqliteEncoder.Select(
- false, -1, currentPerson.UniqueID, currentSession.UniqueID, -1,
- "curve", EncoderSQL.Eccons.ALL,
+ false, -1, currentPerson.UniqueID, currentSession.UniqueID,
currentEncoderGI,
+ -1, "curve", EncoderSQL.Eccons.ALL,
true, true);
}
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index eefb2f0..49ed38e 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -205,8 +205,8 @@ class SqliteEncoder : Sqlite
//in that conversion, we want first the last ones, and later the previous
// (to delete them if they are old copies)
public static ArrayList Select (
- bool dbconOpened, int uniqueID, int personID, int sessionID, int exerciseID,
- string signalOrCurve, EncoderSQL.Eccons ecconSelect,
+ bool dbconOpened, int uniqueID, int personID, int sessionID, Constants.EncoderGI
encoderGI,
+ int exerciseID, string signalOrCurve, EncoderSQL.Eccons ecconSelect,
bool onlyActive, bool orderIDascendent)
{
if(! dbconOpened)
@@ -275,6 +275,12 @@ class SqliteEncoder : Sqlite
Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
econf.ReadParamsFromSQL(strFull);
+ //if encoderGI != ALL discard non wanted repetitions
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia)
+ continue;
+ else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia)
+ continue;
+
LogB.Debug("EncoderConfiguration = " +
econf.ToStringOutput(EncoderConfiguration.Outputs.SQL));
//if there's no video, will be "".
@@ -317,7 +323,7 @@ class SqliteEncoder : Sqlite
//exerciseID can be -1 to get all exercises
- public static ArrayList SelectCompareIntersession (bool dbconOpened, int exerciseID, int personID)
+ public static ArrayList SelectCompareIntersession (bool dbconOpened, Constants.EncoderGI encoderGI,
int exerciseID, int personID)
{
if(! dbconOpened)
Sqlite.Open();
@@ -330,7 +336,8 @@ class SqliteEncoder : Sqlite
dbcmd.CommandText =
"SELECT encoder.sessionID, session.name, session.date, encoder.extraWeight, " +
" SUM(CASE WHEN encoder.status = \"active\" THEN 1 END) as active, " +
- " SUM(CASE WHEN encoder.status = \"inactive\" THEN 1 END) as inactive " +
+ " SUM(CASE WHEN encoder.status = \"inactive\" THEN 1 END) as inactive," +
+ " encoder.encoderConfiguration " +
" FROM encoder, session, person77 " +
" WHERE " +
exerciseIDStr +
@@ -373,6 +380,18 @@ class SqliteEncoder : Sqlite
int inactiveThisSession = 0;
while(reader.Read()) {
+ //discard if != encoderGI
+ string [] strFull = reader[6].ToString().Split(new char[] {':'});
+ EncoderConfiguration econf = new EncoderConfiguration(
+ (Constants.EncoderConfigurationNames)
+ Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
+
+ //if encoderGI != ALL discard non wanted repetitions
+ if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia)
+ continue;
+ else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia)
+ continue;
+
//1 get sessionID of this row
sessIDThisRow = Convert.ToInt32(reader[0].ToString());
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 70a3451..4adcfec 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1532,8 +1532,10 @@ class Sqlite
SqliteEncoder.createTableEncoderSignalCurve();
- ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1, -1, "signal",
EncoderSQL.Eccons.ALL, false, false);
- ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1, -1, "curve",
EncoderSQL.Eccons.ALL, false, false);
+ ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1,
Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL, false, false);
+ ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1,
Constants.EncoderGI.ALL,
+ -1, "curve", EncoderSQL.Eccons.ALL, false, false);
int signalID;
conversionRateTotal = signals.Count;
conversionRate = 1;
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index d8b5be3..e4207c2 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -384,8 +384,8 @@ class SqlitePersonSession : Sqlite
//delete encoder signal and curves (and it's videos)
ArrayList encoderArray = SqliteEncoder.Select(
- true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID), -1,
- "signal", EncoderSQL.Eccons.ALL,
+ true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID),
Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL,
false, true);
foreach(EncoderSQL eSQL in encoderArray) {
@@ -396,8 +396,8 @@ class SqlitePersonSession : Sqlite
}
encoderArray = SqliteEncoder.Select(
- true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID), -1,
- "curve", EncoderSQL.Eccons.ALL,
+ true, -1, Convert.ToInt32(personID), Convert.ToInt32(sessionID),
Constants.EncoderGI.ALL,
+ -1, "curve", EncoderSQL.Eccons.ALL,
false, true);
foreach(EncoderSQL eSQL in encoderArray) {
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 1a08fd7..b43307b 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -658,8 +658,8 @@ class SqliteSession : Sqlite
//signals
ArrayList encoderArray = SqliteEncoder.Select(
- true, -1, -1, Convert.ToInt32(uniqueID), -1,
- "signal", EncoderSQL.Eccons.ALL,
+ true, -1, -1, Convert.ToInt32(uniqueID), Constants.EncoderGI.ALL,
+ -1, "signal", EncoderSQL.Eccons.ALL,
false, true);
foreach(EncoderSQL eSQL in encoderArray) {
@@ -671,8 +671,8 @@ class SqliteSession : Sqlite
//curves
encoderArray = SqliteEncoder.Select(
- true, -1, -1, Convert.ToInt32(uniqueID), -1,
- "curve", EncoderSQL.Eccons.ALL,
+ true, -1, -1, Convert.ToInt32(uniqueID), Constants.EncoderGI.ALL,
+ -1, "curve", EncoderSQL.Eccons.ALL,
false, true);
foreach(EncoderSQL eSQL in encoderArray) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]