[chronojump] Encoder: pass time & minHeight
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: pass time & minHeight
- Date: Fri, 30 Mar 2012 19:28:41 +0000 (UTC)
commit 31422af6e38ea8afae97303b1679b5a457fcf879
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Mar 31 02:45:24 2012 +0800
Encoder: pass time & minHeight
encoder/call_graph.py | 14 ++++++++------
encoder/graph.R | 25 +++++++++++--------------
encoder/pyserial_pyper.py | 16 +++++-----------
glade/chronojump.glade | 2 +-
src/encoder.cs | 14 ++++++++++----
src/gui/encoder.cs | 26 +++++++++++++++++++++-----
6 files changed, 56 insertions(+), 41 deletions(-)
---
diff --git a/encoder/call_graph.py b/encoder/call_graph.py
index 8e1a97c..c6266c2 100644
--- a/encoder/call_graph.py
+++ b/encoder/call_graph.py
@@ -10,12 +10,14 @@ subprocess.Popen([
sys.argv[1], #input data
sys.argv[2], #output graph
sys.argv[3],sys.argv[4], #output data1, output data2
- sys.argv[5], #ep.isJump
- sys.argv[6], #ep.contractionEC
- sys.argv[7], #ep.analysis
- sys.argv[8], #ep.smooth
- sys.argv[9], #ep.curve
- sys.argv[10],sys.argv[11] #ep.width, ep.height
+ sys.argv[5], #ep.minHeight
+ sys.argv[6], #ep.isJump
+ sys.argv[7], #ep.mass
+ sys.argv[8], #ep.contractionEC
+ sys.argv[9], #ep.analysis
+ sys.argv[10], #ep.smooth
+ sys.argv[11], #ep.curve
+ sys.argv[12],sys.argv[13] #ep.width, ep.height
]).wait()
diff --git a/encoder/graph.R b/encoder/graph.R
index 0e5ca36..775b105 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -1,6 +1,4 @@
library("EMD")
-#argv <-commandArgs(TRUE); xmin <- as.numeric(argv[1]); xmax <- as.numeric(argv[2])
-
#this will replace below methods: findPics1ByMinindex, findPics2BySpeed
findCurves <- function(rawdata, eccon, min_height, draw) {
@@ -326,12 +324,8 @@ find.mfrow <- function(n) {
#currently only used "c" and "ec-con". no need of ec-con-rep because c and ec-con are repetitive
eccons=c("c","ec-con","ec-con-rep")
-mass = 79
g = 9.81
smoothingAll= 0.1
-#smoothingOne= 0.7 #good smoothing in ec-con is when speed crosses 0 in lowest and highests points encoder line
-minHeight= 300
-#file="data.txt"; isJump=TRUE
#file="data_falla.txt"; isJump=FALSE #TODO em sembla que falla perque no hi ha cap curve, pq totes son mes petites que minHeight
colSpeed="springgreen3"; colForce="blue2"; colPower="tomato2" #colors
@@ -348,13 +342,15 @@ if(length(args) < 3) {
outputGraph=args[2]
outputData1=args[3]
outputData2=args[4]
- isJump=as.logical(args[5])
- eccon=args[6]
- analysis=args[7]
- smoothingOne=args[8]
- jump=args[9]
- width=as.numeric(args[10])
- height=as.numeric(args[11])
+ minHeight=as.numeric(args[5])*10 #from cm to mm
+ isJump=as.logical(args[6])
+ mass=as.numeric(args[7])
+ eccon=args[8]
+ analysis=args[9]
+ smoothingOne=args[10]
+ jump=args[11]
+ width=as.numeric(args[12])
+ height=as.numeric(args[13])
png(outputGraph, width=width, height=height)
@@ -382,7 +378,8 @@ if(length(args) < 3) {
if(analysis=="single")
if(jump>0)
paint(rawdata, eccon, curves[jump,1],curves[jump,2],"undefined","undefined",FALSE,FALSE,
- 1,curves[jump,3],smoothingOne,mass,paste(analysis,eccon,titleType,jump),TRUE,FALSE,TRUE,TRUE)
+ 1,curves[jump,3],smoothingOne,mass,paste(analysis,eccon,titleType,jump),
+ TRUE,FALSE,TRUE,TRUE)
if(analysis=="side") {
#comparar 6 salts, falta que xlim i ylim sigui el mateix
par(mfrow=find.mfrow(n))
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index e052134..0178d32 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -27,10 +27,10 @@ print(sys.argv)
# ============
# = Variable =
# ============
-#record_time = 10000 # how long do you want to record (ms).
outputFile = sys.argv[1]
-record_time = int(sys.argv[2])
-smoothingOne = float(sys.argv[3])
+record_time = int(sys.argv[2])*1000 #from s to ms
+mass = float(sys.argv[3])
+smoothingOne = float(sys.argv[4])
delete_initial_time = 20 #delete first records because there's encoder bug
#w_baudrate = 9600 # Setting the baudrate of Chronopic(115200)
@@ -104,10 +104,6 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
myR.assign('a',temp[start:end])
myR.run('a.cumsum <- cumsum(a)')
myR.run('range <- abs(a.cumsum[length(a)]-a.cumsum[1])')
-
-#TODO: this spar should be 0.7,configurable, try it
-#then data here and in graph.R will be the same
-
myR.run('speed <- smooth.spline( 1:length(a), a, spar=smoothingOne)')
myR.run('accel <- predict( speed, deriv=1 )')
myR.run('accel$y <- accel$y * 1000') #input data is in mm, conversion to m
@@ -137,9 +133,8 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
if(meanPower > 3500): colPower = REDINV
else: colPower = RED
- print phaseCol + "%6i," % phaseRange + colorize(meanSpeedCol,colSpeed,TRUE) + "%9.2f," % maxSpeed + colorize(meanPowerCol,colPower,TRUE) + "%10.2f," % peakPower + "%11i" % peakPowerT
-# print(phase, "%4i" % phaseRange, "%6.2f" % meanSpeed, "%6.2f" % maxSpeed,
-# "%7.2f" % meanPower, "%8.2f" % peakPower, "%4i" % peakPowerT)
+ print phaseCol + "%6i," % phaseRange + colorize(meanSpeedCol,colSpeed,TRUE) + "%9.2f," % maxSpeed +
+ colorize(meanPowerCol,colPower,TRUE) + "%10.2f," % peakPower + "%11i" % peakPowerT
def calculate_range(temp_cumsum, top_values, bottom_values, direction_now):
@@ -172,7 +167,6 @@ if __name__ == '__main__':
#print "connecting with R"
myR = R()
#myR.run('library("EMD")') #cal per extrema, pero no per splines
- mass = 70
myR.assign('mass',mass)
myR.run('weight=mass*9.81')
myR.assign('k',2)
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index b785ac3..59bb33f 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -23091,7 +23091,7 @@ on current Chronojump version.</property>
<property name="visible">True</property>
<property name="spacing">4</property>
<child>
- <widget class="GtkSpinButton" id="spin_encoder_capture_minimal_height">
+ <widget class="GtkSpinButton" id="spin_encoder_capture_min_height">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
diff --git a/src/encoder.cs b/src/encoder.cs
index f0692d7..0c921b5 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -27,7 +27,9 @@ using Mono.Unix;
public class EncoderParams
{
private int time;
+ private double mass;
+ private int minHeight;
private bool isJump;
private string contractionEC;
private string analysis;
@@ -36,20 +38,24 @@ public class EncoderParams
private int width;
private int height;
- public EncoderParams(int time, string smooth)
+ public EncoderParams(int time, double mass, string smooth)
{
this.time = time;
+ this.mass = mass;
this.smooth = smooth;
}
public string ToString1 ()
{
- return time.ToString() + " " + smooth;
+ return time.ToString() + " " + mass.ToString() + " " + smooth;
}
- public EncoderParams(bool isJump, string contractionEC, string analysis, string smooth, int curve, int width, int height)
+ public EncoderParams(int minHeight, bool isJump, double mass, string contractionEC,
+ string analysis, string smooth, int curve, int width, int height)
{
+ this.minHeight = minHeight;
this.isJump = isJump;
+ this.mass = mass;
this.contractionEC = contractionEC;
this.analysis = analysis;
this.smooth = smooth;
@@ -60,7 +66,7 @@ public class EncoderParams
public string ToString2 ()
{
- return isJump + " " + contractionEC + " " + analysis + " " +
+ return minHeight + " " + isJump + " " + mass + " " + contractionEC + " " + analysis + " " +
smooth + " " + curve + " " + width + " " + height;
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 72b1bce..58224c7 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -35,6 +35,8 @@ public partial class ChronoJumpWindow
[Widget] Gtk.RadioButton radiobutton_encoder_capture_bar;
[Widget] Gtk.Viewport viewport_image_encoder_capture;
[Widget] Gtk.Image image_encoder_bell;
+ [Widget] Gtk.SpinButton spin_encoder_capture_time;
+ [Widget] Gtk.SpinButton spin_encoder_capture_min_height;
[Widget] Gtk.Image image_encoder_capture;
[Widget] Gtk.RadioButton radiobutton_encoder_analyze_powerbars;
@@ -50,9 +52,6 @@ public partial class ChronoJumpWindow
private string encoderEC="c"; //"c" or "ec"
private string encoderAnalysis="powerBars";
-//TODO: pass selected time
-//TODO:pass minimal height
-//
//TODO: on capture only show ups if concentric
//TODO: que el curve no pugui ser mes alt de actual numero de curves, per tant s'ha de retornar algun valor. ha de canviar cada cop que hi ha un capture o recalculate
@@ -73,10 +72,18 @@ public partial class ChronoJumpWindow
{
//TODO: que surti barra de progres de calculando... despres de capturar i boto de cerrar automatico
//TODO: i mostrar valors des de la gui (potser a zona dreta damunt del zoom)
+
+ double mass = 0;
+ if(radiobutton_encoder_capture_bar.Active)
+ mass = spin_encoder_bar_limit.Value;
+ else
+ mass = Convert.ToDouble(label_encoder_person_weight.Text) + spin_encoder_jump_limit.Value;
//capture data
EncoderParams ep = new EncoderParams(
- 4000, Util.ConvertToPoint((double) spin_encoder_analyze_smooth.Value)); //R decimal: '.'
+ (int) spin_encoder_capture_time.Value,
+ mass,
+ Util.ConvertToPoint((double) spin_encoder_analyze_smooth.Value)); //R decimal: '.'
EncoderStruct es = new EncoderStruct(
"", //no data input
@@ -96,7 +103,9 @@ public partial class ChronoJumpWindow
int h = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-2;
ep = new EncoderParams(
+ (int) spin_encoder_capture_min_height.Value,
false, //isJump (1st) is not used in "curves"
+ mass,
encoderEC, "curves",
"0", 0, w, h); //smoothOne, and curve are not used in "curves"
@@ -137,6 +146,12 @@ public partial class ChronoJumpWindow
//TODO: garantir path windows
private void on_button_encoder_analyze_clicked (object o, EventArgs args)
{
+ double mass = 0;
+ if(radiobutton_encoder_capture_bar.Active)
+ mass = spin_encoder_bar_limit.Value;
+ else
+ mass = Convert.ToDouble(label_encoder_person_weight.Text) + spin_encoder_jump_limit.Value;
+
if(radiobutton_encoder_concentric.Active)
encoderEC = "c";
else
@@ -146,7 +161,9 @@ public partial class ChronoJumpWindow
int h = UtilGtk.WidgetHeight(viewport_image_encoder_analyze)-2;
EncoderParams ep = new EncoderParams(
+ (int) spin_encoder_capture_min_height.Value,
!radiobutton_encoder_capture_bar.Active,
+ mass,
encoderEC, encoderAnalysis,
Util.ConvertToPoint((double) spin_encoder_analyze_smooth.Value), //R decimal: '.'
(int) spin_encoder_analyze_curve_num.Value, w, h);
@@ -159,7 +176,6 @@ public partial class ChronoJumpWindow
Util.RunPythonEncoder(Constants.EncoderScriptGraphCall, es, false);
//TODO pensar en si s'ha de fer 1er amb mida petita i despres amb gran (en el zoom), o si es una sola i fa alguna edicio
- //TODO per l'anterior estaria be saber la mida de la image_encoder_analyze i passa-ho al call_graph.py
Pixbuf pixbuf = new Pixbuf (Util.GetEncoderGraphTempFileName()); //from a file
image_encoder_analyze.Pixbuf = pixbuf;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]