Subversion Repositories Projects

Rev

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

Rev 593 Rev 594
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)
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)
120
        self.yAxesChoice = wx.ComboBox(self, -1, choices=["10", "25", "50", "100", "250"], style=wx.CB_DROPDOWN)
121
        self.graphTypeChoise = wx.ComboBox(self, -1, choices=["Raw Data", "Filtered Data", "Spectrum"], style=wx.CB_DROPDOWN)
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)
122
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
123
 
123
 
124
        self.__set_properties()
124
        self.__set_properties()
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.onYAxesChange, self.yAxesChoice)
128
        self.Bind(wx.EVT_COMBOBOX, self.onYAxesChange, self.yAxesChoice)
129
        # end wxGlade
129
        # end wxGlade
130
 
130
 
131
    def setApp(self, app):
131
    def setApp(self, app):
132
        self.app = app
132
        self.app = app
133
 
133
 
134
    def __set_properties(self):
134
    def __set_properties(self):
135
        # begin wxGlade: MainFrame.__set_properties
135
        # begin wxGlade: MainFrame.__set_properties
136
        self.SetTitle("VibrationTest")
136
        self.SetTitle("VibrationTest")
137
        self.GraphPanel.SetMinSize((800,300))
137
        self.GraphPanel.SetMinSize((800,300))
138
        self.yAxesChoice.SetSelection(2)
138
        self.yAxesChoice.SetSelection(2)
139
        self.graphTypeChoise.SetSelection(0)
139
        self.graphTypeChoise.SetSelection(0)
140
        # end wxGlade
140
        # end wxGlade
141
 
141
 
142
    def __do_layout(self):
142
    def __do_layout(self):
143
        # begin wxGlade: MainFrame.__do_layout
143
        # begin wxGlade: MainFrame.__do_layout
144
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
144
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
145
        grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
145
        grid_sizer_2 = wx.GridSizer(2, 1, 4, 4)
146
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
146
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
147
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
147
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
148
        sizer_1.Add((20, 20), 0, 0, 0)
148
        sizer_1.Add((20, 20), 0, 0, 0)
149
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
149
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
150
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
150
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
151
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
151
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
152
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
152
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
153
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
153
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
154
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
154
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
155
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
155
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
156
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
156
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
157
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
157
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
158
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
158
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
159
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
159
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
160
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
160
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
161
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
161
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
162
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
162
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
163
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
163
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
164
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
164
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
165
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
165
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
166
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
166
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
167
        sizer_1.Add((20, 20), 0, 0, 0)
167
        sizer_1.Add((20, 20), 0, 0, 0)
168
        sizer_1.Add(self.GraphPanel, 1, 0, 0)
168
        sizer_1.Add(self.GraphPanel, 1, 0, 0)
169
        sizer_2.Add(self.yAxesChoice, 0, 0, 0)
169
        sizer_2.Add(self.yAxesChoice, 0, 0, 0)
170
        sizer_2.Add(self.graphTypeChoise, 0, 0, 0)
170
        sizer_2.Add(self.graphTypeChoise, 0, 0, 0)
171
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)
171
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)
172
        sizer_1.Add((20, 20), 0, 0, 0)
172
        sizer_1.Add((20, 20), 0, 0, 0)
173
        grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
173
        grid_sizer_2.Add(self.TestListCtrl, 1, wx.ALL|wx.EXPAND, 0)
174
        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
174
        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
175
        self.SetSizer(sizer_1)
175
        self.SetSizer(sizer_1)
176
        sizer_1.Fit(self)
176
        sizer_1.Fit(self)
177
        self.Layout()
177
        self.Layout()
178
        # end wxGlade
178
        # end wxGlade
179
 
179
 
180
        # List events
180
        # List events
181
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
181
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
182
 
182
 
183
        # Configure Graph
183
        # Configure Graph
184
        self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300))
184
        self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300))
185
       
185
       
186
        self.client.SetPointLabelFunc(self.DrawPointLabel)
186
        self.client.SetPointLabelFunc(self.DrawPointLabel)
187
       
187
       
188
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
188
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
189
        self.client.SetFontSizeAxis(10)
189
        self.client.SetFontSizeAxis(10)
190
        self.client.SetFontSizeLegend(7)
190
        self.client.SetFontSizeLegend(7)
191
        self.client.setLogScale((False,False))
191
        self.client.setLogScale((False,False))
192
 
192
 
193
 
193
 
