[chronojump] ForceSensorExport refactorized



commit 218fb8bbb50d6ff6fa1b6a87c317ea142e51dc7d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Mar 8 18:16:03 2021 +0100

    ForceSensorExport refactorized

 po/POTFILES.in                    |   2 +
 r-scripts/maximumIsometricForce.R |  12 +-
 src/Makefile.am                   |   2 +
 src/exportFiles/exportFiles.cs    | 152 ++++++++++
 src/exportFiles/fs.cs             | 483 ++++++++++++++++++++++++++++++
 src/forceSensor.cs                | 614 --------------------------------------
 src/util.cs                       |  10 -
 src/utilEncoder.cs                |   2 +-
 8 files changed, 646 insertions(+), 631 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 79a01e37..79d4537f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -54,6 +54,8 @@ src/executeProcess.cs
 src/execute/pulse.cs
 src/execute/reactionTime.cs
 src/execute/run.cs
+src/exportFiles/exportFiles.cs
+src/exportFiles/fs.cs
 src/exportSession.cs
 src/forceSensor.cs
 src/gui/app1/chronojump.cs
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index bc4a5d1f..2446a615 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -1194,9 +1194,9 @@ start <- function(op)
                dataFiles = read.csv(file = paste(tempPath, "/maximumIsometricForceInputMulti.csv", sep=""), 
sep=";", stringsAsFactors=F)
 
                #3) call doProcess
-               progressFolder = paste(tempPath, "/chronojump_mif_progress", sep ="")
-               tempGraphsFolder = paste(tempPath, "/chronojump_mif_graphs_rfd/", sep ="")
-               tempGraphsABFolder = paste(tempPath, "/chronojump_mif_graphs_ab/", sep ="")
+               progressFolder = paste(tempPath, "/chronojump_export_progress", sep ="")
+               tempGraphsFolder = paste(tempPath, "/chronojump_force_sensor_export_graphs_rfd/", sep ="")
+               tempGraphsABFolder = paste(tempPath, "/chronojump_force_sensor_export_graphs_ab/", sep ="")
 
                #countGraph = 1
                for(i in 1:length(dataFiles[,1]))
@@ -1254,13 +1254,13 @@ start <- function(op)
                #3) write the file
                if(is.null(exportDF)) {
                        # write something blank to be able to know in C# that operation ended
-                       write(0, file = paste(tempPath, "/cj_mif_export.csv", sep = ""))
+                       write(0, file = paste(tempPath, "/chronojump_force_sensor_export.csv", sep = ""))
                } else {
                        #print csv
                        if(op$decimalCharAtExport == ".")
-                               write.csv(exportDF, file = paste(tempPath, "/cj_mif_export.csv", sep = ""), 
row.names = FALSE, col.names = TRUE, quote = FALSE, na="")
+                               write.csv(exportDF, file = paste(tempPath, 
"/chronojump_force_sensor_export.csv", sep = ""), row.names = FALSE, col.names = TRUE, quote = FALSE, na="")
                        else if(op$decimalCharAtExport == ",")
-                               write.csv2(exportDF, file = paste(tempPath, "/cj_mif_export.csv", sep = ""), 
row.names = FALSE, col.names = TRUE, quote = FALSE, na="")
+                               write.csv2(exportDF, file = paste(tempPath, 
"/chronojump_force_sensor_export.csv", sep = ""), row.names = FALSE, col.names = TRUE, quote = FALSE, na="")
                }
        }
 }
diff --git a/src/Makefile.am b/src/Makefile.am
index cbdf9013..138b106e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -181,6 +181,8 @@ SOURCES = \
        execute/pulse.cs\
        execute/reactionTime.cs\
        execute/multiChronopic.cs\
+       exportFiles/exportFiles.cs\
+       exportFiles/fs.cs\
        AssemblyInfo.cs\
        buildInfo.cs\
        chronojump.cs\
