Subversion Repositories Projects

Rev

Rev 590 | Rev 592 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 590 Rev 591
1
#!/usr/bin/env python
1
#!/usr/bin/env python
2
# -*- coding: iso-8859-15 -*-
2
# -*- coding: iso-8859-15 -*-
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
4
 
4
 
5
import sys
5
import sys
6
import wx
6
import wx
7
import wx.lib
7
import wx.lib
8
import wx.lib.plot
8
import wx.lib.plot
9
 
9
 
10
# Needs Numeric or numarray or NumPy
10
# Needs Numeric or numarray or NumPy
11
try:
11
try:
12
    import numpy.oldnumeric as _Numeric
12
    import numpy.oldnumeric as _Numeric
13
except:
13
except:
14
    try:
14
    try:
15
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
15
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
16
    except:
16
    except:
17
        try:
17
        try:
18
            import Numeric as _Numeric
18
            import Numeric as _Numeric
19
        except:
19
        except:
20
            msg= """
20
            msg= """
21
            This module requires the Numeric/numarray or NumPy module,
21
            This module requires the Numeric/numarray or NumPy module,
22
            which could not be imported.  It probably is not installed
22
            which could not be imported.  It probably is not installed
23
            (it's not part of the standard Python distribution). See the
23
            (it's not part of the standard Python distribution). See the
24
            Numeric Python site (http://numpy.scipy.org) for information on
24
            Numeric Python site (http://numpy.scipy.org) for information on
25
            downloading source or binaries."""
25
            downloading source or binaries."""
26
            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
26
            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
27
 
27
 
28
# begin wxGlade: extracode
28
# begin wxGlade: extracode
29
# end wxGlade
29
# end wxGlade
30
 
30
 
31
 
31
 
32
 
32
 
33
class MenuBar(wx.MenuBar):
33
class MenuBar(wx.MenuBar):
34
    def __init__(self, *args, **kwds):
34
    def __init__(self, *args, **kwds):
35
        # content of this block not found: did you rename this class?
35
        # content of this block not found: did you rename this class?
36
        pass
36
        pass
37
 
37
 
38
    def __set_properties(self):
38
    def __set_properties(self):
39
        # content of this block not found: did you rename this class?
39
        # content of this block not found: did you rename this class?
40
        pass
40
        pass
41
 
41
 
42
    def __do_layout(self):
42
    def __do_layout(self):
43
        # content of this block not found: did you rename this class?
43
        # content of this block not found: did you rename this class?
44
        pass
44
        pass
45
 
45
 
46
# end of class MenuBar
46
# end of class MenuBar
47
 
47
 
48
 
48
 
49
class wxFrame(wx.Panel):
49
class wxFrame(wx.Panel):
50
    def __init__(self, *args, **kwds):
50
    def __init__(self, *args, **kwds):
51
        # content of this block not found: did you rename this class?
51
        # content of this block not found: did you rename this class?
52
        pass
52
        pass
53
 
53
 
54
    def __set_properties(self):
54
    def __set_properties(self):
55
        # content of this block not found: did you rename this class?
55
        # content of this block not found: did you rename this class?
56
        pass
56
        pass
57
 
57
 
58
    def __do_layout(self):
58
    def __do_layout(self):
59
        # content of this block not found: did you rename this class?
59
        # content of this block not found: did you rename this class?
60
        pass
60
        pass
61
 
61
 
62
# end of class wxFrame
62
# end of class wxFrame
63
 
63
 
64
 
64
 
65
class MyFrame(wx.Frame):
65
class MyFrame(wx.Frame):
66
    def __init__(self, *args, **kwds):
66
    def __init__(self, *args, **kwds):
67
        # content of this block not found: did you rename this class?
67
        # content of this block not found: did you rename this class?
68
        pass
68
        pass
69
 
69
 
70
    def __set_properties(self):
70
    def __set_properties(self):
71
        # content of this block not found: did you rename this class?
71
        # content of this block not found: did you rename this class?
72
        pass
72
        pass
73
 
73
 
74
    def __do_layout(self):
74
    def __do_layout(self):
75
        # content of this block not found: did you rename this class?
75
        # content of this block not found: did you rename this class?
76
        pass
76
        pass
77
 
77
 
78
# end of class MyFrame
78
# end of class MyFrame
79
 
79
 
80
 
80
 
81
class MainFrame(wx.Frame):
81
class MainFrame(wx.Frame):
82
    def __init__(self, *args, **kwds):
82
    def __init__(self, *args, **kwds):
83
        # begin wxGlade: MainFrame.__init__
83
        # begin wxGlade: MainFrame.__init__
84
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
84
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
85
        wx.Frame.__init__(self, *args, **kwds)
85
        wx.Frame.__init__(self, *args, **kwds)
86
       
86
       
87
        # Menu Bar
87
        # Menu Bar
88
        self.frame_1_menubar = wx.MenuBar()
88
        self.frame_1_menubar = wx.MenuBar()
89
        wxglade_tmp_menu = wx.Menu()
89
        wxglade_tmp_menu = wx.Menu()
90
        wxglade_tmp_menu.Append(wx.NewId(), "Exit", "", wx.ITEM_NORMAL)
90
        wxglade_tmp_menu.Append(wx.NewId(), "Exit", "", wx.ITEM_NORMAL)
91
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
91
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
92
        wxglade_tmp_menu = wx.Menu()
92
        wxglade_tmp_menu = wx.Menu()
93
        wxglade_tmp_menu.Append(wx.NewId(), "Clear", "", wx.ITEM_NORMAL)
93
        wxglade_tmp_menu.Append(wx.NewId(), "Clear", "", wx.ITEM_NORMAL)
94
        wxglade_tmp_menu.Append(wx.NewId(), "Import", "", wx.ITEM_NORMAL)
94
        wxglade_tmp_menu.Append(wx.NewId(), "Import", "", wx.ITEM_NORMAL)
95
        self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet")
95
        self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet")
96
        wxglade_tmp_menu = wx.Menu()
96
        wxglade_tmp_menu = wx.Menu()
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.Port = wx.StaticText(self, -1, "Port")
103
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
103
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
104
        self.label_5 = wx.StaticText(self, -1, "label_5")
104
        self.label_5 = wx.StaticText(self, -1, "label_5")
105
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
105
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
106
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
106
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
107
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
107
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
108
        self.label_6 = wx.StaticText(self, -1, "label_6")
108
        self.label_6 = wx.StaticText(self, -1, "label_6")
109
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
109
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
110
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
110
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
111
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
111
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
112
        self.label_7 = wx.StaticText(self, -1, "label_7")
112
        self.label_7 = wx.StaticText(self, -1, "label_7")
113
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
113
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
114
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
114
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
115
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
115
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
116
        self.label_8 = wx.StaticText(self, -1, "label_8")
116
        self.label_8 = wx.StaticText(self, -1, "label_8")
117
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
117
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
118
        self.button_1 = wx.Button(self, -1, "button_1")
118
        self.button_1 = wx.Button(self, -1, "button_1")
-
 
119
        self.GraphPanel = wx.Panel(self, -1, style=wx.DOUBLE_BORDER|wx.TAB_TRAVERSAL)
-
 
120
        self.choice_3 = wx.Choice(self, -1, choices=[])
119
        self.GraphFanel = wx.Panel(self, -1)
121
        self.choice_4 = wx.Choice(self, -1, choices=[])
120
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
122
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
121
 
123
 
122
        self.__set_properties()
124
        self.__set_properties()
123
        self.__do_layout()
125
        self.__do_layout()
124
 
126
 
125
        self.Bind(wx.EVT_MENU, self.OnImport, id=-1)
127
        self.Bind(wx.EVT_MENU, self.OnImport, id=-1)
126
        # end wxGlade
128
        # end wxGlade
127
 
129
 
128
    def setApp(self, app):
130
    def setApp(self, app):
129
        self.app = app
131
        self.app = app
130
 
132
 
131
    def __set_properties(self):
133
    def __set_properties(self):
132
        # begin wxGlade: MainFrame.__set_properties
134
        # begin wxGlade: MainFrame.__set_properties
133
        self.SetTitle("VibrationTest")
135
        self.SetTitle("VibrationTest")
134
        self.GraphFanel.SetMinSize((800,300))
136
        self.GraphPanel.SetMinSize((800,300))
135
        # end wxGlade
137
        # end wxGlade
136
 
138
 
137
    def __do_layout(self):
139
    def __do_layout(self):
138
        # begin wxGlade: MainFrame.__do_layout
140
        # begin wxGlade: MainFrame.__do_layout
139
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
141
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
140
        grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
142
        grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
-
 
143
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
141
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
144
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
-
 
145
        sizer_1.Add((20, 20), 0, 0, 0)
142
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
146
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
143
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
147
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
144
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
148
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
145
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
149
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
146
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
150
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
147
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
151
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
148
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
152
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
149
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
153
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
150
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
154
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
151
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
155
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
152
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
156
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
153
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
157
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
154
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
158
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
155
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
159
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
156
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
160
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
157
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
161
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
158
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
162
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
159
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
163
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
-
 
164
        sizer_1.Add((20, 20), 0, 0, 0)
-
 
165
        sizer_1.Add(self.GraphPanel, 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
-
 
166
        sizer_2.Add(self.choice_3, 0, 0, 0)
-
 
167
        sizer_2.Add(self.choice_4, 0, 0, 0)
160
        sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
168
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)
-
 
169
        sizer_1.Add((20, 20), 0, 0, 0)
161
        grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
170
        grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
162
        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
171
        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
163
        self.SetSizer(sizer_1)
172
        self.SetSizer(sizer_1)
164
        sizer_1.Fit(self)
173
        sizer_1.Fit(self)
165
        self.Layout()
174
        self.Layout()
166
        # end wxGlade
175
        # end wxGlade
167
 
176
 
168
        # List events
177
        # List events
169
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
178
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
170
 
179
 
171
        # Configure Graph
180
        # Configure Graph
172
        self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
181
        self.client = wx.lib.plot.PlotCanvas(self.GraphPanel)
173
        self.client.SetPointLabelFunc(self.DrawPointLabel)
182
        self.client.SetPointLabelFunc(self.DrawPointLabel)
174
       
183
       
175
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
184
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
176
        self.client.SetFontSizeAxis(10)
185
        self.client.SetFontSizeAxis(10)
177
        self.client.SetFontSizeLegend(7)
186
        self.client.SetFontSizeLegend(7)
178
        self.client.setLogScale((False,False))
187
        self.client.setLogScale((False,False))
179
        self.client.SetXSpec('auto')
188
        self.client.SetXSpec('auto')
180
        self.client.SetYSpec('auto')
189
        self.client.SetYSpec('auto')
181
 
190
 
182
        data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
191
        data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
183
        data1.shape = (100, 2)
192
        data1.shape = (100, 2)
184
        data1[:,1] = _Numeric.sin(data1[:,0])
193
        data1[:,1] = _Numeric.sin(data1[:,0])
185
        markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
194
        markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
186
        pi = 3.1415
195
        pi = 3.1415
187
        markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
196
        markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
188
                          (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
197
                          (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
189
                          marker='cross')
198
                          marker='cross')
190
        #self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
199
        #self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
191
 
200
 
192
        # Configure TestListCtrl
201
        # Configure TestListCtrl
193
        self.TestListCtrl.InsertColumn(0, "Name")
202
        self.TestListCtrl.InsertColumn(0, "Name")
194
        self.TestListCtrl.InsertColumn(1, "Result")
203
        self.TestListCtrl.InsertColumn(1, "Result")
195
 
204
 
196
    def DrawPointLabel(self, dc, mDataDict):
205
    def DrawPointLabel(self, dc, mDataDict):
197
        """This is the fuction that defines how the pointLabels are plotted
206
        """This is the fuction that defines how the pointLabels are plotted
198
            dc - DC that will be passed
207
            dc - DC that will be passed
199
            mDataDict - Dictionary of data that you want to use for the pointLabel
208
            mDataDict - Dictionary of data that you want to use for the pointLabel
200
 
209
 
201
            As an example I have decided I want a box at the curve point
210
            As an example I have decided I want a box at the curve point
202
            with some text information about the curve plotted below.
211
            with some text information about the curve plotted below.
203
            Any wxDC method can be used.
212
            Any wxDC method can be used.
204
        """
213
        """
205
        # ----------
214
        # ----------
206
        dc.SetPen(wx.Pen(wx.BLACK))
215
        dc.SetPen(wx.Pen(wx.BLACK))
207
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
216
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
208
       
217
       
209
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
218
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
210
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
219
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
211
        px,py = mDataDict["pointXY"]
220
        px,py = mDataDict["pointXY"]
212
        cNum = mDataDict["curveNum"]
221
        cNum = mDataDict["curveNum"]
213
        pntIn = mDataDict["pIndex"]
222
        pntIn = mDataDict["pIndex"]
214
        legend = mDataDict["legend"]
223
        legend = mDataDict["legend"]
215
        #make a string to display
224
        #make a string to display
216
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
225
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
217
        dc.DrawText(s, sx , sy+1)
226
        dc.DrawText(s, sx , sy+1)
218
        # -----------
227
        # -----------
219
 
228
 
220
    def OnTestSelected(self, event):
229
    def OnTestSelected(self, event):
221
         testId = event.m_itemIndex
230
         testId = event.m_itemIndex
222
         print "Test Selected id=%d" % (testId)
231
         print "Test Selected id=%d" % (testId)
223
 
232
 
224
         vibTest = self.app.getTest(testId)
233
         vibTest = self.app.getTest(testId)
225
         nb = vibTest.getDataLen()
234
         nb = vibTest.getDataLen()
226
 
235
 
227
         self.client.Clear()
236
         self.client.Clear()
228
         xydata = _Numeric.arange(nb*2)
237
         xydata = _Numeric.arange(nb*2)
229
         xydata.shape = (nb, 2)
238
         xydata.shape = (nb, 2)
230
         xydata[:,1] = vibTest.getRawData()
239
         xydata[:,1] = vibTest.getRawData()
231
         line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
240
         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))
241
         self.client.Draw(wx.lib.plot.PlotGraphics([line],"Graph Title", "Time", "Acc"), yAxis= (-100,100))
233
 
242
 
234
 
243
 
235
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
244
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
236
        self.app.Import()
245
        self.app.Import()
237
 
246
 
238
# end of class MainFrame
247
# end of class MainFrame
239
 
248
 
240
 
249
 
241
class VibTest:
250
class VibTest:
242
    def __init__(self, name, rawData):
251
    def __init__(self, name, rawData):
243
        self.name = name
252
        self.name = name
244
        self.rawData = _Numeric.array(rawData)
253
        self.rawData = _Numeric.array(rawData)
245
        self.dc = self.rawData.mean()
254
        self.dc = self.rawData.mean()
246
        self.rawData -= self.dc
255
        self.rawData -= self.dc
247
        self.dataLen = len(rawData)
256
        self.dataLen = len(rawData)
248
 
257
 
249
    def getName(self):
258
    def getName(self):
250
        return self.name
259
        return self.name
251
 
260
 
252
    def getRawData(self):
261
    def getRawData(self):
253
        return self.rawData
262
        return self.rawData
254
 
263
 
255
    def getDataLen(self):
264
    def getDataLen(self):
256
        return self.dataLen
265
        return self.dataLen
257
 
266
 
258
 
267
 
259
class App(wx.App):
268
class App(wx.App):
260
    def __init__(self, par):
269
    def __init__(self, par):
261
        self.VibTests = []
270
        self.VibTests = []
262
 
271
 
263
        wx.App.__init__(self, par)
272
        wx.App.__init__(self, par)
264
 
273
 
265
 
274
 
266
    def AddTest(self, name, rawData):
275
    def AddTest(self, name, rawData):
267
        test = VibTest(name, rawData)
276
        test = VibTest(name, rawData)
268
        self.VibTests.append(test)
277
        self.VibTests.append(test)
269
 
278
 
270
        index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
279
        index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
271
        self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
280
        self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
272
 
281
 
273
    def getTest(self, testId):
282
    def getTest(self, testId):
274
        return self.VibTests[testId]
283
        return self.VibTests[testId]
275
 
284
 
276
    def OnInit(self):
285
    def OnInit(self):
277
        wx.InitAllImageHandlers()
286
        wx.InitAllImageHandlers()
278
        self.frame_1 = MainFrame(None, -1, "")
287
        self.frame_1 = MainFrame(None, -1, "")
279
        self.frame_1.setApp(self);
288
        self.frame_1.setApp(self);
280
        self.SetTopWindow(self.frame_1)
289
        self.SetTopWindow(self.frame_1)
281
 
290
 
282
        self.frame_1.Show()
291
        self.frame_1.Show()
283
        return 1
292
        return 1
284
 
293
 
285
    def Import(self):
294
    def Import(self):
286
        print "Import"
295
        print "Import"
287
        logfile = open("../Misc/Matlab/Data/unbal200.txt", "r")
296
        logfile = open("../Misc/Matlab/Data/unbal200.txt", "r")
288
        data = None
297
        data = None
289
        for line in logfile:
298
        for line in logfile:
290
            values = line.split(',')
299
            values = line.split(',')
291
            if data == None:
300
            if data == None:
292
                nbCols = len(values)
301
                nbCols = len(values)
293
                print "%d cols" % nbCols
302
                print "%d cols" % nbCols
294
                data = []
303
                data = []
295
                for i in range(nbCols):
304
                for i in range(nbCols):
296
                    data.append([])
305
                    data.append([])
297
            for i in range(nbCols):
306
            for i in range(nbCols):
298
                data[i].append(int(values[i]))
307
                data[i].append(int(values[i]))
299
        logfile.close()
308
        logfile.close()
300
        for i in range(nbCols):
309
        for i in range(nbCols):
301
            self.AddTest("Imported %d"%i, data[i])
310
            self.AddTest("Imported %d"%i, data[i])
302
       
311
       
303
       
312
       
304
           
313
           
305
 
314
 
306
       
315
       
307
# end of class App
316
# end of class App
308
 
317
 
309
if __name__ == "__main__":
318
if __name__ == "__main__":
310
    VibrationTestGui = App(0)
319
    VibrationTestGui = App(0)
311
    VibrationTestGui.MainLoop()
320
    VibrationTestGui.MainLoop()
312
 
321