[chronojump] Implemented debug mode for encoder



commit e7aef8898cf02bc3c51d26fb7f2d35283b97eebe
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Mar 3 21:22:14 2016 +0100

    Implemented debug mode for encoder

 encoder/call_capture.R |    4 ++
 encoder/call_graph.R   |    4 ++
 encoder/capture.R      |   48 +++++++++--------
 encoder/graph.R        |   14 +++--
 encoder/util.R         |  140 ++++++++++++++++++++++++++++--------------------
 glade/chronojump.glade |   78 ++++++++++++++++++++++++++-
 src/encoder.cs         |    8 ++-
 src/encoderRProc.cs    |    7 ++-
 src/gui/chronojump.cs  |    9 +++
 src/util.cs            |    7 +++
 src/utilEncoder.cs     |    6 ++-
 11 files changed, 229 insertions(+), 96 deletions(-)
---
diff --git a/encoder/call_capture.R b/encoder/call_capture.R
index 4dcfafd..3b4178c 100644
--- a/encoder/call_capture.R
+++ b/encoder/call_capture.R
@@ -24,6 +24,10 @@ filenameBegins = options[2]
 
 source(scriptCaptureR)
 
+DEBUG <- FALSE
+DebugFileName <- paste(options[5], "/chronojump-debug.txt", sep="")
+
+
 f <- file("stdin")
 open(f)
 
diff --git a/encoder/call_graph.R b/encoder/call_graph.R
index 6503e4e..a15fb32 100644
--- a/encoder/call_graph.R
+++ b/encoder/call_graph.R
@@ -22,11 +22,15 @@ options <- scan(optionsFile, comment.char="#", what=character(), sep="\n")
 FeedbackFileBase <- paste(options[5], "/chronojump-encoder-status-", sep="")
 SpecialData <- paste(options[5], "/chronojump-special-data.txt", sep="")
 OperatingSystem <- options[27]
+
 EncoderConfigurationName <- ""
 
 English = unlist(strsplit(options[28], "\\;"))
 Translated = unlist(strsplit(options[29], "\\;"))
 
+DEBUG <- FALSE
+DebugFileName <- paste(options[5], "/chronojump-debug.txt", sep="")
+
 source(paste(options[4], "/util.R", sep=""))
 source(paste(options[4], "/graphSmoothingEC.R", sep=""))
 
diff --git a/encoder/capture.R b/encoder/capture.R
index 1cab715..764845d 100644
--- a/encoder/capture.R
+++ b/encoder/capture.R
@@ -14,7 +14,7 @@ write("Arriving at capture.R", stderr())
 
 g = 9.81
 
-debug = FALSE
+#debug = FALSE
                    
 filenameCompose <- function(curveNum)
 {
@@ -29,8 +29,9 @@ filenameCompose <- function(curveNum)
 #calcule <- function(displacement, start, end, op, curveNum)
 calcule <- function(displacement, op, curveNum)
 {
-       if(debug)
-               write("At calcule", stderr())
+       #if(debug)
+       #       write("At calcule", stderr())
+       debugParameters(listN(displacement, op, curveNum), "calcule")
 
        #check displacement1/2 lengths because if it was bad executed,
        #getDisplacementInertialBody maybe returned really small curves that will fail in smooth.spline
@@ -65,8 +66,8 @@ calcule <- function(displacement, op, curveNum)
        }
 
 
-       if(debug)
-               write("At calcule calling kinematics", stderr())
+       #if(debug)
+       #       write("At calcule calling kinematics", stderr())
        
 
        kinematicsResult <- kinematicsF(
@@ -94,8 +95,8 @@ calcule <- function(displacement, op, curveNum)
                  paf$meanForce, paf$maxForce, paf$maxForceT,
                  sep=", "), file = con)
        close(con)
-       if(debug)
-               write("ended calcule", stderr())
+       #if(debug)
+       #       write("ended calcule", stderr())
 
        return(curveNum +1)
 }
