Rev 600 | Rev 602 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 600 | Rev 601 | ||
---|---|---|---|
1 | #!/usr/bin/env python |
1 | #!/usr/bin/env python |
2 | # -*- coding: iso-8859-15 -*- |
2 | # -*- coding: iso-8859-15 -*- |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
4 | 4 | ||
5 | import sys |
5 | import sys |
6 | import wx |
6 | import wx |
7 | import wx.lib |
7 | import wx.lib |
8 | import wx.lib.plot |
8 | import wx.lib.plot |
9 | 9 | ||
10 | # Needs Numeric or numarray or NumPy |
10 | # Needs Numeric or numarray or NumPy |
11 | try: |
11 | try: |
12 | import numpy.oldnumeric as _Numeric |
12 | import numpy.oldnumeric as _Numeric |
13 | except: |
13 | except: |
14 | try: |
14 | try: |
15 | import numarray as _Numeric #if numarray is used it is renamed Numeric |
15 | import numarray as _Numeric #if numarray is used it is renamed Numeric |
16 | except: |
16 | except: |
17 | try: |
17 | try: |
18 | import Numeric as _Numeric |
18 | import Numeric as _Numeric |
19 | except: |
19 | except: |
20 | msg= """ |
20 | msg= """ |
21 | This module requires the Numeric/numarray or NumPy module, |
21 | This module requires the Numeric/numarray or NumPy module, |
22 | which could not be imported. It probably is not installed |
22 | which could not be imported. It probably is not installed |
23 | (it's not part of the standard Python distribution). See the |
23 | (it's not part of the standard Python distribution). See the |
24 | Numeric Python site (http://numpy.scipy.org) for information on |
24 | Numeric Python site (http://numpy.scipy.org) for information on |
25 | downloading source or binaries.""" |
25 | downloading source or binaries.""" |
26 | raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg |
26 | raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg |
27 | 27 | ||
28 | # begin wxGlade: extracode |
28 | # begin wxGlade: extracode |
29 | # end wxGlade |
29 | # end wxGlade |
30 | 30 | ||
31 | 31 | ||
- | 32 | ||
- | 33 | class SettingsFrame(wx.Frame): |
|
- | 34 | def __init__(self, *args, **kwds): |
|
- | 35 | # begin wxGlade: SettingsFrame.__init__ |
|
- | 36 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
|
- | 37 | wx.Frame.__init__(self, *args, **kwds) |
|
- | 38 | self.label_5 = wx.StaticText(self, -1, "COM Port ", style=wx.ALIGN_RIGHT) |
|
- | 39 | self.comPortCtrl = wx.TextCtrl(self, -1, "") |
|
- | 40 | self.button_5 = wx.Button(self, wx.ID_CANCEL, "") |
|
- | 41 | self.button_6 = wx.Button(self, wx.ID_OK, "") |
|
- | 42 | ||
- | 43 | self.__set_properties() |
|
- | 44 | self.__do_layout() |
|
- | 45 | # end wxGlade |
|
- | 46 | ||
- | 47 | def __set_properties(self): |
|
- | 48 | # begin wxGlade: SettingsFrame.__set_properties |
|
- | 49 | self.SetTitle("Settings") |
|
- | 50 | # end wxGlade |
|
- | 51 | ||
- | 52 | def __do_layout(self): |
|
- | 53 | # begin wxGlade: SettingsFrame.__do_layout |
|
- | 54 | sizer_5 = wx.BoxSizer(wx.VERTICAL) |
|
- | 55 | grid_sizer_3 = wx.GridSizer(1, 2, 0, 0) |
|
- | 56 | sizer_6 = wx.BoxSizer(wx.HORIZONTAL) |
|
- | 57 | grid_sizer_2 = wx.GridSizer(1, 2, 4, 4) |
|
- | 58 | sizer_5.Add((20, 20), 0, 0, 0) |
|
- | 59 | sizer_6.Add((20, 20), 0, 0, 0) |
|
- | 60 | grid_sizer_2.Add(self.label_5, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
|
- | 61 | grid_sizer_2.Add(self.comPortCtrl, 0, 0, 0) |
|
- | 62 | sizer_6.Add(grid_sizer_2, 0, 0, 0) |
|
- | 63 | sizer_6.Add((20, 20), 0, 0, 0) |
|
- | 64 | sizer_5.Add(sizer_6, 1, wx.EXPAND, 0) |
|
- | 65 | sizer_5.Add((20, 20), 0, 0, 0) |
|
- | 66 | grid_sizer_3.Add(self.button_5, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) |
|
- | 67 | grid_sizer_3.Add(self.button_6, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) |
|
- | 68 | sizer_5.Add(grid_sizer_3, 0, wx.EXPAND, 0) |
|
- | 69 | sizer_5.Add((20, 20), 0, 0, 0) |
|
- | 70 | self.SetSizer(sizer_5) |
|
- | 71 | sizer_5.Fit(self) |
|
- | 72 | self.Layout() |
|
- | 73 | # end wxGlade |
|
- | 74 | ||
- | 75 | # end of class SettingsFrame |
|
- | 76 | ||
32 | 77 | ||
33 | class MenuBar(wx.MenuBar): |
78 | class MenuBar(wx.MenuBar): |
34 | def __init__(self, *args, **kwds): |
79 | def __init__(self, *args, **kwds): |
35 | # content of this block not found: did you rename this class? |
80 | # content of this block not found: did you rename this class? |
36 | pass |
81 | pass |
37 | 82 | ||
38 | def __set_properties(self): |
83 | def __set_properties(self): |
39 | # content of this block not found: did you rename this class? |
84 | # content of this block not found: did you rename this class? |
40 | pass |
85 | pass |
41 | 86 | ||
42 | def __do_layout(self): |
87 | def __do_layout(self): |
43 | # content of this block not found: did you rename this class? |
88 | # content of this block not found: did you rename this class? |
44 | pass |
89 | pass |
45 | 90 | ||
46 | # end of class MenuBar |
91 | # end of class MenuBar |
47 | 92 | ||
48 | 93 | ||
49 | class wxFrame(wx.Panel): |
94 | class wxFrame(wx.Panel): |
50 | def __init__(self, *args, **kwds): |
95 | def __init__(self, *args, **kwds): |
51 | # content of this block not found: did you rename this class? |
96 | # content of this block not found: did you rename this class? |
52 | pass |
97 | pass |
53 | 98 | ||
54 | def __set_properties(self): |
99 | def __set_properties(self): |
55 | # content of this block not found: did you rename this class? |
100 | # content of this block not found: did you rename this class? |
56 | pass |
101 | pass |
57 | 102 | ||
58 | def __do_layout(self): |
103 | def __do_layout(self): |
59 | # content of this block not found: did you rename this class? |
104 | # content of this block not found: did you rename this class? |
60 | pass |
105 | pass |
61 | 106 | ||
62 | # end of class wxFrame |
107 | # end of class wxFrame |
63 | 108 | ||
64 | 109 | ||
65 | class MyFrame(wx.Frame): |
110 | class MyFrame(wx.Frame): |
66 | def __init__(self, *args, **kwds): |
111 | def __init__(self, *args, **kwds): |
67 | # content of this block not found: did you rename this class? |
112 | # content of this block not found: did you rename this class? |
68 | pass |
113 | pass |
69 | 114 | ||
70 | def __set_properties(self): |
115 | def __set_properties(self): |
71 | # content of this block not found: did you rename this class? |
116 | # content of this block not found: did you rename this class? |
72 | pass |
117 | pass |
73 | 118 | ||
74 | def __do_layout(self): |
119 | def __do_layout(self): |
75 | # content of this block not found: did you rename this class? |
120 | # content of this block not found: did you rename this class? |
76 | pass |
121 | pass |
77 | 122 | ||
78 | # end of class MyFrame |
123 | # end of class MyFrame |
79 | 124 | ||
80 | 125 | ||
81 | class MainFrame(wx.Frame): |
126 | class MainFrame(wx.Frame): |
82 | def __init__(self, *args, **kwds): |
127 | def __init__(self, *args, **kwds): |
83 | # begin wxGlade: MainFrame.__init__ |
128 | # begin wxGlade: MainFrame.__init__ |
84 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
129 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
85 | wx.Frame.__init__(self, *args, **kwds) |
130 | wx.Frame.__init__(self, *args, **kwds) |
86 | 131 | ||
87 | # Menu Bar |
132 | # Menu Bar |
88 | self.frame_1_menubar = wx.MenuBar() |
133 | self.frame_1_menubar = wx.MenuBar() |
89 | wxglade_tmp_menu = wx.Menu() |
134 | wxglade_tmp_menu = wx.Menu() |
90 | wxglade_tmp_menu.Append(wx.NewId(), "Exit", "", wx.ITEM_NORMAL) |
135 | wxglade_tmp_menu.Append(wx.NewId(), "Exit", "", wx.ITEM_NORMAL) |
91 | self.frame_1_menubar.Append(wxglade_tmp_menu, "File") |
136 | self.frame_1_menubar.Append(wxglade_tmp_menu, "File") |
92 | wxglade_tmp_menu = wx.Menu() |
137 | wxglade_tmp_menu = wx.Menu() |
- | 138 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Settings") |
|
- | 139 | wxglade_tmp_menu = wx.Menu() |
|
93 | wxglade_tmp_menu.Append(wx.NewId(), "Clear", "", wx.ITEM_NORMAL) |
140 | wxglade_tmp_menu.Append(wx.NewId(), "Clear", "", wx.ITEM_NORMAL) |
94 | wxglade_tmp_menu.Append(wx.NewId(), "Import", "", wx.ITEM_NORMAL) |
141 | wxglade_tmp_menu.Append(wx.NewId(), "Import", "", wx.ITEM_NORMAL) |
95 | self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet") |
142 | self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet") |
96 | wxglade_tmp_menu = wx.Menu() |
143 | wxglade_tmp_menu = wx.Menu() |
97 | self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
144 | self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
98 | wxglade_tmp_menu = wx.Menu() |
145 | wxglade_tmp_menu = wx.Menu() |
99 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
146 | self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
100 | self.SetMenuBar(self.frame_1_menubar) |
147 | self.SetMenuBar(self.frame_1_menubar) |
101 | # Menu Bar end |
148 | # Menu Bar end |
102 | self.Description = wx.StaticText(self, -1, "Description") |
149 | self.Description = wx.StaticText(self, -1, "Description") |
103 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "Test") |
150 | self.text_ctrl_6 = wx.TextCtrl(self, -1, "Test") |
104 | self.label_37 = wx.StaticText(self, -1, "Speed(s)") |
151 | self.label_37 = wx.StaticText(self, -1, "Speed(s)") |
105 | self.text_ctrl_9 = wx.TextCtrl(self, -1, "100-200:10") |
152 | self.text_ctrl_9 = wx.TextCtrl(self, -1, "100-200:10") |
106 | self.label_35 = wx.StaticText(self, -1, "Motor(s)") |
153 | self.label_35 = wx.StaticText(self, -1, "Motor(s)") |
107 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "1") |
154 | self.text_ctrl_7 = wx.TextCtrl(self, -1, "1") |
108 | self.label_38 = wx.StaticText(self, -1, "") |
155 | self.label_38 = wx.StaticText(self, -1, "") |
109 | self.text_ctrl_10 = wx.TextCtrl(self, -1, "") |
156 | self.text_ctrl_10 = wx.TextCtrl(self, -1, "") |
110 | self.label_36 = wx.StaticText(self, -1, "Channel") |
157 | self.label_36 = wx.StaticText(self, -1, "Channel") |
111 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "6") |
158 | self.text_ctrl_8 = wx.TextCtrl(self, -1, "6") |
112 | self.label_39 = wx.StaticText(self, -1, "") |
159 | self.label_39 = wx.StaticText(self, -1, "") |
113 | self.text_ctrl_11 = wx.TextCtrl(self, -1, "") |
160 | self.text_ctrl_11 = wx.TextCtrl(self, -1, "") |
114 | self.button_4 = wx.Button(self, -1, "Start") |
161 | self.button_4 = wx.Button(self, -1, "Start") |
115 | self.GraphPanel = wx.Panel(self, -1) |
162 | self.GraphPanel = wx.Panel(self, -1) |
116 | self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
163 | self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
117 | self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
164 | self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
118 | self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
165 | self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
119 | self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "100", "200"]) |
166 | self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "100", "200"]) |
120 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
167 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
121 | 168 | ||
122 | self.__set_properties() |
169 | self.__set_properties() |
123 | self.__do_layout() |
170 | self.__do_layout() |
- | 171 | ||
124 | 172 | self.Bind(wx.EVT_MENU, self.onClear, id=-1) |
|
125 | self.Bind(wx.EVT_MENU, self.OnImport, id=-1) |
173 | self.Bind(wx.EVT_MENU, self.OnImport, id=-1) |
126 | self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
174 | self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
127 | self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
175 | self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
128 | # end wxGlade |
176 | # end wxGlade |
129 | 177 | ||
130 | def setApp(self, app): |
178 | def setApp(self, app): |
131 | self.app = app |
179 | self.app = app |
132 | 180 | ||
133 | def __set_properties(self): |
181 | def __set_properties(self): |
134 | # begin wxGlade: MainFrame.__set_properties |
182 | # begin wxGlade: MainFrame.__set_properties |
135 | self.SetTitle("VibrationTest") |
183 | self.SetTitle("VibrationTest") |
136 | self.SetSize((850, 700)) |
184 | self.SetSize((850, 700)) |
137 | self.Description.SetMinSize((53, 13)) |
185 | self.Description.SetMinSize((53, 13)) |
- | 186 | self.button_4.SetMinSize((80, 80)) |
|
138 | self.GraphPanel.SetMinSize((800,300)) |
187 | self.GraphPanel.SetMinSize((800,300)) |
139 | self.graphTypeChoice.SetSelection(0) |
188 | self.graphTypeChoice.SetSelection(0) |
140 | self.yAxisChoice.SetSelection(1) |
189 | self.yAxisChoice.SetSelection(1) |
141 | self.TestListCtrl.SetMinSize((800,300)) |
190 | self.TestListCtrl.SetMinSize((800,300)) |
142 | # end wxGlade |
191 | # end wxGlade |
143 | 192 | ||
144 | def __do_layout(self): |
193 | def __do_layout(self): |
145 | # begin wxGlade: MainFrame.__do_layout |
194 | # begin wxGlade: MainFrame.__do_layout |
146 | sizer_3 = wx.BoxSizer(wx.HORIZONTAL) |
195 | sizer_3 = wx.BoxSizer(wx.HORIZONTAL) |
147 | sizer_8 = wx.BoxSizer(wx.VERTICAL) |
196 | sizer_8 = wx.BoxSizer(wx.VERTICAL) |
148 | sizer_11 = wx.BoxSizer(wx.VERTICAL) |
197 | sizer_11 = wx.BoxSizer(wx.VERTICAL) |
149 | sizer_12 = wx.BoxSizer(wx.HORIZONTAL) |
198 | sizer_12 = wx.BoxSizer(wx.HORIZONTAL) |
150 | sizer_9 = wx.BoxSizer(wx.HORIZONTAL) |
199 | sizer_9 = wx.BoxSizer(wx.HORIZONTAL) |
151 | sizer_10 = wx.BoxSizer(wx.HORIZONTAL) |
200 | sizer_10 = wx.BoxSizer(wx.HORIZONTAL) |
152 | grid_sizer_1 = wx.GridSizer(3, 4, 4, 5) |
201 | grid_sizer_1 = wx.GridSizer(3, 4, 4, 5) |
153 | sizer_3.Add((20, 20), 0, 0, 0) |
202 | sizer_3.Add((20, 20), 0, 0, 0) |
154 | sizer_8.Add((20, 20), 0, 0, 0) |
203 | sizer_8.Add((20, 20), 0, 0, 0) |
155 | grid_sizer_1.Add(self.Description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
204 | grid_sizer_1.Add(self.Description, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
156 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
205 | grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0) |
157 | grid_sizer_1.Add(self.label_37, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
206 | grid_sizer_1.Add(self.label_37, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
158 | grid_sizer_1.Add(self.text_ctrl_9, 0, 0, 0) |
207 | grid_sizer_1.Add(self.text_ctrl_9, 0, 0, 0) |
159 | grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
208 | grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
160 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
209 | grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0) |
161 | grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
210 | grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
162 | grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0) |
211 | grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0) |
163 | grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
212 | grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
164 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
213 | grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0) |
165 | grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
214 | grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
166 | grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0) |
215 | grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0) |
167 | sizer_9.Add(grid_sizer_1, 0, 0, 0) |
216 | sizer_9.Add(grid_sizer_1, 0, 0, 0) |
168 | sizer_10.Add((50, 20), 0, 0, 0) |
217 | sizer_10.Add((50, 20), 0, 0, 0) |
169 | sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
218 | sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
170 | sizer_9.Add(sizer_10, 1, wx.EXPAND, 0) |
219 | sizer_9.Add(sizer_10, 1, wx.EXPAND, 0) |
171 | sizer_8.Add(sizer_9, 0, 0, 0) |
220 | sizer_8.Add(sizer_9, 0, 0, 0) |
172 | sizer_8.Add((20, 30), 0, 0, 0) |
221 | sizer_8.Add((20, 30), 0, 0, 0) |
173 | sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0) |
222 | sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0) |
174 | sizer_11.Add((20, 5), 0, 0, 0) |
223 | sizer_11.Add((20, 5), 0, 0, 0) |
175 | sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
224 | sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
176 | sizer_12.Add(self.graphTypeChoice, 0, 0, 0) |
225 | sizer_12.Add(self.graphTypeChoice, 0, 0, 0) |
177 | sizer_12.Add((40, 20), 0, 0, 0) |
226 | sizer_12.Add((40, 20), 0, 0, 0) |
178 | sizer_12.Add(self.label_41, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
227 | sizer_12.Add(self.label_41, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
179 | sizer_12.Add(self.yAxisChoice, 0, 0, 0) |
228 | sizer_12.Add(self.yAxisChoice, 0, 0, 0) |
180 | sizer_11.Add(sizer_12, 0, 0, 0) |
229 | sizer_11.Add(sizer_12, 0, 0, 0) |
181 | sizer_8.Add(sizer_11, 0, 0, 0) |
230 | sizer_8.Add(sizer_11, 0, 0, 0) |
182 | sizer_8.Add((20, 30), 0, 0, 0) |
231 | sizer_8.Add((20, 30), 0, 0, 0) |
183 | sizer_8.Add(self.TestListCtrl, 1, 0, 0) |
232 | sizer_8.Add(self.TestListCtrl, 1, 0, 0) |
184 | sizer_8.Add((20, 20), 0, 0, 0) |
233 | sizer_8.Add((20, 20), 0, 0, 0) |
185 | sizer_3.Add(sizer_8, 1, wx.EXPAND, 0) |
234 | sizer_3.Add(sizer_8, 1, wx.EXPAND, 0) |
186 | self.SetSizer(sizer_3) |
235 | self.SetSizer(sizer_3) |
187 | self.Layout() |
236 | self.Layout() |
188 | self.SetSize((850, 700)) |
237 | self.SetSize((850, 700)) |
189 | # end wxGlade |
238 | # end wxGlade |
190 | 239 | ||
191 | # List events |
240 | # List events |
192 | self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl) |
241 | self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl) |
193 | 242 | ||
194 | # Configure Graph |
243 | # Configure Graph |
195 | self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300)) |
244 | self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300)) |
196 | 245 | ||
197 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
246 | self.client.SetPointLabelFunc(self.DrawPointLabel) |
198 | 247 | ||
199 | self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
248 | self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
200 | self.client.SetFontSizeAxis(10) |
249 | self.client.SetFontSizeAxis(10) |
201 | self.client.SetFontSizeLegend(7) |
250 | self.client.SetFontSizeLegend(7) |
202 | self.client.setLogScale((False,False)) |
251 | self.client.setLogScale((False,False)) |
203 | 252 | ||
204 | 253 | ||
205 | # Configure TestListCtrl |
254 | # Configure TestListCtrl |
206 | self.TestListCtrl.InsertColumn(0, "Description") |
255 | self.TestListCtrl.InsertColumn(0, "Description") |
207 | self.TestListCtrl.InsertColumn(1, "Speed") |
256 | self.TestListCtrl.InsertColumn(1, "Speed") |
208 | self.TestListCtrl.InsertColumn(2, "Channel") |
257 | self.TestListCtrl.InsertColumn(2, "Channel") |
209 | self.TestListCtrl.InsertColumn(3, "Result") |
258 | self.TestListCtrl.InsertColumn(3, "Result") |
210 | 259 | ||
211 | def DrawPointLabel(self, dc, mDataDict): |
260 | def DrawPointLabel(self, dc, mDataDict): |
212 | """This is the fuction that defines how the pointLabels are plotted |
261 | """This is the fuction that defines how the pointLabels are plotted |
213 | dc - DC that will be passed |
262 | dc - DC that will be passed |
214 | mDataDict - Dictionary of data that you want to use for the pointLabel |
263 | mDataDict - Dictionary of data that you want to use for the pointLabel |
215 | 264 | ||
216 | As an example I have decided I want a box at the curve point |
265 | As an example I have decided I want a box at the curve point |
217 | with some text information about the curve plotted below. |
266 | with some text information about the curve plotted below. |
218 | Any wxDC method can be used. |
267 | Any wxDC method can be used. |
219 | """ |
268 | """ |
220 | # ---------- |
269 | # ---------- |
221 | dc.SetPen(wx.Pen(wx.BLACK)) |
270 | dc.SetPen(wx.Pen(wx.BLACK)) |
222 | dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) |
271 | dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) |
223 | 272 | ||
224 | sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point |
273 | sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point |
225 | dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point |
274 | dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point |
226 | px,py = mDataDict["pointXY"] |
275 | px,py = mDataDict["pointXY"] |
227 | cNum = mDataDict["curveNum"] |
276 | cNum = mDataDict["curveNum"] |
228 | pntIn = mDataDict["pIndex"] |
277 | pntIn = mDataDict["pIndex"] |
229 | legend = mDataDict["legend"] |
278 | legend = mDataDict["legend"] |
230 | #make a string to display |
279 | #make a string to display |
231 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
280 | s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn) |
232 | dc.DrawText(s, sx , sy+1) |
281 | dc.DrawText(s, sx , sy+1) |
233 | # ----------- |
282 | # ----------- |
234 | 283 | ||
235 | 284 | ||
236 | def onNewTest(self, test): |
285 | def onNewTest(self, test): |
237 | index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr) |
286 | index = self.TestListCtrl.InsertStringItem(sys.maxint, test.descr) |
238 | self.TestListCtrl.SetStringItem(index, 1, str(test.speed)) |
287 | self.TestListCtrl.SetStringItem(index, 1, str(test.speed)) |
239 | self.TestListCtrl.SetStringItem(index, 2, test.channel) |
288 | self.TestListCtrl.SetStringItem(index, 2, test.channel) |
240 | self.TestListCtrl.SetStringItem(index, 3, "OK") |
289 | self.TestListCtrl.SetStringItem(index, 3, "OK") |
241 | 290 | ||
242 | 291 | ||
243 | def OnTestSelected(self, event): |
292 | def OnTestSelected(self, event): |
244 | testId = event.m_itemIndex |
293 | testId = event.m_itemIndex |
245 | print "Test Selected id=%d" % (testId) |
294 | print "Test Selected id=%d" % (testId) |
246 | self.activeTestId = testId |
295 | self.activeTestId = testId |
247 | self.drawGraph() |
296 | self.drawGraph() |
248 | 297 | ||
249 | def drawGraph(self): |
298 | def drawGraph(self): |
250 | vibTest = self.app.getTest(self.activeTestId) |
299 | vibTest = self.app.getTest(self.activeTestId) |
251 | nb = vibTest.getDataLen() |
300 | nb = vibTest.getDataLen() |
252 | y = int(self.yAxisChoice.GetStringSelection()) |
301 | y = int(self.yAxisChoice.GetStringSelection()) |
253 | 302 | ||
254 | if self.graphTypeChoice.GetSelection() == 0: |
303 | if self.graphTypeChoice.GetSelection() == 0: |
255 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
304 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
256 | xydata.shape = (nb, 2) |
305 | xydata.shape = (nb, 2) |
257 | xydata[:,1] = vibTest.getRawData() |
306 | xydata[:,1] = vibTest.getRawData() |
258 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
307 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
259 | 308 | ||
260 | title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
309 | title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
261 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
310 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
262 | self.client.SetEnableGrid('Horizontal') |
311 | self.client.SetEnableGrid('Horizontal') |
263 | 312 | ||
264 | if self.graphTypeChoice.GetSelection() == 1: |
313 | if self.graphTypeChoice.GetSelection() == 1: |
265 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
314 | xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
266 | xydata.shape = (nb, 2) |
315 | xydata.shape = (nb, 2) |
267 | xydata[:,1] = vibTest.getFilteredData() |
316 | xydata[:,1] = vibTest.getFilteredData() |
268 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
317 | line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
269 | 318 | ||
270 | title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
319 | title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
271 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
320 | self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
272 | self.client.SetEnableGrid('Horizontal') |
321 | self.client.SetEnableGrid('Horizontal') |
273 | 322 | ||
274 | elif self.graphTypeChoice.GetSelection() == 2: |
323 | elif self.graphTypeChoice.GetSelection() == 2: |
275 | xydata = _Numeric.linspace(0,5555,nb) |
324 | xydata = _Numeric.linspace(0,5555,nb) |
276 | xydata.shape = (nb/2, 2) |
325 | xydata.shape = (nb/2, 2) |
277 | 326 | ||
278 | xydata[:,1] = vibTest.getSpectrum() |
327 | xydata[:,1] = vibTest.getSpectrum() |
279 | 328 | ||
280 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
329 | line = wx.lib.plot.PolyLine(xydata, legend= 'Spectrum', colour='red') |
281 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2) |
330 | markers = wx.lib.plot.PolyMarker(xydata, legend= '', colour='red', marker='circle',size=2) |
282 | 331 | ||
283 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
332 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
284 | self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,300), yAxis= (-0,y)) |
333 | self.client.Draw(wx.lib.plot.PlotGraphics([line,markers], title, "Freq (Hz)", "Acc"), xAxis=(0,300), yAxis= (-0,y)) |
285 | self.client.SetEnableGrid(True) |
334 | self.client.SetEnableGrid(True) |
286 | 335 | ||
287 | 336 | ||
288 | def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
337 | def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
289 | self.app.Import() |
338 | self.app.Import() |
290 | 339 | ||
291 | def onYAxisChange(self, event): # wxGlade: MainFrame.<event_handler> |
340 | def onYAxisChange(self, event): # wxGlade: MainFrame.<event_handler> |
292 | self.drawGraph() |
341 | self.drawGraph() |
293 | 342 | ||
294 | def onGraphTypeChange(self, event): # wxGlade: MainFrame.<event_handler> |
343 | def onGraphTypeChange(self, event): # wxGlade: MainFrame.<event_handler> |
295 | self.drawGraph() |
344 | self.drawGraph() |
- | 345 | ||
- | 346 | def onClear(self, event): # wxGlade: MainFrame.<event_handler> |
|
- | 347 | print "Event handler `onClear' not implemented" |
|
- | 348 | event.Skip() |
|
296 | 349 | ||
297 | # end of class MainFrame |
350 | # end of class MainFrame |
298 | 351 | ||
299 | 352 | ||
300 | class VibTest: |
353 | class VibTest: |
301 | def __init__(self, descr, motor, speed, channel, rawData): |
354 | def __init__(self, descr, motor, speed, channel, rawData): |
302 | self.descr = descr |
355 | self.descr = descr |
303 | self.motor = motor |
356 | self.motor = motor |
304 | self.speed = speed |
357 | self.speed = speed |
305 | self.channel = channel |
358 | self.channel = channel |
306 | 359 | ||
307 | self.dataLen = len(rawData) |
360 | self.dataLen = len(rawData) |
308 | 361 | ||
309 | self.rawData = _Numeric.array(rawData) |
362 | self.rawData = _Numeric.array(rawData) |
310 | self.dc = self.rawData.mean() |
363 | self.dc = self.rawData.mean() |
311 | self.rawData -= self.dc |
364 | self.rawData -= self.dc |
312 | 365 | ||
313 | self.fft = _Numeric.fft.rfft(self.rawData) |
366 | self.fft = _Numeric.fft.rfft(self.rawData) |
314 | 367 | ||
315 | self.spectrum = None |
368 | self.spectrum = None |
316 | self.filteredData = None |
369 | self.filteredData = None |
317 | 370 | ||
318 | def getDescr(self): |
371 | def getDescr(self): |
319 | return self.Descr |
372 | return self.Descr |
320 | 373 | ||
321 | def getRawData(self): |
374 | def getRawData(self): |
322 | return self.rawData |
375 | return self.rawData |
323 | 376 | ||
324 | def getDataLen(self): |
377 | def getDataLen(self): |
325 | return self.dataLen |
378 | return self.dataLen |
326 | 379 | ||
327 | def getSpectrum(self): |
380 | def getSpectrum(self): |
328 | if self.spectrum == None: |
381 | if self.spectrum == None: |
329 | self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
382 | self.spectrum = _Numeric.absolute(self.fft[1:self.dataLen/2+1]) / (self.dataLen/2) |
330 | return self.spectrum |
383 | return self.spectrum |
331 | 384 | ||
332 | def getFilteredData(self): |
385 | def getFilteredData(self): |
333 | if self.filteredData == None: |
386 | if self.filteredData == None: |
334 | tmpfft = self.fft.copy() |
387 | tmpfft = self.fft.copy() |
335 | for i in range(0,7): |
388 | for i in range(0,7): |
336 | tmpfft[i] = 0 |
389 | tmpfft[i] = 0 |
337 | for i in range(30, len(tmpfft)): |
390 | for i in range(30, len(tmpfft)): |
338 | tmpfft[i] = 0 |
391 | tmpfft[i] = 0 |
339 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
392 | self.filteredData = _Numeric.fft.irfft(tmpfft) |
340 | return self.filteredData |
393 | return self.filteredData |
341 | 394 | ||
342 | class App(wx.App): |
395 | class App(wx.App): |
343 | def __init__(self, par): |
396 | def __init__(self, par): |
344 | self.VibTests = [] |
397 | self.VibTests = [] |
345 | 398 | ||
346 | wx.App.__init__(self, par) |
399 | wx.App.__init__(self, par) |
347 | 400 | ||
348 | 401 | ||
349 | def AddTest(self, descr, motor, speed, channel, rawData): |
402 | def AddTest(self, descr, motor, speed, channel, rawData): |
350 | test = VibTest(descr, motor, speed, channel, rawData) |
403 | test = VibTest(descr, motor, speed, channel, rawData) |
351 | self.VibTests.append(test) |
404 | self.VibTests.append(test) |
352 | self.frame_1.onNewTest(test) |
405 | self.frame_1.onNewTest(test) |
353 | 406 | ||
354 | def getTest(self, testId): |
407 | def getTest(self, testId): |
355 | return self.VibTests[testId] |
408 | return self.VibTests[testId] |
356 | 409 | ||
357 | def OnInit(self): |
410 | def OnInit(self): |
358 | wx.InitAllImageHandlers() |
411 | wx.InitAllImageHandlers() |
359 | self.frame_1 = MainFrame(None, -1, "") |
412 | self.frame_1 = MainFrame(None, -1, "") |
360 | self.frame_1.setApp(self); |
413 | self.frame_1.setApp(self); |
361 | self.SetTopWindow(self.frame_1) |
414 | self.SetTopWindow(self.frame_1) |
362 | 415 | ||
363 | self.frame_1.Show() |
416 | self.frame_1.Show() |
364 | return 1 |
417 | return 1 |
365 | 418 | ||
366 | def Import(self): |
419 | def Import(self): |
367 | 420 | ||
368 | filePath = "./unbal150.txt" |
421 | filePath = "./unbal150.txt" |
369 | #filePath = "./nikivan.txt" |
422 | #filePath = "./nikivan.txt" |
370 | 423 | ||
371 | print "Import %s" % filePath |
424 | print "Import %s" % filePath |
372 | 425 | ||
373 | logfile = open(filePath, "r") |
426 | logfile = open(filePath, "r") |
374 | data = None |
427 | data = None |
375 | 428 | ||
376 | headers = (logfile.readline()).split(',') |
429 | headers = (logfile.readline()).split(',') |
377 | nbCols = len(headers) |
430 | nbCols = len(headers) |
378 | print "NbCols =", nbCols |
431 | print "NbCols =", nbCols |
379 | 432 | ||
380 | data = [] |
433 | data = [] |
381 | descr = [] |
434 | descr = [] |
382 | speed = [] |
435 | speed = [] |
383 | channel = [] |
436 | channel = [] |
384 | for c in range(nbCols): |
437 | for c in range(nbCols): |
385 | data.append([]) |
438 | data.append([]) |
386 | h = headers[c].split(' ') |
439 | h = headers[c].split(' ') |
387 | descr.append(h[0]); |
440 | descr.append(h[0]); |
388 | speed.append(h[1]); |
441 | speed.append(h[1]); |
389 | channel.append(h[2]); |
442 | channel.append(h[2]); |
390 | 443 | ||
391 | for line in logfile: |
444 | for line in logfile: |
392 | values = line.split(',') |
445 | values = line.split(',') |
393 | for i in range(nbCols): |
446 | for i in range(nbCols): |
394 | data[i].append(int(values[i])) |
447 | data[i].append(int(values[i])) |
395 | logfile.close() |
448 | logfile.close() |
396 | 449 | ||
397 | for c in range(nbCols): |
450 | for c in range(nbCols): |
398 | if (len(data[c]) % 2) != 0: |
451 | if (len(data[c]) % 2) != 0: |
399 | data[c].append(data[c][-1]) |
452 | data[c].append(data[c][-1]) |
400 | self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c]) |
453 | self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c]) |
401 | 454 | ||
402 | 455 | ||
403 | 456 | ||
404 | 457 | ||
405 | 458 | ||
406 | # end of class App |
459 | # end of class App |
407 | 460 | ||
408 | if __name__ == "__main__": |
461 | if __name__ == "__main__": |
409 | VibrationTestGui = App(0) |
462 | VibrationTestGui = App(0) |
410 | VibrationTestGui.MainLoop() |
463 | VibrationTestGui.MainLoop() |
411 | 464 |