[chronojump] encoder added curve buttons & pp/ppt
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] encoder added curve buttons & pp/ppt
- Date: Fri, 25 May 2012 09:10:29 +0000 (UTC)
commit 73709fccb49219640d4ec0cc3abeb54896584139
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri May 25 02:13:54 2012 +0200
encoder added curve buttons & pp/ppt
encoder/graph.R | 10 +--
encoder/pyserial_pyper.py | 5 +-
glade/chronojump.glade | 210 +++++++++++++++++++++------------------------
src/encoder.cs | 4 +-
src/gui/chronojump.cs | 1 -
src/gui/encoder.cs | 66 ++++++++++-----
6 files changed, 150 insertions(+), 146 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 1ab0116..59bb08a 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -125,7 +125,8 @@ powerBars <- function(kinematics) {
meanPower <- mean(abs(kinematics$power))
peakPower <- max(kinematics$power)
peakPowerT <- min(which(kinematics$power == peakPower))
- return(data.frame(meanSpeed, maxSpeed, meanPower,peakPower,peakPowerT))
+ pp_ppt <- peakPower / (peakPowerT/1000) # ms->s
+ return(data.frame(meanSpeed, maxSpeed, meanPower,peakPower,peakPowerT,pp_ppt))
}
kinematicRanges <- function(rawdata,curves,mass,g) {
@@ -423,10 +424,6 @@ if(length(args) < 3) {
curvesPlot = FALSE
if(analysis=="curves") {
- #on curves ec, show eccentric-concentric phases separately
-# if(eccon=="ec") {
-# eccon="ecS"
-# }
curvesPlot = TRUE
par(mar=c(2,2.5,1,1))
}
@@ -515,7 +512,8 @@ if(length(args) < 3) {
}
if(analysis=="curves") {
paf=cbind(curves[,2]-curves[,1],rawdata.cumsum[curves[,2]]-curves[,3],paf)
- colnames(paf)=c("width","height","meanSpeed","maxSpeed","meanPower","peakPower","peakPowerT")
+ colnames(paf)=c("width","height","meanSpeed","maxSpeed",
+ "meanPower","peakPower","peakPowerT","pp_ppt")
write.csv(paf, outputData1, quote=FALSE)
}
}
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index 4cf21b3..c2611c3 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -199,6 +199,7 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
meanPower = myR.get('meanPower')
peakPower = myR.get('peakPower')
peakPowerT = myR.get('peakPowerT/1000') #ms -> s
+ pp_ppt = peakPower / peakPowerT
meanSpeedCol = "%10.2f," % meanSpeed
@@ -234,7 +235,7 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
if eccon == "ec" or direction_now == -1:
if height >= minHeight:
- print phaseCol + colorize(heightF,colorHeight,colorHeight!=BLACK) + colorize(meanSpeedF,colorMeanSpeed,colorMeanSpeed!=BLACK) + colorize(maxSpeedF,colorMaxSpeed,colorMaxSpeed!=BLACK) + colorize(meanPowerF,colorMeanPower,colorMeanPower!=BLACK) + colorize(peakPowerF,colorPeakPower,colorPeakPower!=BLACK) + "%10.2f" % peakPowerT
+ print phaseCol + colorize(heightF,colorHeight,colorHeight!=BLACK) + colorize(meanSpeedF,colorMeanSpeed,colorMeanSpeed!=BLACK) + colorize(maxSpeedF,colorMaxSpeed,colorMaxSpeed!=BLACK) + colorize(meanPowerF,colorMeanPower,colorMeanPower!=BLACK) + colorize(peakPowerF,colorPeakPower,colorPeakPower!=BLACK) + "%10.2f" % peakPowerT + "%10.2f" % pp_ppt
if play:
playsound(soundFile)
else:
@@ -301,7 +302,7 @@ if __name__ == '__main__':
print("START!\n")
playsound(soundFileStart)
- print("phase, range, meanSpeed, maxSpeed, meanPower, peakPower, peakPowerT")
+ print("phase, range, meanSpeed, maxSpeed, meanPower, peakPower, peakPowerT, peakPower/ppt")
for i in xrange(record_time):
#if ser.readable(): #commented because don't work on linux
byte_data = ser.read()
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7c985ba..8db58c5 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -24432,51 +24432,42 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox73">
+ <widget class="GtkHButtonBox" id="hbuttonbox9">
<property name="visible">True</property>
- <property name="spacing">10</property>
+ <property name="layout_style">spread</property>
<child>
- <widget class="GtkHButtonBox" id="hbuttonbox9">
+ <widget class="GtkButton" id="button_encoder_capture">
+ <property name="label" translatable="yes">Capture from encoder</property>
<property name="visible">True</property>
- <property name="layout_style">spread</property>
- <child>
- <widget class="GtkButton" id="button_encoder_capture">
- <property name="label" translatable="yes">Capture from encoder</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_button_encoder_capture_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="button_encoder_recalculate">
- <property name="label" translatable="yes">Recalculate</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_button_encoder_recalculate_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_button_encoder_capture_clicked"/>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
+ <widget class="GtkButton" id="button_encoder_recalculate">
+ <property name="label" translatable="yes">Recalculate</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_button_encoder_recalculate_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkProgressBar" id="encoder_pulsebar_capture">
<property name="visible">True</property>
<property name="activity_mode">True</property>
@@ -24485,46 +24476,21 @@ Evaluator can use real name or nickname.</property>
</widget>
<packing>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
- <widget class="GtkHButtonBox" id="hbuttonbox10">
+ <widget class="GtkButton" id="button_encoder_load_stream">
+ <property name="label">Load stream</property>
<property name="visible">True</property>
- <property name="layout_style">spread</property>
- <child>
- <widget class="GtkButton" id="button_encoder_save">
- <property name="label">gtk-save</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_button_encoder_save_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="button_encoder_load">
- <property name="label">gtk-open</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_button_encoder_load_clicked"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_button_encoder_load_stream_clicked"/>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
@@ -24542,22 +24508,48 @@ Evaluator can use real name or nickname.</property>
<child>
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
- <property name="homogeneous">True</property>
+ <property name="spacing">4</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="width_request">200</property>
+ <widget class="GtkVBox" id="vbox41">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">etched-in</property>
+ <property name="spacing">4</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <widget class="GtkViewport" id="viewport_image_encoder_capture">
+ <property name="visible">True</property>
+ <property name="resize_mode">queue</property>
+ <child>
+ <widget class="GtkImage" id="image_encoder_capture">
+ <property name="visible">True</property>
+ <property name="stock">gtk-missing-image</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
- <widget class="GtkTreeView" id="treeview_encoder_curves">
+ <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="width_request">200</property>
+ <property name="height_request">175</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="rules_hint">True</property>
- <property name="enable_search">False</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview_encoder_curves">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="rules_hint">True</property>
+ <property name="enable_search">False</property>
+ </widget>
+ </child>
</widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</widget>
<packing>
@@ -24565,78 +24557,68 @@ Evaluator can use real name or nickname.</property>
</packing>
</child>
<child>
- <widget class="GtkHBox" id="hbox63">
+ <widget class="GtkHBox" id="hbox78">
<property name="visible">True</property>
+ <property name="spacing">20</property>
<child>
- <widget class="GtkViewport" id="viewport_image_encoder_capture">
+ <widget class="GtkButton" id="button_encoder_delete_selected">
+ <property name="label">Delete selected row</property>
<property name="visible">True</property>
- <property name="resize_mode">queue</property>
- <child>
- <widget class="GtkImage" id="image_encoder_capture">
- <property name="visible">True</property>
- <property name="stock">gtk-missing-image</property>
- </widget>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_button_encoder_delete_selected_clicked"/>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox41">
+ <widget class="GtkHBox" id="hbox80">
<property name="visible">True</property>
+ <property name="spacing">12</property>
<child>
- <placeholder/>
- </child>
- <child>
- <widget class="GtkButton" id="button_encoder_capture_zoom">
+ <widget class="GtkButton" id="button_encoder_save_selected">
+ <property name="label">Save selected row</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <accelerator key="z" signal="clicked"/>
- <child>
- <widget class="GtkImage" id="image_encoder_capture_zoom">
- <property name="visible">True</property>
- </widget>
- </child>
+ <signal name="clicked" handler="on_button_encoder_save_selected_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">2</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkButton" id="button_encoder_capture_properties">
+ <widget class="GtkButton" id="button_encoder_save_stream">
+ <property name="label">Save stream</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip" translatable="yes">Properties</property>
- <child>
- <widget class="GtkImage" id="image4">
- <property name="visible">True</property>
- <property name="stock">gtk-properties</property>
- <property name="icon-size">2</property>
- </widget>
- </child>
+ <signal name="clicked" handler="on_button_encoder_save_stream_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
- <property name="pack_type">end</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index 0cdb987..8240cff 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -142,7 +142,7 @@ public class EncoderStruct
public class EncoderCurve
{
public EncoderCurve (string n, string width, string height, string meanSpeed, string maxSpeed,
- string meanPower, string peakPower, string peakPowerT)
+ string meanPower, string peakPower, string peakPowerT, string PP_PPT)
{
this.N = n;
this.Width = width;
@@ -152,6 +152,7 @@ public class EncoderCurve
this.MeanPower = meanPower;
this.PeakPower = peakPower;
this.PeakPowerT = peakPowerT;
+ this.PP_PPT = PP_PPT; //PeakPower / PeakPowerTime
}
public string N;
@@ -162,5 +163,6 @@ public class EncoderCurve
public string MeanPower;
public string PeakPower;
public string PeakPowerT;
+ public string PP_PPT;
}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 2c53a3b..b2ef807 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -726,7 +726,6 @@ public partial class ChronoJumpWindow
//encoder
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomInIcon);
- image_encoder_capture_zoom.Pixbuf = pixbuf;
image_encoder_analyze_zoom.Pixbuf = pixbuf;
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 5a340cf..579d347 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -221,18 +221,32 @@ public partial class ChronoJumpWindow
Util.RunPythonEncoder(Constants.EncoderScriptGraphCall, es,false);
}
+ void on_button_encoder_load_stream_clicked (object o, EventArgs args)
+ {
+ Log.WriteLine("TODO: Load stream");
+ }
+
+ void on_button_encoder_delete_selected_clicked (object o, EventArgs args)
+ {
+ Log.WriteLine("TODO: Delete selected");
+ }
- void on_button_encoder_save_clicked (object o, EventArgs args)
+ void on_button_encoder_save_selected_clicked (object o, EventArgs args)
+ {
+ Log.WriteLine("TODO: Save selected");
+ }
+
+ void on_button_encoder_save_stream_clicked (object o, EventArgs args)
{
genericWinForEncoder = GenericWindow.Show(Catalog.GetString("Add an optional description"), Constants.GenericWindowShow.TEXTVIEW);
genericWinForEncoder.SetTextview("");
genericWinForEncoder.SetButtonAcceptLabel(Catalog.GetString("Save"));
- genericWinForEncoder.Button_accept.Clicked += new EventHandler(on_save_description_add_accepted);
+ genericWinForEncoder.Button_accept.Clicked += new EventHandler(on_save_stream_description_add_accepted);
}
- private void on_save_description_add_accepted (object o, EventArgs args) {
- genericWinForEncoder.Button_accept.Clicked -= new EventHandler(on_save_description_add_accepted);
+ private void on_save_stream_description_add_accepted (object o, EventArgs args) {
+ genericWinForEncoder.Button_accept.Clicked -= new EventHandler(on_save_stream_description_add_accepted);
string desc = genericWinForEncoder.TextviewSelected;
Log.WriteLine(desc);
@@ -257,10 +271,6 @@ public partial class ChronoJumpWindow
encoder_pulsebar_capture.Text = Catalog.GetString("Saved.");
}
- void on_button_encoder_load_clicked (object o, EventArgs args)
- {
- }
-
//TODO: garantir path windows
private void on_button_encoder_analyze_clicked (object o, EventArgs args)
@@ -362,13 +372,14 @@ public partial class ChronoJumpWindow
private int createTreeViewEncoder(string contents) {
string [] columnsString = {
"n",
- Catalog.GetString("Duration") + " (s)",
- Catalog.GetString("Height") + " (cm)",
- Catalog.GetString("MeanSpeed") + " (m/s)",
- Catalog.GetString("MaxSpeed") + " (m/s)", //duration (s): width
- Catalog.GetString("MeanPower") + " (W)",
- Catalog.GetString("PeakPower") + " (W)",
- Catalog.GetString("PeakPowerTime") + " (s)"
+ Catalog.GetString("Duration") + "\n (s)",
+ Catalog.GetString("Height") + "\n (cm)",
+ Catalog.GetString("MeanSpeed") + "\n (m/s)",
+ Catalog.GetString("MaxSpeed") + "\n (m/s)", //duration (s): width
+ Catalog.GetString("MeanPower") + "\n (W)",
+ Catalog.GetString("PeakPower") + "\n (W)",
+ Catalog.GetString("PeakPowerTime") + "\n (s)",
+ Catalog.GetString("PeakPower/PPT") + "\n (W/s)"
};
@@ -392,7 +403,7 @@ public partial class ChronoJumpWindow
//iter = encoderStore.AppendValues(cells);
encoderCurves.Add (new EncoderCurve (cells[0], cells[1], cells[2],
- cells[3], cells[4], cells[5], cells[6],cells[7]));
+ cells[3], cells[4], cells[5], cells[6], cells[7], cells[8]));
} while(true);
}
@@ -441,6 +452,9 @@ public partial class ChronoJumpWindow
case 7:
aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc (RenderPeakPowerT));
break;
+ case 8:
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc (RenderPP_PPT));
+ break;
}
@@ -496,7 +510,7 @@ public partial class ChronoJumpWindow
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
double myWidth = Convert.ToDouble(curve.Width)/1000; //ms->s
(cell as Gtk.CellRendererText).Text =
- String.Format(UtilGtk.TVNumPrint(myWidth.ToString(),8,3),myWidth);
+ String.Format(UtilGtk.TVNumPrint(myWidth.ToString(),6,3),myWidth);
}
private void RenderHeight (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
{
@@ -514,7 +528,7 @@ public partial class ChronoJumpWindow
(cell as Gtk.CellRendererText).Foreground = null; //will show default color
(cell as Gtk.CellRendererText).Text =
- String.Format(UtilGtk.TVNumPrint(heightToCm,8,1),Convert.ToDouble(heightToCm));
+ String.Format(UtilGtk.TVNumPrint(heightToCm,6,1),Convert.ToDouble(heightToCm));
}
private void RenderMeanSpeed (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
@@ -533,7 +547,7 @@ public partial class ChronoJumpWindow
//no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
(cell as Gtk.CellRendererText).Text =
- String.Format("{0,12:0.000}",Convert.ToDouble(curve.MeanSpeed));
+ String.Format("{0,10:0.000}",Convert.ToDouble(curve.MeanSpeed));
}
private void RenderMaxSpeed (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
@@ -552,7 +566,7 @@ public partial class ChronoJumpWindow
//no need of UtilGtk.TVNumPrint, always has 1 digit on left of decimal
(cell as Gtk.CellRendererText).Text =
- String.Format("{0,12:0.000}",Convert.ToDouble(curve.MaxSpeed));
+ String.Format("{0,10:0.000}",Convert.ToDouble(curve.MaxSpeed));
}
private void RenderMeanPower (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
@@ -596,7 +610,14 @@ public partial class ChronoJumpWindow
EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
double myPPT = Convert.ToDouble(curve.PeakPowerT)/1000; //ms->s
(cell as Gtk.CellRendererText).Text =
- String.Format(UtilGtk.TVNumPrint(myPPT.ToString(),8,3),myPPT);
+ String.Format(UtilGtk.TVNumPrint(myPPT.ToString(),7,3),myPPT);
+ }
+
+ private void RenderPP_PPT (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
+ {
+ EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererText).Text =
+ String.Format(UtilGtk.TVNumPrint(curve.PP_PPT,6,1),curve.PP_PPT);
}
/* end of rendering cols */
@@ -605,8 +626,9 @@ public partial class ChronoJumpWindow
private string [] fixDecimals(string [] cells) {
for(int i=1; i <= 2; i++)
cells[i] = Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),1);
- for(int i=3; i <= 6; i++)
+ for(int i=3; i <= 7; i++)
cells[i] = Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[i])),3);
+ cells[8] = Util.TrimDecimals(Convert.ToDouble(Util.ChangeDecimalSeparator(cells[8])),1); //pp/ppt
return cells;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]