Subversion Repositories Projects

Rev

Rev 717 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 717 Rev 718
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: 717 $
6
# Mikrokopter VibrationTest  Rev: $Rev: 718 $
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 62... Line 62...
62
 
62
 
63
# This creates a new Event class and a EVT binder function
63
# This creates a new Event class and a EVT binder function
64
(MeasStatusUpdateEvent, EVT_MEAS_STATUS_UPDATE) = wx.lib.newevent.NewEvent()  
64
(MeasStatusUpdateEvent, EVT_MEAS_STATUS_UPDATE) = wx.lib.newevent.NewEvent()  
Line -... Line 65...
-
 
65
(MeasDataEvent, EVT_MEAS_DATA) = wx.lib.newevent.NewEvent()  
-
 
66
 
-
 
67
class MkSettingsDialog(wx.Frame):
-
 
68
    def __init__(self, *args, **kwds):
-
 
69
        # begin wxGlade: MkSettingsDialog.__init__
-
 
70
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
-
 
71
        wx.Frame.__init__(self, *args, **kwds)
-
 
72
        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.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.label_2_copy_1 = wx.StaticText(self, -1, "Gyro-D", style=wx.ALIGN_RIGHT)
-
 
77
        self.slider_GyroD = wx.Slider(self, -1, 0, 0, 255, style=wx.SL_HORIZONTAL|wx.SL_LABELS)
-
 
78
        self.label_2_copy_2 = wx.StaticText(self, -1, "Factor-I", style=wx.ALIGN_RIGHT)
-
 
79
        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.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.storeButton = wx.Button(self, -1, "Store")
-
 
84
 
-
 
85
        self.__set_properties()
-
 
86
        self.__do_layout()
-
 
87
 
-
 
88
        self.Bind(wx.EVT_BUTTON, self.onLoad, self.loadButton)
-
 
89
        # end wxGlade
-
 
90
 
-
 
91
    def __set_properties(self):
-
 
92
        # begin wxGlade: MkSettingsDialog.__set_properties
-
 
93
        self.SetTitle("MK Settings")
-
 
94
        self.SetSize((600, 450))
-
 
95
        self.label_2.SetMinSize((80, 16))
-
 
96
        self.label_2.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
-
 
97
        self.slider_GyroP.SetMinSize((400, -1))
-
 
98
        self.slider_GyroP.SetBackgroundColour(wx.Colour(128, 128, 128))
-
 
99
        self.label_2_copy.SetMinSize((80, 16))
-
 
100
        self.label_2_copy.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
-
 
101
        self.slider_GyroI.SetMinSize((400, -1))
-
 
102
        self.slider_GyroI.SetBackgroundColour(wx.Colour(128, 128, 128))
-
 
103
        self.label_2_copy_1.SetMinSize((80, 16))
-
 
104
        self.label_2_copy_1.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
-
 
105
        self.slider_GyroD.SetMinSize((400, -1))
-
 
106
        self.slider_GyroD.SetBackgroundColour(wx.Colour(128, 128, 128))
-
 
107
        self.label_2_copy_2.SetMinSize((80, 16))
-
 
108
        self.label_2_copy_2.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
-
 
109
        self.slider_FactorI.SetMinSize((400, -1))
-
 
110
        self.slider_FactorI.SetBackgroundColour(wx.Colour(128, 128, 128))
-
 
111
        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, ""))
-
 
113
        self.slider_1_copy_3.SetMinSize((400, -1))
-
 
114
        self.slider_1_copy_3.SetBackgroundColour(wx.Colour(128, 128, 128))
-
 
115
        # end wxGlade
-
 
116
 
-
 
117
    def __do_layout(self):
-
 
118
        # begin wxGlade: MkSettingsDialog.__do_layout
-
 
119
        sizer_15 = wx.BoxSizer(wx.VERTICAL)
-
 
120
        sizer_21 = wx.BoxSizer(wx.HORIZONTAL)
-
 
