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