Subversion Repositories Projects

Rev

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

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