Rev 648 | Rev 650 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 648 | Rev 649 | ||
---|---|---|---|
Line 510... | Line 510... | ||
510 | self.TestListCtrl.SetStringItem(index, 0, test.descr) |
510 | self.TestListCtrl.SetStringItem(index, 0, test.descr) |
511 | self.TestListCtrl.SetStringItem(index, 1, "%.1f V" %test.voltage) |
511 | self.TestListCtrl.SetStringItem(index, 1, "%.1f V" %test.voltage) |
512 | self.TestListCtrl.SetStringItem(index, 2, str(test.speed)) |
512 | self.TestListCtrl.SetStringItem(index, 2, str(test.speed)) |
513 | self.TestListCtrl.SetStringItem(index, 3, test.channel) |
513 | self.TestListCtrl.SetStringItem(index, 3, test.channel) |
Line 514... | Line 514... | ||
514 | 514 | ||
515 | vv = test.getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value) |
515 | vv = test.getVibValue() |
516 | vvs = "|%s| (%.1f)" % ("----------------------------------------------------------------------------------------------------"[0:min(int(vv+1)/2,100)], vv) |
516 | vvs = "|%s| (%.1f)" % ("----------------------------------------------------------------------------------------------------"[0:min(int(vv+1)/2,100)], vv) |
Line 517... | Line 517... | ||
517 | self.TestListCtrl.SetStringItem(index, 4, vvs) |
517 | self.TestListCtrl.SetStringItem(index, 4, vvs) |
518 | 518 | ||
Line 565... | Line 565... | ||
565 | cCnt = 0 |
565 | cCnt = 0 |
566 | for s in tests: |
566 | for s in tests: |
567 | data = [] |
567 | data = [] |
568 | x=1 |
568 | x=1 |
569 | for t in s[1:]: |
569 | for t in s[1:]: |
570 | data.append([x,self.app.getTest(t).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)]) |
570 | data.append([x,self.app.getTest(t).getVibValue()]) |
571 | x += 1 |
571 | x += 1 |
572 | lines.append(wx.lib.plot.PolyLine(data, legend= s[0], colour=COLORS[cCnt], width=2)) |
572 | lines.append(wx.lib.plot.PolyLine(data, legend= s[0], colour=COLORS[cCnt], width=2)) |
573 | lines.append(wx.lib.plot.PolyMarker(data, legend= "", colour=COLORS[cCnt], marker='circle',size=2)) |
573 | lines.append(wx.lib.plot.PolyMarker(data, legend= "", colour=COLORS[cCnt], marker='circle',size=2)) |
574 | maxX = max(maxX, x) |
574 | maxX = max(maxX, x) |
575 | cCnt += 1 |
575 | cCnt += 1 |
Line 601... | Line 601... | ||
601 | 601 | ||
602 | 602 | ||
603 | if self.graphTypeChoice.GetSelection() == 1: |
603 | if self.graphTypeChoice.GetSelection() == 1: |
604 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
604 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
605 | xydata.shape = (nb, 2) |
605 | xydata.shape = (nb, 2) |
Line 606... | Line 606... | ||
606 | xydata[:,1] = vibTest.getFilteredData(self.app.settings["hpf"].value, self.app.settings["lpf"].value) |
606 | xydata[:,1] = vibTest.getFilteredData() |
607 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
607 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
608 | 608 | ||
Line 763... | Line 763... | ||
763 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
763 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
764 | # First we create and fill the info object |
764 | # First we create and fill the info object |
765 | print "about" |
765 | print "about" |
766 | info = wx.AboutDialogInfo() |
766 | info = wx.AboutDialogInfo() |
767 | info.Name = "- MK Vibration Test - " |
767 | info.Name = "- MK Vibration Test - " |
768 | info.Version = "v0.9 RC1" |
768 | info.Version = "v0.9 RC2" |
769 | info.Copyright = "" |
769 | info.Copyright = "" |
770 | info.Developers=["Frederic Goddeeris Frederic@rc-flight.be"] |
770 | info.Developers=["Frederic Goddeeris Frederic@rc-flight.be"] |
771 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
771 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
772 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
772 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
773 | wx.AboutBox(info) |
773 | wx.AboutBox(info) |
Line 784... | Line 784... | ||
784 | def onCopyGraphData(self, event): # wxGlade: MainFrame.<event_handler> |
784 | def onCopyGraphData(self, event): # wxGlade: MainFrame.<event_handler> |
785 | clipdata = wx.TextDataObject() |
785 | clipdata = wx.TextDataObject() |
786 | txt = "" |
786 | txt = "" |
787 | idx = self.TestListCtrl.GetFirstSelected() |
787 | idx = self.TestListCtrl.GetFirstSelected() |
788 | while idx != -1: |
788 | while idx != -1: |
789 | txt += ("%d\n" % self.app.getTest(idx).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)) |
789 | txt += ("%d\n" % self.app.getTest(idx).getVibValue()) |
790 | idx = self.TestListCtrl.GetNextSelected(idx) |
790 | idx = self.TestListCtrl.GetNextSelected(idx) |
791 | clipdata.SetText(txt) |
791 | clipdata.SetText(txt) |
792 | wx.TheClipboard.Open() |
792 | wx.TheClipboard.Open() |
793 | wx.TheClipboard.SetData(clipdata) |
793 | wx.TheClipboard.SetData(clipdata) |
794 | wx.TheClipboard.Close() |
794 | wx.TheClipboard.Close() |
Line 925... | Line 925... | ||
925 | self._sendEvent("", speed = 0) |
925 | self._sendEvent("", speed = 0) |
Line 926... | Line 926... | ||
926 | 926 | ||
927 | 927 | ||
- | 928 | class VibTest: |
|
- | 929 | useRms = True |
|
- | 930 | fc1 = None |
|
Line 928... | Line 931... | ||
928 | class VibTest: |
931 | fc2 = None |
929 | useRms = True |
932 | |
930 | 933 | ||
931 | def __init__(self, descr, voltage, motor, speed, channel, rawData): |
934 | def __init__(self, descr, voltage, motor, speed, channel, rawData): |
Line 943... | Line 946... | ||
943 | 946 | ||
Line 944... | Line 947... | ||
944 | self.fft = _Numeric.fft.rfft(self.rawData) |
947 | self.fft = _Numeric.fft.rfft(self.rawData) |
945 | 948 | ||
946 | self.spectrum = None |
- | |
947 | self.filteredData = None |
- | |
Line 948... | Line 949... | ||
948 | self.fc1 = None |
949 | self.spectrum = None |
Line 949... | Line 950... | ||
949 | self.fc2 = None |
950 | self.filteredData = None |
950 | 951 | ||
Line 966... | Line 967... | ||
966 | 967 | ||
967 | def refresh(self): |
968 | def refresh(self): |
968 | self.filteredData = None |
969 | self.filteredData = None |
Line 969... | Line 970... | ||
969 | self.vibValue = None |
970 | self.vibValue = None |
970 | - | ||
971 | def getFilteredData(self, fc1, fc2): |
- | |
972 | if self.fc1 != fc1 or self.fc2 != fc2: |
- | |
973 | self.filteredData = None |
971 | |
974 | 972 | def getFilteredData(self): |
|
975 | if self.filteredData == None: |
973 | if self.filteredData == None: |
976 | tmpfft = self.fft.copy() |
974 | tmpfft = self.fft.copy() |
977 | fc = (float(fc1))/(FS/2)*len(tmpfft) |
975 | fc = (float(self.fc1))/(FS/2)*len(tmpfft) |
978 | print "fc1=%d => fc=%f" % (fc1,fc) |
976 | print "fc1=%d => fc=%f" % (self.fc1, fc) |
979 | for i in range(0,int(fc)+2): |
977 | for i in range(0,int(fc)+2): |
980 | tmpfft[i] = 0 |
978 | tmpfft[i] = 0 |
981 | fc = (float(fc2))/(FS/2)*len(tmpfft) |
979 | fc = (float(self.fc2))/(FS/2)*len(tmpfft) |
982 | print "fc2=%d => fc=%f" % (fc2,fc) |
980 | print "fc2=%d => fc=%f" % (self.fc2,fc) |
983 | for i in range(int(fc)+2, len(tmpfft)): |
981 | for i in range(int(fc)+2, len(tmpfft)): |
984 | tmpfft[i] = 0 |
- | |
985 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
- | |
Line 986... | Line 982... | ||
986 | self.fc1 = fc1 |
982 | tmpfft[i] = 0 |
Line 987... | Line 983... | ||
987 | self.fc2 = fc2 |
983 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
988 | - | ||
989 | return self.filteredData |
- | |
990 | - | ||
991 | def getVibValue(self, fc1, fc2): |
984 | |
992 | if self.fc1 != fc1 or self.fc2 != fc2: |
985 | return self.filteredData |
993 | self.vibValue = None |
986 | |
994 | 987 | def getVibValue(self): |
|
995 | if self.vibValue == None: |
988 | if self.vibValue == None: |
996 | fd = self.getFilteredData(fc1, fc2)[100:-100]; |
989 | fd = self.getFilteredData()[100:-100]; |
997 | if self.useRms: |
990 | if self.useRms: |
Line 1060... | Line 1053... | ||
1060 | 1053 | ||
1061 | 1054 | ||
1062 | def onSettingsChanged(self, store): |
1055 | def onSettingsChanged(self, store): |
- | 1056 | if store: |
|
1063 | if store: |
1057 | self.storeSettings() |
1064 | self.storeSettings() |
1058 | |
1065 | if self.settings["calcmethod"].value == "rms": |
1059 | if self.settings["calcmethod"].value == "rms": |
1066 | VibTest.useRms = True |
1060 | VibTest.useRms = True |
- | 1061 | else: |
|
- | 1062 | VibTest.useRms = False |
|
- | 1063 | ||
- | 1064 | VibTest.fc1 = self.settings["hpf"].value |
|
1067 | else: |
1065 | VibTest.fc2 = self.settings["lpf"].value |
1068 | VibTest.useRms = False |
1066 | |
1069 | for test in self.VibTests: |
1067 | for test in self.VibTests: |
Line 1070... | Line 1068... | ||
1070 | test.refresh() |
1068 | test.refresh() |