Subversion Repositories Projects

Compare Revisions

Regard whitespace Rev 622 → Rev 623

/VibrationTest/trunk/VibrationTest/VibrationTestGui.py
12,6 → 12,7
import wx.lib
import wx.lib.plot
import wx.lib.newevent
import wx.lib.agw.speedmeter as speedmeter
 
import mkProto
 
19,6 → 20,7
 
CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"]
FS = 11111
pi = 3.14
 
# Needs Numeric or numarray or NumPy
try:
53,7 → 55,8
wx.Dialog.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.button = wx.Button(self, -1, "STOP")
 
self.voltageCtrl = speedmeter.SpeedMeter(self, extrastyle=speedmeter.SM_DRAW_HAND | speedmeter.SM_DRAW_PARTIAL_SECTORS | speedmeter.SM_DRAW_MIDDLE_ICON )
self.speedCtrl = speedmeter.SpeedMeter(self, extrastyle=speedmeter.SM_DRAW_HAND | speedmeter.SM_DRAW_PARTIAL_SECTORS | speedmeter.SM_DRAW_MIDDLE_TEXT | speedmeter.SM_DRAW_SECONDARY_TICKS)
self.__set_properties()
self.__do_layout()
 
60,6 → 63,54
self.Bind(wx.EVT_BUTTON, self.onButton, self.button)
# end wxGlade
YELLOW = wx.Colour(255, 240, 0)
BG = wx.Colour(0x80, 0x80, 0x80)
# Configure Voltage Ctrl
#self.voltageCtrl.SetAngleRange(-3.14/3, 3.14/3)
self.voltageCtrl.SetAngleRange(0,pi)
intervals = range(0, 5)
self.voltageCtrl.SetIntervals(intervals)
colours = [wx.RED, wx.GREEN, wx.GREEN, YELLOW]
self.voltageCtrl.SetIntervalColours(colours)
ticks = ["", "", "", "", ""]
self.voltageCtrl.SetTicks(ticks)
self.voltageCtrl.SetTicksColour(wx.WHITE)
self.voltageCtrl.SetHandColour(YELLOW)
 
icon = wx.Icon("fuel.ico", wx.BITMAP_TYPE_ICO)
icon.SetWidth(24)
icon.SetHeight(24)
 
self.voltageCtrl.SetMiddleIcon(icon)
self.voltageCtrl.SetSpeedBackground(BG)
self.voltageCtrl.SetArcColour(wx.WHITE)
self.voltageCtrl.SetSpeedValue(2)
 
 
# Configure Speed Ctr;
#self.speedCtrl.SetAngleRange(-pi/6, 7*pi/6)
self.speedCtrl.SetAngleRange(0,pi)
intervals = range(0, 261, 20)
self.speedCtrl.SetIntervals(intervals)
 
colours = [BG]*(len(intervals)-1)
for i in range(5,10):
colours[i] = wx.GREEN
self.speedCtrl.SetIntervalColours(colours)
ticks = [str(interval) for interval in intervals]
self.speedCtrl.SetTicks(ticks)
self.speedCtrl.SetTicksColour(wx.WHITE)
self.speedCtrl.SetNumberOfSecondaryTicks(1)
self.speedCtrl.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))
self.speedCtrl.SetMiddleText("Speed")
self.speedCtrl.SetMiddleTextColour(wx.WHITE)
self.speedCtrl.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))
self.speedCtrl.SetHandColour(YELLOW)
self.speedCtrl.SetSpeedBackground(BG)
self.speedCtrl.SetArcColour(wx.WHITE)
self.speedCtrl.SetSpeedValue(0)
 
self.running = True
self.Bind(EVT_MEAS_STATUS_UPDATE, self.OnUpdate)
self.Bind(EVT_MEAS_DATA, self.OnData)
66,16 → 117,21
# The first argument that is passed to the constructor is the parent
self.app = args[0].app
self.error = False
self.firstVoltage = True
 
 
def __set_properties(self):
# begin wxGlade: MeasureDialog.__set_properties
self.SetTitle("Measuring Status")
self.text_ctrl_1.SetMinSize((400,300))
self.voltageCtrl.SetMinSize((50,-1))
self.speedCtrl.SetMinSize((50,-1))
# end wxGlade
 
