Subversion Repositories Projects

Rev

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

Rev 607 Rev 608
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 os
6
import os
7
import wx
7
import wx
8
import wx.lib
8
import wx.lib
9
import wx.lib.plot
9
import wx.lib.plot
10
import ConfigParser
10
import ConfigParser
11
 
11
 
12
# Needs Numeric or numarray or NumPy
12
# Needs Numeric or numarray or NumPy
13
try:
13
try:
14
    import numpy.oldnumeric as _Numeric
14
    import numpy.oldnumeric as _Numeric
15
except:
15
except:
16
    try:
16
    try:
17
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
17
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
18
    except:
18
    except:
19
        try:
19
        try:
20
            import Numeric as _Numeric
20
            import Numeric as _Numeric
21
        except:
21
        except:
22
            msg= """
22
            msg= """
23
            This module requires the Numeric/numarray or NumPy module,
23
            This module requires the Numeric/numarray or NumPy module,
24
            which could not be imported.  It probably is not installed
24
            which could not be imported.  It probably is not installed
25
            (it's not part of the standard Python distribution). See the
25
            (it's not part of the standard Python distribution). See the
26
            Numeric Python site (http://numpy.scipy.org) for information on
26
            Numeric Python site (http://numpy.scipy.org) for information on
27
            downloading source or binaries."""
27
            downloading source or binaries."""
28
            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
28
            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
29
 
29
 
30
# begin wxGlade: extracode
30
# begin wxGlade: extracode
31
# end wxGlade
31
# end wxGlade
32
 
32
 
33
 
33
 
34
 
34
 
35
class SettingsDialog(wx.Dialog):
35
class SettingsDialog(wx.Dialog):
36
    def __init__(self, *args, **kwds):
36
    def __init__(self, *args, **kwds):
37
        # begin wxGlade: SettingsDialog.__init__
37
        # begin wxGlade: SettingsDialog.__init__
38
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
38
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
39
        wx.Dialog.__init__(self, *args, **kwds)
39
        wx.Dialog.__init__(self, *args, **kwds)
40
        self.label_5_copy = wx.StaticText(self, -1, "COM Port ", style=wx.ALIGN_RIGHT)
-
 
41
        self.comPortCtrl_copy = wx.TextCtrl(self, -1, "")
-
 
42
        self.button_5_copy = wx.Button(self, wx.ID_CANCEL, "")
40
        self.button_5 = wx.Button(self, wx.ID_CANCEL, "")
43
        self.button_6_copy = wx.Button(self, wx.ID_OK, "")
41
        self.button_6 = wx.Button(self, wx.ID_OK, "")
44
 
42
 
45
        self.__set_properties()
43
        self.__set_properties()
46
        self.__do_layout()
44
        self.__do_layout()
47
        # end wxGlade
45
        # end wxGlade
-
 
46
 
-
 
47
        # The first argument that is passed to the constructor is the parent
-
 
48
        settings = args[0].app.settings
-
 
49
        # Add text-boxes for all settings
-
 
50
        self.grid_sizer_2.SetRows(len(settings))
-
 
51
        for setting in settings.iteritems():
-
 
52
            lb = wx.StaticText(self, -1, setting[1].descr, style=wx.ALIGN_RIGHT)
-
 
53
            tb = wx.TextCtrl(self, -1, str(setting[1].value))
-
 
54
            self.grid_sizer_2.Add(lb, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
55
            self.grid_sizer_2.Add(tb, 0, 0, 0)
-
 
56
        self.sizer_5.Fit(self)
-
 
57
        self.Layout()
48
 
58
 
49
    def __set_properties(self):
59
    def __set_properties(self):
50
        # begin wxGlade: SettingsDialog.__set_properties
60
        # begin wxGlade: SettingsDialog.__set_properties
51
        self.SetTitle("Settings")
61
        self.SetTitle("Settings")
52
        # end wxGlade
62
        # end wxGlade
53
 
63
 
54
    def __do_layout(self):
64
    def __do_layout(self):
55
        # begin wxGlade: SettingsDialog.__do_layout
65
        # begin wxGlade: SettingsDialog.__do_layout
56
        sizer_5_copy = wx.BoxSizer(wx.VERTICAL)
66
        sizer_5 = wx.BoxSizer(wx.VERTICAL)
57
        grid_sizer_3_copy = wx.GridSizer(1, 2, 0, 0)
67
        grid_sizer_3 = wx.GridSizer(1, 2, 0, 0)
58
        sizer_6_copy = wx.BoxSizer(wx.HORIZONTAL)
68
        sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
59
        grid_sizer_2_copy = wx.GridSizer(1, 2, 4, 4)
69
        grid_sizer_2 = wx.GridSizer(1, 2, 4, 4)
60
        sizer_5_copy.Add((20, 20), 0, 0, 0)
70
        sizer_5.Add((20, 20), 0, 0, 0)
61
        sizer_6_copy.Add((20, 20), 0, 0, 0)
71
        sizer_6.Add((20, 20), 0, 0, 0)
62
        grid_sizer_2_copy.Add(self.label_5_copy, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
63
        grid_sizer_2_copy.Add(self.comPortCtrl_copy, 0, 0, 0)
-
 
64
        sizer_6_copy.Add(grid_sizer_2_copy, 0, 0, 0)
72
        sizer_6.Add(grid_sizer_2, 0, 0, 0)
65
        sizer_6_copy.Add((20, 20), 0, 0, 0)
73
        sizer_6.Add((20, 20), 0, 0, 0)
66
        sizer_5_copy.Add(sizer_6_copy, 1, wx.EXPAND, 0)
74
        sizer_5.Add(sizer_6, 1, wx.EXPAND, 0)
67
        sizer_5_copy.Add((20, 20), 0, 0, 0)
75
        sizer_5.Add((20, 20), 0, 0, 0)
68
        grid_sizer_3_copy.Add(self.button_5_copy, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
76
        grid_sizer_3.Add(self.button_5, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
69
        grid_sizer_3_copy.Add(self.button_6_copy, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
77
        grid_sizer_3.Add(self.button_6, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
70
        sizer_5_copy.Add(grid_sizer_3_copy, 0, wx.EXPAND, 0)
78
        sizer_5.Add(grid_sizer_3, 0, wx.EXPAND, 0)
71
        sizer_5_copy.Add((20, 20), 0, 0, 0)
79
        sizer_5.Add((20, 20), 0, 0, 0)
72
        self.SetSizer(sizer_5_copy)
80
        self.SetSizer(sizer_5)
73
        sizer_5_copy.Fit(self)
81
        sizer_5.Fit(self)
74
        self.Layout()
82
        self.Layout()
75
        # end wxGlade
83
        # end wxGlade
-
 
84
 
-
 
85
        # Store some of the items, we will need them later
-
 
86
        self.grid_sizer_2 = grid_sizer_2  
-
 
87
        self.sizer_5 = sizer_5
-
 
88
 
-
 
89
       
76
 
90
 
77
# end of class SettingsDialog
91
# end of class SettingsDialog
78
 
92
 
79
 
93
 
80
class SettingsFrame(wx.Frame):
94
class SettingsFrame(wx.Frame):
81
    def __init__(self, *args, **kwds):
95
    def __init__(self, *args, **kwds):
82
        # content of this block not found: did you rename this class?
96
        # content of this block not found: did you rename this class?
83
        pass
97
        pass
84
 
98
 
85
    def __set_properties(self):
99
    def __set_properties(self):
86
        # content of this block not found: did you rename this class?
100
        # content of this block not found: did you rename this class?
87
        pass
101
        pass
88
 
102
 
89
    def __do_layout(self):
103
    def __do_layout(self):
90
        # content of this block not found: did you rename this class?
104
        # content of this block not found: did you rename this class?
91
        pass
105
        pass
92
 
106
 
93
# end of class SettingsFrame
107
# end of class SettingsFrame
94
 
108
 
95
 
109
 
96
class MenuBar(wx.MenuBar):
110
class MenuBar(wx.MenuBar):
97
    def __init__(self, *args, **kwds):
111
    def __init__(self, *args, **kwds):
98
        # content of this block not found: did you rename this class?
112
        # content of this block not found: did you rename this class?
99
        pass
113
        pass
100
 
114
 
101
    def __set_properties(self):
115
    def __set_properties(self):
102
        # content of this block not found: did you rename this class?
116
        # content of this block not found: did you rename this class?
103
        pass
117
        pass
104
 
118
 
105
    def __do_layout(self):
119
    def __do_layout(self):
106
        # content of this block not found: did you rename this class?
120
        # content of this block not found: did you rename this class?
107
        pass
121
        pass
108
 
122
 
109
# end of class MenuBar
123
# end of class MenuBar
110
 
124
 
111
 
125
 
112
class wxFrame(wx.Panel):
126
class wxFrame(wx.Panel):
113
    def __init__(self, *args, **kwds):
127
    def __init__(self, *args, **kwds):
114
        # content of this block not found: did you rename this class?
128
        # content of this block not found: did you rename this class?
115
        pass
129
        pass
116
 
130
 
117
    def __set_properties(self):
131
    def __set_properties(self):
118
        # content of this block not found: did you rename this class?
132
        # content of this block not found: did you rename this class?
119
        pass
133
        pass
120
 
134
 
121
    def __do_layout(self):
135
    def __do_layout(self):
122
        # content of this block not found: did you rename this class?
136
        # content of this block not found: did you rename this class?
123
        pass
137
        pass
124
 
138
 
125
# end of class wxFrame
139
# end of class wxFrame
126
 
140
 
127
 
141
 
128
class MyFrame(wx.Frame):
142
class MyFrame(wx.Frame):
129
    def __init__(self, *args, **kwds):
143
    def __init__(self, *args, **kwds):
130
        # content of this block not found: did you rename this class?
144
        # content of this block not found: did you rename this class?
131
        pass
145
        pass
132
 
146
 
133
    def __set_properties(self):
147
    def __set_properties(self):
134
        # content of this block not found: did you rename this class?
148
        # content of this block not found: did you rename this class?
135
        pass
149
        pass
136
 
150
 
137
    def __do_layout(self):
151
    def __do_layout(self):
138
        # content of this block not found: did you rename this class?
152
        # content of this block not found: did you rename this class?
139
        pass
153
        pass
140
 
154
 
141
# end of class MyFrame
155
# end of class MyFrame
142
 
156
 
143
 
157
 
144
class MainFrame(wx.Frame):
158
class MainFrame(wx.Frame):
145
    def __init__(self, *args, **kwds):
159
    def __init__(self, *args, **kwds):
146
        # begin wxGlade: MainFrame.__init__
160
        # begin wxGlade: MainFrame.__init__
147
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
161
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
148
        wx.Frame.__init__(self, *args, **kwds)
162
        wx.Frame.__init__(self, *args, **kwds)
149
       
163
       
150
        # Menu Bar
164
        # Menu Bar
151
        self.frame_1_menubar = wx.MenuBar()
165
        self.frame_1_menubar = wx.MenuBar()
152
        wxglade_tmp_menu = wx.Menu()
166
        wxglade_tmp_menu = wx.Menu()
153
        wxglade_tmp_menu.Append(101, "Settings", "", wx.ITEM_NORMAL)
167
        wxglade_tmp_menu.Append(101, "Settings", "", wx.ITEM_NORMAL)
154
        wxglade_tmp_menu.Append(150, "Exit", "", wx.ITEM_NORMAL)
168
        wxglade_tmp_menu.Append(150, "Exit", "", wx.ITEM_NORMAL)
155
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
169
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
156
        wxglade_tmp_menu = wx.Menu()
170
        wxglade_tmp_menu = wx.Menu()
157
        wxglade_tmp_menu.Append(301, "Clear", "", wx.ITEM_NORMAL)
171
        wxglade_tmp_menu.Append(301, "Clear", "", wx.ITEM_NORMAL)
158
        wxglade_tmp_menu.Append(302, "Import", "", wx.ITEM_NORMAL)
172
        wxglade_tmp_menu.Append(302, "Import", "", wx.ITEM_NORMAL)
159
        self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet")
173
        self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet")
160
        wxglade_tmp_menu = wx.Menu()
174
        wxglade_tmp_menu = wx.Menu()
161
        self.frame_1_menubar.Append(wxglade_tmp_menu, "MK")
175
        self.frame_1_menubar.Append(wxglade_tmp_menu, "MK")
162
        wxglade_tmp_menu = wx.Menu()
176
        wxglade_tmp_menu = wx.Menu()
163
        self.frame_1_menubar.Append(wxglade_tmp_menu, "Help")
177
        self.frame_1_menubar.Append(wxglade_tmp_menu, "Help")
164
        self.SetMenuBar(self.frame_1_menubar)
178
        self.SetMenuBar(self.frame_1_menubar)
165
        # Menu Bar end
179
        # Menu Bar end
166
        self.Description = wx.StaticText(self, -1, "Description")
180
        self.Description = wx.StaticText(self, -1, "Description")
167
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "Test")
181
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "Test")
168
        self.label_37 = wx.StaticText(self, -1, "Speed(s)")
182
        self.label_37 = wx.StaticText(self, -1, "Speed(s)")
169
        self.text_ctrl_9 = wx.TextCtrl(self, -1, "100-200:10")
183
        self.text_ctrl_9 = wx.TextCtrl(self, -1, "100-200:10")
170
        self.label_35 = wx.StaticText(self, -1, "Motor(s)")
184
        self.label_35 = wx.StaticText(self, -1, "Motor(s)")
171
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "1")
185
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "1")
172
        self.label_38 = wx.StaticText(self, -1, "")
186
        self.label_38 = wx.StaticText(self, -1, "")
173
        self.text_ctrl_10 = wx.TextCtrl(self, -1, "")
187
        self.text_ctrl_10 = wx.TextCtrl(self, -1, "")
174
        self.label_36 = wx.StaticText(self, -1, "Channel")
188
        self.label_36 = wx.StaticText(self, -1, "Channel")
175
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "6")
189
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "6")
176
        self.label_39 = wx.StaticText(self, -1, "")
190
        self.label_39 = wx.StaticText(self, -1, "")
177
        self.text_ctrl_11 = wx.TextCtrl(self, -1, "")
191
        self.text_ctrl_11 = wx.TextCtrl(self, -1, "")
178
        self.button_4 = wx.Button(self, -1, "Start")
192
        self.button_4 = wx.Button(self, -1, "Start")
179
        self.GraphPanel = wx.Panel(self, -1)
193
        self.GraphPanel = wx.Panel(self, -1)
180
        self.label_40 = wx.StaticText(self, -1, "Graph Type ")
194
        self.label_40 = wx.StaticText(self, -1, "Graph Type ")
181
        self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"])
195
        self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"])
182
        self.label_41 = wx.StaticText(self, -1, "Y Axis Range ")
196
        self.label_41 = wx.StaticText(self, -1, "Y Axis Range ")
183
        self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "100", "200"])
197
        self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "100", "200"])
