[chronojump] Encoder analyze single instant DONE. Finished exporting to CSV
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder analyze single instant DONE. Finished exporting to CSV
- Date: Sat, 6 Feb 2016 14:57:50 +0000 (UTC)
commit 4253717c52dded048e558fbc2246de0417792688
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Feb 6 15:56:39 2016 +0100
Encoder analyze single instant DONE. Finished exporting to CSV
glade/chronojump.glade | 134 +++++++++++++++++++++++++++++++++++++++++++-----
src/constants.cs | 2 +-
src/encoder.cs | 84 ++++++++++++++++++++++++++++++
src/gui/encoder.cs | 52 +++++++++++++++++--
src/util.cs | 11 ++++-
5 files changed, 262 insertions(+), 21 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 5b9afcf..4dcb17e 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7958,6 +7958,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -9450,6 +9453,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -10583,6 +10589,9 @@ after time</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -17308,18 +17317,18 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton"
id="radiobutton_encoder_analyze_side">
+ <widget class="GtkRadioButton"
id="radiobutton_encoder_analyze_single">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property
name="receives_default">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip" translatable="yes">Side
compare</property>
+ <property name="tooltip"
translatable="yes">Single repetition</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property
name="group">radiobutton_encoder_analyze_powerbars</property>
- <signal name="toggled"
handler="on_radiobutton_encoder_analyze_side_toggled" swapped="no"/>
+ <signal name="toggled"
handler="on_radiobutton_encoder_analyze_single_toggled" swapped="no"/>
<child>
- <widget class="GtkImage"
id="image_encoder_analyze_side">
+ <widget class="GtkImage"
id="image_encoder_analyze_single">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="stock">gtk-missing-image</property>
@@ -17334,18 +17343,18 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <widget class="GtkRadioButton"
id="radiobutton_encoder_analyze_single">
+ <widget class="GtkRadioButton"
id="radiobutton_encoder_analyze_side">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property
name="receives_default">False</property>
<property name="has_tooltip">True</property>
- <property name="tooltip"
translatable="yes">Single repetition</property>
+ <property name="tooltip" translatable="yes">Side
compare</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property
name="group">radiobutton_encoder_analyze_powerbars</property>
- <signal name="toggled"
handler="on_radiobutton_encoder_analyze_single_toggled" swapped="no"/>
+ <signal name="toggled"
handler="on_radiobutton_encoder_analyze_side_toggled" swapped="no"/>
<child>
- <widget class="GtkImage"
id="image_encoder_analyze_single">
+ <widget class="GtkImage"
id="image_encoder_analyze_side">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="stock">gtk-missing-image</property>
@@ -18730,9 +18739,6 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel"
id="label_encoder_analyze_max">
<property name="can_focus">False</property>
<property name="xalign">1</property>
@@ -18760,6 +18766,9 @@ on current Chronojump version.</property>
<property name="y_options"/>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -18848,6 +18857,52 @@ on current Chronojump version.</property>
</packing>
</child>
<child>
+ <widget class="GtkButton"
id="button_encoder_analyze_AB_save">
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip"
translatable="yes">Export repetition from A to B</property>
+ <signal name="clicked"
handler="on_button_encoder_analyze_AB_save_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkVBox" id="vbox68">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkLabel" id="label82">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">AB</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkImage"
id="image_encoder_analyze_image_save_2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-save</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkButton"
id="button_encoder_analyze_1RM_save">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -23255,6 +23310,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -24287,6 +24345,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25811,6 +25872,9 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -26392,6 +26456,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -38486,6 +38553,24 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -40577,6 +40662,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -41845,9 +41942,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -42879,6 +42973,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -46683,6 +46780,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -47379,6 +47479,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -48090,6 +48193,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/constants.cs b/src/constants.cs
index 6882f08..46cf3cc 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -733,7 +733,7 @@ public class Constants
public static string EccentricConcentric = "Eccentric-concentric";
//public static string ConcentricEccentric = "Concentric-eccentric";
- public enum EncoderCheckFileOp { CAPTURE_EXPORT_ALL, ANALYZE_SAVE_IMAGE, ANALYZE_SAVE_TABLE}
+ public enum EncoderCheckFileOp { CAPTURE_EXPORT_ALL, ANALYZE_SAVE_IMAGE, ANALYZE_SAVE_AB,
ANALYZE_SAVE_TABLE}
public static double EncoderErrorCode = -1;
diff --git a/src/encoder.cs b/src/encoder.cs
index 40c4cb0..0699191 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -1599,7 +1599,91 @@ public class EncoderAnalyzeInstant
return Convert.ToInt32(px);
}
+
+ public void ExportToCSV(int msa, int msb, string selectedFileName, string sepString)
+ {
+ //if msb < msa invert them
+ if(msb < msa) {
+ int temp = msa;
+ msa = msb;
+ msb = temp;
+ }
+
+ //this overwrites if needed
+ TextWriter writer = File.CreateText(selectedFileName);
+
+ string sep = " ";
+ if (sepString == "COMMA")
+ sep = ";";
+ else
+ sep = ",";
+
+ string header =
+ "" + sep +
+ Catalog.GetString("Time") + sep +
+ Catalog.GetString("Displacement") + sep +
+ Catalog.GetString("Speed") + sep +
+ Catalog.GetString("Acceleration") + sep +
+ Catalog.GetString("Force") + sep +
+ Catalog.GetString("Power");
+
+ //write header
+ writer.WriteLine(header);
+
+ //write statistics
+ writer.WriteLine(
+ Catalog.GetString("Difference") + sep +
+ (msb-msa).ToString() + sep +
+ Util.DoubleToCSV( (GetParam("displ",msb) - GetParam("displ",msa)), sepString
) + sep +
+ Util.DoubleToCSV( (GetParam("speed",msb) - GetParam("speed",msa)), sepString
) + sep +
+ Util.DoubleToCSV( (GetParam("accel",msb) - GetParam("accel",msa)), sepString
) + sep +
+ Util.DoubleToCSV( (GetParam("force",msb) - GetParam("force",msa)), sepString
) + sep +
+ Util.DoubleToCSV( (GetParam("power",msb) - GetParam("power",msa)), sepString
) );
+
+ //done here because GetParam does the same again, and if we put it in the top of this method,
it will be done two times
+ msa --; //converts from starting at 1 (graph) to starting at 0 (data)
+ msb --; //converts from starting at 1 (graph) to starting at 0 (data)
+
+ writer.WriteLine(
+ Catalog.GetString("Average") + sep +
+ "" + sep +
+ Util.DoubleToCSV(displAverageLast, sepString) + sep +
+ Util.DoubleToCSV(speedAverageLast, sepString) + sep +
+ Util.DoubleToCSV(accelAverageLast, sepString) + sep +
+ Util.DoubleToCSV(forceAverageLast, sepString) + sep +
+ Util.DoubleToCSV(powerAverageLast, sepString) );
+ writer.WriteLine(
+ Catalog.GetString("Maximum") + sep +
+ "" + sep +
+ Util.DoubleToCSV(displMaxLast, sepString) + sep +
+ Util.DoubleToCSV(speedMaxLast, sepString) + sep +
+ Util.DoubleToCSV(accelMaxLast, sepString) + sep +
+ Util.DoubleToCSV(forceMaxLast, sepString) + sep +
+ Util.DoubleToCSV(powerMaxLast, sepString) );
+
+ //blank line
+ writer.WriteLine();
+
+ //write header
+ writer.WriteLine(header);
+
+ //write data
+ for(int i = msa; i <= msb; i ++)
+ writer.WriteLine(
+ "" + sep +
+ (i+1).ToString() + sep +
+ Util.DoubleToCSV(displ[i], sepString) + sep +
+ Util.DoubleToCSV(speed[i], sepString) + sep +
+ Util.DoubleToCSV(accel[i], sepString) + sep +
+ Util.DoubleToCSV(force[i], sepString) + sep +
+ Util.DoubleToCSV(power[i], sepString) );
+
+ writer.Flush();
+ writer.Close();
+ ((IDisposable)writer).Dispose();
+ }
+
public void PrintDebug() {
LogB.Information("Printing speed");
foreach(double s in speed)
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 97bfe94..46a468c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -171,6 +171,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Label label_encoder_analyze_diff;
[Widget] Gtk.Label label_encoder_analyze_average;
[Widget] Gtk.Label label_encoder_analyze_max;
+ [Widget] Gtk.Button button_encoder_analyze_AB_save;
[Widget] Gtk.Button button_encoder_analyze_image_save;
[Widget] Gtk.Button button_encoder_analyze_table_save;
@@ -1737,23 +1738,35 @@ public partial class ChronoJumpWindow
//encoder_pulsebar_capture.Text = string.Format(Catalog.GetString(
// "Exported to {0}."), UtilEncoder.GetEncoderExportTempFileName());
}
+
+ void on_button_encoder_save_AB_file_selected (string selectedFileName)
+ {
+ int msa = Convert.ToInt32(hscale_encoder_analyze_a.Value);
+ int msb = Convert.ToInt32(hscale_encoder_analyze_b.Value);
+
+ eai.ExportToCSV(msa, msb, selectedFileName, preferences.CSVExportDecimalSeparator);
+ }
string exportFileName;
protected void checkFile (Constants.EncoderCheckFileOp checkFileOp)
{
string exportString = "";
if(checkFileOp == Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL)
- exportString = Catalog.GetString ("Export set in format CSV");
+ exportString = Catalog.GetString ("Export set in CSV format");
else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
exportString = Catalog.GetString ("Save image");
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB)
+ exportString = Catalog.GetString ("Export repetition in CSV format");
else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_TABLE)
exportString = Catalog.GetString ("Save table");
string nameString = "";
if(checkFileOp == Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL)
- nameString = "encoder_export.csv";
+ nameString = "encoder_set_export.csv";
else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
nameString = "encoder_image.png";
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB)
+ nameString = "encoder_repetition_export.csv";
else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_TABLE)
nameString = "encoder_curves_table.csv";
@@ -1762,7 +1775,7 @@ public partial class ChronoJumpWindow
app1,
FileChooserAction.Save,
Catalog.GetString("Cancel"),ResponseType.Cancel,
- Catalog.GetString("Export"),ResponseType.Accept
+ Catalog.GetString("Accept"),ResponseType.Accept
);
fc.CurrentName = nameString;
@@ -1771,6 +1784,7 @@ public partial class ChronoJumpWindow
exportFileName = fc.Filename;
//add ".csv" if needed
if(checkFileOp == Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL ||
+ checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB ||
checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_TABLE)
exportFileName = Util.AddCsvIfNeeded(exportFileName);
else
@@ -1793,6 +1807,9 @@ public partial class ChronoJumpWindow
else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
confirmWin.Button_accept.Clicked +=
new
EventHandler(on_overwrite_file_encoder_save_image_accepted);
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB)
+ confirmWin.Button_accept.Clicked +=
+ new
EventHandler(on_overwrite_file_encoder_save_AB_accepted);
else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_TABLE)
confirmWin.Button_accept.Clicked +=
new
EventHandler(on_overwrite_file_encoder_save_table_accepted);
@@ -1802,13 +1819,16 @@ public partial class ChronoJumpWindow
on_button_encoder_export_all_curves_file_selected
(exportFileName);
else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_IMAGE)
on_button_encoder_save_image_file_selected (exportFileName);
+ else if(checkFileOp == Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB)
+ on_button_encoder_save_AB_file_selected (exportFileName);
else if(checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_TABLE)
on_button_encoder_save_table_file_selected (exportFileName);
string myString = string.Format(Catalog.GetString("Saved to {0}"),
exportFileName);
- if(checkFileOp == Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL)
- myString += Constants.SpreadsheetString;
+ if(checkFileOp == Constants.EncoderCheckFileOp.CAPTURE_EXPORT_ALL ||
+ checkFileOp ==
Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB)
+ myString += Constants.SpreadsheetString;
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
} catch {
@@ -1845,6 +1865,14 @@ public partial class ChronoJumpWindow
string myString = string.Format(Catalog.GetString("Saved to {0}"), exportFileName);
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
+ private void on_overwrite_file_encoder_save_AB_accepted(object o, EventArgs args)
+ {
+ on_button_encoder_save_AB_file_selected (exportFileName);
+
+ string myString = string.Format(Catalog.GetString("Saved to {0}"),
+ exportFileName) + Constants.SpreadsheetString;
+ new DialogMessage(Constants.MessageTypes.INFO, myString);
+ }
private void on_overwrite_file_encoder_save_table_accepted(object o, EventArgs args)
{
on_button_encoder_save_table_file_selected (exportFileName);
@@ -4126,6 +4154,7 @@ public partial class ChronoJumpWindow
image_encoder_analyze.Sensitive = false;
treeview_encoder_analyze_curves.Sensitive = false;
button_encoder_analyze_image_save.Sensitive = false;
+ button_encoder_analyze_AB_save.Sensitive = false;
button_encoder_analyze_table_save.Sensitive = false;
button_encoder_analyze_1RM_save.Visible = false;
@@ -4934,6 +4963,7 @@ public partial class ChronoJumpWindow
encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
treeview_encoder_analyze_curves.Sensitive = false;
button_encoder_analyze_image_save.Sensitive = false;
+ button_encoder_analyze_AB_save.Sensitive = false;
button_encoder_analyze_table_save.Sensitive = false;
button_encoder_analyze_1RM_save.Visible = false;
@@ -5498,9 +5528,15 @@ public partial class ChronoJumpWindow
label_encoder_analyze_diff.Visible = visible;
label_encoder_analyze_average.Visible = visible;
label_encoder_analyze_max.Visible = visible;
+ button_encoder_analyze_AB_save.Visible = visible;
drawingarea_encoder_analyze_instant.QueueDraw(); //will fire ExposeEvent
}
+
+ void on_button_encoder_analyze_AB_save_clicked (object o, EventArgs args)
+ {
+ checkFile(Constants.EncoderCheckFileOp.ANALYZE_SAVE_AB);
+ }
public void on_drawingarea_encoder_analyze_instant_expose_event(object o, ExposeEventArgs args)
{
@@ -5777,6 +5813,7 @@ public partial class ChronoJumpWindow
image_encoder_analyze.Sensitive = false;
treeview_encoder_analyze_curves.Sensitive = false;
button_encoder_analyze_image_save.Sensitive = false;
+ button_encoder_analyze_AB_save.Sensitive = false;
button_encoder_analyze_table_save.Sensitive = false;
button_encoder_analyze_1RM_save.Visible = false;
@@ -5796,6 +5833,8 @@ public partial class ChronoJumpWindow
drawingarea_encoder_analyze_instant.QueueDraw(); //will fire
ExposeEvent
+ button_encoder_analyze_AB_save.Visible =
checkbutton_encoder_analyze_b.Active;
+
notebook_encoder_analyze.CurrentPage = 1;
} else {
//maybe image is still not readable
@@ -5803,6 +5842,8 @@ public partial class ChronoJumpWindow
UtilEncoder.GetEncoderGraphTempFileName(),
image_encoder_analyze);
+ button_encoder_analyze_AB_save.Visible = false;
+
notebook_encoder_analyze.CurrentPage = 0;
}
@@ -5841,6 +5882,7 @@ public partial class ChronoJumpWindow
treeview_encoder_analyze_curves.Sensitive = true;
button_encoder_analyze_image_save.Sensitive = true;
+ button_encoder_analyze_AB_save.Sensitive = true;
button_encoder_analyze_table_save.Sensitive = true;
string my1RMName =
Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM),
diff --git a/src/util.cs b/src/util.cs
index dbf99e2..1832a6d 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -52,6 +52,15 @@ public class Util
myStringBuilder.Replace(".", ",");
return myStringBuilder.ToString();
}
+
+ public static string DoubleToCSV(double d, string CSVsepString) {
+ string s = d.ToString();
+ if(CSVsepString == "COMMA")
+ return ConvertToComma(s);
+ else
+ return ConvertToPoint(s);
+ }
+
//when we do a query to the server, it returns avg as "0,54" because it's latin localized
@@ -939,7 +948,7 @@ public class Util
/********** start of encoder paths ************/
public static string GetEncoderExportTempFileName() {
- return Path.Combine(Path.GetTempPath(), "encoder_export.csv");
+ return Path.Combine(Path.GetTempPath(), "encoder_set_export.csv");
}
/********** end of encoder paths ************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]