diff --git a/src/exportFiles/exportFiles.cs b/src/exportFiles/exportFiles.cs
new file mode 100644
index 00000000..7af5914c
--- /dev/null
+++ b/src/exportFiles/exportFiles.cs
@@ -0,0 +1,152 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2021   Xavier de Blas <xaviblas gmail com>
+ */
+
+using System.IO;               //for detect OS //TextWriter
+using System.Collections.Generic; //List<T>
+using System.Threading;
+using Mono.Unix;
+
+public abstract class ExportFiles
+{
+       public Gtk.Button Button_done;
+
+       //passed variables
+       protected Gtk.Notebook notebook;
+       protected Gtk.ProgressBar progressbar;
+       protected Gtk.Label labelResult;
+       protected bool includeImages;
+       protected int imageWidth;
+       protected int imageHeight;
+       protected string exportURL; //folder or .csv depending on includeImages
+       protected bool isWindows;
+       protected int personID; // -1: all
+       protected int sessionID;
+
+       protected static Thread thread;
+       protected static bool cancel;
+       protected static bool noData;
+       protected static bool cannotCopy;
+       protected static string messageToProgressbar;
+
+       protected void assignParams (
+                       Gtk.Notebook notebook,
+                       Gtk.ProgressBar progressbar,
+                       Gtk.Label labelResult,
+                       bool includeImages,
+                       int imageWidth, int imageHeight,
+                       bool isWindows, int personID, int sessionID)
+
+       {
+               this.notebook = notebook;
+               this.progressbar = progressbar;
+               this.labelResult = labelResult;
+               this.includeImages = includeImages;
+               this.imageWidth = imageWidth;
+               this.imageHeight = imageHeight;
+               this.isWindows = isWindows;
+               this.personID = personID;
+               this.sessionID = sessionID;
+       }
+
+       protected void prepare(string exportURL)
+       {
+               this.exportURL = exportURL;
+
+               createOrEmptyDirs();
+
+               cancel = false;
+               noData = false;
+               cannotCopy = false;
+               progressbar.Fraction = 0;
+               messageToProgressbar = "";
+               notebook.CurrentPage = 1;
+       }
+               
+       protected virtual void createOrEmptyDirs()
+       {
+       }
+
+       protected void createOrEmptyDir(string dir)
+       {
+               if( ! Directory.Exists(dir))
+                       Directory.CreateDirectory (dir);
+               else {
+                       DirectoryInfo dirInfo = new DirectoryInfo(dir);
+                       foreach (FileInfo file in dirInfo.GetFiles())
+                               file.Delete();
+               }
+       }
+
+       protected string getTempProgressDir() {
+               return Path.Combine(Path.GetTempPath(), "chronojump_export_progress");
+       }
+
+       public void Cancel()
+       {
+               cancel = true;
+       }
+
+       protected bool pulseExportGTK ()
+       {
+               if(! thread.IsAlive || cancel)
+               {
+                       if(cancel)
+                               LogB.Information("pulseExportGTK cancelled");
+
+                       LogB.Information("pulseExportGTK ending here");
+                       LogB.ThreadEnded();
+
+                       progressbar.Fraction = 1;
+                       notebook.CurrentPage = 0;
+
+                       if(cancel)
+                               labelResult.Text = Catalog.GetString("Cancelled.");
+                       else if (noData)
+                               labelResult.Text = Catalog.GetString("Missing data.");
+                       else if (cannotCopy)
+                               labelResult.Text = string.Format(Catalog.GetString("Cannot copy to {0} "), 
exportURL);
+                       else
+                               labelResult.Text = string.Format(Catalog.GetString("Exported to {0}"), 
exportURL);// +
+                                               //Constants.GetSpreadsheetString(CSVExportDecimalSeparator)
+                                               //);
+
+                       Button_done.Click();
+
+                       return false;
+               }
+
+               DirectoryInfo dirInfo = new DirectoryInfo(getTempProgressDir());
+               //LogB.Information(string.Format("pulse files: {0}", dirInfo.GetFiles().Length));
+
+               int fileCount = dirInfo.GetFiles().Length;
+               if(fileCount == 0) {
+                       progressbar.Text = messageToProgressbar;
+                       progressbar.Pulse();
+               } else {
+                       setProgressBarTextAndFraction(fileCount);
+               }
+
+               Thread.Sleep (100);
+               //Log.Write(" (pulseForceSensorExportGTK:" + thread.ThreadState.ToString() + ") ");
+               return true;
+       }
+
+       protected abstract void setProgressBarTextAndFraction (int fileCount);
+}
diff --git a/src/exportFiles/fs.cs b/src/exportFiles/fs.cs
new file mode 100644
index 00000000..5ca679b8
--- /dev/null
+++ b/src/exportFiles/fs.cs
@@ -0,0 +1,483 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2021   Xavier de Blas <xaviblas gmail com>
+ */
+
+
+using System.IO;               //for detect OS //TextWriter
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List<T>
+using System.Threading;
+using Mono.Unix;
+
+public class ForceSensorExport : ExportFiles
+{
+       private List<ForceSensorRFD> rfdList;
+       private ForceSensorImpulse impulse;
+       private double duration;
+       private int durationPercent;
+       private double forceSensorElasticEccMinDispl;
+       private int forceSensorNotElasticEccMinForce;
+       private double forceSensorElasticConMinDispl;
+       private int forceSensorNotElasticConMinForce;
+       private bool forceSensorStartEndOptimized;
+       private char CSVExportDecimalSeparatorChar;
+       private double forceSensorAnalyzeMaxAVGInWindowSeconds;
+
+       private List<ForceSensor> fs_l;
+       private ArrayList personSession_l;
+       private ArrayList fsEx_l;
+       private static int totalRepsToExport;
+       private List<string> exportedRFDs;
+
+       public ForceSensorExport (
+                       Gtk.Notebook notebook,
+                       Gtk.ProgressBar progressbar,
+                       Gtk.Label labelResult,
+                       bool includeImages,
+                       int imageWidth, int imageHeight,
+                       bool isWindows, int personID, int sessionID,
+                       List<ForceSensorRFD> rfdList, ForceSensorImpulse impulse,
+                       double duration, int durationPercent,
+                       double forceSensorElasticEccMinDispl,
+                       int forceSensorNotElasticEccMinForce,
+                       double forceSensorElasticConMinDispl,
+                       int forceSensorNotElasticConMinForce,
+                       bool forceSensorStartEndOptimized,
+                       char CSVExportDecimalSeparatorChar,
+                       double forceSensorAnalyzeMaxAVGInWindowSeconds)
+
+       {
+               Button_done = new Gtk.Button();
+
+               assignParams(notebook, progressbar, labelResult, includeImages,
+                               imageWidth, imageHeight, isWindows, personID, sessionID);
+
+               this.rfdList = rfdList;
+               this.impulse = impulse;
+               this.duration = duration;
+               this.durationPercent = durationPercent;
+               this.forceSensorElasticEccMinDispl = forceSensorElasticEccMinDispl;
+               this.forceSensorNotElasticEccMinForce = forceSensorNotElasticEccMinForce;
+               this.forceSensorElasticConMinDispl = forceSensorElasticConMinDispl;
+               this.forceSensorNotElasticConMinForce = forceSensorNotElasticConMinForce;
+               this.forceSensorStartEndOptimized = forceSensorStartEndOptimized;
+               this.CSVExportDecimalSeparatorChar = CSVExportDecimalSeparatorChar;
+               this.forceSensorAnalyzeMaxAVGInWindowSeconds = forceSensorAnalyzeMaxAVGInWindowSeconds;
+       }
+
+       private string getForceSensorTempGraphsDir() {
+               return Path.Combine(Path.GetTempPath(), "chronojump_force_sensor_export_graphs_rfd");
+       }
+       private string getForceSensorTempGraphsABDir() {
+               return Path.Combine(Path.GetTempPath(), "chronojump_force_sensor_export_graphs_ab");
+       }
+
+       protected override void createOrEmptyDirs()
+       {
+               //create progressbar and graph files dirs or delete their contents
+               createOrEmptyDir(getTempProgressDir());
+               createOrEmptyDir(getForceSensorTempGraphsDir());
+               createOrEmptyDir(getForceSensorTempGraphsABDir());
+       }
+
+       ///public method
+       public void Start(string exportURL)
+       {
+               prepare(exportURL);
+
+               thread = new Thread (new ThreadStart (forceSensorExportDo));
+               GLib.Idle.Add (new GLib.IdleHandler (pulseExportGTK));
+               thread.Start();
+       }
+
+       private void forceSensorExportDo()
+       {
+               getData();
+
+               if(fs_l.Count == 0)
+               {
+                       LogB.Information("There's no data");
+                       noData = true;
+                       return;
+               }
+
+//             if(processForceSensorSets()) //false if cancelled
+//                     writeFile();
+               processForceSensorSets();
+       }
+
+       private void getData ()
+       {
+               fs_l = SqliteForceSensor.Select(false, -1, personID, sessionID);
+               personSession_l = SqlitePersonSession.SelectCurrentSessionPersons(sessionID, true);
+               fsEx_l = SqliteForceSensorExercise.Select (false, -1, false);
+               exportedRFDs = new List<string>();
+               //totalUnitsToExport = 0;
+               totalRepsToExport = 0;
+       }
+
+       private bool processForceSensorSets ()
+       {
+               Person p = new Person();
+               PersonSession ps = new PersonSession();
+
+               List<ForceSensorGraphABExport> fsgABe_l = new List<ForceSensorGraphABExport>();
+
+               //to manage sets we need previousPerson and previousExercise
+               ForceSensorExportSetManage fsesm = new ForceSensorExportSetManage();
+
+               int count = 1;
+               foreach(ForceSensor fs in fs_l)
+               {
+                       messageToProgressbar = string.Format(Catalog.GetString("Preparing sets {0}/{1}"), 
count++, fs_l.Count);
+
+                       if(cancel)
+                               return false;
+
+                       // 1) checks
+                       //check fs is ok
+                       if(fs == null || ! Util.FileExists(fs.FullURL))
+                               continue;
+
+                       //check fs has data
+                       List<string> contents = Util.ReadFileAsStringList(fs.FullURL);
+                       if(contents.Count < 3)
+                       {
+                               //new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileEmptyStr());
+                               //return;
+                               continue;
+                       }
+
+                       // 2) get the person
+                       bool found = false;
+                       foreach(PersonAndPS paps in personSession_l)
+                       {
+                               if(paps.p.UniqueID == fs.PersonID)
+                               {
+                                       p = paps.p;
+                                       ps = paps.ps;
+
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if(! found)
+                               continue;
+
+                       // 3) get the exercise
+                       found = false;
+                       ForceSensorExercise fsEx = new ForceSensorExercise();
+                       foreach(ForceSensorExercise fsExTemp in fsEx_l)
+                               if(fsExTemp.UniqueID == fs.ExerciseID)
+                               {
+                                       fsEx = fsExTemp;
+                                       found = true;
+                                       break;
+                               }
+                       if(! found)
+                               continue;
+
+                       if(! fsesm.Exists(p.UniqueID, fsEx.UniqueID, fs.Laterality))
+                               fsesm.AddForceSensorExportSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
+
+                       //make the exercise have EccReps = true in order to have an AB wiht the concentric 
and eccentric part
+                       //and send both to R to be able to have the force window in that AB
+                       fsEx.EccReps = true;
+
+                       double eccMinDispl = fsEx.GetEccOrConMinMaybePreferences(true,
+                                       forceSensorElasticEccMinDispl,
+                                       forceSensorNotElasticEccMinForce);
+                       double conMinDispl = fsEx.GetEccOrConMinMaybePreferences(false,
+                                       forceSensorElasticConMinDispl,
+                                       forceSensorNotElasticConMinForce);
+
+                       // 4) create fsAI (includes the repetitions)
+                       ForceSensorAnalyzeInstant fsAI = new ForceSensorAnalyzeInstant(
+                                       fs.FullURL,
+                                       imageWidth, imageHeight,
+                                       -1, -1,
+                                       fsEx, ps.Weight,
+                                       fs.CaptureOption, fs.Stiffness,
+                                       eccMinDispl, conMinDispl
+                                       );
+
+                       // 5) call R
+                       string title = p.Name;
+                       string exercise = fsEx.Name;
+                       if (isWindows) {
+                               title = Util.ConvertToUnicode(title);
+                               exercise = Util.ConvertToUnicode(exercise);
+                       }
+                       if (title == null || title == "")
+                               title = "unnamed";
+
+
+                       string destination = UtilEncoder.GetmifCSVInputMulti();
+                       Util.FileDelete(destination);
+
+
+                       /*
+                       //copy file to tmp to be written readed by R
+                       File.Copy(fs.FullURL, UtilEncoder.GetmifCSVFileName(), true); //can be overwritten
+                       */
+
+                       //delete result file
+                       Util.FileDelete(UtilEncoder.GetmifExportFileName());
+
+                       bool addedSet = false;
+                       int repCount = 1;
+                       int repConcentricSampleStart = -1;
+                       bool lastIsCon = false;
+                       ForceSensorRepetition repLast = null;
+                       foreach(ForceSensorRepetition rep in fsAI.ForceSensorRepetition_l)
+                       {
+                               if(rep.type == ForceSensorRepetition.Types.CON)
+                               {
+                                       repConcentricSampleStart = rep.sampleStart;
+                                       repLast = rep;
+                                       lastIsCon = true;
+                               }
+                               else if(rep.type == ForceSensorRepetition.Types.ECC && 
repConcentricSampleStart != -1)
+                               {
+                                       double maxAvgForceInWindow = 0;
+                                       double maxAvgForceInWindowSampleStart = 0;
+                                       double maxAvgForceInWindowSampleEnd = 0;
+                                       bool success = fsAI.CalculateRangeParams(repConcentricSampleStart, 
rep.sampleEnd,
+                                                       forceSensorAnalyzeMaxAVGInWindowSeconds);
+                                       if(success) {
+                                               maxAvgForceInWindow = fsAI.ForceMaxAvgInWindow;
+                                               maxAvgForceInWindowSampleStart = 
fsAI.ForceMaxAvgInWindowSampleStart;
+                                               maxAvgForceInWindowSampleEnd = 
fsAI.ForceMaxAvgInWindowSampleEnd;
+                                       }
+
+                                       if(! addedSet) {
+                                               fsesm.AddSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
+                                               addedSet = true;
+                                       }
+                                       fsgABe_l.Add(new ForceSensorGraphABExport (
+                                                               fs.FullURL,
+                                                               Util.CSVDecimalColumnIsPoint(fs.FullURL, 1),
+                                                               fsAI.ForceMAX,                  //raw
+                                                               maxAvgForceInWindow,            //raw
+                                                               forceSensorAnalyzeMaxAVGInWindowSeconds, //raw
+                                                               maxAvgForceInWindowSampleStart, //the start 
sample of the result
+                                                               maxAvgForceInWindowSampleEnd,   //the end 
sample of the result
+                                                               fs.Laterality,
+                                                               fsesm.GetCount(p.UniqueID, fsEx.UniqueID, 
fs.Laterality),
+                                                               repCount ++,
+                                                               fs.Comments,
+                                                               fs.CaptureOption,
+                                                               repConcentricSampleStart,       //start of 
concentric rep
+                                                               rep.sampleEnd,                  //end of 
eccentric rep
+                                                               title, exercise, fs.DatePublic, 
fs.TimePublic, new TriggerList()
+                                                               ));
+
+                                       lastIsCon = false;
+                               }
+                       }
+
+                       /*
+                        *1 if the last rep is con, also send to R (no problem if there is no ending ecc 
phase)
+                        *2 if we have not found any rep on this set, just pass from A to B on the set.
+                               This happens eg if the person starts with the maximum force (or using the 
forceSensor to weight things)
+                               or where the test has no force increase at all.
+                       */
+                       if(
+                                       (lastIsCon && repLast != null)          // *1
+                                       ||
+                                       (repCount == 1 && ! lastIsCon)          // *2
+                                       )
+                       {
+                               //if (repCount == 1 && ! lastIsCon) {           // *2
+                                       int sampleA = 1;
+                                       int sampleB = fsAI.GetLength() -1;
+                               //}
+                               if(lastIsCon && repLast != null) {              // *1
+                                       sampleA = repConcentricSampleStart; //start of concentric rep
+                                       sampleB = repLast.sampleEnd;    //end of eccentric rep
+                               }
+
+                               double maxAvgForceInWindow = 0;
+                               double maxAvgForceInWindowSampleStart = 0;
+                               double maxAvgForceInWindowSampleEnd = 0;
+                               bool success = fsAI.CalculateRangeParams(sampleA, sampleB,
+                                               forceSensorAnalyzeMaxAVGInWindowSeconds);
+                               if(success) {
+                                       maxAvgForceInWindow = fsAI.ForceMaxAvgInWindow;
+                                       maxAvgForceInWindowSampleStart = fsAI.ForceMaxAvgInWindowSampleStart;
+                                       maxAvgForceInWindowSampleEnd = fsAI.ForceMaxAvgInWindowSampleEnd;
+                               }
+
+                               if(! addedSet) {
+                                       fsesm.AddSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
+                                       addedSet = true;
+                               }
+                               fsgABe_l.Add(new ForceSensorGraphABExport (
+                                                       fs.FullURL,
+                                                       Util.CSVDecimalColumnIsPoint(fs.FullURL, 1),
+                                                       fsAI.ForceMAX,                  //raw
+                                                       maxAvgForceInWindow,            //raw
+                                                       forceSensorAnalyzeMaxAVGInWindowSeconds, //raw
+                                                       maxAvgForceInWindowSampleStart, //the start sample of 
the result
+                                                       maxAvgForceInWindowSampleEnd,   //the end sample of 
the result
+                                                       fs.Laterality,
+                                                       fsesm.GetCount(p.UniqueID, fsEx.UniqueID, 
fs.Laterality),
+                                                       repCount ++,
+                                                       fs.Comments,
+                                                       fs.CaptureOption,
+                                                       sampleA,
+                                                       sampleB,
+                                                       title, exercise, fs.DatePublic, fs.TimePublic, new 
TriggerList()
+                                                       ));
+                       }
+               }
+
+               if(fsgABe_l.Count > 0)
+               {
+                       totalRepsToExport = fsgABe_l.Count;
+                       ForceSensorGraph fsg = new ForceSensorGraph(
+                                       rfdList, impulse,
+                                       duration, durationPercent,
+                                       forceSensorStartEndOptimized,
+                                       true, //not used to read data, but used to print data
+                                       CSVExportDecimalSeparatorChar, // at write file
+                                       fsgABe_l,
+                                       forceSensorAnalyzeMaxAVGInWindowSeconds,
+                                       includeImages
+                                       );
+
+                       bool success = fsg.CallR(imageWidth, imageHeight, false);
+               }
+
+               LogB.Information("Waiting creation of file... ");
+               while ( ! ( Util.FileReadable(UtilEncoder.GetmifExportFileName()) || cancel ) )
+                       ;
+
+               if(cancel)
+                       return false;
+
+               if(includeImages)
+               {
+                       LogB.Information("going to copy export files with images ...");
+                       if( ! Directory.Exists(exportURL))
+                                Directory.CreateDirectory (exportURL);
+
+                       try{
+                               // 1) rfd graphs
+                               string sourceFolder = getForceSensorTempGraphsDir();
+                               DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceFolder);
+
+                               string destFolder = Path.Combine(exportURL, 
"chronojump_force_sensor_export_graphs_rfd");
+                               Directory.CreateDirectory (destFolder);
+
+                               foreach (FileInfo file in sourceDirInfo.GetFiles())
+                                       file.CopyTo(destFolder, true);
+
+                               // 2) AB graphs
+                               sourceFolder = getForceSensorTempGraphsABDir();
+                               sourceDirInfo = new DirectoryInfo(sourceFolder);
+
+                               destFolder = Path.Combine(exportURL, 
"chronojump_force_sensor_export_graphs_ab");
+                               Directory.CreateDirectory (destFolder);
+
+                               foreach (FileInfo file in sourceDirInfo.GetFiles())
+                                       file.CopyTo(destFolder, true);
+                       } catch {
+                               return false;
+                       }
+
+                       //LogB.Information("done copy export files with images!");
+               }
+
+               //copy the CSV
+               File.Copy(UtilEncoder.GetmifExportFileName(), exportURL, true);
+
+               return true;
+       }
+
+       protected override void setProgressBarTextAndFraction (int fileCount)
+       {
+               progressbar.Text = string.Format(Catalog.GetString("Exporting repetition {0}/{1}"),
+                               fileCount, totalRepsToExport);
+               progressbar.Fraction = UtilAll.DivideSafeFraction(fileCount, totalRepsToExport);
+       }
+}
+
+//to count sets according to person and exercise
+public class ForceSensorExportSet
+{
+       public int pID; //personID
+       public int exID; //forceSensor exercise ID
+       public string lat; //laterality
+       public int count; //how many sets with this pID && exID
+
+       public ForceSensorExportSet (int pID, int exID, string lat)
+       {
+               this.pID = pID;
+               this.exID = exID;
+               this.lat = lat;
+               this.count = 0;
+       }
+
+       public bool IsEqual (int pID, int exID, string lat)
+       {
+               return (this.pID == pID && this.exID == exID && this.lat == lat);
+       }
+}
+
+public class ForceSensorExportSetManage
+{
+       List<ForceSensorExportSet> l;
+
+       public ForceSensorExportSetManage()
+       {
+               l = new List<ForceSensorExportSet>();
+       }
+
+       public bool Exists (int pID, int exID, string lat)
+       {
+               foreach(ForceSensorExportSet fses in l)
+                       if(fses.IsEqual(pID, exID, lat))
+                               return true;
+
+               return false;
+       }
+
+       public void AddForceSensorExportSet (int pID, int exID, string lat)
+       {
+               ForceSensorExportSet fses = new ForceSensorExportSet(pID, exID, lat);
+               l.Add(fses);
+       }
+
+       public void AddSet (int pID, int exID, string lat)
+       {
+               foreach(ForceSensorExportSet fses in l)
+                       if(fses.IsEqual(pID, exID, lat))
+                               fses.count ++;
+       }
+
+       public int GetCount (int pID, int exID, string lat)
+       {
+               foreach(ForceSensorExportSet fses in l)
+                       if(fses.IsEqual(pID, exID, lat))
+                               return fses.count;
+
+               return -1;
+       }
+}
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 542e189e..3f1439be 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -22,7 +22,6 @@ using System;
 using System.IO;               //for detect OS //TextWriter
 using System.Collections; //ArrayList
 using System.Collections.Generic; //List<T>
-using System.Threading;
 using Mono.Unix;
 
 public class ForceSensor
@@ -2496,619 +2495,6 @@ public class ForceSensorAnalyzeInstant
        }
 }
 
