Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 614 → Rev 615

/VibrationTest/trunk/VibrationTest/VibrationTestGui.py
18,6 → 18,7
 
 
CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"]
FS = 11111
 
# Needs Numeric or numarray or NumPy
try:
358,7 → 359,7
self.TestListCtrl.SetStringItem(index, 1, str(test.speed))
self.TestListCtrl.SetStringItem(index, 2, test.channel)
 
vv = int(test.getVibValue())
vv = int(test.getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value))
vvs = "|%s| (%d)" % ("----------------------------------------------------------------------------------------------------"[0:min(vv,100)], vv)
self.TestListCtrl.SetStringItem(index, 3, vvs)
self.TestListCtrl.Select(index)
382,7 → 383,7
data = []
idx = self.TestListCtrl.GetFirstSelected()
while idx != -1:
data.append([x,self.app.getTest(idx).getVibValue()])
data.append([x,self.app.getTest(idx).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)
409,7 → 410,7
if self.graphTypeChoice.GetSelection() == 1:
xydata = _Numeric.linspace(0,0.09*nb,2*nb)
xydata.shape = (nb, 2)
xydata[:,1] = vibTest.getFilteredData()
xydata[:,1] = vibTest.getFilteredData(self.app.settings["hpf"].value, self.app.settings["lpf"].value)
line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2)
title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
417,7 → 418,7
self.client.SetEnableGrid('Horizontal')
elif self.graphTypeChoice.GetSelection() == 2:
xydata = _Numeric.linspace(0,5555,nb)
xydata = _Numeric.linspace(0,FS/2,nb)
xydata.shape = (nb/2, 2)
xydata[:,1] = vibTest.getSpectrum()
424,9 → 425,14
line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red')
markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2)
fc = self.app.settings["hpf"].value
filterLine1 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4)
fc = self.app.settings["lpf"].value
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.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y))
self.client.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y))
self.client.SetEnableGrid(True)
 
 
607,6 → 613,8
 
self.spectrum = None
self.filteredData = None
self.fc1 = None
self.fc2 = None
self.vibValue = None
624,19 → 632,31
self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2)
return self.spectrum
 
def getFilteredData(self):
def getFilteredData(self, fc1, fc2):
if self.fc1 != fc1 or self.fc2 != fc2:
self.filteredData = None
if self.filteredData == None:
tmpfft = self.fft.copy()
for i in range(0,5):
fc = (float(fc1))/(FS/2)*len(tmpfft)
print "fc1=%d => fc=%d" % (fc1,fc)
for i in range(0,int(fc)):
tmpfft[i] = 0
for i in range(30, len(tmpfft)):
fc = (float(fc2))/(FS/2)*len(tmpfft)
print "fc2=%d => fc=%d" % (fc2,fc)
for i in range(int(fc), len(tmpfft)):
tmpfft[i] = 0
self.filteredData = _Numeric.fft.irfft(tmpfft)
self.fc1 = fc1
self.fc2 = fc2
return self.filteredData
def getVibValue(self):
def getVibValue(self, fc1, fc2):
if self.fc1 != fc1 or self.fc2 != fc2:
self.vibValue = None
if self.vibValue == None:
fd = self.getFilteredData()[100:-100];
fd = self.getFilteredData(fc1, fc2)[100:-100];
self.vibValue = max(fd)-min(fd)
return self.vibValue
 
657,7 → 677,7
self.settings["startupsettling"] = Setting("Motor Startup Setting time (s)", 3)
self.settings["serialport"] = Setting("Serial Port", "COM1")
self.settings["hpf"] = Setting("HP Filter cutoff (Hz)", 50)
self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 400)
self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 180)
 
self.readSettings()