@@ -123,10 +124,11 @@ uncompress <- function(curveSent)
 
 doProcess <- function(options) 
 {
-       if(debug)
-               write("doProcess", stderr())
+       #if(debug)
+       #       write("doProcess", stderr())
        op <- assignOptions(options)
-
+                       
+       DEBUG <<- op$Debug
 
        #print ("----op----")
        #print (op)
@@ -138,10 +140,10 @@ doProcess <- function(options)
        
        input <- readLines(f, n = 1L)
        while(input[1] != "Q") {
-               if(debug) {
-                       write("doProcess main while", stderr())
-                       write(c("input = ", input), stderr())
-               }
+               #if(debug) {
+               #       write("doProcess main while", stderr())
+               #       write(c("input = ", input), stderr())
+               #}
                        
                
                #if should continue with another capture
@@ -159,6 +161,8 @@ doProcess <- function(options)
                        
                        options <- scan(optionsFile, comment.char="#", what=character(), sep="\n")
                        op <- assignOptions(options)
+                       DEBUG <<- op$Debug
+
 
                        curveNum = 0
                        inertialPositionCurveSentStart = 0
@@ -185,8 +189,8 @@ doProcess <- function(options)
                #-- curve readed
 
                
-               if(debug)
-                       write("doProcess input", stderr())
+               #if(debug)
+               #       write("doProcess input", stderr())
                #write(input, stderr())
 
                #when data is sent uncompressed
@@ -198,8 +202,8 @@ doProcess <- function(options)
                #this removes all NAs
                displacement  = displacement[!is.na(displacement)]
 
-               if(debug)
-                       write("doProcess 2", stderr())
+               #if(debug)
+               #       write("doProcess 2", stderr())
                        
                if(isInertial(op$EncoderConfigurationName))
                {
@@ -234,8 +238,8 @@ doProcess <- function(options)
 
                        displacement = displacement[start:end]
                }
-               if(debug)
-                       write("doProcess 3", stderr())
+               #if(debug)
+               #       write("doProcess 3", stderr())
 
                #if isInertial: getDisplacementInertialBody separate phases using initial height of full 
extended person
                #so now there will be two different curves to process
@@ -266,8 +270,8 @@ doProcess <- function(options)
                        
                inertialPositionCurveSentStart = inertialPositionCurveSentEnd
 
-               if(debug)
-                       write("doProcess 4", stderr())
+               #if(debug)
+               #       write("doProcess 4", stderr())
 
                input <- readLines(f, n = 1L)
        }
diff --git a/encoder/graph.R b/encoder/graph.R
index 742861e..4b6e738 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -64,7 +64,7 @@
 #
 #
 
-debug = FALSE
+debugOld = FALSE #this will be deprecated and DEBUG will be used
 
 #concentric, eccentric-concentric, repetitions of eccentric-concentric
 #currently only used "c" and "ec". no need of ec-rep because c and ec are repetitive
@@ -741,7 +741,7 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
        power = dynamics$power
 
 
-       if(draw && isInertial(encoderConfigurationName) && debug) 
+       if(draw && isInertial(encoderConfigurationName) && debugOld) 
        {
                #start blank graph with ylim of position
                ylim = yrange
@@ -780,7 +780,7 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                        axisLineRight = axisLineRight +2
                }
                
-               if(isInertial(encoderConfigurationName) && debug) {
+               if(isInertial(encoderConfigurationName) && debugOld) {
                        #print("dynamics$forceDisc")
                        #print(dynamics$forceDisc)
                        par(new=T)
@@ -967,7 +967,7 @@ paint <- function(displacement, eccon, xmin, xmax, yrange, knRanges, superpose,
                             
xlim=c(1,length(displacement)),ylim=ylim,xlab="",ylab="",col="darkred",lty=2,lwd=3,axes=F)
        
 
-               if(isInertial(encoderConfigurationName) && debug) {
+               if(isInertial(encoderConfigurationName) && debugOld) {
                        par(new=T)
                        plot(dynamics$powerDisc, col="orangered3", xlab="", ylab="", 
xlim=c(1,length(displacement)),ylim=ylim, type="p", pch=1, axes=F);
 
@@ -2065,6 +2065,8 @@ doProcess <- function(options)
        #if unicodeWorks, then translations will be done
        #<<- to assign to a global variable
        unicodeWorks <<- checkUnicodeWorks()
+
+       DEBUG <<- op$Debug
        
        print(c("1 Title=",op$Title))
        #unicoded titles arrive here like this "\\", convert to "\", as this is difficult, do like this:
@@ -2927,8 +2929,8 @@ doProcess <- function(options)
                                }
                        }
 
-                       print("---- 3 ----")
-                       print(pafCurves)
+                       #print("---- 3 ----")
+                       #print(pafCurves)
 
                        write.csv(pafCurves, op$OutputData1, quote=FALSE)
                        #print("curves written")
diff --git a/encoder/util.R b/encoder/util.R
index 14d4aea..2028a6b 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -71,8 +71,11 @@ assignOptions <- function(options) {
                    Height              = as.numeric(options[24]),
                    DecimalSeparator    = options[25],
                    Title               = options[26],
-                   OperatingSystem     = options[27]#, #if this changes, change it also at start of this R 
file
-                   #IMPORTANT, if this grows, change the readLines value on getOptionsFromFile
+                   OperatingSystem     = options[27],  #if this changes, change it also at start of this R 
file
+                   Debug               = options[30]
+                   #Unassigned here:
+                   #   englishWords [28]
+                   #   translatedWords [29]
                    ))
 }
 
@@ -736,42 +739,47 @@ getDynamics <- function(encoderConfigurationName,
                        speed, accel, massBody, massExtra, exercisePercentBodyWeight, gearedDown, anglePush, 
angleWeight,
                        displacement, diameter, inertiaMomentum, smoothing)
 {
-  massBody = getMassBodyByExercise(massBody,exercisePercentBodyWeight)
-  
-  if(
-    encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON1" ||
-      encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON1INV" ||
-      encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON2" ||
-      encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON2INV" ||
-      encoderConfigurationName == "WEIGHTEDMOVPULLEYROTARYFRICTION" ||
-      encoderConfigurationName == "WEIGHTEDMOVPULLEYROTARYAXIS" ) 
-  {
-    massExtra = getMass(massExtra, gearedDown, anglePush)
-  } 
-  
-  massTotal = massBody + massExtra
-  
-  if(isInertial(encoderConfigurationName))
-    return (getDynamicsInertial(encoderConfigurationName, displacement, diameter, massTotal, 
inertiaMomentum, gearedDown, smoothing))
-  else 
-    return (getDynamicsNotInertial (encoderConfigurationName, speed, accel, 
-                                    massBody, massExtra, massTotal, 
-                                    exercisePercentBodyWeight, gearedDown, anglePush, angleWeight))
+       debugParameters(listN(encoderConfigurationName,
+                            speed, accel, massBody, massExtra, exercisePercentBodyWeight, gearedDown, 
anglePush, angleWeight,
+                            displacement, diameter, inertiaMomentum, smoothing), "getDynamics")
+       
+
+       massBody = getMassBodyByExercise(massBody,exercisePercentBodyWeight)
+
+       if(
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON1" ||
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON1INV" ||
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON2" ||
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYLINEARONPERSON2INV" ||
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYROTARYFRICTION" ||
+          encoderConfigurationName == "WEIGHTEDMOVPULLEYROTARYAXIS" ) 
+       {
+               massExtra = getMass(massExtra, gearedDown, anglePush)
+       } 
+
+       massTotal = massBody + massExtra
+
+       if(isInertial(encoderConfigurationName))
+               return (getDynamicsInertial(encoderConfigurationName, displacement, diameter, massTotal, 
inertiaMomentum, gearedDown, smoothing))
+       else 
+               return (getDynamicsNotInertial (encoderConfigurationName, speed, accel, 
+                                               massBody, massExtra, massTotal, 
+                                               exercisePercentBodyWeight, gearedDown, anglePush, 
angleWeight))
 }
 
 #mass extra can be connected to body or connected to a pulley depending on encoderConfiguration
 getDynamicsNotInertial <- function(encoderConfigurationName, speed, accel, 
-                                   massBody, massExtra, massTotal,
-                                   exercisePercentBodyWeight, gearedDown, anglePush, angleWeight) 
+                                  massBody, massExtra, massTotal,
+                                  exercisePercentBodyWeight, gearedDown, anglePush, angleWeight) 
 { 
-  force = NULL
-  if(encoderConfigurationName == "LINEARONPLANEWEIGHTDIFFANGLE") {
-    force <- massBody*(accel + g*sin(anglePush * pi / 180)) + massExtra*(g*sin(angleWeight * pi / 180) + 
accel)
-  } else if(encoderConfigurationName == "LINEARONPLANE"){
-    force <- (massBody + massExtra)*(accel + g*sin(anglePush * pi / 180))
-  } else {
-       force <- massTotal*(accel+g)    #g:9.81 (used when movement is against gravity)
-  }
+       force = NULL
+       if(encoderConfigurationName == "LINEARONPLANEWEIGHTDIFFANGLE") {
+               force <- massBody*(accel + g*sin(anglePush * pi / 180)) + massExtra*(g*sin(angleWeight * pi / 
180) + accel)
+       } else if(encoderConfigurationName == "LINEARONPLANE"){
+               force <- (massBody + massExtra)*(accel + g*sin(anglePush * pi / 180))
+       } else {
+               force <- massTotal*(accel+g)    #g:9.81 (used when movement is against gravity)
+       }
 
        power <- force*speed
 
@@ -1113,54 +1121,68 @@ getInertialDiametersPerMs <- function(displacement, diametersPerTick)
 
 
 #----------- Begin debug file output -------------
+debugParameters <- function (parameterList, currentFunction) 
+{
+       if(is.null(DEBUG) || DEBUG == FALSE || is.null(DebugFileName) || DebugFileName == "")
+               return()
 
-debugParameters <- function (outlist, outfile, currentFunction) {
-        write(paste("Parameters of the", currentFunction, "function are:\n"), outfile, append=FALSE)
+        write(paste("Parameters of the", currentFunction, "function are:\n"), DebugFileName, append=FALSE)
         
         #based on http://stackoverflow.com/a/34996874
-        for (i in 1:length(outlist)) {
-                if ((is.character(outlist[[i]]) || is.numeric(outlist[[i]])) &
-                    !is.data.frame(outlist[[i]]) &
-                    !is.matrix(outlist[[i]])) {
-                        write(paste("---------", names(outlist)[i], ":", "---------", sep = ""), outfile, 
append=TRUE) 
-                        write(paste(outlist[[i]],collapse = " "), outfile, append=TRUE)
+        for (i in 1:length(parameterList)) {
+                if ( (is.character(parameterList[[i]]) || is.numeric(parameterList[[i]])) &&
+                    ! is.data.frame(parameterList[[i]]) && ! is.matrix(parameterList[[i]]) ) {
+                       writedebugParameters(parameterList, i)
+                        write(paste(parameterList[[i]],collapse = " "), DebugFileName, append=TRUE)
                 }
-                if (is.data.frame(outlist[[i]])) {
-                        write(paste("---------", names(outlist)[i], ":", "---------", sep =""), outfile, 
append=TRUE)
-                        write.table(outlist[[i]], outfile, append=TRUE, quote=FALSE, sep="\t", col.names = 
TRUE)
+                if (is.data.frame(parameterList[[i]])) {
+                       writedebugParameters(parameterList, i)
+                        write.table(parameterList[[i]], DebugFileName, append=TRUE, quote=FALSE, sep="\t", 
col.names = TRUE)
                 }
-                else if (is.POSIXlt(outlist[[i]])) {
-                        write(paste("---------",names(outlist)[i], ":", "---------", sep =""), outfile, 
append=TRUE)
-                        write(as.character(outlist[[i]]), outfile, append=TRUE)
+                else if (is.POSIXlt(parameterList[[i]])) {
+                       writedebugParameters(parameterList, i)
+                        write(as.character(parameterList[[i]]), DebugFileName, append=TRUE)
                 }
-                else if  (is.list(outlist[[i]])) {
-                        write(paste("---------",names(outlist)[i], ":", "---------", sep =""), outfile, 
append=TRUE)
-                        write_list(outlist = outlist[[i]], outfile, append = TRUE)
+                else if  (is.list(parameterList[[i]])) {
+                       writedebugParameters(parameterList, i)
+                        write_list(parameterList = parameterList[[i]], DebugFileName, append = TRUE)
                 }
-                else if (is.matrix(outlist[[i]])) {
-                        write(paste("---------", names(outlist)[i], ":", "---------", sep =""), outfile, 
append=TRUE) 
-                        write.table(outlist[[i]], outfile, append=TRUE, quote=FALSE, col.names = TRUE)
+                else if (is.matrix(parameterList[[i]])) {
+                       writedebugParameters(parameterList, i)
+                        write.table(parameterList[[i]], DebugFileName, append=TRUE, quote=FALSE, col.names = 
TRUE)
                 }
         }
 }
 
+writedebugParameters <- function(parameterList, i) {
+       write(paste("---------", names(parameterList)[i], ":", "---------", sep = ""), DebugFileName, 
append=TRUE) 
+}
+
 is.POSIXlt <- function (ts) {
         isPOS=c("POSIXlt", "POSIXt")
         identical (class(ts),isPOS)
 }
 
-test_debugParameters <- function(outfile){
+test_debugParameters <- function() {
         numVariable = c(1,2,3,4)
         charVariable = c("Hello", "how", "are", "you")
         dataframeVariable = as.data.frame(matrix(c(10,20,40,50), ncol = 2))
         matrixVariable = matrix(c(100,200,400,500), ncol = 2)
-        testData = list(numVariable = numVariable,
-                        charVariable = charVariable,
-                        dataframeVariable = dataframeVariable,
-                        matrixVariable = matrixVariable)
+
+       l = list(numVariable = numVariable,
+                charVariable = charVariable,
+                dataframeVariable = dataframeVariable,
+                matrixVariable = matrixVariable)
         
-        debugParameters(dades, outfile, "testFunction")
+        debugParameters(l, "test_debugParameters")
 }
 
+#create a list assigning names
+#http://stackoverflow.com/a/21059868
+listN <- function(...){
+       anonList <- list(...)
+       names(anonList) <- as.character(substitute(list(...)))[-1]
+       anonList
+}
 
 #----------- End debug file output -------------
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index b68ea6b..a1002c0 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -500,6 +500,15 @@
                         <signal name="activate" handler="on_menuitem_SQL_stress_test_not_safe_long_activate" 
swapped="no"/>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="menuitem_debug_mode">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Enter debug mode (developers)</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_menuitem_debug_mode_activate" swapped="no"/>
+                      </widget>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -7879,6 +7888,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -9401,6 +9413,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -10564,6 +10579,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -18960,6 +18978,9 @@ on current Chronojump version.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -23541,6 +23562,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24603,6 +24627,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -26157,6 +26184,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>
@@ -26768,6 +26798,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -39080,6 +39113,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>
@@ -41291,6 +41342,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>
@@ -42654,9 +42717,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>
@@ -43718,6 +43778,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>
@@ -47521,6 +47584,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>
@@ -48247,6 +48313,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -48988,6 +49057,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index c9a2ecc..158d188 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -164,13 +164,15 @@ public class EncoderGraphROptions
        public string operatingSystem;
        public string englishWords;
        public string translatedWords;
+       public bool debug;
        
        public EncoderGraphROptions(
                        string inputData, string outputGraph, string outputData1, 
                        string encoderRPath, string encoderTempPath,
                        EncoderParams ep,
                        string title, string operatingSystem,
-                       string englishWords, string translatedWords)
+                       string englishWords, string translatedWords,
+                       bool debug)
        {
                this.inputData = inputData;
                this.outputGraph = outputGraph;
@@ -182,6 +184,7 @@ public class EncoderGraphROptions
                this.operatingSystem = operatingSystem;
                this.englishWords = englishWords;
                this.translatedWords = translatedWords;
+               this.debug = debug;
        }
 
        public override string ToString() {
@@ -195,7 +198,8 @@ public class EncoderGraphROptions
                        "#title\n" +            title + "\n" + 
                        "#operatingsystem\n" +  operatingSystem + "\n" +
                        "#englishWords\n" +     englishWords + "\n" +
-                       "#translatedWords\n" +  translatedWords + "\n";
+                       "#translatedWords\n" +  translatedWords + "\n" +
+                       "#debug\n" +            Util.BoolToRBool(debug) + "\n";
        }
        
 
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index 04b408f..ecd8537 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -30,6 +30,7 @@ public abstract class EncoderRProc
 
        public enum Status { WAITING, RUNNING, DONE } 
        public Status status;
+       public bool Debug = false;
 
        protected string optionsFile;   
        protected EncoderStruct es;
@@ -307,7 +308,8 @@ public class EncoderRProcCapture : EncoderRProc
                                "none",         //title
                                es, 
                                false,  //neuromuscularProfile
-                               false   //translate (graphs)
+                               false,  //translate (graphs)
+                               Debug
                                ).ToString();
 
                TextWriter writer = File.CreateText(optionsFile);
@@ -541,7 +543,8 @@ public class EncoderRProcAnalyze : EncoderRProc
                                title,
                                es, 
                                neuromuscularProfileDo,
-                               translate
+                               translate,
+                               Debug
                                ).ToString();
 
                TextWriter writer = File.CreateText(optionsFile);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 26b15f8..3b6028a 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -463,6 +463,8 @@ public partial class ChronoJumpWindow
 
        private bool normalGUI; //false means small gui
 
+       private bool debugMode; //currently only for encoder R
+
        //int chronopicCancelledTimes = 0;
 
 
@@ -6273,6 +6275,13 @@ LogB.Debug("X");
        }
 
        // <---- end SQL stress tests ----
+       
+       private void on_menuitem_debug_mode_activate (object o, EventArgs args) {
+               encoderRProcCapture.Debug = true;
+               encoderRProcAnalyze.Debug = true;
+                       
+               new DialogMessage(Constants.MessageTypes.INFO, "Activated debug mode while Chronojump is 
running.");
+       }
 
 
        private void on_about1_activate (object o, EventArgs args) {
diff --git a/src/util.cs b/src/util.cs
index 1df50a9..1f87d63 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1496,6 +1496,13 @@ public class Util
                else
                        return 0;
        }
+       
+       public static string BoolToRBool (bool myBool) {
+               if(myBool)
+                       return "TRUE";
+               else
+                       return "FALSE";
+       }
 
        //used by simulated, since cj 0.8.1.2, db: 0.60
        //-1 simulated test
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index d7529e9..20c97b8 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -295,7 +295,7 @@ public class UtilEncoder
        }
        */
        
-       public static EncoderGraphROptions PrepareEncoderGraphOptions(string title, EncoderStruct es, bool 
neuromuscularProfileDo, bool translate) 
+       public static EncoderGraphROptions PrepareEncoderGraphOptions(string title, EncoderStruct es, bool 
neuromuscularProfileDo, bool translate, bool debug) 
        {
                string operatingSystem = "Linux";
                        
@@ -350,7 +350,9 @@ public class UtilEncoder
                                es.Ep,
                                title, operatingSystem,
                                Util.StringArrayToString(Constants.EncoderEnglishWords,";"),
-                               Util.StringArrayToString(encoderTranslatedWordsOK,";"));
+                               Util.StringArrayToString(encoderTranslatedWordsOK,";"),
+                               debug
+                               );
        }
 
 


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