Rev 611 | Rev 613 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 611 | Rev 612 | ||
---|---|---|---|
Line 2... | Line 2... | ||
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 | import sys |
5 | import sys |
- | 6 | import os |
|
- | 7 | import time |
|
- | 8 | import thread |
|
- | 9 | import ConfigParser |
|
6 | import os |
10 | |
7 | import wx |
11 | import wx |
8 | import wx.lib |
12 | import wx.lib |
9 | import wx.lib.plot |
13 | import wx.lib.plot |
Line 10... | Line 14... | ||
10 | import ConfigParser |
14 | import wx.lib.newevent |
11 | 15 | ||
12 | # Needs Numeric or numarray or NumPy |
16 | # Needs Numeric or numarray or NumPy |
13 | try: |
17 | try: |
Line 29... | Line 33... | ||
29 | 33 | ||
30 | # begin wxGlade: extracode |
34 | # begin wxGlade: extracode |
Line -... | Line 35... | ||
- | 35 | # end wxGlade |
|
- | 36 | ||
- | 37 | ||
- | 38 | # This creates a new Event class and a EVT binder function |
|
- | 39 | (MeasStatusUpdateEvent, EVT_MEAS_STATUS_UPDATE) = wx.lib.newevent.NewEvent() |
|
- | 40 | ||
- | 41 | class MeasureDialog(wx.Dialog): |
|
- | 42 | def __init__(self, *args, **kwds): |
|
- | 43 | # begin wxGlade: MeasureDialog.__init__ |
|
- | 44 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME |
|
- | 45 | wx.Dialog.__init__(self, *args, **kwds) |
|
- | 46 | self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL) |
|
- | 47 | self.button = wx.Button(self, -1, "STOP") |
|
- | 48 | ||
- | 49 | self.__set_properties() |
|
- | 50 | self.__do_layout() |
|
- | 51 | ||
- | 52 | self.Bind(wx.EVT_BUTTON, self.onButton, self.button) |
|
- | 53 | # end wxGlade |
|
- | 54 | ||
- | 55 | self.running = True |
|
- | 56 | self.Bind(EVT_MEAS_STATUS_UPDATE, self.OnUpdate) |
|
- | 57 | ||
- | 58 | def __set_properties(self): |
|
- | 59 | # begin wxGlade: MeasureDialog.__set_properties |
|
- | 60 | self.SetTitle("Measuring Status") |
|
- | 61 | self.text_ctrl_1.SetMinSize((400,300)) |
|
- | 62 | # end wxGlade |
|
- | 63 | ||
- | 64 | def __do_layout(self): |
|
- | 65 | # begin wxGlade: MeasureDialog.__do_layout |
|
- | 66 | sizer_1 = wx.BoxSizer(wx.HORIZONTAL) |
|
- | 67 | sizer_2 = wx.BoxSizer(wx.VERTICAL) |
|
- | 68 | sizer_1.Add((20, 20), 0, 0, 0) |
|
- | 69 | sizer_2.Add((20, 20), 0, 0, 0) |
|
- | 70 | sizer_2.Add(self.text_ctrl_1, 1, wx.EXPAND, 0) |
|
- | 71 | sizer_2.Add((20, 20), 0, 0, 0) |
|
- | 72 | sizer_2.Add(self.button, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) |
|
- | 73 | sizer_2.Add((20, 20), 0, 0, 0) |
|
- | 74 | sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) |
|
- | 75 | sizer_1.Add((20, 20), 0, 0, 0) |
|
- | 76 | self.SetSizer(sizer_1) |
|
- | 77 | sizer_1.Fit(self) |
|
- | 78 | self.Layout() |
|
- | 79 | # end wxGlade |
|
- | 80 | ||
- | 81 | def OnUpdate(self, evt): |
|
- | 82 | print "Event received" |
|
- | 83 | self.running = evt.running |
|
- | 84 | self.text_ctrl_1.WriteText("%s\n"%evt.msg) |
|
- | 85 | if (not self.running): |
|
- | 86 | self.button.SetLabel("Close") |
|
- | 87 | ||
- | 88 | def onButton(self, event): # wxGlade: MeasureDialog.<event_handler> |
|
- | 89 | if (not self.running): |
|
- | 90 | self.Destroy() |
|
Line 31... | Line 91... | ||
31 | # end wxGlade |
91 | |
32 | 92 | # end of class MeasureDialog |
|
33 | 93 | ||
34 | 94 | ||
Line 104... | Line 164... | ||
104 | wx.MessageBox("Invalid format for \"%s\" setting." % setting[1].descr) |
164 | wx.MessageBox("Invalid format for \"%s\" setting." % setting[1].descr) |
Line 105... | Line 165... | ||
105 | 165 | ||
Line 106... | Line -... | ||
106 | # end of class SettingsDialog |
- | |
107 | - | ||
108 | - | ||
109 | class SettingsFrame(wx.Frame): |
- | |
110 | def __init__(self, *args, **kwds): |
- | |
111 | # content of this block not found: did you rename this class? |
- | |
112 | pass |
- | |
113 | - | ||
114 | def __set_properties(self): |
- | |
115 | # content of this block not found: did you rename this class? |
- | |
116 | pass |
- | |
117 | - | ||
118 | def __do_layout(self): |
- | |
119 | # content of this block not found: did you rename this class? |
- | |
120 | pass |
- | |
121 | - | ||
122 | # end of class SettingsFrame |
- | |
123 | - | ||
124 | - | ||
125 | class MenuBar(wx.MenuBar): |
- | |
126 | def __init__(self, *args, **kwds): |
- | |
127 | # content of this block not found: did you rename this class? |
- | |
128 | pass |
- | |
129 | - | ||
130 | def __set_properties(self): |
- | |
131 | # content of this block not found: did you rename this class? |
- | |
132 | pass |
- | |
133 | - | ||
134 | def __do_layout(self): |
- | |
135 | # content of this block not found: did you rename this class? |
- | |
136 | pass |
- | |
137 | - | ||
138 | # end of class MenuBar |
- | |
139 | - | ||
140 | - | ||
141 | class wxFrame(wx.Panel): |
- | |
142 | def __init__(self, *args, **kwds): |
- | |
143 | # content of this block not found: did you rename this class? |
- | |
144 | pass |
- | |
145 | - | ||
146 | def __set_properties(self): |
- | |
147 | # content of this block not found: did you rename this class? |
- | |
148 | pass |
- | |
149 | - | ||
150 | def __do_layout(self): |
- | |
151 | # content of this block not found: did you rename this class? |
- | |
152 | pass |
- | |
153 | - | ||
154 | # end of class wxFrame |
- | |
155 | - | ||
156 | - | ||
157 | class MyFrame(wx.Frame): |
- | |
158 | def __init__(self, *args, **kwds): |
- | |
159 | # content of this block not found: did you rename this class? |
- | |
160 | pass |
- | |
161 | - | ||
162 | def __set_properties(self): |
- | |
163 | # content of this block not found: did you rename this class? |
- | |
164 | pass |
- | |
165 | - | ||
166 | def __do_layout(self): |
- | |
167 | # content of this block not found: did you rename this class? |
- | |
168 | pass |
- | |
Line 169... | Line 166... | ||
169 | 166 | # end of class SettingsDialog |
|
170 | # end of class MyFrame |
167 | |
171 | 168 | ||
172 | 169 | ||
Line 216... | Line 213... | ||
216 | self.__do_layout() |
213 | self.__do_layout() |
Line 217... | Line 214... | ||
217 | 214 | ||
218 | self.Bind(wx.EVT_MENU, self.OnSettings, id=101) |
215 | self.Bind(wx.EVT_MENU, self.OnSettings, id=101) |
219 | self.Bind(wx.EVT_MENU, self.onClear, id=301) |
216 | self.Bind(wx.EVT_MENU, self.onClear, id=301) |
- | 217 | self.Bind(wx.EVT_MENU, self.OnImport, id=302) |
|
220 | self.Bind(wx.EVT_MENU, self.OnImport, id=302) |
218 | self.Bind(wx.EVT_BUTTON, self.onStartMeasure, self.button_4) |
221 | self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
219 | self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
222 | self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
220 | self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
Line 223... | Line 221... | ||
223 | # end wxGlade |
221 | # end wxGlade |
Line 439... | Line 437... | ||
439 | dlg.CenterOnScreen() |
437 | dlg.CenterOnScreen() |
440 | val = dlg.ShowModal() # this does not return until the dialog is closed. |
438 | val = dlg.ShowModal() # this does not return until the dialog is closed. |
441 | dlg.Destroy() |
439 | dlg.Destroy() |
442 | self.app.onSettingsChanged() |
440 | self.app.onSettingsChanged() |
Line -... | Line 441... | ||
- | 441 | ||
- | 442 | def onStartMeasure(self, event): # wxGlade: MainFrame.<event_handler> |
|
- | 443 | ||
- | 444 | # create the dialog that will show the satus |
|
- | 445 | dlg = MeasureDialog(self) |
|
- | 446 | dlg.CenterOnScreen() |
|
- | 447 | # Signal that application |
|
- | 448 | self.app.startMeasure(dlg) |
|
- | 449 | # Show the dialog |
|
- | 450 | val = dlg.ShowModal() # this does not return until the dialog is closed. |
|
- | 451 | dlg.Destroy() |
|
443 | 452 | ||
Line 444... | Line 453... | ||
444 | # end of class MainFrame |
453 | # end of class MainFrame |
445 | 454 | ||
446 | class Setting: |
455 | class Setting: |
Line 452... | Line 461... | ||
452 | if isinstance(self.value, int): |
461 | if isinstance(self.value, int): |
453 | self.value = int(newValue) |
462 | self.value = int(newValue) |
454 | else: |
463 | else: |
455 | self.value = str(newValue) |
464 | self.value = str(newValue) |
Line -... | Line 465... | ||
- | 465 | ||
- | 466 | ||
- | 467 | class MeasureThread: |
|
- | 468 | def __init__(self, evtConsumer): |
|
- | 469 | self.evtConsumer = evtConsumer |
|
- | 470 | ||
- | 471 | def start(self): |
|
- | 472 | thread.start_new_thread(self._run, ()) |
|
- | 473 | ||
- | 474 | def _run(self): |
|
- | 475 | i=0 |
|
- | 476 | for i in range(20): |
|
- | 477 | time.sleep(0.5) |
|
- | 478 | evt = MeasStatusUpdateEvent(running=True, msg="Hello %d" % i) |
|
- | 479 | wx.PostEvent(self.evtConsumer, evt) |
|
- | 480 | evt = MeasStatusUpdateEvent(running=False, msg="Done") |
|
- | 481 | wx.PostEvent(self.evtConsumer, evt) |
|
- | 482 | ||
- | 483 | ||
456 | 484 | ||
457 | class VibTest: |
485 | class VibTest: |
458 | def __init__(self, descr, motor, speed, channel, rawData): |
486 | def __init__(self, descr, motor, speed, channel, rawData): |
459 | self.descr = descr |
487 | self.descr = descr |
460 | self.motor = motor |
488 | self.motor = motor |
Line 607... | Line 635... | ||
607 | for c in range(nbCols): |
635 | for c in range(nbCols): |
608 | if (len(data[c]) % 2) != 0: |
636 | if (len(data[c]) % 2) != 0: |
609 | data[c].append(data[c][-1]) |
637 | data[c].append(data[c][-1]) |
610 | self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c]) |
638 | self.AddTest(descr[c], 0, int(speed[c]), channel[c], data[c]) |
Line -... | Line 639... | ||
- | 639 | ||
- | 640 | def startMeasure(self, dialog): |
|
- | 641 | print "Start measuring" |
|
- | 642 | ||
- | 643 | self.measureThread = MeasureThread(dialog) |
|
- | 644 | self.measureThread.start() |
|
- | 645 | ||
- | 646 | ||
- | 647 | ||
Line 611... | Line 648... | ||
611 | 648 |