184
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
198
        self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
185
 
199
 
186
        self.__set_properties()
200
        self.__set_properties()
187
        self.__do_layout()
201
        self.__do_layout()
188
 
202
 
189
        self.Bind(wx.EVT_MENU, self.OnSettings, id=101)
203
        self.Bind(wx.EVT_MENU, self.OnSettings, id=101)
190
        self.Bind(wx.EVT_MENU, self.onClear, id=301)
204
        self.Bind(wx.EVT_MENU, self.onClear, id=301)
191
        self.Bind(wx.EVT_MENU, self.OnImport, id=302)
205
        self.Bind(wx.EVT_MENU, self.OnImport, id=302)
192
        self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice)
206
        self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice)
193
        self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice)
207
        self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice)
194
        # end wxGlade
208
        # end wxGlade
195
 
209
 
196
    def setApp(self, app):
210
    def setApp(self, app):
197
        self.app = app
211
        self.app = app
198
 
212
 
199
    def __set_properties(self):
213
    def __set_properties(self):
200
        # begin wxGlade: MainFrame.__set_properties
214
        # begin wxGlade: MainFrame.__set_properties
201
        self.SetTitle("VibrationTest")
215
        self.SetTitle("VibrationTest")
202
        self.SetSize((850, 700))