194
        # Configure TestListCtrl
194
        # Configure TestListCtrl
-
 
195
        self.TestListCtrl.InsertColumn(0, "Description")
195
        self.TestListCtrl.InsertColumn(0, "Name")
196
        self.TestListCtrl.InsertColumn(1, "Speed")
-
 
197
        self.TestListCtrl.InsertColumn(2, "Channel")
196
        self.TestListCtrl.InsertColumn(1, "Result")
198
        self.TestListCtrl.InsertColumn(3, "Result")
197
 
199
 
198
    def DrawPointLabel(self, dc, mDataDict):
200
    def DrawPointLabel(self, dc, mDataDict):
199
        """This is the fuction that defines how the pointLabels are plotted
201
        """This is the fuction that defines how the pointLabels are plotted
200
            dc - DC that will be passed
202
            dc - DC that will be passed
201
            mDataDict - Dictionary of data that you want to use for the pointLabel
203
            mDataDict - Dictionary of data that you want to use for the pointLabel
202
 
204
 
203
            As an example I have decided I want a box at the curve point
205
            As an example I have decided I want a box at the curve point
204
            with some text information about the curve plotted below.
206
            with some text information about the curve plotted below.
205
            Any wxDC method can be used.
207
            Any wxDC method can be used.
206
        """
208
        """
207
        # ----------
209
        # ----------
208
        dc.SetPen(wx.Pen(wx.BLACK))
210
        dc.SetPen(wx.Pen(wx.BLACK))
209
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
211
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
210
       
212
       
211
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
213
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
212
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
214
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
213
        px,py = mDataDict["pointXY"]
215
        px,py = mDataDict["pointXY"]
214
        cNum = mDataDict["curveNum"]
216
        cNum = mDataDict["curveNum"]
215
        pntIn = mDataDict["pIndex"]
217
        pntIn = mDataDict["pIndex"]
216
        legend = mDataDict["legend"]
218
        legend = mDataDict["legend"]
217
        #make a string to display
219
        #make a string to display
218
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
220
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
219
        dc.DrawText(s, sx , sy+1)
221
        dc.DrawText(s, sx , sy+1)
220
        # -----------
222
        # -----------
221
 
223
 
222
    def OnTestSelected(self, event):
224
    def OnTestSelected(self, event):
223
         testId = event.m_itemIndex
225
         testId = event.m_itemIndex
224
         print "Test Selected id=%d" % (testId)
226
         print "Test Selected id=%d" % (testId)
225
         self.activeTestId = testId
227
         self.activeTestId = testId
226
         self.drawGraph()
228
         self.drawGraph()
227
 
229
 
228
    def drawGraph(self):
230
    def drawGraph(self):
229
         vibTest = self.app.getTest(self.activeTestId)
231
         vibTest = self.app.getTest(self.activeTestId)
230
         nb = vibTest.getDataLen()
232
         nb = vibTest.getDataLen()
231
         y = int(self.yAxesChoice.GetStringSelection())
233
         y = int(self.yAxesChoice.GetStringSelection())
232
 
234
 
233
         #self.client.Clear()
235
         #self.client.Clear()
234
         xydata = _Numeric.linspace(0,0.09*nb,2*nb)
236
         xydata = _Numeric.linspace(0,0.09*nb,2*nb)
235
         xydata.shape = (nb, 2)
237
         xydata.shape = (nb, 2)
236
         xydata[:,1] = vibTest.getRawData()
238
         xydata[:,1] = vibTest.getRawData()
237
         line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
239
         line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red')
238
         self.client.Draw(wx.lib.plot.PlotGraphics([line],"Graph Title", "Time (ms)", "Acc"), yAxis= (-y,y))
240
         self.client.Draw(wx.lib.plot.PlotGraphics([line],"Graph Title", "Time (ms)", "Acc"), yAxis= (-y,y))
239
         self.client.SetEnableGrid('Horizontal')
241
         self.client.SetEnableGrid('Horizontal')
240
 
242
 
241
 
243
 
242
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
244
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
243
        self.app.Import()
245
        self.app.Import()
244
 
246
 
245
    def onYAxesChange(self, event): # wxGlade: MainFrame.<event_handler>
247
    def onYAxesChange(self, event): # wxGlade: MainFrame.<event_handler>
246
        self.drawGraph()
248
        self.drawGraph()
247
 
249
 
248
# end of class MainFrame
250
# end of class MainFrame
249
 
251
 
