Rev 718 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 718 | Rev 720 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | # |
5 | # |
6 | # Mikrokopter VibrationTest Rev: $Rev: 718 $ |
6 | # Mikrokopter VibrationTest Rev: $Rev: 720 $ |
7 | # |
7 | # |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
Line 9... | Line 9... | ||
9 | # |
9 | # |
Line 67... | Line 67... | ||
67 | class MkSettingsDialog(wx.Frame): |
67 | class MkSettingsDialog(wx.Frame): |
68 | def __init__(self, *args, **kwds): |
68 | def __init__(self, *args, **kwds): |
69 | # begin wxGlade: MkSettingsDialog.__init__ |
69 | # begin wxGlade: MkSettingsDialog.__init__ |
70 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
70 | kwds["style"] = wx.DEFAULT_FRAME_STYLE |
71 | wx.Frame.__init__(self, *args, **kwds) |
71 | wx.Frame.__init__(self, *args, **kwds) |
- | 72 | self.statusText = wx.StaticText(self, -1, "--") |
|
72 | self.label_2 = wx.StaticText(self, -1, "Gyro-P", style=wx.ALIGN_RIGHT) |
73 | self.label_2 = wx.StaticText(self, -1, "Gyro-P", style=wx.ALIGN_RIGHT) |
73 | self.slider_GyroP = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
74 | self.slider_GyroP = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
74 | self.label_2_copy = wx.StaticText(self, -1, "Gyro-I", style=wx.ALIGN_RIGHT) |
75 | self.label_2_copy = wx.StaticText(self, -1, "Gyro-I", style=wx.ALIGN_RIGHT) |
75 | self.slider_GyroI = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
76 | self.slider_GyroI = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
76 | self.label_2_copy_1 = wx.StaticText(self, -1, "Gyro-D", style=wx.ALIGN_RIGHT) |
77 | self.label_2_copy_1 = wx.StaticText(self, -1, "Gyro-D", style=wx.ALIGN_RIGHT) |
Line 79... | Line 80... | ||
79 | self.slider_FactorI = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
80 | self.slider_FactorI = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
80 | self.label_2_copy_3 = wx.StaticText(self, -1, "", style=wx.ALIGN_RIGHT) |
81 | self.label_2_copy_3 = wx.StaticText(self, -1, "", style=wx.ALIGN_RIGHT) |
81 | self.slider_1_copy_3 = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
82 | self.slider_1_copy_3 = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS) |
82 | self.loadButton = wx.Button(self, -1, "Load") |
83 | self.loadButton = wx.Button(self, -1, "Load") |
83 | self.storeButton = wx.Button(self, -1, "Store") |
84 | self.storeButton = wx.Button(self, -1, "Store") |
- | 85 | self.defaultButton = wx.Button(self, -1, "Default") |
|
Line 84... | Line 86... | ||
84 | 86 | ||
85 | self.__set_properties() |
87 | self.__set_properties() |
Line 86... | Line 88... | ||
86 | self.__do_layout() |
88 | self.__do_layout() |
- | 89 | ||
- | 90 | self.Bind(wx.EVT_BUTTON, self.onLoad, self.loadButton) |
|
87 | 91 | self.Bind(wx.EVT_BUTTON, self.onStore, self.storeButton) |
|
Line 88... | Line 92... | ||
88 | self.Bind(wx.EVT_BUTTON, self.onLoad, self.loadButton) |
92 | self.Bind(wx.EVT_BUTTON, self.onDefault, self.defaultButton) |
89 | # end wxGlade |
93 | # end wxGlade |
90 | 94 | ||
91 | def __set_properties(self): |
95 | def __set_properties(self): |
- | 96 | # begin wxGlade: MkSettingsDialog.__set_properties |
|
92 | # begin wxGlade: MkSettingsDialog.__set_properties |
97 | self.SetTitle("MK Settings") |
93 | self.SetTitle("MK Settings") |
98 | self.SetSize((600, 450)) |
94 | self.SetSize((600, 450)) |
99 | self.statusText.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
95 | self.label_2.SetMinSize((80, 16)) |
100 | self.label_2.SetMinSize((80, 16)) |
96 | self.label_2.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
101 | self.label_2.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
Line 110... | Line 115... | ||
110 | self.slider_FactorI.SetBackgroundColour(wx.Colour(128, 128, 128)) |
115 | self.slider_FactorI.SetBackgroundColour(wx.Colour(128, 128, 128)) |
111 | self.label_2_copy_3.SetMinSize((80, 16)) |
116 | self.label_2_copy_3.SetMinSize((80, 16)) |
112 | self.label_2_copy_3.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
117 | self.label_2_copy_3.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
113 | self.slider_1_copy_3.SetMinSize((400, -1)) |
118 | self.slider_1_copy_3.SetMinSize((400, -1)) |
114 | self.slider_1_copy_3.SetBackgroundColour(wx.Colour(128, 128, 128)) |
119 | self.slider_1_copy_3.SetBackgroundColour(wx.Colour(128, 128, 128)) |
- | 120 | self.loadButton.SetBackgroundColour(wx.Colour(0, 255, 0)) |
|
- | 121 | self.storeButton.SetBackgroundColour(wx.Colour(255, 0, 0)) |
|
115 | # end wxGlade |
122 | # end wxGlade |
Line 116... | Line 123... | ||
116 | 123 | ||
117 | def __do_layout(self): |
124 | def __do_layout(self): |
118 | # begin wxGlade: MkSettingsDialog.__do_layout |
125 | # begin wxGlade: MkSettingsDialog.__do_layout |
Line 126... | Line 133... | ||
126 | sizer_24_copy_1 = wx.BoxSizer(wx.HORIZONTAL) |
133 | sizer_24_copy_1 = wx.BoxSizer(wx.HORIZONTAL) |
127 | sizer_24_copy = wx.BoxSizer(wx.HORIZONTAL) |
134 | sizer_24_copy = wx.BoxSizer(wx.HORIZONTAL) |
128 | sizer_24 = wx.BoxSizer(wx.HORIZONTAL) |
135 | sizer_24 = wx.BoxSizer(wx.HORIZONTAL) |
129 | sizer_21.Add((20, 20), 0, 0, 0) |
136 | sizer_21.Add((20, 20), 0, 0, 0) |
130 | sizer_22.Add((20, 20), 0, 0, 0) |
137 | sizer_22.Add((20, 20), 0, 0, 0) |
- | 138 | sizer_23.Add(self.statusText, 0, 0, 0) |
|
- | 139 | sizer_23.Add((20, 20), 0, 0, 0) |
|
131 | sizer_24.Add(self.label_2, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
140 | sizer_24.Add(self.label_2, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
132 | sizer_24.Add((20, 20), 0, 0, 0) |
141 | sizer_24.Add((20, 20), 0, 0, 0) |
133 | sizer_24.Add(self.slider_GyroP, 0, 0, 0) |
142 | sizer_24.Add(self.slider_GyroP, 0, 0, 0) |
134 | sizer_23.Add(sizer_24, 1, wx.EXPAND, 0) |
143 | sizer_23.Add(sizer_24, 1, wx.EXPAND, 0) |
135 | sizer_23.Add((20, 20), 0, 0, 0) |
144 | sizer_23.Add((20, 20), 0, 0, 0) |
Line 151... | Line 160... | ||
151 | sizer_24_copy_3.Add(self.label_2_copy_3, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
160 | sizer_24_copy_3.Add(self.label_2_copy_3, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
152 | sizer_24_copy_3.Add((20, 20), 0, 0, 0) |
161 | sizer_24_copy_3.Add((20, 20), 0, 0, 0) |
153 | sizer_24_copy_3.Add(self.slider_1_copy_3, 0, 0, 0) |
162 | sizer_24_copy_3.Add(self.slider_1_copy_3, 0, 0, 0) |
154 | sizer_23.Add(sizer_24_copy_3, 1, wx.EXPAND, 0) |
163 | sizer_23.Add(sizer_24_copy_3, 1, wx.EXPAND, 0) |
155 | sizer_23.Add((20, 20), 0, 0, 0) |
164 | sizer_23.Add((20, 20), 0, 0, 0) |
- | 165 | sizer_23.Add((20, 20), 0, 0, 0) |
|
156 | sizer_22.Add(sizer_23, 1, wx.EXPAND, 0) |
166 | sizer_22.Add(sizer_23, 1, wx.EXPAND, 0) |
157 | sizer_25.Add(self.loadButton, 0, 0, 0) |
167 | sizer_25.Add(self.loadButton, 0, 0, 0) |
158 | sizer_25.Add((20, 20), 0, 0, 0) |
168 | sizer_25.Add((20, 20), 0, 0, 0) |
159 | sizer_25.Add(self.storeButton, 0, 0, 0) |
169 | sizer_25.Add(self.storeButton, 0, 0, 0) |
160 | sizer_25.Add((20, 20), 0, 0, 0) |
170 | sizer_25.Add((20, 20), 0, 0, 0) |
- | 171 | sizer_25.Add(self.defaultButton, 0, 0, 0) |
|
161 | sizer_22.Add(sizer_25, 1, wx.EXPAND, 0) |
172 | sizer_22.Add(sizer_25, 1, wx.EXPAND, 0) |
162 | sizer_22.Add((20, 20), 0, 0, 0) |
173 | sizer_22.Add((20, 20), 0, 0, 0) |
163 | sizer_21.Add(sizer_22, 0, 0, 0) |
174 | sizer_21.Add(sizer_22, 0, 0, 0) |
164 | sizer_21.Add((20, 20), 0, 0, 0) |
175 | sizer_21.Add((20, 20), 0, 0, 0) |
165 | sizer_15.Add(sizer_21, 0, 0, 0) |
176 | sizer_15.Add(sizer_21, 0, 0, 0) |
166 | self.SetSizer(sizer_15) |
177 | self.SetSizer(sizer_15) |
167 | self.Layout() |
178 | self.Layout() |
168 | self.SetSize((600, 450)) |
179 | self.SetSize((600, 450)) |
169 | # end wxGlade |
180 | # end wxGlade |
Line 170... | Line 181... | ||
170 | 181 | ||
171 | def onLoad(self, event): # wxGlade: MkSettingsDialog.<event_handler> |
182 | def doLoad(self): |
Line 172... | Line 183... | ||
172 | print "Loading MK Settings" |
183 | print "Loading MK Settings" |
173 | 184 | ||
Line 174... | Line 185... | ||
174 | mk = MkProtocol.MkComm() |
185 | mk = MkProtocol.MkComm() |
175 | mk.open(comPort=self.app.settings["serialport"].value) |
186 | mk.open(comPort=self.app.settings["serialport"].value) |
- | 187 | ||
- | 188 | msg = mk.getSettingsMsg() |
|
176 | 189 | s = "%d %s" % (msg.getIndex(), msg.getName()) |
|
Line 177... | Line 190... | ||
177 | msg = mk.getSettingsMsg() |
190 | print s |
178 | print "Index=",msg.getIndex() |
191 | |
179 | print "Name=",msg.getName() |
192 | self.statusText.SetLabel(s) |
- | 193 | ||
Line 180... | Line 194... | ||
180 | 194 | self.slider_GyroP.SetValue(msg.getSetting(MkProtocol.SettingsMsg.IDX_GYRO_P)) |
|
Line -... | Line 195... | ||
- | 195 | self.slider_GyroI.SetValue(msg.getSetting(MkProtocol.SettingsMsg.IDX_GYRO_I)) |
|
- | 196 | self.slider_GyroD.SetValue(msg.getSetting(MkProtocol.SettingsMsg.IDX_GYRO_D)) |
|
- | 197 | self.slider_FactorI.SetValue(msg.getSetting(MkProtocol.SettingsMsg.IDX_I_FACTOR)) |
|
- | 198 | ||
- | 199 | mk.close() |
|
181 | self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_P)) |
200 | |
- | 201 | ||
- | 202 | ||
- | 203 | def doStore(self): |
|
- | 204 | print "Storing MK Settings" |
|
- | 205 | ||
- | 206 | mk = MkProtocol.MkComm() |
|
- | 207 | mk.open(comPort=self.app.settings["serialport"].value) |
|
- | 208 | ||
- | 209 | msg = mk.getSettingsMsg() |
|
- | 210 | ||
Line 182... | Line -... | ||
182 | self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_I)) |
- | |
183 | self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_D)) |
211 | msg.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_P, self.slider_GyroP.GetValue()) |
184 | 212 | msg.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_I, self.slider_GyroI.GetValue()) |
|
- | 213 | msg.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_D, self.slider_GyroD.GetValue()) |
|
- | 214 | msg.setSetting(MkProtocol.SettingsMsg.IDX_I_FACTOR, self.slider_FactorI.GetValue()) |
|
- | 215 | ||
- | 216 | mk.sendSettings(msg.getSettings()) |
|
- | 217 | ||
- | 218 | def setApp(self, app): |
|
- | 219 | self.app = app |
|
- | 220 | ||
- | 221 | ||
- | 222 | def onLoad(self, event): # wxGlade: MkSettingsDialog.<event_handler> |
|
- | 223 | self.doLoad() |
|
- | 224 | event.Skip() |
|
- | 225 | ||
- | 226 | def onStore(self, event): # wxGlade: MkSettingsDialog.<event_handler> |
|
- | 227 | self.doStore() |
|
- | 228 | event.Skip() |
|
- | 229 | ||
185 | mk.close() |
230 | def onDefault(self, event): # wxGlade: MkSettingsDialog.<event_handler> |
Line 954... | Line 999... | ||
954 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
999 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
955 | # First we create and fill the info object |
1000 | # First we create and fill the info object |
956 | print "about" |
1001 | print "about" |
957 | info = wx.AboutDialogInfo() |
1002 | info = wx.AboutDialogInfo() |
958 | info.Name = "MK Vibration Test - " |
1003 | info.Name = "MK Vibration Test - " |
959 | info.Version = "v1.2 ($Rev: 718 $)".replace("$","") |
1004 | info.Version = "v1.2 ($Rev: 720 $)".replace("$","") |
960 | info.Copyright = "" |
1005 | info.Copyright = "" |
961 | info.Developers=["Frederic Goddeeris (Frederic@rc-flight.be)"] |
1006 | info.Developers=["Frederic Goddeeris (Frederic@rc-flight.be)"] |
962 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
1007 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
963 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
1008 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
964 | wx.AboutBox(info) |
1009 | wx.AboutBox(info) |
Line 1082... | Line 1127... | ||
1082 | for I in self.param.speeds: |
1127 | for I in self.param.speeds: |
1083 | self._sendEvent("TestSettings I=%d" % I) |
1128 | self._sendEvent("TestSettings I=%d" % I) |
1084 | orgSetting = self.mk.getSettingsMsg() |
1129 | orgSetting = self.mk.getSettingsMsg() |
1085 | testSettings = copy.deepcopy(orgSetting) |
1130 | testSettings = copy.deepcopy(orgSetting) |
Line 1086... | Line 1131... | ||
1086 | 1131 | ||
1087 | # testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_P, I) |
1132 | testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_P, I) |
Line 1088... | Line 1133... | ||
1088 | # testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_I, 65) |
1133 | testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_I, 120) |
1089 | 1134 | ||
Line 1090... | Line 1135... | ||
1090 | testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_P, 0) |
1135 | # testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_P, 0) |
Line 1091... | Line 1136... | ||
1091 | testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_I, I) |
1136 | # testSettings.setSetting(MkProtocol.SettingsMsg.IDX_GYRO_I, I) |
Line 1092... | Line 1137... | ||
1092 | 1137 | ||
1093 | self.mk.sendSettings(testSettings.getSettings()) |
1138 | self.mk.sendSettings(testSettings.getSettings()) |
1094 | 1139 | ||
1095 | #time.sleep(3) |
1140 | #time.sleep(3) |
Line 1096... | Line 1141... | ||
1096 | 1141 | ||
1097 | ## DISTURB |
1142 | ## DISTURB |