216
        self.SetSize((850, 700))
203
        self.Description.SetMinSize((53, 13))
217
        self.Description.SetMinSize((53, 13))
204
        self.button_4.SetMinSize((80, 80))
218
        self.button_4.SetMinSize((80, 80))
205
        self.GraphPanel.SetMinSize((800,300))
219
        self.GraphPanel.SetMinSize((800,300))
206
        self.graphTypeChoice.SetSelection(0)
220
        self.graphTypeChoice.SetSelection(0)
207
        self.yAxisChoice.SetSelection(1)
221
        self.yAxisChoice.SetSelection(1)
208
        self.TestListCtrl.SetMinSize((800,300))
222
        self.TestListCtrl.SetMinSize((800,300))
209
        # end wxGlade
223
        # end wxGlade
210
 
224
 
211
    def __do_layout(self):
225
    def __do_layout(self):
212
        # begin wxGlade: MainFrame.__do_layout
226
        # begin wxGlade: MainFrame.__do_layout
213
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
227
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
214
        sizer_8 = wx.BoxSizer(wx.VERTICAL)
228
        sizer_8 = wx.BoxSizer(wx.VERTICAL)
215
        sizer_11 = wx.BoxSizer(wx.VERTICAL)
229
        sizer_11 = wx.BoxSizer(wx.VERTICAL)