-//to count sets according to person and exercise
-public class ForceSensorExportSet
-{
-       public int pID; //personID
-       public int exID; //forceSensor exercise ID
-       public string lat; //laterality
-       public int count; //how many sets with this pID && exID
-
-       public ForceSensorExportSet (int pID, int exID, string lat)
-       {
-               this.pID = pID;
-               this.exID = exID;
-               this.lat = lat;
-               this.count = 0;
-       }
-
-       public bool IsEqual (int pID, int exID, string lat)
-       {
-               return (this.pID == pID && this.exID == exID && this.lat == lat);
-       }
-}
-public class ForceSensorExportSetManage
-{
-       List<ForceSensorExportSet> l;
-
-       public ForceSensorExportSetManage()
-       {
-               l = new List<ForceSensorExportSet>();
-       }
-
-       public bool Exists (int pID, int exID, string lat)
-       {
-               foreach(ForceSensorExportSet fses in l)
-                       if(fses.IsEqual(pID, exID, lat))
-                               return true;
-
-               return false;
-       }
-
-       public void AddForceSensorExportSet (int pID, int exID, string lat)
-       {
-               ForceSensorExportSet fses = new ForceSensorExportSet(pID, exID, lat);
-               l.Add(fses);
-       }
-
-       public void AddSet (int pID, int exID, string lat)
-       {
-               foreach(ForceSensorExportSet fses in l)
-                       if(fses.IsEqual(pID, exID, lat))
-                               fses.count ++;
-       }
-
-       public int GetCount (int pID, int exID, string lat)
-       {
-               foreach(ForceSensorExportSet fses in l)
-                       if(fses.IsEqual(pID, exID, lat))
-                               return fses.count;
-
-               return -1;
-       }
-}
-
-public class ForceSensorExport
-{
-       public Gtk.Button Button_done;
-
-       //passed variables
-       private Gtk.Notebook notebook;
-       private Gtk.ProgressBar progressbar;
-       private Gtk.Label labelResult;
-       private bool includeImages;
-       private int imageWidth;
-       private int imageHeight;
-       private string exportURL; //folder or .csv depending on includeImages
-       private bool isWindows;
-       private int personID; // -1: all
-       private int sessionID;
-       private List<ForceSensorRFD> rfdList;
-       private ForceSensorImpulse impulse;
-       private double duration;
-       private int durationPercent;
-       private double forceSensorElasticEccMinDispl;
-       private int forceSensorNotElasticEccMinForce;
-       private double forceSensorElasticConMinDispl;
-       private int forceSensorNotElasticConMinForce;
-       private bool forceSensorStartEndOptimized;
-       private char CSVExportDecimalSeparatorChar;
-       private double forceSensorAnalyzeMaxAVGInWindowSeconds;
-
-       private static Thread thread;
-       private static bool cancel;
-       private static bool noData;
-       private static bool cannotCopy;
-       private static string messageToProgressbar;
-       //private static double pulseFraction; unused because its managed on pulse, better because on thread 
is working 100% on R call
-
-       List<ForceSensor> fs_l;
-       ArrayList personSession_l;
-       ArrayList fsEx_l;
-       private static int totalRepsToExport;
-       List<string> exportedRFDs;
-
-       //constructor
-       public ForceSensorExport (
-                       Gtk.Notebook notebook,
-                       Gtk.ProgressBar progressbar,
-                       Gtk.Label labelResult,
-                       bool includeImages,
-                       int imageWidth, int imageHeight,
-                       bool isWindows, int personID, int sessionID,
-                       List<ForceSensorRFD> rfdList, ForceSensorImpulse impulse,
-                       double duration, int durationPercent,
-                       double forceSensorElasticEccMinDispl,
-                       int forceSensorNotElasticEccMinForce,
-                       double forceSensorElasticConMinDispl,
-                       int forceSensorNotElasticConMinForce,
-                       bool forceSensorStartEndOptimized,
-                       char CSVExportDecimalSeparatorChar,
-                       double forceSensorAnalyzeMaxAVGInWindowSeconds)
-
-       {
-               this.notebook = notebook;
-               this.progressbar = progressbar;
-               this.labelResult = labelResult;
-               this.includeImages = includeImages;
-               this.imageWidth = imageWidth;
-               this.imageHeight = imageHeight;
-               this.isWindows = isWindows;
-               this.personID = personID;
-               this.sessionID = sessionID;
-               this.rfdList = rfdList;
-               this.impulse = impulse;
-               this.duration = duration;
-               this.durationPercent = durationPercent;
-               this.forceSensorElasticEccMinDispl = forceSensorElasticEccMinDispl;
-               this.forceSensorNotElasticEccMinForce = forceSensorNotElasticEccMinForce;
-               this.forceSensorElasticConMinDispl = forceSensorElasticConMinDispl;
-               this.forceSensorNotElasticConMinForce = forceSensorNotElasticConMinForce;
-               this.forceSensorStartEndOptimized = forceSensorStartEndOptimized;
-               this.CSVExportDecimalSeparatorChar = CSVExportDecimalSeparatorChar;
-               this.forceSensorAnalyzeMaxAVGInWindowSeconds = forceSensorAnalyzeMaxAVGInWindowSeconds;
-
-               Button_done = new Gtk.Button();
-       }
-
-       ///public method
-       public void Start(string exportURL)
-       {
-               this.exportURL = exportURL;
-
-               //create progressbar and graph files dirs or delete their contents
-               createOrEmptyDir(Util.GetForceSensorTempProgressDir());
-               createOrEmptyDir(Util.GetForceSensorTempGraphsDir());
-               createOrEmptyDir(Util.GetForceSensorTempGraphsABDir());
-
-               cancel = false;
-               noData = false;
-               cannotCopy = false;
-               progressbar.Fraction = 0;
-               messageToProgressbar = "";
-               notebook.CurrentPage = 1;
-
-               thread = new Thread (new ThreadStart (forceSensorExportDo));
-               GLib.Idle.Add (new GLib.IdleHandler (pulseForceSensorExportGTK));
-               thread.Start();
-       }
-
-       private void createOrEmptyDir(string dir)
-       {
-               if( ! Directory.Exists(dir))
-                       Directory.CreateDirectory (dir);
-               else {
-                       DirectoryInfo dirInfo = new DirectoryInfo(dir);
-                       foreach (FileInfo file in dirInfo.GetFiles())
-                               file.Delete();
-               }
-       }
-
-       public void Cancel()
-       {
-               cancel = true;
-       }
-
-       private bool pulseForceSensorExportGTK ()
-       {
-               if(! thread.IsAlive || cancel)
-               {
-                       if(cancel)
-                               LogB.Information("pulseForceSensorExportGTK cancelled");
-
-                       LogB.Information("pulseForceSensorExportGTK ending here");
-                       LogB.ThreadEnded();
-
-                       progressbar.Fraction = 1;
-                       notebook.CurrentPage = 0;
-
-                       if(cancel)
-                               labelResult.Text = Catalog.GetString("Cancelled.");
-                       else if (noData)
-                               labelResult.Text = Catalog.GetString("Missing data.");
-                       else if (cannotCopy)
-                               labelResult.Text = string.Format(Catalog.GetString("Cannot copy to {0} "), 
exportURL);
-                       else
-                               labelResult.Text = string.Format(Catalog.GetString("Exported to {0}"), 
exportURL);// +
-                                               //Constants.GetSpreadsheetString(CSVExportDecimalSeparator)
-                                               //);
-
-                       Button_done.Click();
-
-                       return false;
-               }
-
-               DirectoryInfo dirInfo = new DirectoryInfo(Util.GetForceSensorTempProgressDir());
-               //LogB.Information(string.Format("pulse files: {0}", dirInfo.GetFiles().Length));
-
-               int files = dirInfo.GetFiles().Length;
-               if(files == 0) {
-                       progressbar.Text = messageToProgressbar;
-                       progressbar.Pulse();
-               } else {
-                       progressbar.Text = string.Format(Catalog.GetString("Exporting repetition {0}/{1}"), 
files, totalRepsToExport);
-                       progressbar.Fraction = UtilAll.DivideSafeFraction(files, totalRepsToExport);
-               }
-
-               Thread.Sleep (100);
-               //Log.Write(" (pulseForceSensorExportGTK:" + thread.ThreadState.ToString() + ") ");
-               return true;
-       }
-
-       private void forceSensorExportDo()
-       {
-               getData();
-
-               if(fs_l.Count == 0)
-               {
-                       LogB.Information("There's no data");
-                       noData = true;
-                       return;
-               }
-
-//             if(processForceSensorSets()) //false if cancelled
-//                     writeFile();
-               processForceSensorSets();
-       }
-
-       private void getData ()
-       {
-               fs_l = SqliteForceSensor.Select(false, -1, personID, sessionID);
-               personSession_l = SqlitePersonSession.SelectCurrentSessionPersons(sessionID, true);
-               fsEx_l = SqliteForceSensorExercise.Select (false, -1, false);
-               exportedRFDs = new List<string>();
-               totalRepsToExport = 0;
-       }
-
-       private bool processForceSensorSets ()
-       {
-               Person p = new Person();
-               PersonSession ps = new PersonSession();
-
-               List<ForceSensorGraphABExport> fsgABe_l = new List<ForceSensorGraphABExport>();
-
-               //to manage sets we need previousPerson and previousExercise
-               ForceSensorExportSetManage fsesm = new ForceSensorExportSetManage();
-
-               int count = 1;
-               foreach(ForceSensor fs in fs_l)
-               {
-                       messageToProgressbar = string.Format(Catalog.GetString("Preparing sets {0}/{1}"), 
count++, fs_l.Count);
-
-                       if(cancel)
-                               return false;
-
-                       // 1) checks
-                       //check fs is ok
-                       if(fs == null || ! Util.FileExists(fs.FullURL))
-                               continue;
-
-                       //check fs has data
-                       List<string> contents = Util.ReadFileAsStringList(fs.FullURL);
-                       if(contents.Count < 3)
-                       {
-                               //new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileEmptyStr());
-                               //return;
-                               continue;
-                       }
-
-                       // 2) get the person
-                       bool found = false;
-                       foreach(PersonAndPS paps in personSession_l)
-                       {
-                               if(paps.p.UniqueID == fs.PersonID)
-                               {
-                                       p = paps.p;
-                                       ps = paps.ps;
-
-                                       found = true;
-                                       break;
-                               }
-                       }
-                       if(! found)
-                               continue;
-
-                       // 3) get the exercise
-                       found = false;
-                       ForceSensorExercise fsEx = new ForceSensorExercise();
-                       foreach(ForceSensorExercise fsExTemp in fsEx_l)
-                               if(fsExTemp.UniqueID == fs.ExerciseID)
-                               {
-                                       fsEx = fsExTemp;
-                                       found = true;
-                                       break;
-                               }
-                       if(! found)
-                               continue;
-
-                       if(! fsesm.Exists(p.UniqueID, fsEx.UniqueID, fs.Laterality))
-                               fsesm.AddForceSensorExportSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
-
-                       //make the exercise have EccReps = true in order to have an AB wiht the concentric 
and eccentric part
-                       //and send both to R to be able to have the force window in that AB
-                       fsEx.EccReps = true;
-
-                       double eccMinDispl = fsEx.GetEccOrConMinMaybePreferences(true,
-                                       forceSensorElasticEccMinDispl,
-                                       forceSensorNotElasticEccMinForce);
-                       double conMinDispl = fsEx.GetEccOrConMinMaybePreferences(false,
-                                       forceSensorElasticConMinDispl,
-                                       forceSensorNotElasticConMinForce);
-
-                       // 4) create fsAI (includes the repetitions)
-                       ForceSensorAnalyzeInstant fsAI = new ForceSensorAnalyzeInstant(
-                                       fs.FullURL,
-                                       imageWidth, imageHeight,
-                                       -1, -1,
-                                       fsEx, ps.Weight,
-                                       fs.CaptureOption, fs.Stiffness,
-                                       eccMinDispl, conMinDispl
-                                       );
-
-                       // 5) call R
-                       string title = p.Name;
-                       string exercise = fsEx.Name;
-                       if (isWindows) {
-                               title = Util.ConvertToUnicode(title);
-                               exercise = Util.ConvertToUnicode(exercise);
-                       }
-                       if (title == null || title == "")
-                               title = "unnamed";
-
-
-                       string destination = UtilEncoder.GetmifCSVInputMulti();
-                       Util.FileDelete(destination);
-
-
-                       /*
-                       //copy file to tmp to be written readed by R
-                       File.Copy(fs.FullURL, UtilEncoder.GetmifCSVFileName(), true); //can be overwritten
-                       */
-
-                       //delete result file
-                       Util.FileDelete(UtilEncoder.GetmifExportFileName());
-
-                       bool addedSet = false;
-                       int repCount = 1;
-                       int repConcentricSampleStart = -1;
-                       bool lastIsCon = false;
-                       ForceSensorRepetition repLast = null;
-                       foreach(ForceSensorRepetition rep in fsAI.ForceSensorRepetition_l)
-                       {
-                               if(rep.type == ForceSensorRepetition.Types.CON)
-                               {
-                                       repConcentricSampleStart = rep.sampleStart;
-                                       repLast = rep;
-                                       lastIsCon = true;
-                               }
-                               else if(rep.type == ForceSensorRepetition.Types.ECC && 
repConcentricSampleStart != -1)
-                               {
-                                       double maxAvgForceInWindow = 0;
-                                       double maxAvgForceInWindowSampleStart = 0;
-                                       double maxAvgForceInWindowSampleEnd = 0;
-                                       bool success = fsAI.CalculateRangeParams(repConcentricSampleStart, 
rep.sampleEnd,
-                                                       forceSensorAnalyzeMaxAVGInWindowSeconds);
-                                       if(success) {
-                                               maxAvgForceInWindow = fsAI.ForceMaxAvgInWindow;
-                                               maxAvgForceInWindowSampleStart = 
fsAI.ForceMaxAvgInWindowSampleStart;
-                                               maxAvgForceInWindowSampleEnd = 
fsAI.ForceMaxAvgInWindowSampleEnd;
-                                       }
-
-                                       if(! addedSet) {
-                                               fsesm.AddSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
-                                               addedSet = true;
-                                       }
-                                       fsgABe_l.Add(new ForceSensorGraphABExport (
-                                                               fs.FullURL,
-                                                               Util.CSVDecimalColumnIsPoint(fs.FullURL, 1),
-                                                               fsAI.ForceMAX,                  //raw
-                                                               maxAvgForceInWindow,            //raw
-                                                               forceSensorAnalyzeMaxAVGInWindowSeconds, //raw
-                                                               maxAvgForceInWindowSampleStart, //the start 
sample of the result
-                                                               maxAvgForceInWindowSampleEnd,   //the end 
sample of the result
-                                                               fs.Laterality,
-                                                               fsesm.GetCount(p.UniqueID, fsEx.UniqueID, 
fs.Laterality),
-                                                               repCount ++,
-                                                               fs.Comments,
-                                                               fs.CaptureOption,
-                                                               repConcentricSampleStart,       //start of 
concentric rep
-                                                               rep.sampleEnd,                  //end of 
eccentric rep
-                                                               title, exercise, fs.DatePublic, 
fs.TimePublic, new TriggerList()
-                                                               ));
-
-                                       lastIsCon = false;
-                               }
-                       }
-
-                       /*
-                        *1 if the last rep is con, also send to R (no problem if there is no ending ecc 
phase)
-                        *2 if we have not found any rep on this set, just pass from A to B on the set.
-                               This happens eg if the person starts with the maximum force (or using the 
forceSensor to weight things)
-                               or where the test has no force increase at all.
-                       */
-                       if(
-                                       (lastIsCon && repLast != null)          // *1
-                                       ||
-                                       (repCount == 1 && ! lastIsCon)          // *2
-                                       )
-                       {
-                               //if (repCount == 1 && ! lastIsCon) {           // *2
-                                       int sampleA = 1;
-                                       int sampleB = fsAI.GetLength() -1;
-                               //}
-                               if(lastIsCon && repLast != null) {              // *1
-                                       sampleA = repConcentricSampleStart; //start of concentric rep
-                                       sampleB = repLast.sampleEnd;    //end of eccentric rep
-                               }
-
-                               double maxAvgForceInWindow = 0;
-                               double maxAvgForceInWindowSampleStart = 0;
-                               double maxAvgForceInWindowSampleEnd = 0;
-                               bool success = fsAI.CalculateRangeParams(sampleA, sampleB,
-                                               forceSensorAnalyzeMaxAVGInWindowSeconds);
-                               if(success) {
-                                       maxAvgForceInWindow = fsAI.ForceMaxAvgInWindow;
-                                       maxAvgForceInWindowSampleStart = fsAI.ForceMaxAvgInWindowSampleStart;
-                                       maxAvgForceInWindowSampleEnd = fsAI.ForceMaxAvgInWindowSampleEnd;
-                               }
-
-                               if(! addedSet) {
-                                       fsesm.AddSet(p.UniqueID, fsEx.UniqueID, fs.Laterality);
-                                       addedSet = true;
-                               }
-                               fsgABe_l.Add(new ForceSensorGraphABExport (
-                                                       fs.FullURL,
-                                                       Util.CSVDecimalColumnIsPoint(fs.FullURL, 1),
-                                                       fsAI.ForceMAX,                  //raw
-                                                       maxAvgForceInWindow,            //raw
-                                                       forceSensorAnalyzeMaxAVGInWindowSeconds, //raw
-                                                       maxAvgForceInWindowSampleStart, //the start sample of 
the result
-                                                       maxAvgForceInWindowSampleEnd,   //the end sample of 
the result
-                                                       fs.Laterality,
-                                                       fsesm.GetCount(p.UniqueID, fsEx.UniqueID, 
fs.Laterality),
-                                                       repCount ++,
-                                                       fs.Comments,
-                                                       fs.CaptureOption,
-                                                       sampleA,
-                                                       sampleB,
-                                                       title, exercise, fs.DatePublic, fs.TimePublic, new 
TriggerList()
-                                                       ));
-                       }
-
-                       //TODO: or check cancel when there is a thread, also R should write something blank 
if there is any problem
-                       //also the problem with this code is: if R code fails for any reason (bad data), will 
exit R code and this file will never be created
-/*
-                       // 6) write exportedRFDs (includes impulse)
-                       if(File.Exists(UtilEncoder.GetmifExportFileName()))
-                       {
-                               List<string> repRFDs = 
Util.ReadFileAsStringList(UtilEncoder.GetmifExportFileName());
-                               int countRep = 0; //0 will be the header
-                               foreach(string row in repRFDs)
-                               {
-                                       //discard header
-                                       if(countRep == 0)
-                                       {
-                                               countRep ++;
-                                               continue;
-                                       }
-                                       //TODO: respect latin/not latin (decimal character, column separator)
-                                       exportedRFDs.Add(p.Name + ";" + fs.DateTimePublic + ";" +
-                                                       fsEx.Name + ";" + (countRep++).ToString() + ";" + 
fs.Laterality + ";" +
-                                                       row);
-                               }
-                       }
-                       pulseFraction = UtilAll.DivideSafeFraction (count ++, fs_l.Count);
-*/
-               }
-
-               if(fsgABe_l.Count > 0)
-               {
-                       totalRepsToExport = fsgABe_l.Count;
-                       ForceSensorGraph fsg = new ForceSensorGraph(
-                                       rfdList, impulse,
-                                       duration, durationPercent,
-                                       forceSensorStartEndOptimized,
-                                       true, //not used to read data, but used to print data
-                                       CSVExportDecimalSeparatorChar, // at write file
-                                       fsgABe_l,
-                                       forceSensorAnalyzeMaxAVGInWindowSeconds,
-                                       includeImages
-                                       );
-
-                       bool success = fsg.CallR(imageWidth, imageHeight, false);
-               }
-
-               LogB.Information("Waiting creation of file... ");
-               while ( ! ( Util.FileReadable(UtilEncoder.GetmifExportFileName()) || cancel ) )
-                       ;
-
-               if(cancel)
-                       return false;
-
-               if(includeImages)
-               {
-                       LogB.Information("going to copy export files with images ...");
-                       if( ! Directory.Exists(exportURL))
-                                Directory.CreateDirectory (exportURL);
-
-                       try{
-                               // 1) rfd graphs
-                               string sourceFolder = Path.Combine(Path.GetTempPath(), 
"chronojump_mif_graphs_rfd");
-                               DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceFolder);
-
-                               string destFolder = Path.Combine(exportURL, "chronojump_mif_graphs_rfd");
-                               Directory.CreateDirectory (destFolder);
-
-                               foreach (FileInfo file in sourceDirInfo.GetFiles())
-                                       file.CopyTo(destFolder, true);
-
-                               // 2) AB graphs
-                               sourceFolder = Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs_ab");
-                               sourceDirInfo = new DirectoryInfo(sourceFolder);
-
-                               destFolder = Path.Combine(exportURL, "chronojump_mif_graphs_ab");
-                               Directory.CreateDirectory (destFolder);
-
-                               foreach (FileInfo file in sourceDirInfo.GetFiles())
-                                       file.CopyTo(destFolder, true);
-                       } catch {
-                               return false;
-                       }
-
-                       //LogB.Information("done copy export files with images!");
-               }
-
-               //copy the CSV
-               File.Copy(UtilEncoder.GetmifExportFileName(), exportURL, true);
-
-               return true;
-       }
-
-       /*
-       //this exports the csv... it should be done by R
-       private bool writeFile()
-       {
-               string destination = UtilEncoder.GetmifExportFileName();
-               Util.FileDelete(destination);
-               try {
-                       //this overwrites if needed
-                       TextWriter writer = File.CreateText(destination);
-
-                       string sep = " ";
-                       if (CSVExportDecimalSeparator == "COMMA")
-                               sep = ";";
-                       else
-                               sep = ",";
-
-                       //write header
-                       string [] headers = { "Person", "Datetime", "Exercise", "Repetition", "Laterality", 
"Fmax"};
-                       int i = 0;
-                       foreach(ForceSensorRFD rfd in rfdList)
-                       {
-                               if(rfdList[i].Active)
-                                       headers = Util.AddArrayString(headers,
-                                                       string.Format("RFD{0}", i+1) + "_" + 
rfd.ToExport(true, "_"),
-                                                       false);
-                               i ++;
-                       }
-                       if(impulse.Active)
-                               headers = Util.AddArrayString(headers,
-                                               Catalog.GetString("Impulse") + "_" + impulse.ToExport(true, 
"_"),
-                                               false);
-
-                       writer.WriteLine(Util.RemoveNewLine(Util.StringArrayToString(headers, sep), false));
-
-                       //write data
-                       foreach(string str in exportedRFDs)
-                               writer.WriteLine(str);
-
-                       writer.Flush();
-                       writer.Close();
-                       ((IDisposable)writer).Dispose();
-
-                       return true;
-               } catch {
-                       string myString = string.Format(
-                                       Catalog.GetString("Cannot save file {0} "), destination);
-                       //new DialogMessage(Constants.MessageTypes.WARNING, myString);
-                       LogB.Information("Error: " + myString);
-
-                       return false;
-               }
-       }
-       */
-}
-
 //we need this class because we started using forcesensor without database (only text files)
 public class ForceSensorLoadTryToAssignPersonAndMore
 {
diff --git a/src/util.cs b/src/util.cs
index 342c9f4e..bba5ea5a 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1067,16 +1067,6 @@ public class Util
                }
        }
 
-       public static string GetForceSensorTempProgressDir() {
-               return Path.Combine(Path.GetTempPath(), "chronojump_mif_progress");
-       }
-       public static string GetForceSensorTempGraphsDir() {
-               return Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs_rfd");
-       }
-       public static string GetForceSensorTempGraphsABDir() {
-               return Path.Combine(Path.GetTempPath(), "chronojump_mif_graphs_ab");
-       }
-
        /*
         * <--------------- end of force sensor suff
         */
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 94cf3caf..b1fe0bb7 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -268,7 +268,7 @@ public class UtilEncoder
        }
        //R exports here, then C# move it and rename it
        public static string GetmifExportFileName() {
-               return Path.Combine(Path.GetTempPath(), "cj_mif_export.csv");
+               return Path.Combine(Path.GetTempPath(), "chronojump_force_sensor_export.csv");
        }
 
        /********** end of r-scripts paths ************/


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