Rev 614 | Rev 616 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 614 | Rev 615 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | import mkProto |
16 | import mkProto |
Line 17... | Line 17... | ||
17 | 17 | ||
- | 18 | ||
Line 18... | Line 19... | ||
18 | 19 | ||
19 | 20 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
|
20 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
21 | FS = 11111 |
21 | 22 | ||
Line 356... | Line 357... | ||
356 | def onNewTest(self, test): |
357 | def onNewTest(self, test): |
357 | index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr) |
358 | index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr) |
358 | self.TestListCtrl.SetStringItem(index, 1, str(test.speed)) |
359 | self.TestListCtrl.SetStringItem(index, 1, str(test.speed)) |
359 | self.TestListCtrl.SetStringItem(index, 2, test.channel) |
360 | self.TestListCtrl.SetStringItem(index, 2, test.channel) |
Line 360... | Line 361... | ||
360 | 361 | ||
361 | vv = int(test.getVibValue()) |
362 | vv = int(test.getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)) |
362 | vvs = "|%s| (%d)" % ("----------------------------------------------------------------------------------------------------"[0:min(vv,100)], vv) |
363 | vvs = "|%s| (%d)" % ("----------------------------------------------------------------------------------------------------"[0:min(vv,100)], vv) |
363 | self.TestListCtrl.SetStringItem(index, 3, vvs) |
364 | self.TestListCtrl.SetStringItem(index, 3, vvs) |
Line 380... | Line 381... | ||
380 | self.graphTypeChoice.Disable() |
381 | self.graphTypeChoice.Disable() |
381 | x = 1 |
382 | x = 1 |
382 | data = [] |
383 | data = [] |
383 | idx = self.TestListCtrl.GetFirstSelected() |
384 | idx = self.TestListCtrl.GetFirstSelected() |
384 | while idx != -1: |
385 | while idx != -1: |
385 | data.append([x,self.app.getTest(idx).getVibValue()]) |
386 | data.append([x,self.app.getTest(idx).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)]) |
386 | x += 1 |
387 | x += 1 |
387 | idx = self.TestListCtrl.GetNextSelected(idx) |
388 | idx = self.TestListCtrl.GetNextSelected(idx) |
388 | line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2) |
389 | line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2) |
389 | markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2) |
390 | markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2) |
390 | title = "Comparing tests" |
391 | title = "Comparing tests" |
Line 407... | Line 408... | ||
407 | self.client.SetEnableGrid('Horizontal') |
408 | self.client.SetEnableGrid('Horizontal') |
Line 408... | Line 409... | ||
408 | 409 | ||
409 | if self.graphTypeChoice.GetSelection() == 1: |
410 | if self.graphTypeChoice.GetSelection() == 1: |
410 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
411 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
411 | xydata.shape = (nb, 2) |
412 | xydata.shape = (nb, 2) |
412 | xydata[:,1] = vibTest.getFilteredData() |
413 | xydata[:,1] = vibTest.getFilteredData(self.app.settings["hpf"].value, self.app.settings["lpf"].value) |
Line 413... | Line 414... | ||
413 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
414 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
414 | 415 | ||
415 | title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
416 | title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
Line 416... | Line 417... | ||
416 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
417 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
417 | self.client.SetEnableGrid('Horizontal') |
418 | self.client.SetEnableGrid('Horizontal') |
418 | 419 | ||
Line 419... | Line 420... | ||
419 | elif self.graphTypeChoice.GetSelection() == 2: |
420 | elif self.graphTypeChoice.GetSelection() == 2: |
Line 420... | Line 421... | ||
420 | xydata = _Numeric.linspace(0,5555,nb) |
421 | xydata = _Numeric.linspace(0,FS/2,nb) |
421 | xydata.shape = (nb/2, 2) |
422 | xydata.shape = (nb/2, 2) |
- | 423 | ||
- | 424 | xydata[:,1] = vibTest.getSpectrum() |
|
- | 425 | ||
- | 426 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
|
- | 427 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2) |
|
Line 422... | Line 428... | ||
422 | 428 | ||
423 | xydata[:,1] = vibTest.getSpectrum() |
429 | fc = self.app.settings["hpf"].value |
424 | 430 | filterLine1 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4) |
|
Line 425... | Line 431... | ||
425 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
431 | fc = self.app.settings["lpf"].value |
426 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2) |
432 | filterLine2 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4) |
Line 605... | Line 611... | ||
605 | 611 | ||
Line 606... | Line 612... | ||
606 | self.fft = _Numeric.fft.rfft(self.rawData) |
612 | self.fft = _Numeric.fft.rfft(self.rawData) |
607 | 613 | ||
- | 614 | self.spectrum = None |
|
- | 615 | self.filteredData = None |
|
Line 608... | Line 616... | ||
608 | self.spectrum = None |
616 | self.fc1 = None |
Line 609... | Line 617... | ||
609 | self.filteredData = None |
617 | self.fc2 = None |
610 | 618 | ||
Line 622... | Line 630... | ||
622 | def getSpectrum(self): |
630 | def getSpectrum(self): |
623 | if self.spectrum == None: |
631 | if self.spectrum == None: |
624 | self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
632 | self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
625 | return self.spectrum |
633 | return self.spectrum |
Line 626... | Line 634... | ||
626 | 634 | ||
- | 635 | def getFilteredData(self, fc1, fc2): |
|
- | 636 | if self.fc1 != fc1 or self.fc2 != fc2: |
|
- | 637 | self.filteredData = None |
|
627 | def getFilteredData(self): |
638 | |
628 | if self.filteredData == None: |
639 | if self.filteredData == None: |
- | 640 | tmpfft = self.fft.copy() |
|
- | 641 | fc = (float(fc1))/(FS/2)*len(tmpfft) |
|
629 | tmpfft = self.fft.copy() |
642 | print "fc1=%d => fc=%d" % (fc1,fc) |
630 | for i in range(0,5): |
643 | for i in range(0,int(fc)): |
- | 644 | tmpfft[i] = 0 |
|
- | 645 | fc = (float(fc2))/(FS/2)*len(tmpfft) |
|
631 | tmpfft[i] = 0 |
646 | print "fc2=%d => fc=%d" % (fc2,fc) |
632 | for i in range(30, len(tmpfft)): |
647 | for i in range(int(fc), len(tmpfft)): |
633 | tmpfft[i] = 0 |
648 | tmpfft[i] = 0 |
- | 649 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
|
- | 650 | self.fc1 = fc1 |
|
- | 651 | self.fc2 = fc2 |
|
634 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
652 | |
Line 635... | Line 653... | ||
635 | return self.filteredData |
653 | return self.filteredData |
- | 654 | ||
- | 655 | def getVibValue(self, fc1, fc2): |
|
636 | 656 | if self.fc1 != fc1 or self.fc2 != fc2: |
|
637 | def getVibValue(self): |
657 | self.vibValue = None |
638 | if self.vibValue == None: |
658 | if self.vibValue == None: |
639 | fd = self.getFilteredData()[100:-100]; |
659 | fd = self.getFilteredData(fc1, fc2)[100:-100]; |
Line 655... | Line 675... | ||
655 | self.settings["serialport"] = Setting("Serial Port", "COM1") |
675 | self.settings["serialport"] = Setting("Serial Port", "COM1") |
656 | self.settings["startupspeed"] = Setting("Motor Startup Speed", 25) |
676 | self.settings["startupspeed"] = Setting("Motor Startup Speed", 25) |
657 | self.settings["startupsettling"] = Setting("Motor Startup Setting time (s)", 3) |
677 | self.settings["startupsettling"] = Setting("Motor Startup Setting time (s)", 3) |
658 | self.settings["serialport"] = Setting("Serial Port", "COM1") |
678 | self.settings["serialport"] = Setting("Serial Port", "COM1") |
659 | self.settings["hpf"] = Setting("HP Filter cutoff (Hz)", 50) |
679 | self.settings["hpf"] = Setting("HP Filter cutoff (Hz)", 50) |
660 | self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 400) |
680 | self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 180) |
Line 661... | Line 681... | ||
661 | 681 | ||
Line 662... | Line 682... | ||
662 | self.readSettings() |
682 | self.readSettings() |
663 | 683 |