121
        sizer_22 = wx.BoxSizer(wx.VERTICAL)
-
 
122
        sizer_25 = wx.BoxSizer(wx.HORIZONTAL)
-
 
123
        sizer_23 = wx.BoxSizer(wx.VERTICAL)
-
 
124
        sizer_24_copy_3 = wx.BoxSizer(wx.HORIZONTAL)
-
 
125
        sizer_24_copy_2 = wx.BoxSizer(wx.HORIZONTAL)
-
 
126
        sizer_24_copy_1 = wx.BoxSizer(wx.HORIZONTAL)
-
 
127
        sizer_24_copy = wx.BoxSizer(wx.HORIZONTAL)
-
 
128
        sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
-
 
129
        sizer_21.Add((20, 20), 0, 0, 0)
-
 
130
        sizer_22.Add((20, 20), 0, 0, 0)
-
 
131
        sizer_24.Add(self.label_2, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
132
        sizer_24.Add((20, 20), 0, 0, 0)
-
 
133
        sizer_24.Add(self.slider_GyroP, 0, 0, 0)
-
 
134
        sizer_23.Add(sizer_24, 1, wx.EXPAND, 0)
-
 
135
        sizer_23.Add((20, 20), 0, 0, 0)
-
 
136
        sizer_24_copy.Add(self.label_2_copy, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
137
        sizer_24_copy.Add((20, 20), 0, 0, 0)
-
 
138
        sizer_24_copy.Add(self.slider_GyroI, 0, 0, 0)
-
 
139
        sizer_23.Add(sizer_24_copy, 1, wx.EXPAND, 0)
-
 
140
        sizer_23.Add((20, 20), 0, 0, 0)
-
 
141
        sizer_24_copy_1.Add(self.label_2_copy_1, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
142
        sizer_24_copy_1.Add((20, 20), 0, 0, 0)
-
 
143
        sizer_24_copy_1.Add(self.slider_GyroD, 0, 0, 0)
-
 
144
        sizer_23.Add(sizer_24_copy_1, 1, wx.EXPAND, 0)
-
 
145
        sizer_23.Add((20, 20), 0, 0, 0)
-
 
146
        sizer_24_copy_2.Add(self.label_2_copy_2, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0)
-
 
147
        sizer_24_copy_2.Add((20, 20), 0, 0, 0)
-
 
148
        sizer_24_copy_2.Add(self.slider_FactorI, 0, 0, 0)
-
 
149
        sizer_23.Add(sizer_24_copy_2, 1, wx.EXPAND, 0)
-
 
150
        sizer_23.Add((20, 20), 0, 0, 0)
-
 
151
        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)
-
 
153
        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)
-
 
155
        sizer_23.Add((20, 20), 0, 0, 0)
-
 
156
        sizer_22.Add(sizer_23, 1, wx.EXPAND, 0)
-
 
157
        sizer_25.Add(self.loadButton, 0, 0, 0)
-
 
158
        sizer_25.Add((20, 20), 0, 0, 0)
-
 
159
        sizer_25.Add(self.storeButton, 0, 0, 0)
-
 
160
        sizer_25.Add((20, 20), 0, 0, 0)
-
 
161
        sizer_22.Add(sizer_25, 1, wx.EXPAND, 0)
-
 
162
        sizer_22.Add((20, 20), 0, 0, 0)
-
 
163
        sizer_21.Add(sizer_22, 0, 0, 0)
-
 
164
        sizer_21.Add((20, 20), 0, 0, 0)
-
 
165
        sizer_15.Add(sizer_21, 0, 0, 0)
-
 
166
        self.SetSizer(sizer_15)
-
 
167
        self.Layout()
-
 
168
        self.SetSize((600, 450))
-
 
169
        # end wxGlade
-
 
170
 
-
 
171
    def onLoad(self, event): # wxGlade: MkSettingsDialog.<event_handler>
-
 
172
        print "Loading MK Settings"
-
 
173
       
-
 
174
        mk = MkProtocol.MkComm()
-
 
175
        mk.open(comPort=self.app.settings["serialport"].value)
-
 
176
   
-
 
177
        msg = mk.getSettingsMsg()
-
 
178
        print "Index=",msg.getIndex()
-
 
179
        print "Name=",msg.getName()
-
 
180
 
-
 
181
        self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_P))
