Rev 599 | Rev 601 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 599 | Rev 600 | ||
---|---|---|---|
Line 97... | Line 97... | ||
97 | self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
97 | self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
98 | wxglade_tmp_menu = wx.Menu() |
98 | wxglade_tmp_menu = wx.Menu() |
99 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
99 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
100 | self.SetMenuBar(self.frame_1_menubar) |
100 | self.SetMenuBar(self.frame_1_menubar) |
101 | # Menu Bar end |
101 | # Menu Bar end |
102 | self.Port = wx.StaticText(self, -1, "Port") |
102 | self.Description = wx.StaticText(self, -1, "Description") |
103 | self.text_ctrl_1 = wx.TextCtrl(self, -1, "") |
103 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "Test") |
104 | self.label_5 = wx.StaticText(self, -1, "label_5") |
104 | self.label_37 = wx.StaticText(self, -1, "Speed(s)") |
105 | self.text_ctrl_5 = wx.TextCtrl(self, -1, "") |
105 | self.text_ctrl_9 = wx.TextCtrl(self, -1, "100-200:10") |
106 | self.label_2 = wx.StaticText(self, -1, "Motor(s)") |
106 | self.label_35 = wx.StaticText(self, -1, "Motor(s)") |
107 | self.text_ctrl_2 = wx.TextCtrl(self, -1, "") |
107 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "1") |
108 | self.label_6 = wx.StaticText(self, -1, "label_6") |
108 | self.label_38 = wx.StaticText(self, -1, "") |
109 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "") |
109 | self.text_ctrl_10 = wx.TextCtrl(self, -1, "") |
110 | self.label_3 = wx.StaticText(self, -1, "Channel(s)") |
110 | self.label_36 = wx.StaticText(self, -1, "Channel") |
111 | self.text_ctrl_3 = wx.TextCtrl(self, -1, "") |
111 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "6") |
112 | self.label_7 = wx.StaticText(self, -1, "label_7") |
112 | self.label_39 = wx.StaticText(self, -1, "") |
113 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "") |
113 | self.text_ctrl_11 = wx.TextCtrl(self, -1, "") |
114 | self.label_4 = wx.StaticText(self, -1, "Speed(s)") |
114 | self.button_4 = wx.Button(self, -1, "Start") |
115 | self.text_ctrl_4 = wx.TextCtrl(self, -1, "") |
115 | self.GraphPanel = wx.Panel(self, -1) |
116 | self.label_8 = wx.StaticText(self, -1, "label_8") |
116 | self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
117 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "") |
117 | self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
118 | self.button_1 = wx.Button(self, -1, "button_1") |
118 | self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
119 | self.GraphPanel = wx.Panel(self, -1, style=wx.DOUBLE_BORDER|wx.TAB_TRAVERSAL) |
- | |
120 | self.yAxesChoice = wx.ComboBox(self, -1, choices=["10", "25", "50", "100", "250"], style=wx.CB_DROPDOWN) |
119 | self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "100", "200"]) |
121 | self.graphTypeChoise = wx.ComboBox(self, -1, choices=["Raw Data", "Filtered Data", "Spectrum"], style=wx.CB_DROPDOWN) |
- | |
122 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
120 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
Line 123... | Line 121... | ||
123 | 121 | ||
124 | self.__set_properties() |
122 | self.__set_properties() |
Line 125... | Line 123... | ||
125 | self.__do_layout() |
123 | self.__do_layout() |
126 | 124 | ||
127 | self.Bind(wx.EVT_MENU, self.OnImport, id=-1) |
125 | self.Bind(wx.EVT_MENU, self.OnImport, id=-1) |
128 | self.Bind(wx.EVT_COMBOBOX, self.onYAxisChange, self.yAxesChoice) |
126 | self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
Line 129... | Line 127... | ||
129 | self.Bind(wx.EVT_COMBOBOX, self.onYAxisChange, self.graphTypeChoise) |
127 | self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
130 | # end wxGlade |
128 | # end wxGlade |
Line 131... | Line 129... | ||
131 | 129 | ||
132 | def setApp(self, app): |
130 | def setApp(self, app): |
133 | self.app = app |
131 | self.app = app |
- | 132 | ||
- | 133 | def __set_properties(self): |
|
134 | 134 | # begin wxGlade: MainFrame.__set_properties |
|
135 | def __set_properties(self): |
135 | self.SetTitle("VibrationTest") |
136 | # begin wxGlade: MainFrame.__set_properties |
136 | self.SetSize((850, 700)) |
- | 137 | self.Description.SetMinSize((53, 13)) |
|
137 | self.SetTitle("VibrationTest") |
138 | self.GraphPanel.SetMinSize((800,300)) |
Line 138... | Line 139... | ||
138 | self.GraphPanel.SetMinSize((800,350)) |
139 | self.graphTypeChoice.SetSelection(0) |
139 | self.yAxesChoice.SetSelection(2) |
140 | self.yAxisChoice.SetSelection(1) |
140 | self.graphTypeChoise.SetSelection(0) |
141 | self.TestListCtrl.SetMinSize((800,300)) |
141 | # end wxGlade |
142 | # end wxGlade |
142 | 143 | ||
143 | def __do_layout(self): |
144 | def __do_layout(self): |
144 | # begin wxGlade: MainFrame.__do_layout |
145 | # begin wxGlade: MainFrame.__do_layout |
145 | sizer_1 = wx.BoxSizer(wx.VERTICAL) |
146 | sizer_3 = wx.BoxSizer(wx.HORIZONTAL) |
146 | grid_sizer_2 = wx.GridSizer(2, 1, 4, 4) |
147 | sizer_8 = wx.BoxSizer(wx.VERTICAL) |
147 | sizer_2 = wx.BoxSizer(wx.HORIZONTAL) |
- | |
148 | grid_sizer_1 = wx.GridSizer(5, 4, 4, 4) |
148 | sizer_11 = wx.BoxSizer(wx.VERTICAL) |
149 | sizer_1.Add((20, 20), 0, 0, 0) |
- | |
150 | grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0) |
149 | sizer_12 = wx.BoxSizer(wx.HORIZONTAL) |
151 | grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0) |
150 | sizer_9 = wx.BoxSizer(wx.HORIZONTAL) |
152 | grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0) |
151 | sizer_10 = wx.BoxSizer(wx.HORIZONTAL) |
153 | grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0) |
152 | grid_sizer_1 = wx.GridSizer(3, 4, 4, 5) |
154 | grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0) |
153 | sizer_3.Add((20, 20), 0, 0, 0) |
155 | grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0) |
154 | sizer_8.Add((20, 20), 0, 0, 0) |
156 | grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0) |
155 | grid_sizer_1.Add(self.Description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
157 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
156 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
158 | grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0) |
157 | grid_sizer_1.Add(self.label_37, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
159 | grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0) |
158 | grid_sizer_1.Add(self.text_ctrl_9, 0, 0, 0) |
160 | grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0) |
159 | grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
- | 160 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
|
161 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
161 | grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
162 | grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0) |
162 | grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0) |
163 | grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0) |
163 | grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
- | 164 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
|
- | 165 | grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
|
- | 166 | grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0) |
|
- | 167 | sizer_9.Add(grid_sizer_1, 0, 0, 0) |
|
164 | grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0) |
168 | sizer_10.Add((50, 20), 0, 0, 0) |
- | 169 | sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
|
- | 170 | sizer_9.Add(sizer_10, 1, wx.EXPAND, 0) |
|
165 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
171 | sizer_8.Add(sizer_9, 0, 0, 0) |
- | 172 | sizer_8.Add((20, 30), 0, 0, 0) |
|
- | 173 | sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0) |
|
166 | grid_sizer_1.Add(self.button_1, 0, 0, 0) |
174 | sizer_11.Add((20, 5), 0, 0, 0) |
167 | sizer_1.Add(grid_sizer_1, 0, 0, 2) |
175 | sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
- | 176 | sizer_12.Add(self.graphTypeChoice, 0, 0, 0) |
|
168 | sizer_1.Add((20, 20), 0, 0, 0) |
177 | sizer_12.Add((40, 20), 0, 0, 0) |
169 | sizer_1.Add(self.GraphPanel, 1, 0, 0) |
178 | sizer_12.Add(self.label_41, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
- | 179 | sizer_12.Add(self.yAxisChoice, 0, 0, 0) |
|
170 | sizer_2.Add(self.yAxesChoice, 0, 0, 0) |
180 | sizer_11.Add(sizer_12, 0, 0, 0) |
171 | sizer_2.Add(self.graphTypeChoise, 0, 0, 0) |
181 | sizer_8.Add(sizer_11, 0, 0, 0) |
172 | sizer_1.Add(sizer_2, 0, wx.EXPAND, 0) |
- | |
173 | sizer_1.Add((20, 20), 0, 0, 0) |
182 | sizer_8.Add((20, 30), 0, 0, 0) |
- | 183 | sizer_8.Add(self.TestListCtrl, 1, 0, 0) |
|
174 | grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0) |
184 | sizer_8.Add((20, 20), 0, 0, 0) |
Line 175... | Line 185... | ||
175 | sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0) |
185 | sizer_3.Add(sizer_8, 1, wx.EXPAND, 0) |
176 | self.SetSizer(sizer_1) |
186 | self.SetSizer(sizer_3) |
Line 237... | Line 247... | ||
237 | self.drawGraph() |
247 | self.drawGraph() |
Line 238... | Line 248... | ||
238 | 248 | ||
239 | def drawGraph(self): |
249 | def drawGraph(self): |
240 | vibTest = self.app.getTest(self.activeTestId) |
250 | vibTest = self.app.getTest(self.activeTestId) |
241 | nb = vibTest.getDataLen() |
251 | nb = vibTest.getDataLen() |
Line 242... | Line 252... | ||
242 | y = int(self.yAxesChoice.GetStringSelection()) |
252 | y = int(self.yAxisChoice.GetStringSelection()) |
243 | 253 | ||
244 | if self.graphTypeChoise.GetSelection() == 0: |
254 | if self.graphTypeChoice.GetSelection() == 0: |
245 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
255 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
246 | xydata.shape = (nb, 2) |
256 | xydata.shape = (nb, 2) |
Line 247... | Line 257... | ||
247 | xydata[:,1] = vibTest.getRawData() |
257 | xydata[:,1] = vibTest.getRawData() |
248 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red') |
258 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
249 | 259 | ||
Line -... | Line 260... | ||
- | 260 | title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
|
- | 261 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
|
- | 262 | self.client.SetEnableGrid('Horizontal') |
|
- | 263 | ||
- | 264 | if self.graphTypeChoice.GetSelection() == 1: |
|
- | 265 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
|
- | 266 | xydata.shape = (nb, 2) |
|
- | 267 | xydata[:,1] = vibTest.getFilteredData() |
|
- | 268 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
|
- | 269 | ||
250 | title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
270 | title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
251 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
271 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
252 | self.client.SetEnableGrid('Horizontal') |
272 | self.client.SetEnableGrid('Horizontal') |
Line 253... | Line 273... | ||
253 | 273 | ||
Line 254... | Line 274... | ||
254 | elif self.graphTypeChoise.GetSelection() == 2: |
274 | elif self.graphTypeChoice.GetSelection() == 2: |
255 | xydata = _Numeric.linspace(0,5555,nb) |
275 | xydata = _Numeric.linspace(0,5555,nb) |
Line 256... | Line 276... | ||
256 | xydata.shape = (nb/2, 2) |
276 | xydata.shape = (nb/2, 2) |
257 | 277 | ||
258 | xydata[:,1] = vibTest.getSpectrum() |
278 | xydata[:,1] = vibTest.getSpectrum() |
Line 259... | Line 279... | ||
259 | 279 | ||
260 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
280 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
Line 261... | Line 281... | ||
261 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=1) |
281 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2) |
262 | 282 | ||
Line 263... | Line 283... | ||
263 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
283 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
264 | self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,500), yAxis= (-0,y)) |
284 | self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,300), yAxis= (-0,y)) |
Line 265... | Line 285... | ||
265 | self.client.SetEnableGrid('Horizontal') |
285 | self.client.SetEnableGrid(True) |
Line 283... | Line 303... | ||
283 | self.motor = motor |
303 | self.motor = motor |
284 | self.speed = speed |
304 | self.speed = speed |
285 | self.channel = channel |
305 | self.channel = channel |
Line 286... | Line 306... | ||
286 | 306 | ||
287 | self.dataLen = len(rawData) |
- | |
Line 288... | Line 307... | ||
288 | print self.dataLen |
307 | self.dataLen = len(rawData) |
289 | 308 | ||
290 | self.rawData = _Numeric.array(rawData) |
309 | self.rawData = _Numeric.array(rawData) |
Line 291... | Line 310... | ||
291 | self.dc = self.rawData.mean() |
310 | self.dc = self.rawData.mean() |
- | 311 | self.rawData -= self.dc |
|
- | 312 | ||
- | 313 | self.fft = _Numeric.fft.rfft(self.rawData) |
|
Line 292... | Line 314... | ||
292 | self.rawData -= self.dc |
314 | |
293 | 315 | self.spectrum = None |
|
Line 294... | Line 316... | ||
294 | self.fft = _Numeric.fft.fft(self.rawData) |
316 | self.filteredData = None |
Line 301... | Line 323... | ||
301 | 323 | ||
302 | def getDataLen(self): |
324 | def getDataLen(self): |
Line 303... | Line 325... | ||
303 | return self.dataLen |
325 | return self.dataLen |
- | 326 | ||
304 | 327 | def getSpectrum(self): |
|
- | 328 | if self.spectrum == None: |
|
305 | def getSpectrum(self): |
329 | self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
- | 330 | return self.spectrum |
|
- | 331 | ||
- | 332 | def getFilteredData(self): |
|
- | 333 | if self.filteredData == None: |
|
- | 334 | tmpfft = self.fft.copy() |
|
- | 335 | for i in range(0,7): |
|
- | 336 | tmpfft[i] = 0 |
|
- | 337 | for i in range(30, len(tmpfft)): |
|
- | 338 | tmpfft[i] = 0 |
|
Line 306... | Line 339... | ||
306 | return _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
339 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
307 | 340 | return self.filteredData |
|
308 | 341 | ||
Line 329... | Line 362... | ||
329 | 362 | ||
330 | self.frame_1.Show() |
363 | self.frame_1.Show() |
Line 331... | Line 364... | ||
331 | return 1 |
364 | return 1 |
- | 365 | ||
332 | 366 | def Import(self): |
|
333 | def Import(self): |
367 | |
Line 334... | Line 368... | ||
334 | filePath = "./unbal200.txt" |
368 | filePath = "./unbal150.txt" |
Line 335... | Line 369... | ||
335 | #filePath = "./nikivan.txt" |
369 | #filePath = "./nikivan.txt" |
Line 348... | Line 382... | ||
348 | speed = [] |
382 | speed = [] |
349 | channel = [] |
383 | channel = [] |
350 | for c in range(nbCols): |
384 | for c in range(nbCols): |
351 | data.append([]) |
385 | data.append([]) |
352 | h = headers[c].split(' ') |
386 | h = headers[c].split(' ') |
353 | print h |
- | |
354 | descr.append(h[0]); |
387 | descr.append(h[0]); |
355 | speed.append(h[1]); |
388 | speed.append(h[1]); |
356 | channel.append(h[2]); |
389 | channel.append(h[2]); |
Line 357... | Line 390... | ||
357 | 390 |