Rev 587 | Rev 591 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 587 | Rev 590 | ||
---|---|---|---|
Line 163... | Line 163... | ||
163 | self.SetSizer(sizer_1) |
163 | self.SetSizer(sizer_1) |
164 | sizer_1.Fit(self) |
164 | sizer_1.Fit(self) |
165 | self.Layout() |
165 | self.Layout() |
166 | # end wxGlade |
166 | # end wxGlade |
Line -... | Line 167... | ||
- | 167 | ||
- | 168 | # List events |
|
- | 169 | self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl) |
|
167 | 170 | ||
168 | # Configure Graph |
171 | # Configure Graph |
169 | self.client = wx.lib.plot.PlotCanvas(self.GraphFanel) |
172 | self.client = wx.lib.plot.PlotCanvas(self.GraphFanel) |
Line 170... | Line 173... | ||
170 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
173 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
Line 182... | Line 185... | ||
182 | markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1) |
185 | markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1) |
183 | pi = 3.1415 |
186 | pi = 3.1415 |
184 | markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), |
187 | markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), |
185 | (3.*pi/4., -1)], legend='Cross Legend', colour='blue', |
188 | (3.*pi/4., -1)], legend='Cross Legend', colour='blue', |
186 | marker='cross') |
189 | marker='cross') |
187 | self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis")) |
190 | #self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis")) |
Line 188... | Line 191... | ||
188 | 191 | ||
189 | # Configure TestListCtrl |
192 | # Configure TestListCtrl |
190 | self.TestListCtrl.InsertColumn(0, "Name") |
193 | self.TestListCtrl.InsertColumn(0, "Name") |
Line 212... | Line 215... | ||
212 | #make a string to display |
215 | #make a string to display |
213 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
216 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
214 | dc.DrawText(s, sx , sy+1) |
217 | dc.DrawText(s, sx , sy+1) |
215 | # ----------- |
218 | # ----------- |
Line -... | Line 219... | ||
- | 219 | ||
- | 220 | def OnTestSelected(self, event): |
|
- | 221 | testId = event.m_itemIndex |
|
- | 222 | print "Test Selected id=%d" % (testId) |
|
- | 223 | ||
- | 224 | vibTest = self.app.getTest(testId) |
|
- | 225 | nb = vibTest.getDataLen() |
|
- | 226 | ||
- | 227 | self.client.Clear() |
|
- | 228 | xydata = _Numeric.arange(nb*2) |
|
- | 229 | xydata.shape = (nb, 2) |
|
- | 230 | xydata[:,1] = vibTest.getRawData() |
|
- | 231 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red') |
|
- | 232 | self.client.Draw(wx.lib.plot.PlotGraphics([line],"Graph Title", "Time", "Acc"), yAxis= (-100,100)) |
|
- | 233 | ||
216 | 234 | ||
217 | def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
235 | def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
Line 218... | Line 236... | ||
218 | self.app.Import() |
236 | self.app.Import() |
Line 219... | Line 237... | ||
219 | 237 | ||
220 | # end of class MainFrame |
238 | # end of class MainFrame |
221 | 239 | ||
- | 240 | ||
- | 241 | class VibTest: |
|
222 | 242 | def __init__(self, name, rawData): |
|
- | 243 | self.name = name |
|
- | 244 | self.rawData = _Numeric.array(rawData) |
|
- | 245 | self.dc = self.rawData.mean() |
|
- | 246 | self.rawData -= self.dc |
|
- | 247 | self.dataLen = len(rawData) |
|
- | 248 | ||
- | 249 | def getName(self): |
|
- | 250 | return self.name |
|
- | 251 | ||
- | 252 | def getRawData(self): |
|
Line 223... | Line 253... | ||
223 | class VibTest: |
253 | return self.rawData |
224 | def __init__(self, name, rawData): |
254 | |
225 | self.name = name |
255 | def getDataLen(self): |
Line 238... | Line 268... | ||
238 | self.VibTests.append(test) |
268 | self.VibTests.append(test) |
Line 239... | Line 269... | ||
239 | 269 | ||
240 | index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name) |
270 | index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name) |
Line -... | Line 271... | ||
- | 271 | self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK") |
|
- | 272 | ||
- | 273 | def getTest(self, testId): |
|
241 | self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK") |
274 | return self.VibTests[testId] |
242 | 275 | ||
243 | def OnInit(self): |
276 | def OnInit(self): |
244 | wx.InitAllImageHandlers() |
277 | wx.InitAllImageHandlers() |
245 | self.frame_1 = MainFrame(None, -1, "") |
278 | self.frame_1 = MainFrame(None, -1, "") |
Line 249... | Line 282... | ||
249 | self.frame_1.Show() |
282 | self.frame_1.Show() |
250 | return 1 |
283 | return 1 |
Line 251... | Line 284... | ||
251 | 284 | ||
252 | def Import(self): |
285 | def Import(self): |
- | 286 | print "Import" |
|
- | 287 | logfile = open("../Misc/Matlab/Data/unbal200.txt", "r") |
|
- | 288 | data = None |
|
- | 289 | for line in logfile: |
|
- | 290 | values = line.split(',') |
|
- | 291 | if data == None: |
|
- | 292 | nbCols = len(values) |
|
- | 293 | print "%d cols" % nbCols |
|
253 | print "Import" |
294 | data = [] |
- | 295 | for i in range(nbCols): |
|
- | 296 | data.append([]) |
|
- | 297 | for i in range(nbCols): |
|
- | 298 | data[i].append(int(values[i])) |
|
- | 299 | logfile.close() |
|
254 | self.AddTest("Test1", range(0,1000)) |
300 | for i in range(nbCols): |
- | 301 | self.AddTest("Imported %d"%i, data[i]) |
|
- | 302 | ||
- | 303 | ||
Line -... | Line 304... | ||
- | 304 | ||
255 | self.AddTest("Test2", range(0,1000)) |
305 | |
Line 256... | Line 306... | ||
256 | 306 | ||
257 | # end of class App |
307 | # end of class App |
258 | 308 |