def __do_layout(self):
# begin wxGlade: MeasureDialog.__do_layout
sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add((20, 20), 0, 0, 0)
sizer_2.Add((20, 20), 0, 0, 0)
85,6 → 141,10
sizer_2.Add((20, 20), 0, 0, 0)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
sizer_1.Add((20, 20), 0, 0, 0)
sizer_4.Add(self.voltageCtrl, 1, wx.EXPAND, 0)
sizer_4.Add(self.speedCtrl, 1, wx.EXPAND, 0)
sizer_1.Add(sizer_4, 1, wx.EXPAND, 0)
sizer_1.Add((20, 20), 0, 0, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
108,7 → 168,23
self.text_ctrl_1.write(" ") # so that the background is redrawn
self.button.SetLabel("Close")
if evt.speed != None:
self.speedCtrl.SetSpeedValue(evt.speed)
if evt.voltage != None:
vmin,vmax,v = evt.voltage
if self.firstVoltage:
ticks = ["", "%.1f V"%vmin, "", "%.1f V"%vmax, ""]
self.voltageCtrl.SetTicks(ticks)
self.firstVoltage = False
i = (v-vmin)/(vmax-vmin) # 0..1
i *= 2
i = i+1
i = min(max(i,0),5)
self.voltageCtrl.SetSpeedValue(i)
def onButton(self, event): # wxGlade: MeasureDialog.<event_handler>
if (not self.running):
self.Destroy()
574,8 → 650,8
if self.cancel:
raise Exception("Operation cancelled")
def _sendEvent(self, msg, error=False):
evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error)
def _sendEvent(self, msg=None, error=False, parVoltage=None, speed=None):
evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error, voltage=parVoltage, speed=speed)
wx.PostEvent(self.evtConsumer, evt)
 
def _setMotorSpeed(self, speed, settlingTime):
604,20 → 680,23
voltage = msg.getVoltage()
if (voltage == 0):
minVoltage = 0
maxVoltage = 1
else:
if (voltage > 4.2*3):
minVoltage = 4*3.5
nbCells = 4
else:
minVoltage = 3*3.5
 
nbCells = 3
minVoltage = nbCells*3.5
maxVoltage = nbCells*3.9
self._sendEvent("Voltage: %2.1fV" % voltage)
self._sendEvent("Minimum Voltage: %2.1fV" % minVoltage)
self._sendEvent("Min/Max Voltage: %2.1fV-%2.1fV" % (minVoltage, maxVoltage), parVoltage=(minVoltage, maxVoltage, voltage))
self._sendEvent("Starting motor(s) (speed=%d)... " % self.param.motorStartupSpeed)
self._sendEvent("Starting motor(s) (speed=%d)... " % self.param.motorStartupSpeed, speed=self.param.motorStartupSpeed)
self._setMotorSpeed(self.param.motorStartupSpeed, self.param.motorStartupSettlingTime)
for speed in self.param.speeds:
self._sendEvent("Changing motor speed to %d... " % speed)
self._sendEvent("Changing motor speed to %d... " % speed, speed=speed)
self._setMotorSpeed(speed, 1)
for channel in self.param.channels:
625,7 → 704,7
msg = self.mk.getDebugMsg()
voltage = msg.getVoltage()
self._sendEvent("Getting data from channel %s" % CHANNEL_NAMES[channel])
self._sendEvent("Getting data from channel %s" % CHANNEL_NAMES[channel], parVoltage=(minVoltage, maxVoltage, voltage))
data = self.mk.doVibrationTest(1000, channel)
vt = VibTest(self.param.descr, voltage, self.param.motors, speed, CHANNEL_NAMES[channel], data)
/VibrationTest/trunk/VibrationTest/VibrationTestGui.wxg
1,5 → 1,5
<?xml version="1.0"?>
<!-- generated by wxGlade 0.6.3 on Sat Oct 03 22:26:38 2009 -->
<!-- generated by wxGlade 0.6.3 on Mon Oct 05 03:20:42 2009 -->
 
<application path="C:\DATA\MK\SVN\Projects\VibrationTest\trunk\VibrationTest\VibrationTestGui.py" name="VibrationTestGui" class="App" option="0" language="python" top_window="frame_1" encoding="ISO-8859-15" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6" is_template="0">
<object class="MainFrame" name="frame_1" base="EditFrame">
516,6 → 516,46
<width>20</width>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="speedmeter.SpeedMeter" name="voltageCtrl" base="CustomWidget">
<arguments>
<argument>$parent</argument>
<argument>extrastyle=speedmeter.SM_DRAW_HAND | speedmeter.SM_DRAW_PARTIAL_SECTORS | speedmeter.SM_DRAW_MIDDLE_ICON </argument>
</arguments>
<size>50,-1</size>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>0</border>
<option>1</option>
<object class="speedmeter.SpeedMeter" name="speedCtrl" base="CustomWidget">
<arguments>
<argument>$parent</argument>
<argument>extrastyle=speedmeter.SM_DRAW_HAND | speedmeter.SM_DRAW_SECTORS | speedmeter.SM_DRAW_MIDDLE_TEXT | speedmeter.SM_DRAW_SECONDARY_TICKS</argument>
</arguments>
<size>50,-1</size>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<border>0</border>
<option>0</option>
<object class="spacer" name="spacer" base="EditSpacer">
<height>20</height>
<width>20</width>
</object>
</object>
</object>
</object>
</application>