[chronojump] Encoder: graph capture improved
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: graph capture improved
- Date: Wed, 21 Nov 2012 12:28:41 +0000 (UTC)
commit 38481d06aeb23e0485cc4ff8203c09f090202acf
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Nov 21 13:27:57 2012 +0100
Encoder: graph capture improved
encoder/pyserial_pyper.py | 48 ++++++++++++++++++++++++++++++++------------
src/gui/encoder.cs | 9 ++++++-
src/util.cs | 7 ++++++
3 files changed, 49 insertions(+), 15 deletions(-)
---
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index 7800448..c7c3ecd 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -244,16 +244,18 @@ def calculate_all_in_r(temp, top_values, bottom_values, direction_now, smoothing
playsound(soundFile)
#screen.fill((0,0,0)) #make redraw background black
+ printTitle("running")
rangeList.append(height)
meanPowerList.append(meanPower)
graphsWidth = 792 #800-4-4
- update_graph("Range", rangeList, heightLowerCondition, heightHigherCondition,
- graphsWidth, 112, (200,200,200), 4, 40)
+ update_graph("Range (cm)", rangeList, heightLowerCondition, heightHigherCondition,
+ graphsWidth, 112, (222,222,222), 4, 40)
#vertical_height: 112, position it at 40 pixels vert
- update_graph("Mean Power", meanPowerList, powerLowerCondition, powerHigherCondition,
- graphsWidth, 440, (255,255,255), 4, 156)
+
+ update_graph("Mean Power (W)", meanPowerList, powerLowerCondition, powerHigherCondition,
+ graphsWidth, 440, (222,222,222), 4, 156)
#position it at 40+112+4 pixels vert: 156
#vertical_height: 600 -4 (lower sep) - 156 : 440
@@ -346,6 +348,29 @@ def update_graph(paramName, paramList, lowCondition, highCondition,
screen.blit(s,(horizPosToCopy,vertPosToCopy)) #render the surface into the rectangle
pygame.display.flip() #update the screen
+def printTitle(option):
+ s=pygame.Surface((792,32))
+ s.fill(ColorBackground) #color the surface
+
+ string = "%s" % title
+ text = FontBig.render(string,1, (255,255,255))
+ textpos = text.get_rect(left=10,centery=14)
+ s.blit(text,textpos)
+
+ if option == "start":
+ string = "Start!"
+ text = FontBig.render(string,1, (255,91,0))
+ textpos = text.get_rect(right=792-10,centery=14)
+ s.blit(text,textpos)
+ elif option == "end":
+ string = "Done! Please close this window."
+ text = FontBig.render(string,1, (255,91,0))
+ textpos = text.get_rect(right=792-10,centery=14)
+ s.blit(text,textpos)
+
+ screen.blit(s,(4,4)) #render the surface into the rectangle
+ pygame.display.flip() #update the screen
+
# ================
# = Main Problem =
@@ -402,15 +427,9 @@ if __name__ == '__main__':
ColorGood = (0,255,0)
#print title
- s=pygame.Surface((792,32))
- s.fill(ColorBackground) #color the surface
- string = "%s" % title
- text = FontBig.render(string,1, (255,255,255))
- textpos = text.get_rect(left=10,centery=14)
- s.blit(text,textpos)
- screen.blit(s,(4,4)) #render the surface into the rectangle
- pygame.display.flip() #update the screen
-
+ title = title.replace('_',' ')
+ title = title.replace('-',' ')
+ printTitle("start")
for i in xrange(record_time):
#if ser.readable(): #commented because don't work on linux
@@ -527,6 +546,9 @@ if __name__ == '__main__':
print "\nDone! Please, close this window."
+ printTitle("end")
+
+
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 40e2c04..ebcee6a 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -203,12 +203,13 @@ public partial class ChronoJumpWindow
if(repetitiveConditionsWin.EncoderPeakPowerLower)
peakPowerLowerCondition = repetitiveConditionsWin.EncoderPeakPowerLowerValue;
+ string exerciseNameShown = UtilGtk.ComboGetActive(combo_encoder_exercise);
//capture data
EncoderParams ep = new EncoderParams(
(int) spin_encoder_capture_time.Value,
(int) spin_encoder_capture_min_height.Value,
Convert.ToInt32(
- Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
+ Util.FindOnArray(':', 2, 3, exerciseNameShown,
encoderExercisesTranslationAndBodyPWeight) ), //ex.percentBodyWeight
findMass(true),
Util.ConvertToPoint((double) spin_encoder_smooth.Value), //R decimal: '.'
@@ -225,7 +226,11 @@ public partial class ChronoJumpWindow
"", //no graph ouptut
Util.GetEncoderDataTempFileName(), "", ep);
- Util.RunPythonEncoder(Constants.EncoderScriptCapture, "my_title___without_spaces", es, true);
+ //title to sen to python software has to be without spaces
+ Util.RunPythonEncoder(Constants.EncoderScriptCapture,
+ Util.ChangeSpaceForUnderscore(currentPerson.Name) + "----" +
+ Util.ChangeSpaceForUnderscore(exerciseNameShown) + "----(" + findMass(true) + "Kg)",
+ es, true);
encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
encoderSignalUniqueID = "-1"; //mark to know that there's no ID for this until it's saved on database
diff --git a/src/util.cs b/src/util.cs
index 08c66d4..b35622b 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -305,6 +305,13 @@ public class Util
return myStringBuilder.ToString();
}
+ public static string ChangeSpaceForUnderscore(string myString)
+ {
+ StringBuilder myStringBuilder = new StringBuilder(myString);
+ myStringBuilder.Replace(" ", "_");
+ return myStringBuilder.ToString();
+ }
+
public static string GetHeightInCentimeters (string time) {
// s = 4.9 * (tv/2)^2
double timeAsDouble = Convert.ToDouble(time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]