-
 
182
        self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_I))
-
 
183
        self.slider_GyroP.SetValue(msg.getSetting(SettingsMsg.IDX_STICK_D))
-
 
184
       
-
 
185
        mk.close()
-
 
186
       
-
 
187
        event.Skip()
-
 
188
       
-
 
189
   
-
 
190
    def setApp(self, app):
-
 
191
        self.app = app
-
 
192
# end of class MkSettingsDialog
-
 
193
 
-
 
194
 
65
(MeasDataEvent, EVT_MEAS_DATA) = wx.lib.newevent.NewEvent()  
195
 
66
 
196
 
67
class MeasureDialog(wx.Dialog):
197
class MeasureDialog(wx.Dialog):
68
    def __init__(self, *args, **kwds):
198
    def __init__(self, *args, **kwds):
69
        # begin wxGlade: MeasureDialog.__init__
199
        # begin wxGlade: MeasureDialog.__init__
Line 824... Line 954...
824
    def onAbout(self, event): # wxGlade: MainFrame.<event_handler>
954
    def onAbout(self, event): # wxGlade: MainFrame.<event_handler>
825
         # First we create and fill the info object
955
         # First we create and fill the info object
826
        print "about"
956
        print "about"
827
        info = wx.AboutDialogInfo()
957
        info = wx.AboutDialogInfo()
828
        info.Name = "MK Vibration Test - "
958
        info.Name = "MK Vibration Test - "
829
        info.Version = "v1.2 ($Rev: 717 $)".replace("$","")
959
        info.Version = "v1.2 ($Rev: 718 $)".replace("$","")
830
        info.Copyright = ""
960
        info.Copyright = ""
831
        info.Developers=["Frederic Goddeeris  (Frederic@rc-flight.be)"]
961
        info.Developers=["Frederic Goddeeris  (Frederic@rc-flight.be)"]
832
        info.Description = "Please consult the WIKI page for a complete description of the tool:"
962
        info.Description = "Please consult the WIKI page for a complete description of the tool:"
833
        info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page")
963
        info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page")
834
        wx.AboutBox(info)
964
        wx.AboutBox(info)
Line 1160... Line 1290...
1160
    def getTest(self, testId):
1290
    def getTest(self, testId):
1161
        return self.VibTests[testId]
1291
        return self.VibTests[testId]
Line 1162... Line 1292...
1162
 
1292
 
1163
    def OnInit(self):
1293
    def OnInit(self):
-
 
1294
        wx.InitAllImageHandlers()
1164
        wx.InitAllImageHandlers()
1295
       
1165
        self.frame_1 = MainFrame(None, -1, "")
1296
        self.frame_1 = MainFrame(None, -1, "")
1166
        self.frame_1.setApp(self);
1297
        self.frame_1.setApp(self)
1167
        self.SetTopWindow(self.frame_1)
-
 
1168
 
1298
        self.SetTopWindow(self.frame_1)
1169
        self.frame_1.CenterOnScreen()
1299
        self.frame_1.CenterOnScreen()
-
 
1300
        self.frame_1.Show()
-
 
1301
       
-
 
1302
        self.mkSettingsFrame = MkSettingsDialog(None, -1, "")
-
 
1303
        self.mkSettingsFrame.setApp(self);
-
 
1304
        self.mkSettingsFrame.Show()
1170
        self.frame_1.Show()
1305
 
Line 1171... Line 1306...
1171
        return 1
1306
        return 1
1172
 
1307
 
1173
    def saveTests(self, filePath):
1308
    def saveTests(self, filePath):