Subversion Repositories Projects

Rev

Rev 596 | Rev 600 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 596 Rev 599
Line 123... Line 123...
123
 
123
 
124
        self.__set_properties()
124
        self.__set_properties()
Line 125... Line 125...
125
        self.__do_layout()
125
        self.__do_layout()
126
 
126
 
-
 
127
        self.Bind(wx.EVT_MENU, self.OnImport, id=-1)
127
        self.Bind(wx.EVT_MENU, self.OnImport, id=-1)
128
        self.Bind(wx.EVT_COMBOBOX, self.onYAxisChange, self.yAxesChoice)
Line 128... Line 129...
128
        self.Bind(wx.EVT_COMBOBOX, self.onYAxesChange, self.yAxesChoice)
129
        self.Bind(wx.EVT_COMBOBOX, self.onYAxisChange, self.graphTypeChoise)
129
        # end wxGlade
130
        # end wxGlade
Line 130... Line 131...
130
 
131
 
131
    def setApp(self, app):
132
    def setApp(self, app):
132
        self.app = app
133
        self.app = app
133
 
134
 
134
    def __set_properties(self):
135
    def __set_properties(self):
135
        # begin wxGlade: MainFrame.__set_properties
136
        # begin wxGlade: MainFrame.__set_properties
136
        self.SetTitle("VibrationTest")
137
        self.SetTitle("VibrationTest")
Line 137... Line 138...
137
        self.GraphPanel.SetMinSize((800,300))
138
        self.GraphPanel.SetMinSize((800,350))
Line 238... Line 239...
238
    def drawGraph(self):
239
    def drawGraph(self):
239
         vibTest = self.app.getTest(self.activeTestId)
240
         vibTest = self.app.getTest(self.activeTestId)
240
         nb = vibTest.getDataLen()
241
         nb = vibTest.getDataLen()
241
         y = int(self.yAxesChoice.GetStringSelection())
242
         y = int(self.yAxesChoice.GetStringSelection())
Line 242... Line 243...
242
 
243
 
243
         #self.client.Clear()
244
         if self.graphTypeChoise.GetSelection() == 0:
244
         xydata = _Numeric.linspace(0,0.09*nb,2*nb)
245
             xydata = _Numeric.linspace(0,0.09*nb,2*nb)
245
         xydata.shape = (nb, 2)
246
             xydata.shape = (nb, 2)
246
         xydata[:,1] = vibTest.getRawData()
247
             xydata[:,1] = vibTest.getRawData()
247
         line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
248
             line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
248
 
249
   
249
         title = "%s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
250
             title = "Raw 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))
-
 
252
             self.client.SetEnableGrid('Horizontal')
-
 
253
 
-
 
254
         elif self.graphTypeChoise.GetSelection() == 2:
-
 
255
             xydata = _Numeric.linspace(0,5555,nb)
-
 
256
             xydata.shape = (nb/2, 2)
-
 
257
             
-
 
258
             xydata[:,1] = vibTest.getSpectrum()
-
 
259
 
-
 
260
             line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red')
-
 
261
             markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=1)
-
 
262
   
-
 
263
             title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
250
         self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
264
             self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,500), yAxis= (-0,y))
Line 251... Line 265...
251
         self.client.SetEnableGrid('Horizontal')
265
             self.client.SetEnableGrid('Horizontal')
252
 
266
 
Line 253... Line 267...
253
 
267
 
-
 
268
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
-
 
269
        self.app.Import()
-
 
270
 
254
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
271
    def onYAxisChange(self, event): # wxGlade: MainFrame.<event_handler>
Line 255... Line 272...
255
        self.app.Import()
272
        self.drawGraph()
Line 264... Line 281...
264
    def __init__(self, descr, motor, speed, channel, rawData):
281
    def __init__(self, descr, motor, speed, channel, rawData):
265
        self.descr = descr
282
        self.descr = descr
266
        self.motor = motor
283
        self.motor = motor
267
        self.speed = speed
284
        self.speed = speed
268
        self.channel = channel
285
        self.channel = channel
-
 
286
 
-
 
287
        self.dataLen = len(rawData)
-
 
288
        print self.dataLen
-
 
289
 
269
        self.rawData = _Numeric.array(rawData)
290
        self.rawData = _Numeric.array(rawData)
270
        self.dc = self.rawData.mean()
291
        self.dc = self.rawData.mean()
271
        self.rawData -= self.dc
292
        self.rawData -= self.dc
272
        self.dataLen = len(rawData)
-
 
Line -... Line 293...
-
 
293
 
-
 
294
        self.fft = _Numeric.fft.fft(self.rawData)
273
 
295
       
274
    def getDescr(self):
296
    def getDescr(self):
Line 275... Line 297...
275
        return self.Descr
297
        return self.Descr
276
 
298
 
Line 277... Line 299...
277
    def getRawData(self):
299
    def getRawData(self):
278
        return self.rawData
300
        return self.rawData
Line -... Line 301...
-
 
301
 
-
 
302
    def getDataLen(self):
-
 
303
        return self.dataLen
Line 279... Line 304...
279
 
304
 
280
    def getDataLen(self):
305
    def getSpectrum(self):
281
        return self.dataLen
306
        return _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2)
Line 304... Line 329...
304
 
329
 
305
        self.frame_1.Show()
330
        self.frame_1.Show()
Line 306... Line 331...
306
        return 1
331
        return 1
307
 
332
 
308
    def Import(self):
333
    def Import(self):
Line 309... Line 334...
309
        #filePath = "./unbal200.txt"
334
        filePath = "./unbal200.txt"
Line 310... Line 335...
310
        filePath = "./nikivan.txt"
335
        #filePath = "./nikivan.txt"
311
       
336
       
Line 335... Line 360...
335
            for i in range(nbCols):
360
            for i in range(nbCols):
336
                data[i].append(int(values[i]))
361
                data[i].append(int(values[i]))
337
        logfile.close()
362
        logfile.close()
Line 338... Line 363...
338
 
363
 
-
 
364
        for c in range(nbCols):
-
 
365
            if (len(data[c]) % 2) != 0:
339
        for c in range(nbCols):
366
                data[c].append(data[c][-1])