250
 
252
 
251
class VibTest:
253
class VibTest:
252
    def __init__(self, name, rawData):
254
    def __init__(self, descr, motor, speed, rawData):
-
 
255
        self.descr = descr
-
 
256
        self.motor = motor
253
        self.name = name
257
        self.speed = speed
254
        self.rawData = _Numeric.array(rawData)
258
        self.rawData = _Numeric.array(rawData)
255
        self.dc = self.rawData.mean()
259
        self.dc = self.rawData.mean()
256
        self.rawData -= self.dc
260
        self.rawData -= self.dc
257
        self.dataLen = len(rawData)
261
        self.dataLen = len(rawData)
258
 
262
 
259
    def getName(self):
263
    def getDescr(self):
260
        return self.name
264
        return self.Descr
261
 
265
 
262
    def getRawData(self):
266
    def getRawData(self):
263
        return self.rawData
267
        return self.rawData
264
 
268
 
265
    def getDataLen(self):
269
    def getDataLen(self):
266
        return self.dataLen
270
        return self.dataLen
267
 
271
 
268
 
272
 
269
class App(wx.App):
273
class App(wx.App):
270
    def __init__(self, par):
274
    def __init__(self, par):
271
        self.VibTests = []
275
        self.VibTests = []
272
 
276
 
273
        wx.App.__init__(self, par)
277
        wx.App.__init__(self, par)
274
 
278
 
275
 
279
 
276
    def AddTest(self, name, rawData):
280
    def AddTest(self, descr, motor, speed, rawData):
277
        test = VibTest(name, rawData)
281
        test = VibTest(descr, motor, speed, rawData)
278
        self.VibTests.append(test)
282
        self.VibTests.append(test)
279
 
283
 
280
        index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.name)
284
        index = self.frame_1.TestListCtrl.InsertStringItem(sys.maxint, test.descr)
281
        self.frame_1.TestListCtrl.SetStringItem(index, 1, "OK")
285
        self.frame_1.TestListCtrl.SetStringItem(index, 3, "OK")
282
 
286
 
283
    def getTest(self, testId):
287
    def getTest(self, testId):
284
        return self.VibTests[testId]
288
        return self.VibTests[testId]
285
 
289
 
286
    def OnInit(self):
290
    def OnInit(self):
287
        wx.InitAllImageHandlers()
291
        wx.InitAllImageHandlers()
288
        self.frame_1 = MainFrame(None, -1, "")
292
        self.frame_1 = MainFrame(None, -1, "")
289
        self.frame_1.setApp(self);
293
        self.frame_1.setApp(self);
290
        self.SetTopWindow(self.frame_1)
294
        self.SetTopWindow(self.frame_1)
291
 
295
 
292
        self.frame_1.Show()
296
        self.frame_1.Show()
293
        return 1
297
        return 1
294
 
298
 
295
    def Import(self):
299
    def Import(self):
296
        print "Import"
300
        print "Import"
297
        logfile = open("../Misc/Matlab/Data/unbal200.txt", "r")
301
        logfile = open("./unbal200.txt", "r")
298
        data = None
302
        data = None
299
        for line in logfile:
303
        for line in logfile:
300
            values = line.split(',')
304
            values = line.split(',')
301
            if data == None:
305
            if data == None:
302
                nbCols = len(values)
306
                nbCols = len(values)
303
                print "%d cols" % nbCols
307
                print "%d cols" % nbCols
304
                data = []
308
                data = []
305
                for i in range(nbCols):
309
                for i in range(nbCols):
306
                    data.append([])
310
                    data.append([])
-
 
311
            else:
307
            for i in range(nbCols):
312
              for i in range(nbCols):
308
                data[i].append(int(values[i]))
313
                  data[i].append(int(values[i]))
309
        logfile.close()
314
        logfile.close()
310
        for i in range(nbCols):
315
        for i in range(nbCols):
311
            self.AddTest("Imported %d"%i, data[i])
316
            self.AddTest("Imported %d"%i, 0,0, data[i])
312
       
317
       
313
       
318
       
314
           
319
           
315
 
320
 
316
       
321
       
317
# end of class App
322
# end of class App
318
 
323
 
319
if __name__ == "__main__":
324
if __name__ == "__main__":
320
    VibrationTestGui = App(0)
325
    VibrationTestGui = App(0)
321
    VibrationTestGui.MainLoop()
326
    VibrationTestGui.MainLoop()
322
 
327