[chronojump] Encoder GROUPAL_CURRENT_SESSION shows name on analyze table



commit ae3ab7fc49821152101f7768438e6f63fd8dc2c6
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Feb 14 20:27:32 2019 +0100

    Encoder GROUPAL_CURRENT_SESSION shows name on analyze table

 encoder/graph.R     |  9 ++++++---
 encoder/util.R      |  3 ++-
 src/encoder.cs      | 11 ++++++++---
 src/encoderRProc.cs | 11 +++++++----
 src/gui/encoder.cs  | 25 ++++++++++++++++++++++---
 src/utilEncoder.cs  |  4 ++--
 6 files changed, 47 insertions(+), 16 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index ae3ea0e8..cdce508c 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -3830,7 +3830,6 @@ doProcess <- function(options)
                                        mySeriesNames = chunks #mySeriesNames will be: "2018-09-06" (so 
different series will have the same series number and analyzed together)
                                }
 
-                                
                                 pafCurves = cbind(
                                         mySeriesNames,         #seriesName
                                         curves[,4],            #exerciseName
@@ -3911,10 +3910,14 @@ doProcess <- function(options)
                        pafCurvesWrite = pafCurves
                         if(! singleFile)
                        {
+                               myTimestamps = curves[,7]
                                if( length(pafCurvesWrite[,1]) > length(curves[,7]) )
-                                       pafCurvesWrite[,1] = c( curves[,7], rep(NA, 
length(pafCurvesWrite[,1]) - length(curves[,7])) )
+                                       myTimestamps = c( myTimestamps, rep(NA, length(pafCurvesWrite[,1]) - 
length(curves[,7])) )
+
+                               if(op$AnalysisMode == "GROUPAL_CURRENT_SESSION")
+                                       pafCurvesWrite[,1] = paste(pafCurves[,1], myTimestamps) 
#pafCurves[,1] is the name, needed on 4th analysis mode
                                else
-                                       pafCurvesWrite[,1] = curves[,7]
+                                       pafCurvesWrite[,1] = myTimestamps
                        }
                        write.csv(pafCurvesWrite, op$OutputData1, quote=FALSE)
                         #print("curves written")
diff --git a/encoder/util.R b/encoder/util.R
index efcf975c..e388fb52 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -98,7 +98,8 @@ assignOptions <- function(options) {
                    #Unassigned here:
                    #   englishWords [29]
                    #   translatedWords [30]
-                   SeparateSessionInDays = options[35]
+                   SeparateSessionInDays = options[35],
+                   AnalysisMode         = options[36]
                    ))
 }
 
diff --git a/src/encoder.cs b/src/encoder.cs
index 0902c1b6..0e300811 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -162,7 +162,10 @@ public class EncoderGraphROptions
        private bool cutByTriggers;
        private string triggerList;
        public bool separateSessionInDays;
-       
+       public AnalysisModes analysisMode; //the four analysisModes
+
+       public enum AnalysisModes { CAPTURE, INDIVIDUAL_CURRENT_SET, INDIVIDUAL_CURRENT_SESSION, 
INDIVIDUAL_ALL_SESSIONS, GROUPAL_CURRENT_SESSION }
+
        public EncoderGraphROptions(
                        string inputData, string outputGraph, string outputData1, 
                        string encoderRPath, string encoderTempPath,
@@ -170,7 +173,7 @@ public class EncoderGraphROptions
                        string title, string operatingSystem,
                        string englishWords, string translatedWords,
                        bool debug, bool crossValidate, bool cutByTriggers, string triggerList,
-                       bool separateSessionInDays)
+                       bool separateSessionInDays, AnalysisModes analysisMode)
        {
                this.inputData = inputData;
                this.outputGraph = outputGraph;
@@ -187,6 +190,7 @@ public class EncoderGraphROptions
                this.cutByTriggers = cutByTriggers;
                this.triggerList = triggerList;
                this.separateSessionInDays = separateSessionInDays;
+               this.analysisMode = analysisMode;
 
                //ensure triggerList is not null or blank
                if(triggerList == null || triggerList == "")
@@ -209,7 +213,8 @@ public class EncoderGraphROptions
                        "#crossValidate\n" +    Util.BoolToRBool(crossValidate) + "\n" +
                        "#cutByTriggers\n" +    Util.BoolToRBool(cutByTriggers) + "\n" +
                        "#triggerList\n" +      triggerList + "\n" +
-                       "#separateSessionInDays\n" +    Util.BoolToRBool(separateSessionInDays) + "\n";
+                       "#separateSessionInDays\n" +    Util.BoolToRBool(separateSessionInDays) + "\n" +
+                       "#analysisMode\n" +     analysisMode.ToString() + "\n";
        }
        
 
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index 3a3d5735..3dfc0941 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -259,8 +259,8 @@ public class EncoderRProcCapture : EncoderRProc
                                false,  //crossValidate (unactive on capture at the moment)
                                (CutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS),
                                printTriggers(),
-                               false   //separateSessionInDays (false at capture)
-                               ).ToString();
+                               false,  //separateSessionInDays (false at capture)
+                               EncoderGraphROptions.AnalysisModes.CAPTURE).ToString();
 
                TextWriter writer = File.CreateText(optionsFile);
                writer.Write(scriptOptions);
