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