216
        sizer_12 = wx.BoxSizer(wx.HORIZONTAL)
230
        sizer_12 = wx.BoxSizer(wx.HORIZONTAL)
217
        sizer_9 = wx.BoxSizer(wx.HORIZONTAL)
231
        sizer_9 = wx.BoxSizer(wx.HORIZONTAL)
218
        sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
232
        sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
219
        grid_sizer_1 = wx.GridSizer(3, 4, 4, 5)
233
        grid_sizer_1 = wx.GridSizer(3, 4, 4, 5)
220
        sizer_3.Add((20, 20), 0, 0, 0)
234
        sizer_3.Add((20, 20), 0, 0, 0)
221
        sizer_8.Add((20, 20), 0, 0, 0)
235
        sizer_8.Add((20, 20), 0, 0, 0)
222
        grid_sizer_1.Add(self.Description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
236
        grid_sizer_1.Add(self.Description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
223
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
237
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
224
        grid_sizer_1.Add(self.label_37, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
238
        grid_sizer_1.Add(self.label_37, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
225
        grid_sizer_1.Add(self.text_ctrl_9, 0, 0, 0)
239
        grid_sizer_1.Add(self.text_ctrl_9, 0, 0, 0)
226
        grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
240
        grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
227
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
241
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
228
        grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
242
        grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
229
        grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0)
243
        grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0)
230
        grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
244
        grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
231
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
245
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
232
        grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
246
        grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
233
        grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0)
247
        grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0)
234
        sizer_9.Add(grid_sizer_1, 0, 0, 0)
248
        sizer_9.Add(grid_sizer_1, 0, 0, 0)
235
        sizer_10.Add((50, 20), 0, 0, 0)
249
        sizer_10.Add((50, 20), 0, 0, 0)
236
        sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0)
250
        sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0)
237
        sizer_9.Add(sizer_10, 1, wx.EXPAND, 0)
251
        sizer_9.Add(sizer_10, 1, wx.EXPAND, 0)
238
        sizer_8.Add(sizer_9, 0, 0, 0)
252
        sizer_8.Add(sizer_9, 0, 0, 0)
239
        sizer_8.Add((20, 30), 0, 0, 0)
253
        sizer_8.Add((20, 30), 0, 0, 0)
240
        sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0)
254
        sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0)
241
        sizer_11.Add((20, 5), 0, 0, 0)
255
        sizer_11.Add((20, 5), 0, 0, 0)
242
        sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0)
256
        sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0)
243
        sizer_12.Add(self.graphTypeChoice, 0, 0, 0)
257
        sizer_12.Add(self.graphTypeChoice, 0, 0, 0)
244
        sizer_12.Add((40, 20), 0, 0, 0)
258
        sizer_12.Add((40, 20), 0, 0, 0)
245
        sizer_12.Add(self.label_41, 0, wx.ALIGN_CENTER_VERTICAL, 0)
259
        sizer_12.Add(self.label_41, 0, wx.ALIGN_CENTER_VERTICAL, 0)
246
        sizer_12.Add(self.yAxisChoice, 0, 0, 0)
260
        sizer_12.Add(self.yAxisChoice, 0, 0, 0)
247
        sizer_11.Add(sizer_12, 0, 0, 0)
261
        sizer_11.Add(sizer_12, 0, 0, 0)
248
        sizer_8.Add(sizer_11, 0, 0, 0)
262
        sizer_8.Add(sizer_11, 0, 0, 0)
249
        sizer_8.Add((20, 30), 0, 0, 0)
263
        sizer_8.Add((20, 30), 0, 0, 0)
250
        sizer_8.Add(self.TestListCtrl, 1, 0, 0)
264
        sizer_8.Add(self.TestListCtrl, 1, 0, 0)
251
        sizer_8.Add((20, 20), 0, 0, 0)
265
        sizer_8.Add((20, 20), 0, 0, 0)
252
        sizer_3.Add(sizer_8, 1, wx.EXPAND, 0)
266
        sizer_3.Add(sizer_8, 1, wx.EXPAND, 0)
253
        self.SetSizer(sizer_3)
267
        self.SetSizer(sizer_3)
254
        self.Layout()
268
        self.Layout()
255
        self.SetSize((850, 700))
269
        self.SetSize((850, 700))
256
        # end wxGlade
270
        # end wxGlade
257
 
271
 
258
        # List events
272
        # List events
259
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
273
        self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl)