@@ -288,6 +288,7 @@ public class EncoderRProcAnalyze : EncoderRProc
        private bool translate;
        private bool cutByTriggers;
        private TriggerList triggerList;
+       private EncoderGraphROptions.AnalysisModes analysisMode;
 
        /*
         * to avoid problems on some windows. R exports csv to Util.GetEncoderExportTempFileName()
@@ -301,13 +302,14 @@ public class EncoderRProcAnalyze : EncoderRProc
        }
 
        public void SendData(string title, bool neuromuscularProfileDo, bool translate,
-                       bool cutByTriggers, TriggerList triggerList)
+                       bool cutByTriggers, TriggerList triggerList, EncoderGraphROptions.AnalysisModes 
analysisMode)
        {
                this.title = title;
                this.neuromuscularProfileDo = neuromuscularProfileDo;
                this.translate = translate;
                this.cutByTriggers = cutByTriggers;
                this.triggerList = triggerList;
+               this.analysisMode = analysisMode;
                
                CancelRScript = false;
        }
@@ -517,7 +519,8 @@ public class EncoderRProcAnalyze : EncoderRProc
                                CrossValidate,
                                cutByTriggers,
                                printTriggers(),
-                               SeparateSessionInDays
+                               SeparateSessionInDays,
+                               analysisMode
                                ).ToString();
 
                TextWriter writer = File.CreateText(optionsFile);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index cc1467c8..29ef6e87 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1437,7 +1437,8 @@ public partial class ChronoJumpWindow
                                false,  //do not use neuromuscularProfile script
                                preferences.RGraphsTranslate,
                                (preferences.encoderCaptureCutByTriggers != 
Preferences.TriggerTypes.NO_TRIGGERS),
-                               triggerList
+                               triggerList,
+                               getAnalysisMode()
                                ); 
                bool result = encoderRProcAnalyze.StartOrContinue(es);
                                
@@ -1958,13 +1959,30 @@ public partial class ChronoJumpWindow
                                false,                  //do not use neuromuscularProfile script
                                preferences.RGraphsTranslate,
                                (preferences.encoderCaptureCutByTriggers != 
Preferences.TriggerTypes.NO_TRIGGERS),
-                               new TriggerList()
+                               new TriggerList(),
+                               getAnalysisMode()
                                );
                encoderRProcAnalyze.StartOrContinue(encoderStruct);
 
                //encoder_pulsebar_capture.Text = string.Format(Catalog.GetString(
                //                      "Exported to {0}."), UtilEncoder.GetEncoderExportTempFileName());
        }
+
+       private EncoderGraphROptions.AnalysisModes getAnalysisMode()
+       {
+               EncoderGraphROptions.AnalysisModes am = 
EncoderGraphROptions.AnalysisModes.INDIVIDUAL_CURRENT_SET; //default
+
+               if(radio_encoder_analyze_individual_current_set.Active)
+                       am = EncoderGraphROptions.AnalysisModes.INDIVIDUAL_CURRENT_SET;
+               else if(radio_encoder_analyze_individual_current_session.Active)
+                       am = EncoderGraphROptions.AnalysisModes.INDIVIDUAL_CURRENT_SESSION;
+               else if(radio_encoder_analyze_individual_all_sessions.Active)
+                       am = EncoderGraphROptions.AnalysisModes.INDIVIDUAL_ALL_SESSIONS;
+               else if(radio_encoder_analyze_groupal_current_session.Active)
+                       am = EncoderGraphROptions.AnalysisModes.GROUPAL_CURRENT_SESSION;
+
+               return am;
+       }
                                                
        void on_button_encoder_save_AB_file_selected (string selectedFileName)
        {
@@ -3168,7 +3186,8 @@ public partial class ChronoJumpWindow
                                encoderSelectedAnalysis == "neuromuscularProfile",
                                preferences.RGraphsTranslate,
                                (preferences.encoderCaptureCutByTriggers != 
Preferences.TriggerTypes.NO_TRIGGERS),
-                               triggerList
+                               triggerList,
+                               getAnalysisMode()
                                );
 
                encoderRProcAnalyze.StartOrContinue(encoderStruct);
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 17f1bea8..eae88d23 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -350,7 +350,7 @@ public class UtilEncoder
 
        public static EncoderGraphROptions PrepareEncoderGraphOptions(
                        string title, EncoderStruct es, bool neuromuscularProfileDo, bool translate, bool 
debug, bool crossValidate,
-                       bool cutByTriggers, string triggerStr, bool separateSessionInDays)
+                       bool cutByTriggers, string triggerStr, bool separateSessionInDays, 
EncoderGraphROptions.AnalysisModes analysisMode)
        {
                string operatingSystem = OperatingSystemForRGraphs();
                        
@@ -405,7 +405,7 @@ public class UtilEncoder
                                title, operatingSystem,
                                Util.StringArrayToString(Constants.EncoderEnglishWords,";"),
                                Util.StringArrayToString(encoderTranslatedWordsOK,";"),
-                               debug, crossValidate, cutByTriggers, triggerStr, separateSessionInDays
+                               debug, crossValidate, cutByTriggers, triggerStr, separateSessionInDays, 
analysisMode
                                );
        }
 


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