Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 588 → Rev 590

/VibrationTest/trunk/VibrationTest/VibrationTestGui.py
165,6 → 165,9
self.Layout()
# end wxGlade
 
# List events
self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
 
# Configure Graph
self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
self.client.SetPointLabelFunc(self.DrawPointLabel)
184,7 → 187,7
markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
(3.*pi/4., -1)], legend='Cross Legend', colour='blue',
marker='cross')
self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
#self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
 
# Configure TestListCtrl
self.TestListCtrl.InsertColumn(0, "Name")
214,6 → 217,21
dc.DrawText(s, sx , sy+1)
# -----------
 
def OnTestSelected(self, event):
testId = event.m_itemIndex
print "Test Selected id=%d" % (testId)
 
vibTest = self.app.getTest(testId)
nb = vibTest.getDataLen()
 
self.client.Clear()
xydata = _Numeric.arange(nb*2)
xydata.shape = (nb, 2)
xydata[:,1] = vibTest.getRawData()
line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
self.client.Draw(wx.lib.plot.PlotGraphics([line],"Graph Title", "Time", "Acc"), yAxis= (-100,100))
 
 
def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
self.app.Import()
 
223,9 → 241,21
class VibTest:
def __init__(self, name, rawData):
self.name = name
self.rawData = rawData
self.rawData = _Numeric.array(rawData)
self.dc = self.rawData.mean()
self.rawData -= self.dc
self.dataLen = len(rawData)
 
def getName(self):
return self.name
 
def getRawData(self):
return self.rawData
 
def getDataLen(self):
return self.dataLen
 
 
class App(wx.App):
def __init__(self, par):
self.VibTests = []
240,6 → 270,9
index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
 
def getTest(self, testId):
return self.VibTests[testId]
 
def OnInit(self):
wx.InitAllImageHandlers()
self.frame_1 = MainFrame(None, -1, "")
251,9 → 284,26
 
def Import(self):
print "Import"
self.AddTest("Test1", range(0,1000))
self.AddTest("Test2", range(0,1000))
logfile = open("../Misc/Matlab/Data/unbal200.txt", "r")
data = None
for line in logfile:
values = line.split(',')
if data == None:
nbCols = len(values)
print "%d cols" % nbCols
data = []
for i in range(nbCols):
data.append([])
for i in range(nbCols):
data[i].append(int(values[i]))
logfile.close()
for i in range(nbCols):
self.AddTest("Imported %d"%i, data[i])
 
# end of class App
 
if __name__ == "__main__":