260
 
274
 
261
        # Configure Graph
275
        # Configure Graph
262
        self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300))
276
        self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300))
263
       
277
       
264
        self.client.SetPointLabelFunc(self.DrawPointLabel)
278
        self.client.SetPointLabelFunc(self.DrawPointLabel)
265
       
279
       
266
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
280
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
267
        self.client.SetFontSizeAxis(10)
281
        self.client.SetFontSizeAxis(10)
268
        self.client.SetFontSizeLegend(7)
282
        self.client.SetFontSizeLegend(7)
269
        self.client.setLogScale((False,False))
283
        self.client.setLogScale((False,False))
270
 
284
 
271
 
285
 
272
        # Configure TestListCtrl
286
        # Configure TestListCtrl
273
        self.TestListCtrl.InsertColumn(0, "Description")
287
        self.TestListCtrl.InsertColumn(0, "Description")
274
        self.TestListCtrl.InsertColumn(1, "Speed")
288
        self.TestListCtrl.InsertColumn(1, "Speed")
275
        self.TestListCtrl.InsertColumn(2, "Channel")
289
        self.TestListCtrl.InsertColumn(2, "Channel")
276
        self.TestListCtrl.InsertColumn(3, "Vibration Value")
290
        self.TestListCtrl.InsertColumn(3, "Vibration Value")
277
        self.TestListCtrl.SetColumnWidth(3, 500)
291
        self.TestListCtrl.SetColumnWidth(3, 500)
278
 
292
 
279
    def DrawPointLabel(self, dc, mDataDict):
293
    def DrawPointLabel(self, dc, mDataDict):
280
        """This is the fuction that defines how the pointLabels are plotted
294
        """This is the fuction that defines how the pointLabels are plotted
281
            dc - DC that will be passed
295
            dc - DC that will be passed
282
            mDataDict - Dictionary of data that you want to use for the pointLabel
296
            mDataDict - Dictionary of data that you want to use for the pointLabel
283
 
297
 
284
            As an example I have decided I want a box at the curve point
298
            As an example I have decided I want a box at the curve point
285
            with some text information about the curve plotted below.
299
            with some text information about the curve plotted below.
286
            Any wxDC method can be used.
300
            Any wxDC method can be used.
287
        """
301
        """
288
        # ----------
302
        # ----------
289
        dc.SetPen(wx.Pen(wx.BLACK))
303
        dc.SetPen(wx.Pen(wx.BLACK))
290
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
304
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
291
       
305
       
292
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
306
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
293
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
307
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
294
        px,py = mDataDict["pointXY"]
308
        px,py = mDataDict["pointXY"]
295
        cNum = mDataDict["curveNum"]
309
        cNum = mDataDict["curveNum"]
296
        pntIn = mDataDict["pIndex"]
310
        pntIn = mDataDict["pIndex"]
297
        legend = mDataDict["legend"]
311
        legend = mDataDict["legend"]
298
        #make a string to display
312
        #make a string to display
299
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
313
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
300
        dc.DrawText(s, sx , sy+1)
314
        dc.DrawText(s, sx , sy+1)
301
        # -----------
315
        # -----------
302
 
316
 
303
 
317
 
304
    def onNewTest(self, test):
318
    def onNewTest(self, test):
305
        index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr)
319
        index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr)
306
        self.TestListCtrl.SetStringItem(index, 1, str(test.speed))
320
        self.TestListCtrl.SetStringItem(index, 1, str(test.speed))
307
        self.TestListCtrl.SetStringItem(index, 2, test.channel)
321
        self.TestListCtrl.SetStringItem(index, 2, test.channel)
308
 
322
 
309
        vv = int(test.getVibValue())
323
        vv = int(test.getVibValue())
310
        vvs = "|%s| (%d)" % ("----------------------------------------------------------------------------------------------------"[0:min(vv,100)], vv)
324
        vvs = "|%s| (%d)" % ("----------------------------------------------------------------------------------------------------"[0:min(vv,100)], vv)
311
        self.TestListCtrl.SetStringItem(index, 3, vvs)
325
        self.TestListCtrl.SetStringItem(index, 3, vvs)
312
        if (index == 0):
326
        if (index == 0):
313
            self.TestListCtrl.Select(index)
327
            self.TestListCtrl.Select(index)
314
 
328
 
315
 
329
 
316
    def OnTestSelected(self, event):
330
    def OnTestSelected(self, event):
317
         testId = event.m_itemIndex
331
         testId = event.m_itemIndex
318
         print "Test Selected id=%d" % (testId)
332
         print "Test Selected id=%d" % (testId)
319
         self.activeTestId = testId
333
         self.activeTestId = testId
320
         self.drawGraph()
334
         self.drawGraph()
321
 
335
 
322
    def drawGraph(self):
336
    def drawGraph(self):
323
         
337
         
324
         y = int(self.yAxisChoice.GetStringSelection())
338
         y = int(self.yAxisChoice.GetStringSelection())
325
 
339
 
326
         nbSelected = self.TestListCtrl.SelectedItemCount
340
         nbSelected = self.TestListCtrl.SelectedItemCount
327
 
341
 
328
         if nbSelected > 1:
342
         if nbSelected > 1:
329
             self.graphTypeChoice.Disable()
343
             self.graphTypeChoice.Disable()
330
             x = 1
344
             x = 1
331
             data = []
345
             data = []
332
             idx = self.TestListCtrl.GetFirstSelected()
346
             idx = self.TestListCtrl.GetFirstSelected()
333
             while idx != -1:
347
             while idx != -1:
