[chronojump] encoderConfiguration gets stored on database
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoderConfiguration gets stored on database
- Date: Wed, 27 May 2015 07:25:09 +0000 (UTC)
commit 0a0119b9c6f9e212fa7835214ce02b628812a02a
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed May 27 09:23:23 2015 +0200
encoderConfiguration gets stored on database
src/encoder.cs | 9 ++++++++-
src/gui/encoder.cs | 37 +++++++++++++++++++++++--------------
src/sqlite/encoder.cs | 28 +++++++++++++++++++++++++++-
src/sqlite/main.cs | 13 ++++++++++++-
src/sqlite/preferences.cs | 3 +++
5 files changed, 73 insertions(+), 17 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index 0e79dc5..0f301e9 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -1229,7 +1229,8 @@ public class EncoderConfiguration {
}
}
- public void FromSQL (string [] strFull) {
+ public void ReadParamsFromSQL (string [] strFull)
+ {
//adds other params
this.d = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]));
this.D = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[2]));
@@ -1252,6 +1253,12 @@ public class EncoderConfiguration {
}
}
+ //called on capture, recalculate, load
+ public void SQLUpdate()
+ {
+ SqlitePreferences.Update("encoderConfiguration", this.ToStringOutput(Outputs.SQL), false);
+ }
+
public enum Outputs { ROPTIONS, RCSV, SQL}
public string ToStringOutput(Outputs o)
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index fbdd7af..fcd0e26 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -310,9 +310,9 @@ public partial class ChronoJumpWindow
encoder_pulsebar_analyze.Fraction = 1;
encoder_pulsebar_analyze.Text = "";
- //default values
- encoderConfigurationCurrent = new EncoderConfiguration();
- label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ //read from SQL
+ encoderConfigurationCurrent = SqliteEncoder.LoadEncoderConfiguration();
+ encoderConfigurationGUIUpdate();
encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
@@ -451,6 +451,8 @@ public partial class ChronoJumpWindow
LogB.Debug("Calling encoderThreadStart for capture");
+ encoderConfigurationCurrent.SQLUpdate(); //record this encoderConfiguration to SQL for next
Chronojump open
+
needToCallPrepareEncoderGraphs = false;
encoderProcessFinish = false;
encoderThreadStart(encoderActions.CAPTURE);
@@ -656,6 +658,7 @@ public partial class ChronoJumpWindow
}
void on_button_encoder_recalculate_clicked (object o, EventArgs args) {
+ encoderConfigurationCurrent.SQLUpdate(); //record this encoderConfiguration to SQL for next
Chronojump open
encoderCalculeCurves(encoderActions.CURVES);
}
@@ -1351,18 +1354,8 @@ public partial class ChronoJumpWindow
radiobutton_video_encoder_play.Active = true;
encoderConfigurationCurrent = eSQL.encoderConfiguration;
-
- if(encoderConfigurationCurrent.has_inertia) {
- notebook_encoder_capture_extra_mass.CurrentPage = 1;
-
- spin_encoder_im_weights_n.Value =
encoderConfigurationCurrent.extraWeightN;
- label_encoder_im_total.Text =
encoderConfigurationCurrent.inertiaTotal.ToString();
- }
- else
- notebook_encoder_capture_extra_mass.CurrentPage = 0;
-
- label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ encoderConfigurationGUIUpdate();
}
}
@@ -1373,6 +1366,8 @@ public partial class ChronoJumpWindow
//LogB.Information(UtilEncoder.CompressSignal(UtilEncoder.GetEncoderDataTempFileName()));
if(success) {
+ encoderConfigurationCurrent.SQLUpdate(); //record this encoderConfiguration to SQL
for next Chronojump open
+
//force a recalculate but not save the curve (we are loading)
encoderCalculeCurves(encoderActions.LOAD);
@@ -1448,6 +1443,20 @@ public partial class ChronoJumpWindow
}
genericWin.Delete_row_accepted();
}
+
+ void encoderConfigurationGUIUpdate()
+ {
+ if(encoderConfigurationCurrent.has_inertia) {
+ notebook_encoder_capture_extra_mass.CurrentPage = 1;
+
+ spin_encoder_im_weights_n.Value = encoderConfigurationCurrent.extraWeightN;
+ label_encoder_im_total.Text = encoderConfigurationCurrent.inertiaTotal.ToString();
+ }
+ else
+ notebook_encoder_capture_extra_mass.CurrentPage = 0;
+
+ label_encoder_selected.Text = encoderConfigurationCurrent.code;
+ }
void encoderSignalDelete (string signalURL, int signalID)
{
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 6c39b0a..81c53a9 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -269,7 +269,7 @@ class SqliteEncoder : Sqlite
EncoderConfiguration econf = new EncoderConfiguration(
(Constants.EncoderConfigurationNames)
Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
- econf.FromSQL(strFull);
+ econf.ReadParamsFromSQL(strFull);
//if there's no video, will be "".
//if there's video, will be with full path
@@ -884,4 +884,30 @@ class SqliteEncoder : Sqlite
return -1;
}
+ /*
+ * EncoderConfiguration
+ */
+
+ //called on startup to load last encoderConfiguration
+ public static EncoderConfiguration LoadEncoderConfiguration()
+ {
+ string ecStr = SqlitePreferences.Select("encoderConfiguration", false);
+
+ //1.5.1 and previous don't store encoderConfiguration on SqlitePreferences
+ if(ecStr == null || ecStr.Length == 0 || ecStr == "0" || ecStr == "")
+ return new EncoderConfiguration();
+
+ string [] ecStrFull = ecStr.Split(new char[] {':'});
+
+ //create object
+ EncoderConfiguration ec = new EncoderConfiguration(
+ (Constants.EncoderConfigurationNames)
+ Enum.Parse(typeof(Constants.EncoderConfigurationNames), ecStrFull[0]) );
+
+ //assign the rest of params
+ ec.ReadParamsFromSQL(ecStrFull);
+
+ return ec;
+ }
+
}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 3b416ae..c9af628 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -73,7 +73,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.22";
+ static string lastChronojumpDatabaseVersion = "1.23";
public Sqlite() {
}
@@ -1783,6 +1783,16 @@ class Sqlite
currentVersion = "1.22";
}
+ if(currentVersion == "1.22") {
+ LogB.SQL("Added encoder configuration");
+
+ Sqlite.Open();
+ SqlitePreferences.Insert ("encoderConfiguration", new
EncoderConfiguration().ToStringOutput(EncoderConfiguration.Outputs.SQL));
+ SqlitePreferences.Update ("databaseVersion", "1.23", true);
+ Sqlite.Close();
+
+ currentVersion = "1.23";
+ }
}
@@ -1927,6 +1937,7 @@ class Sqlite
SqliteExecuteAuto.addChronojumpProfileAndBilateral();
//changes [from - to - desc]
+ //1.22 - 1.23 Converted DB to 1.23 Added encoder configuration
//1.21 - 1.22 Converted DB to 1.22 Encoder laterality in english again
//1.20 - 1.21 Converted DB to 1.21 Fixing loosing of encoder videoURL after recalculate
//1.19 - 1.20 Converted DB to 1.20 Preferences: added user email
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index e00bafe..f29285d 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -88,6 +88,9 @@ class SqlitePreferences : Sqlite
Insert ("useHeightsOnJumpIndexes", "True", dbcmdTr);
Insert ("encoderAutoSaveCurve",
Constants.EncoderAutoSaveCurve.BESTMEANPOWER.ToString(), dbcmdTr);
Insert ("email", "", dbcmdTr);
+
+ //last encoderConfiguration, to be used on next session
+ Insert ("encoderConfiguration", new
EncoderConfiguration().ToStringOutput(EncoderConfiguration.Outputs.SQL), dbcmdTr);
}
tr.Commit();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]