Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 635 → Rev 636

/VibrationTest/trunk/VibrationTest/VibrationTestGui.py
27,7 → 27,11
CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"]
FS = 11111
pi = 3.14
COLOR_YELLOW = wx.Colour(255, 240, 0)
COLOR_BACKGROUND = wx.Colour(0x80, 0x80, 0x80)
 
COLORS = [wx.RED, wx.GREEN, wx.BLUE, COLOR_YELLOW, COLOR_BACKGROUND, wx.BLACK,]*2
 
rootPath = ""
 
# Needs Numeric or numarray or NumPy
74,18 → 78,18
self.button.SetFocus()
YELLOW = wx.Colour(255, 240, 0)
BG = wx.Colour(0x80, 0x80, 0x80)
# Configure Voltage Ctrl
self.voltageCtrl.SetAngleRange(0,pi)
intervals = range(0, 5)
self.voltageCtrl.SetIntervals(intervals)
colours = [wx.RED, wx.GREEN, wx.GREEN, YELLOW]
colours = [wx.RED, wx.GREEN, wx.GREEN, COLOR_YELLOW]
self.voltageCtrl.SetIntervalColours(colours)
ticks = ["", "", "", "", ""]
self.voltageCtrl.SetTicks(ticks)
self.voltageCtrl.SetTicksColour(wx.WHITE)
self.voltageCtrl.SetHandColour(YELLOW)
self.voltageCtrl.SetHandColour(COLOR_YELLOW)
 
icon = wx.Icon("%s/Resources/fuel.ico" % rootPath, wx.BITMAP_TYPE_ICO)
icon.SetWidth(24)
92,7 → 96,7
icon.SetHeight(24)
 
self.voltageCtrl.SetMiddleIcon(icon)
self.voltageCtrl.SetSpeedBackground(BG)
self.voltageCtrl.SetSpeedBackground(COLOR_BACKGROUND)
self.voltageCtrl.SetArcColour(wx.WHITE)
self.voltageCtrl.SetSpeedValue(2)
 
102,7 → 106,7
intervals = range(0, 261, 20)
self.speedCtrl.SetIntervals(intervals)
 
colours = [BG]*(len(intervals)-1)
colours = [COLOR_BACKGROUND]*(len(intervals)-1)
for i in range(5,10):
colours[i] = wx.GREEN
self.speedCtrl.SetIntervalColours(colours)
114,8 → 118,8
self.speedCtrl.SetMiddleText("Speed")
self.speedCtrl.SetMiddleTextColour(wx.WHITE)
self.speedCtrl.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))
self.speedCtrl.SetHandColour(YELLOW)
self.speedCtrl.SetSpeedBackground(BG)
self.speedCtrl.SetHandColour(COLOR_YELLOW)
self.speedCtrl.SetSpeedBackground(COLOR_BACKGROUND)
self.speedCtrl.SetArcColour(wx.WHITE)
self.speedCtrl.SetSpeedValue(0)
 
513,6 → 517,24
print "Test Selected id=%d" % (testId)
self.activeTestId = testId
self.drawGraph()
def orderSelectedTests(self):
tests = []
idx = self.TestListCtrl.GetFirstSelected()
while idx != -1:
header = "%s %s"%(self.app.getTest(idx).descr,self.app.getTest(idx).channel)
found = False
for t in tests:
if t[0] == header:
t.append(idx)
found = True
break
if not found:
tests.append([header, idx])
idx = self.TestListCtrl.GetNextSelected(idx)
return tests
 
def drawGraph(self):
526,19 → 548,29
elif nbSelected > 1:
self.graphTypeChoice.Disable()
self.copyGraphButton.Enable()
x = 1
data = []
idx = self.TestListCtrl.GetFirstSelected()
while idx != -1:
data.append([x,self.app.getTest(idx).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)])
tests = self.orderSelectedTests()
lines = []
maxX = 0
cCnt = 0
for s in tests:
data = []
x=1
for t in s[1:]:
data.append([x,self.app.getTest(t).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)])
x += 1
idx = self.TestListCtrl.GetNextSelected(idx)
line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2)
markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2)
lines.append(wx.lib.plot.PolyLine(data, legend= s[0], colour=COLORS[cCnt], width=2))
lines.append(wx.lib.plot.PolyMarker(data, legend= "", colour=COLORS[cCnt], marker='circle',size=2))
maxX = max(maxX, x)
cCnt += 1
title = "Comparing tests"
self.graphCtrl.setLogScale((False,False))
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line, markers], title, "Test", "Vibration Value"), xAxis=(1,max(x,10)), yAxis=(0,y))
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics(lines, title, "Test", "Vibration Value"), xAxis=(1,maxX), yAxis=(0,y))
self.graphCtrl.SetEnableGrid('Horizontal')
self.graphCtrl.SetEnableLegend(True)
 
else:
self.graphTypeChoice.Enable()
556,6 → 588,8
self.graphCtrl.setLogScale((False,False))
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
self.graphCtrl.SetEnableGrid('Horizontal')
self.graphCtrl.SetEnableLegend(False)
if self.graphTypeChoice.GetSelection() == 1:
xydata = _Numeric.linspace(0,0.09*nb,2*nb)
567,6 → 601,7
self.graphCtrl.setLogScale((False,False))
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
self.graphCtrl.SetEnableGrid('Horizontal')
self.graphCtrl.SetEnableLegend(False)
elif self.graphTypeChoice.GetSelection() == 2:
xydata = _Numeric.linspace(0,FS/2,nb)
585,9 → 620,10
filterLine2 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4)
title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
self.graphCtrl.SetEnableGrid(True)
self.graphCtrl.setLogScale((True,False))
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(20,500), yAxis= (0,y))
self.graphCtrl.SetEnableGrid(True)
self.graphCtrl.SetEnableLegend(False)