334
                 data.append([x,self.app.getTest(idx).getVibValue()])
348
                 data.append([x,self.app.getTest(idx).getVibValue()])
335
                 x += 1
349
                 x += 1
336
                 idx = self.TestListCtrl.GetNextSelected(idx)
350
                 idx = self.TestListCtrl.GetNextSelected(idx)
337
             line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2)
351
             line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2)
338
             markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2)
352
             markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2)
339
             title = "Comparing tests"
353
             title = "Comparing tests"
340
             self.client.Draw(wx.lib.plot.PlotGraphics([line, markers], title, "Test", "Vibration Value"), xAxis=(1,max(x,10)), yAxis=(0,y))
354
             self.client.Draw(wx.lib.plot.PlotGraphics([line, markers], title, "Test", "Vibration Value"), xAxis=(1,max(x,10)), yAxis=(0,y))
341
             self.client.SetEnableGrid('Horizontal')
355
             self.client.SetEnableGrid('Horizontal')
342
 
356
 
343
         else:
357
         else:
344
             self.graphTypeChoice.Enable()
358
             self.graphTypeChoice.Enable()
345
             vibTest = self.app.getTest(self.activeTestId)
359
             vibTest = self.app.getTest(self.activeTestId)
346
             nb = vibTest.getDataLen()
360
             nb = vibTest.getDataLen()
347
 
361
 
348
             if self.graphTypeChoice.GetSelection() == 0:
362
             if self.graphTypeChoice.GetSelection() == 0:
349
                 xydata = _Numeric.linspace(0,0.09*nb,2*nb)
363
                 xydata = _Numeric.linspace(0,0.09*nb,2*nb)
350
                 xydata.shape = (nb, 2)
364
                 xydata.shape = (nb, 2)
351
                 xydata[:,1] = vibTest.getRawData()
365
                 xydata[:,1] = vibTest.getRawData()
352
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2)
366
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2)
353
       
367
       
354
                 title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
368
                 title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
355
                 self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
369
                 self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
356
                 self.client.SetEnableGrid('Horizontal')
370
                 self.client.SetEnableGrid('Horizontal')
357
   
371
   
358
             if self.graphTypeChoice.GetSelection() == 1:
372
             if self.graphTypeChoice.GetSelection() == 1:
359
                 xydata = _Numeric.linspace(0,0.09*nb,2*nb)
373
                 xydata = _Numeric.linspace(0,0.09*nb,2*nb)
360
                 xydata.shape = (nb, 2)
374
                 xydata.shape = (nb, 2)
361
                 xydata[:,1] = vibTest.getFilteredData()
375
                 xydata[:,1] = vibTest.getFilteredData()
362
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2)
376
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2)
363
       
377
       
364
                 title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
378
                 title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
365
                 self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
379
                 self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y))
366
                 self.client.SetEnableGrid('Horizontal')
380
                 self.client.SetEnableGrid('Horizontal')
367
   
381
   
368
             elif self.graphTypeChoice.GetSelection() == 2:
382
             elif self.graphTypeChoice.GetSelection() == 2:
369
                 xydata = _Numeric.linspace(0,5555,nb)
383
                 xydata = _Numeric.linspace(0,5555,nb)
370
                 xydata.shape = (nb/2, 2)
384
                 xydata.shape = (nb/2, 2)
371
                 
385
                 
372
                 xydata[:,1] = vibTest.getSpectrum()
386
                 xydata[:,1] = vibTest.getSpectrum()
373
   
387
   
374
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red')
388
                 line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red')
375
                 markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2)
389
                 markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2)
376
       
390
       
377
                 title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
391
                 title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed)
378
                 self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y))
392
                 self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y))
379
                 self.client.SetEnableGrid(True)
393
                 self.client.SetEnableGrid(True)
380
 
394
 
381
 
395
 
382
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
396
    def OnImport(self, event): # wxGlade: MainFrame.<event_handler>
383
        dlg = wx.FileDialog(
397
        dlg = wx.FileDialog(
384
            self, message="Choose a file",
398
            self, message="Choose a file",
385
            defaultDir=os.getcwd(),
399
            defaultDir=os.getcwd(),
386
            defaultFile="*.txt",
400
            defaultFile="*.txt",
387
            wildcard="",
401
            wildcard="",
388
            style=wx.OPEN | wx.CHANGE_DIR
402
            style=wx.OPEN | wx.CHANGE_DIR
389
            )
403
            )
390
        if dlg.ShowModal() == wx.ID_OK:
404
        if dlg.ShowModal() == wx.ID_OK:
391
            paths = dlg.GetPaths();
405
            paths = dlg.GetPaths();
392
            self.app.Import(paths[0])
406
            self.app.Import(paths[0])
393
        dlg.Destroy()
407
        dlg.Destroy()
394
 
408
 
395
    def onYAxisChange(self, event): # wxGlade: MainFrame.<event_handler>
409
    def onYAxisChange(self, event): # wxGlade: MainFrame.<event_handler>
396
        self.drawGraph()
410
        self.drawGraph()
397
 
411
 
398
    def onGraphTypeChange(self, event): # wxGlade: MainFrame.<event_handler>
412
    def onGraphTypeChange(self, event): # wxGlade: MainFrame.<event_handler>
399
        self.drawGraph()
413
        self.drawGraph()
400
 
414
 
401
    def onClear(self, event): # wxGlade: MainFrame.<event_handler>
415
    def onClear(self, event): # wxGlade: MainFrame.<event_handler>
402
        print "Event handler `onClear' not implemented"
416
        print "Event handler `onClear' not implemented"
