[chronojump] Encoder: capture showing diff variables, start ok
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: capture showing diff variables, start ok
- Date: Fri, 7 Dec 2012 11:40:05 +0000 (UTC)
commit 8116e3533961592d7b6d3ca3fe74292f49254e1a
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Dec 7 12:36:23 2012 +0100
Encoder: capture showing diff variables, start ok
encoder/pyserial_pyper.py | 74 +++++++++++++-------
glade/chronojump.glade | 145 +++++++++++++++++++++++++++++++++++++--
src/encoder.cs | 8 ++-
src/gui/encoder.cs | 3 +-
src/gui/repetitiveConditions.cs | 28 +++++++-
5 files changed, 222 insertions(+), 36 deletions(-)
---
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index aaac3ac..55620b6 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -46,7 +46,7 @@ TRUE = 1
title = sys.argv[1]
outputFile = sys.argv[2]
record_time = int(sys.argv[3])*1000 #from s to ms
-minHeight = int(sys.argv[4]) #all is stored, but only display when vertical range is >= minHeight
+minRange = int(sys.argv[4]) #all is stored, but only display when vertical range is >= minRange
isJump = sys.argv[5]
mass = float(sys.argv[6])
smoothingOne = float(sys.argv[7])
@@ -61,6 +61,7 @@ powerHigherCondition = int(sys.argv[15])
powerLowerCondition = int(sys.argv[16])
peakPowerHigherCondition = int(sys.argv[17])
peakPowerLowerCondition = int(sys.argv[18])
+mainVariable = sys.argv[19]
delete_initial_time = 20 #delete first records because there's encoder bug
#w_baudrate = 9600 # Setting the baudrate of Chronopic(9600)
@@ -141,8 +142,11 @@ def assignColor(found, conditionHigher, conditionLower):
return BLACK
rangeList = list()
+meanSpeedList = list()
+maxSpeedList = list()
meanPowerList = list()
-def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothingOne, eccon, minHeight, isJump):
+peakPowerList = list()
+def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothingOne, eccon, minRange, isJump):
if (len(top_values)>0 and len(bottom_values)>0):
if direction_now == 1:
start=top_values[len(top_values)-1]
@@ -235,14 +239,17 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
soundFile = soundFileGood
if eccon == "ec" or direction_now == -1:
- if height >= minHeight:
+ if height >= minRange:
#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
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
if play:
playsound(soundFile)
rangeList.append(height)
+ meanSpeedList.append(meanSpeed)
+ maxSpeedList.append(maxSpeed)
meanPowerList.append(meanPower)
+ peakPowerList.append(peakPower)
graphsWidth = 792 #800-4-4
hasRightMargin = True
@@ -253,14 +260,27 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
update_graph("Range (cm)", rangeList,
heightLowerCondition, heightHigherCondition, hasRightMargin,
- graphsWidth, 112, (222,222,222), 4, 40)
+ graphsWidth, 112, (222,222,222), 4, 40, False)
#vertical_height: 112, position it at 40 pixels vert
- update_graph("Mean Power (W)", meanPowerList,
- powerLowerCondition, powerHigherCondition, hasRightMargin,
- graphsWidth, 440, (222,222,222), 4, 156)
#position it at 40+112+4 pixels vert: 156
#vertical_height: 600 -4 (lower sep) - 156 : 440
+ if mainVariable == "meanSpeed":
+ update_graph("Mean Speed (m/s)", meanSpeedList,
+ meanSpeedLowerCondition, meanSpeedHigherCondition, hasRightMargin,
+ graphsWidth, 440, (222,222,222), 4, 156, True)
+ elif mainVariable == "maxSpeed":
+ update_graph("Max Speed (m/s)", maxSpeedList,
+ maxSpeedLowerCondition, maxSpeedHigherCondition, hasRightMargin,
+ graphsWidth, 440, (222,222,222), 4, 156, True)
+ elif mainVariable == "meanPower":
+ update_graph("Mean Power (W)", meanPowerList,
+ powerLowerCondition, powerHigherCondition, hasRightMargin,
+ graphsWidth, 440, (222,222,222), 4, 156, False)
+ else: #mainVariable == "peakPower"
+ update_graph("Peak Power (W)", peakPowerList,
+ peakPowerLowerCondition, peakPowerHigherCondition, hasRightMargin,
+ graphsWidth, 440, (222,222,222), 4, 156, False)
else:
print chr(27) + "[0;47m" + phase + "%6i," % height + " " + "Discarded" + chr(27)+"[0m"
@@ -282,7 +302,7 @@ def calculate_range(temp_cumsum, top_values, bottom_values, direction_now):
def update_graph(paramName, paramList, lowCondition, highCondition, hasRightMargin,
- my_surface_width, my_surface_height, color, horizPosToCopy, vertPosToCopy):
+ my_surface_width, my_surface_height, color, horizPosToCopy, vertPosToCopy, hasDecimals):
s=pygame.Surface((my_surface_width,my_surface_height))
s.fill(ColorBackground) #color the surface
@@ -338,7 +358,11 @@ def update_graph(paramName, paramList, lowCondition, highCondition, hasRightMarg
param_width = width - sep
pygame.draw.rect(s, colorNow, (left, my_surface_height, param_width, -param_height), 0) #0: filled
- string = "%i" % param
+ if hasDecimals:
+ string = "%.2f" % param
+ else:
+ string = "%i" % param
+
text = FontBig.render(string,1,color, ColorBackground)
if len(paramList) > 20:
text = FontSmall.render(string,1,color, ColorBackground)
@@ -407,21 +431,6 @@ if __name__ == '__main__':
myR.run('weight=mass*9.81')
myR.assign('k',2)
- file = open(outputFile, 'w')
-
- ser = serial.Serial(w_serial_port)
- ser.baudrate = w_baudrate
- temp = list() #raw values
- temp_cumsum = list() #cumulative sums of raw values
- temp_cumsum.append(0)
- temp_speed = list()
- w_time = datetime.now().second
- #print "start read data"
- # Detecting if serial port is available and Recording the data from Chronopic.
- for i in xrange(delete_initial_time):
- #if ser.readable(): #commented because don't work on linux
- ser.read()
-
print("START!\n")
playsound(soundFileStart)
print("phase, range, meanSpeed, MaxSpeed, meanPower, PeakPower, PeakPowerT")#, PPower/PPT")
@@ -439,6 +448,21 @@ if __name__ == '__main__':
ColorBad = (255,0,0)
ColorGood = (0,255,0)
+ #start capture
+ file = open(outputFile, 'w')
+ ser = serial.Serial(w_serial_port)
+ ser.baudrate = w_baudrate
+ temp = list() #raw values
+ temp_cumsum = list() #cumulative sums of raw values
+ temp_cumsum.append(0)
+ temp_speed = list()
+ w_time = datetime.now().second
+ #print "start read data"
+ # Detecting if serial port is available and Recording the data from Chronopic.
+ for i in xrange(delete_initial_time):
+ #if ser.readable(): #commented because don't work on linux
+ ser.read()
+
#print title
title = title.replace('_',' ')
title = title.replace('-',' ')
@@ -507,7 +531,7 @@ if __name__ == '__main__':
if len(frames_pull_top1)>0 and len(frames_push_bottom1)>0:
calculate_all_in_r(temp, frames_pull_top1, frames_push_bottom1,
- direction_now, smoothingOne, eccon, minHeight, isJump)
+ direction_now, smoothingOne, eccon, minRange, isJump)
file.write(''+','.join([str(i) for i in temp[
previous_frame_change:new_frame_change
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 2d5fd9b..76263e3 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -18090,9 +18090,6 @@ comments</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkHButtonBox" id="hbuttonbox37">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -18597,6 +18594,9 @@ comments</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25432,6 +25432,139 @@ show elevation as:</property>
</packing>
</child>
<child>
+ <widget class="GtkFrame" id="frame_encoder_capture_variables">
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">out</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">10</property>
+ <property name="bottom_padding">10</property>
+ <property name="left_padding">10</property>
+ <property name="right_padding">10</property>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkCheckButton" id="checkbutton1">
+ <property name="label" translatable="yes">Range of movement</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">4</property>
+ <property name="row_spacing">4</property>
+ <child>
+ <widget class="GtkRadioButton" id="radio_mean_speed">
+ <property name="label" translatable="yes">Mean speed</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_max_speed">
+ <property name="label" translatable="yes">Max speed</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radio_mean_speed</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_mean_power">
+ <property name="label" translatable="yes">Mean power</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radio_mean_speed</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_peak_power">
+ <property name="label" translatable="yes">Peak power</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radio_mean_speed</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label27">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Display variables on encoder capture</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -27507,7 +27640,7 @@ show elevation as:</property>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -27644,7 +27777,7 @@ show elevation as:</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -27672,7 +27805,7 @@ show elevation as:</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</widget>
diff --git a/src/encoder.cs b/src/encoder.cs
index dd9d9e9..7acd6eb 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -48,6 +48,7 @@ public class EncoderParams
private int powerLowerCondition;
private int peakPowerHigherCondition;
private int peakPowerLowerCondition;
+ private string mainVariable;
public EncoderParams()
{
@@ -59,7 +60,8 @@ public class EncoderParams
double meanSpeedHigherCondition, double meanSpeedLowerCondition,
double maxSpeedHigherCondition, double maxSpeedLowerCondition,
int powerHigherCondition, int powerLowerCondition,
- int peakPowerHigherCondition, int peakPowerLowerCondition)
+ int peakPowerHigherCondition, int peakPowerLowerCondition,
+ string mainVariable)
{
this.time = time;
this.minHeight = minHeight;
@@ -77,6 +79,7 @@ public class EncoderParams
this.powerLowerCondition = powerLowerCondition;
this.peakPowerHigherCondition = peakPowerHigherCondition;
this.peakPowerLowerCondition = peakPowerLowerCondition;
+ this.mainVariable = mainVariable;
}
public string ToString1 ()
@@ -89,7 +92,8 @@ public class EncoderParams
" " + Util.ConvertToPoint(maxSpeedHigherCondition.ToString()) +
" " + Util.ConvertToPoint(maxSpeedLowerCondition.ToString()) +
" " + powerHigherCondition.ToString() + " " + powerLowerCondition.ToString() +
- " " + peakPowerHigherCondition.ToString() + " " + peakPowerLowerCondition.ToString();
+ " " + peakPowerHigherCondition.ToString() + " " + peakPowerLowerCondition.ToString() +
+ " " + mainVariable;
}
//to graph.R
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index ebcee6a..a4e605f 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -218,7 +218,8 @@ public partial class ChronoJumpWindow
meanSpeedHigherCondition, meanSpeedLowerCondition,
maxSpeedHigherCondition, maxSpeedLowerCondition,
powerHigherCondition, powerLowerCondition,
- peakPowerHigherCondition, peakPowerLowerCondition
+ peakPowerHigherCondition, peakPowerLowerCondition,
+ repetitiveConditionsWin.EncoderMainVariable
);
EncoderStruct es = new EncoderStruct(
diff --git a/src/gui/repetitiveConditions.cs b/src/gui/repetitiveConditions.cs
index 0b1ce42..0cb4e63 100644
--- a/src/gui/repetitiveConditions.cs
+++ b/src/gui/repetitiveConditions.cs
@@ -64,6 +64,11 @@ public class RepetitiveConditionsWindow
[Widget] Gtk.SpinButton spinbutton_time_lower;
/* encoder */
+ [Widget] Gtk.Frame frame_encoder_capture_variables;
+ [Widget] Gtk.RadioButton radio_mean_speed;
+ [Widget] Gtk.RadioButton radio_max_speed;
+ [Widget] Gtk.RadioButton radio_mean_power;
+ [Widget] Gtk.RadioButton radio_peak_power;
[Widget] Gtk.Box hbox_encoder_conditions;
[Widget] Gtk.CheckButton checkbutton_encoder_height_higher;
[Widget] Gtk.CheckButton checkbutton_encoder_mean_speed_higher;
@@ -142,6 +147,7 @@ public class RepetitiveConditionsWindow
FakeButtonClose = new Gtk.Button();
putNonStandardIcons();
+ assignDefaultActionsEncoder();
}
static public RepetitiveConditionsWindow Create ()
@@ -174,6 +180,7 @@ public class RepetitiveConditionsWindow
hbox_run_best_worst.Hide();
hbox_jump_conditions.Hide();
hbox_run_conditions.Hide();
+ frame_encoder_capture_variables.Hide();
hbox_encoder_conditions.Hide();
if(bellMode == Constants.BellModes.JUMPS) {
@@ -185,6 +192,7 @@ public class RepetitiveConditionsWindow
hbox_run_best_worst.Show();
hbox_run_conditions.Show();
} else { //encoder
+ frame_encoder_capture_variables.Show();
hbox_encoder_conditions.Show();
}
}
@@ -219,6 +227,10 @@ public class RepetitiveConditionsWindow
image_encoder_peakpower_lower.Pixbuf = pixbuf;
image_repetitive_test_bad.Pixbuf = pixbuf;
}
+
+ void assignDefaultActionsEncoder() {
+ radio_mean_power.Active = true;
+ }
void on_button_test_clicked (object o, EventArgs args)
{
@@ -241,8 +253,11 @@ public class RepetitiveConditionsWindow
void on_delete_event (object o, DeleteEventArgs args)
{
- RepetitiveConditionsWindowBox.repetitive_conditions.Hide();
- RepetitiveConditionsWindowBox = null;
+ //RepetitiveConditionsWindowBox.repetitive_conditions.Hide();
+ //RepetitiveConditionsWindowBox = null;
+
+ button_close.Click();
+ args.RetVal = true;
}
public bool VolumeOn {
@@ -391,6 +406,15 @@ public class RepetitiveConditionsWindow
}
/* ENCODER */
+ public string EncoderMainVariable {
+ get {
+ if(radio_mean_speed.Active) return "meanSpeed";
+ else if(radio_max_speed.Active) return "maxSpeed";
+ else if(radio_mean_power.Active) return "meanPower";
+ else return "peakPower";
+ }
+ }
+
public bool EncoderHeightHigher {
get { return checkbutton_encoder_height_higher.Active; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]