[chronojump] Using new findCurves. Also important fixes on ec when ends on e
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Using new findCurves. Also important fixes on ec when ends on e
- Date: Thu, 7 May 2015 17:57:50 +0000 (UTC)
commit 3ab8020e4aa5d023f0b59b989d3ef69908e40cd3
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 7 19:56:51 2015 +0200
Using new findCurves. Also important fixes on ec when ends on e
encoder/graph.R | 47 ++++++++++++++++++++++++++++++++++++++----
encoder/util.R | 5 ++-
src/gui/encoderTreeviews.cs | 13 +++++++++++
src/util.cs | 7 ++++++
4 files changed, 65 insertions(+), 7 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 9d9bb7a..792970d 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -246,7 +246,7 @@ findCurvesNew <- function(displacement, eccon, min_height, draw, title)
heightAccumulated = heightAccumulated + heightCurve
heightCurve = abs(heightCurve) #mm -> cm
-
+
sendCurve = TRUE
if(heightCurve >= min_height) {
@@ -256,6 +256,8 @@ findCurvesNew <- function(displacement, eccon, min_height, draw, title)
sendCurve = FALSE
if( (eccon == "ec" || eccon == "ecS") && previousWasUp &&
capturingFirstPhase )
sendCurve = FALSE
+
+ capturingFirstPhase = FALSE
} else {
sendCurve = FALSE
}
@@ -277,6 +279,36 @@ findCurvesNew <- function(displacement, eccon, min_height, draw, title)
count = count +1
}
+ #if eccon it's 'ec' and last row it's 'e', delete it
+ if(count > 1 && ( position[startCurrent] > position[endCurrent] ) )
+ {
+ write("deleting last ecc row", stderr())
+ startStored = startStored[-length(startStored)]
+ endStored = endStored[-length(endStored)]
+ startHStored = startHStored[-length(startHStored)]
+
+ }
+
+ #if eccon == "ec" mix 'e' and 'c' curves
+ if(eccon == "ec") {
+ startStoredOld = startStored
+ endStoredOld = endStored
+ startHStoredOld = startHStored
+
+ startStored = NULL
+ endStored = NULL
+ startHStored = NULL
+
+ n=length(startStoredOld)
+ count = 1
+ for(i in seq(1, n, by=2)) {
+ startStored[count] = startStoredOld[i]
+ endStored[count] = endStoredOld[(i+1)]
+ startHStored[count] = startHStoredOld[i]
+ count = count +1
+ }
+ }
+
if(draw) {
lty=1
@@ -451,7 +483,7 @@ findCurvesOld <- function(displacement, eccon, min_height, draw, title) {
findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingOneC) {
smoothings = NULL
n=length(curves[,1])
-
+
#if not "ec" or "ce" just have a value of 0 every curve,
#no problem, this value will not be used
#is just to not make crash other parts of the software like reduceCurveBySpeed
@@ -496,6 +528,7 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
print(unique(concentric))
print("concentric")
print(concentric)
+
speed <- getSpeed(concentric, smoothingOneC)
print("called")
maxSpeedC=max(speed$y)
@@ -504,6 +537,7 @@ findSmoothingsEC <- function(singleFile, displacement, curves, eccon, smoothingO
smoothingOneEC = smoothingOneC
for(j in seq(as.numeric(smoothingOneC),0,by=-.01)) {
print("calling speed 2")
+ write("calling speed 2", stderr())
speed <- getSpeed(eccentric.concentric, j)
print("called")
smoothingOneEC = j
@@ -2150,8 +2184,8 @@ doProcess <- function(options)
#print(c("position",position))
#print(c("displacement",displacement))
- curves=findCurvesOld(displacement, op$Eccon, op$MinHeight, curvesPlot, op$Title)
- #curves=findCurvesNew(displacement, op$Eccon, op$MinHeight, curvesPlot, op$Title)
+ #curves=findCurvesOld(displacement, op$Eccon, op$MinHeight, curvesPlot, op$Title)
+ curves=findCurvesNew(displacement, op$Eccon, op$MinHeight, curvesPlot, op$Title)
if(op$Analysis == "curves")
curvesPlot = TRUE
@@ -2178,11 +2212,14 @@ doProcess <- function(options)
}
}
+ print("curves after reduceCurveBySpeed")
+ print(curves)
+
#find SmoothingsEC
SmoothingsEC = findSmoothingsEC(singleFile, displacement, curves, op$Eccon, op$SmoothingOneC)
print(c("SmoothingsEC:",SmoothingsEC))
- print("curves after reduceCurveBySpeed")
+ print("curves after findSmoothingsEC")
print(curves)
if(curvesPlot) {
diff --git a/encoder/util.R b/encoder/util.R
index 4415ded..f8e4310 100644
--- a/encoder/util.R
+++ b/encoder/util.R
@@ -230,8 +230,6 @@ getMass <- function(mass, gearedDown, angle) {
#used in alls eccons
reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothingOneC)
{
- #print("at reduceCurveBySpeed")
-
#In 1.4.0 and before, we use smoothingOneEC on "ec", "ce"
#but the problem is findSmoothingsEC has problems knowing the smoothingEC when users stays stand up
lot of time before jump.
#is better to reduceCurveBySpeed first in order to remove the not-moving phase
@@ -284,6 +282,9 @@ reduceCurveBySpeed <- function(eccon, row, startT, startH, displacement, smoothi
time1 = min(which(speed$y == max(speed$y)))
time2 = max(which(speed$y == max(speed$y)))
}
+
+ #write("time1, time2",stderr())
+ #write(c(time1,time2),stderr())
#now that times are defined we can work in ABS for all the curves
speed$y=abs(speed$y)
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index 2dda555..c259d46 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -93,6 +93,14 @@ public partial class ChronoJumpWindow
));
}
+ //if last repetition is eccentric (there's no concentric movement after than that)
+ //then delete that curve
+ if(encoderCaptureCurves.Count > 0) {
+ EncoderCurve curve = (EncoderCurve) encoderCaptureCurves[encoderCaptureCurves.Count
-1];
+ if(Convert.ToDouble(curve.Height) < 0) //it's 'e'
+ encoderCaptureCurves = Util.RemoveLastArrayElement(encoderCaptureCurves);
+
+ }
encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve));
@@ -415,6 +423,11 @@ public partial class ChronoJumpWindow
else { // if(eccon == "ecS")
iterPre = iter; //to point at the "e" curve
iterOk = encoderCaptureListStore.IterNext (ref iter);
+
+ //this fixes when there's a 'e' but not a 'c' in last repetition
+ if(! iterOk)
+ break;
+
EncoderCurve curve2 = (EncoderCurve) encoderCaptureListStore.GetValue (iter,
0);
LogB.Information("msCentral, start, end" + msCentral.ToString() + " " +
curve.Start + " " +
diff --git a/src/util.cs b/src/util.cs
index 1f03b2f..c3f22fd 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1340,6 +1340,13 @@ public class Util
return false;
}
+ public static ArrayList RemoveLastArrayElement(ArrayList a) {
+ if(a.Count > 0)
+ a.RemoveAt(a.Count - 1);
+
+ return a;
+ }
+
/*
//delete a row of and arraylist of string[] if the string[0] is the value coming from startsWith
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]