403
        event.Skip()
417
        event.Skip()
404
 
418
 
405
    def OnSettings(self, event): # wxGlade: MainFrame.<event_handler>
419
    def OnSettings(self, event): # wxGlade: MainFrame.<event_handler>
406
        dlg = SettingsDialog(self, -1, "Sample Dialog", size=(350, 200),
420
        dlg = SettingsDialog(self, -1, "Sample Dialog", size=(350, 200),
407
                         #style=wx.CAPTION | wx.SYSTEM_MENU | wx.THICK_FRAME,
421
                         #style=wx.CAPTION | wx.SYSTEM_MENU | wx.THICK_FRAME,
408
                         style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX
422
                         style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX
409
                         )
423
                         )
410
        dlg.CenterOnScreen()
424
        dlg.CenterOnScreen()
411
 
425
 
412
        # this does not return until the dialog is closed.
426
        # this does not return until the dialog is closed.
413
        val = dlg.ShowModal()
427
        val = dlg.ShowModal()
414
 
428
 
415
        dlg.Destroy()
429
        dlg.Destroy()
416
 
430
 
417
# end of class MainFrame
431
# end of class MainFrame
418
 
432
 
419
class Setting:
433
class Setting:
420
    def __init__(self, descr, defaultValue):
434
    def __init__(self, descr, defaultValue):
421
        self.descr = descr
435
        self.descr = descr
422
        self.value = defaultValue
436
        self.value = defaultValue
423
 
437
 
424
class VibTest:
438
class VibTest:
425
    def __init__(self, descr, motor, speed, channel, rawData):
439
    def __init__(self, descr, motor, speed, channel, rawData):
426
        self.descr = descr
440
        self.descr = descr
427
        self.motor = motor
441
        self.motor = motor
428
        self.speed = speed
442
        self.speed = speed
429
        self.channel = channel
443
        self.channel = channel
430
 
444
 
431
        self.dataLen = len(rawData)
445
        self.dataLen = len(rawData)
432
 
446
 
433
        self.rawData = _Numeric.array(rawData)
447
        self.rawData = _Numeric.array(rawData)
434
        self.dc = self.rawData.mean()
448
        self.dc = self.rawData.mean()
435
        self.rawData -= self.dc
449
        self.rawData -= self.dc
436
 
450
 
437
        self.fft = _Numeric.fft.rfft(self.rawData)
451
        self.fft = _Numeric.fft.rfft(self.rawData)
438
 
452
 
439
        self.spectrum = None
453
        self.spectrum = None
440
        self.filteredData = None
454
        self.filteredData = None
441
       
455
       
442
        self.vibValue = None
456
        self.vibValue = None
443
       
457
       
444
    def getDescr(self):
458
    def getDescr(self):
445
        return self.Descr
459
        return self.Descr
446
 
460
 
447
    def getRawData(self):
461
    def getRawData(self):
448
        return self.rawData
462
        return self.rawData
449
 
463
 
450
    def getDataLen(self):
464
    def getDataLen(self):
451
        return self.dataLen
465
        return self.dataLen
452
 
466
 
453
    def getSpectrum(self):
467
    def getSpectrum(self):
454
        if self.spectrum == None:
468
        if self.spectrum == None:
455
            self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2)
469
            self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2)
456
        return self.spectrum
470
        return self.spectrum
457
 
471
 
458
    def getFilteredData(self):
472
    def getFilteredData(self):
459
        if self.filteredData == None:
473
        if self.filteredData == None:
460
            tmpfft = self.fft.copy()
474
            tmpfft = self.fft.copy()
461
            for i in range(0,5):
475
            for i in range(0,5):
462
                tmpfft[i] = 0
476
                tmpfft[i] = 0
463
            for i in range(30, len(tmpfft)):
477
            for i in range(30, len(tmpfft)):
464
                tmpfft[i] = 0
478
                tmpfft[i] = 0
465
            self.filteredData = _Numeric.fft.irfft(tmpfft)
479
            self.filteredData = _Numeric.fft.irfft(tmpfft)
466
        return self.filteredData
480
        return self.filteredData
467
       
481
       
468
    def getVibValue(self):
482
    def getVibValue(self):
469
      if self.vibValue == None:
483
      if self.vibValue == None:
470
        fd = self.getFilteredData();
484
        fd = self.getFilteredData();
471
        self.vibValue = max(fd)-min(fd)
485
        self.vibValue = max(fd)-min(fd)
472
      return self.vibValue
486
      return self.vibValue
473
 
487
 
474
 
488
 
475
 
489
 
476
class App(wx.App):
490
class App(wx.App):
477
 
491
 
478
    SETTINGSFILE = "settings.cfg"
492
    SETTINGSFILE = "settings.cfg"
479
 
493
 
480
    def __init__(self, par):
494
    def __init__(self, par):
481
        self.VibTests = []
495
        self.VibTests = []
482
        wx.App.__init__(self, par)
496
        wx.App.__init__(self, par)
483
 
497
 
484
        # Init settings
498
        # Init settings
485
        self.settings={}
499
        self.settings={}
486
        self.settings["serialPort"] = Setting("SerialPort", "COM1")
500
        self.settings["serialPort"] = Setting("SerialPort", "COM1")
487
        self.settings["hpf"] = Setting("HP Filter cutoff (Hz)", 50)
501
        self.settings["hpf"] = Setting("HP Filter cutoff (Hz)", 50)
488
        self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 400)
502
        self.settings["lpf"] = Setting("LP Filter cutoff (Hz)", 400)
489
 
503
 
