[chronojump] ForceSensor export csv AB without passing label values



commit a32a2bef9cee0c570d5f274d295c4b017132f769
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Nov 25 15:50:56 2019 +0100

    ForceSensor export csv AB without passing label values

 src/forceSensor.cs            | 42 +++++++++++++++++++++++++++---------------
 src/gui/forceSensorAnalyze.cs | 16 +---------------
 2 files changed, 28 insertions(+), 30 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index c2f4c1a9..bfc5ab12 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -1627,13 +1627,25 @@ public class ForceSensorAnalyzeInstant
                lineYEnd = 0;
        }
 
-       //TODO: better if all this time, force, rfd params are on this class, so don't need to read labels 
from main gui
-       public void ExportToCSV(int countA, int countB, string selectedFileName, string sepString,
-                       double timeA, double timeB, double timeDiff,
-                       double forceA, double forceB, double forceDiff, double forceAvg, double forceMax,
-                       double rfdA, double rfdB, double rfdDiff, double rfdAvg, double rfdMax
-                       )
-       {
+       public void ExportToCSV(int countA, int countB, string selectedFileName, string sepString)
+       {
+               //get variables
+               double timeA = GetTimeMS(countA);
+               double timeB = GetTimeMS(countB);
+               double forceA = GetForceAtCount(countA);
+               double forceB = GetForceAtCount(countB);
+               double timeDiff = timeB - timeA;
+               double forceDiff =forceB - forceA;
+               double forceAvg = ForceAVG;
+               double forceMax = ForceMAX;
+               double rfdA = CalculateRFD(countA -1, countA +1);
+               double rfdB = CalculateRFD(countB -1, countB +1);
+               double rfdDiff = rfdB - rfdA;
+               double rfdAvg = CalculateRFD(countA, countB);
+               CalculateMaxRFDInRange(countA, countB);
+               double rfdMax = LastRFDMax;
+
+
                //this overwrites if needed
                TextWriter writer = File.CreateText(selectedFileName);
 
@@ -1655,21 +1667,21 @@ public class ForceSensorAnalyzeInstant
                //write statistics
                writer.WriteLine(
                                Catalog.GetString("Difference") + sep +
-                               Util.DoubleToCSV(timeDiff, sepString) + sep +
-                               Util.DoubleToCSV(forceDiff, sepString) + sep +
-                               Util.DoubleToCSV(rfdDiff, sepString) );
+                               Util.DoubleToCSV(Math.Round(timeDiff, 2), sepString) + sep +
+                               Util.DoubleToCSV(Math.Round(forceDiff, 2), sepString) + sep +
+                               Util.DoubleToCSV(Math.Round(rfdDiff, 2), sepString) );
 
                writer.WriteLine(
                                Catalog.GetString("Average") + sep +
                                "" + sep +
-                               Util.DoubleToCSV(forceAvg, sepString) + sep +
-                               Util.DoubleToCSV(rfdAvg, sepString) );
+                               Util.DoubleToCSV(Math.Round(forceAvg, 2), sepString) + sep +
+                               Util.DoubleToCSV(Math.Round(rfdAvg, 2), sepString) );
 
                writer.WriteLine(
                                Catalog.GetString("Maximum") + sep +
                                "" + sep +
-                               Util.DoubleToCSV(forceMax, sepString) + sep +
-                               Util.DoubleToCSV(rfdMax, sepString) );
+                               Util.DoubleToCSV(Math.Round(forceMax, 2), sepString) + sep +
+                               Util.DoubleToCSV(Math.Round(rfdMax, 2), sepString) );
 
                //blank line
                writer.WriteLine();
@@ -1683,7 +1695,7 @@ public class ForceSensorAnalyzeInstant
                                        (i+1).ToString() + sep +
                                        Util.DoubleToCSV(fscAIPoints.GetTimeAtCount(i), sepString) + sep +
                                        Util.DoubleToCSV(fscAIPoints.GetForceAtCount(i), sepString) + sep +
-                                       Util.DoubleToCSV(CalculateRFD(i-1, i+1), sepString) );
+                                       Util.DoubleToCSV(Math.Round(CalculateRFD(i-1, i+1), 2), sepString) );
 
                writer.Flush();
                writer.Close();
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index e6393106..98b45792 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -1457,21 +1457,7 @@ public partial class ChronoJumpWindow
        void on_button_force_sensor_save_AB_file_selected (string selectedFileName)
        {
                fsAI.ExportToCSV(getLowestForceSensorABScale(), getHighestForceSensorABScale(),
-                               selectedFileName, preferences.CSVExportDecimalSeparator,
-                               Convert.ToDouble(label_force_sensor_ai_time_a.Text),
-                               Convert.ToDouble(label_force_sensor_ai_time_b.Text),
-                               Convert.ToDouble(label_force_sensor_ai_time_diff.Text),
-                               Convert.ToDouble(label_force_sensor_ai_force_a.Text),
-                               Convert.ToDouble(label_force_sensor_ai_force_b.Text),
-                               Convert.ToDouble(label_force_sensor_ai_force_diff.Text),
-                               Convert.ToDouble(label_force_sensor_ai_force_average.Text),
-                               Convert.ToDouble(label_force_sensor_ai_force_max.Text),
-                               Convert.ToDouble(label_force_sensor_ai_rfd_a.Text),
-                               Convert.ToDouble(label_force_sensor_ai_rfd_b.Text),
-                               Convert.ToDouble(label_force_sensor_ai_rfd_diff.Text),
-                               Convert.ToDouble(label_force_sensor_ai_rfd_average.Text),
-                               Convert.ToDouble(label_force_sensor_ai_rfd_max.Text)
-                               );
+                               selectedFileName, preferences.CSVExportDecimalSeparator);
        }
 
        private int getLowestForceSensorABScale()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]