490
        self.readSettings()
504
        self.readSettings()
491
 
505
 
492
        if len(sys.argv)>1:
506
        if len(sys.argv)>1:
493
            self.Import(sys.argv[1])
507
            self.Import(sys.argv[1])
494
 
508
 
495
 
509
 
496
    def readSettings(self):
510
    def readSettings(self):
497
        print "Reading settings"
511
        print "Reading settings"
498
        cp = ConfigParser.ConfigParser()
512
        cp = ConfigParser.ConfigParser()
499
 
513
 
500
        try:
514
        try:
501
            cp.read(App.SETTINGSFILE)
515
            cp.read(App.SETTINGSFILE)
502
            for setting in cp.items("DEFAULT"):
516
            for setting in cp.items("DEFAULT"):
503
                print " ",setting
517
                print " ",setting
504
                try:
518
                try:
505
                    self.settings[setting[0]].value = setting[1]
519
                    self.settings[setting[0]].value = setting[1]
506
                except:
520
                except:
507
                    print "WARNING, unknown setting"
521
                    print "WARNING, unknown setting"
508
        except:
522
        except:
509
            print "ERROR reading settingsfile"
523
            print "ERROR reading settingsfile"
510
 
524
 
511
 
525
 
512
    def storeSettings(self):
526
    def storeSettings(self):
513
        print "Storing settings"
527
        print "Storing settings"
514
 
528
 
515
        cp = ConfigParser.ConfigParser()
529
        cp = ConfigParser.ConfigParser()
516
        for setting in self.settings.iteritems():
530
        for setting in self.settings.iteritems():
517
            cp.set("", setting[0], setting[1].value)
531
            cp.set("", setting[0], setting[1].value)
518
 
532
 
519
        file = open(App.SETTINGSFILE, "w")
533
        file = open(App.SETTINGSFILE, "w")
520
        cp.write(file)
534
        cp.write(file)
521
        file.close()
535
        file.close()
522
 
536
 
523
    def AddTest(self, descr, motor, speed, channel, rawData):
537
    def AddTest(self, descr, motor, speed, channel, rawData):
524
        test = VibTest(descr, motor, speed, channel, rawData)
538
        test = VibTest(descr, motor, speed, channel, rawData)
525
        self.VibTests.append(test)
539
        self.VibTests.append(test)
526
        self.frame_1.onNewTest(test)
540
        self.frame_1.onNewTest(test)
527
 
541
 
528
    def getTest(self, testId):
542
    def getTest(self, testId):
529
        return self.VibTests[testId]
543
        return self.VibTests[testId]
530
 
544
 
531
    def OnInit(self):
545
    def OnInit(self):
532
        wx.InitAllImageHandlers()
546
        wx.InitAllImageHandlers()
533
        self.frame_1 = MainFrame(None, -1, "")
547
        self.frame_1 = MainFrame(None, -1, "")
534
        self.frame_1.setApp(self);
548
        self.frame_1.setApp(self);
535
        self.SetTopWindow(self.frame_1)
549
        self.SetTopWindow(self.frame_1)
536
 
550
 
537
        self.frame_1.CenterOnScreen()
551
        self.frame_1.CenterOnScreen()
538
        self.frame_1.Show()
552
        self.frame_1.Show()
539
        return 1
553
        return 1
540
 
554
 
541
    def Import(self, filePath):
555
    def Import(self, filePath):
542
       
556
       
543
        print "Importing file \"%s\"" % filePath
557
        print "Importing file \"%s\"" % filePath
544
 
558
 
545
        logfile = open(filePath, "r")
559
        logfile = open(filePath, "r")
546
        data = None
560
        data = None
547
 
561
 
548
        headers = (logfile.readline()).split(',')
562
        headers = (logfile.readline()).split(',')
549
        nbCols = len(headers)
563
        nbCols = len(headers)
550
        print "NbCols =", nbCols
564
        print "NbCols =", nbCols
551
 
565
 
552
        data = []
566
        data = []
553
        descr = []
567
        descr = []
554
        speed = []
568
        speed = []
555
        channel = []
569
        channel = []
556
        for c in range(nbCols):
570
        for c in range(nbCols):
557
            data.append([])
571
            data.append([])
558
            h = headers[c].split(' ')
572
            h = headers[c].split(' ')
559
            descr.append(h[0]);
573
            descr.append(h[0]);
560
            speed.append(h[1]);
574
            speed.append(h[1]);
561
            channel.append(h[2]);
575
            channel.append(h[2]);
562
 
576
 
563
        for line in logfile:
577
        for line in logfile:
564
            values = line.split(',')
578
            values = line.split(',')
565
            for i in range(nbCols):
579
            for i in range(nbCols):
566
                data[i].append(int(values[i]))
580
                data[i].append(int(values[i]))
567
        logfile.close()
581
        logfile.close()
568
 
582
 
569
        for c in range(nbCols):
583
        for c in range(nbCols):
570
            if (len(data[c]) % 2) != 0:
584
            if (len(data[c]) % 2) != 0:
571
                data[c].append(data[c][-1])
585
                data[c].append(data[c][-1])
572
            self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c])
586
            self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c])
573
       
587
       
574
       
588
       
575
           
589
           
576
 
590
 
577
       
591
       
578
# end of class App
592
# end of class App
579
 
593
 
580
if __name__ == "__main__":
594
if __name__ == "__main__":
581
    VibrationTestGui = App(0)
595
    VibrationTestGui = App(0)
582
    VibrationTestGui.MainLoop()
596
    VibrationTestGui.MainLoop()
583
 
597