22,6 → 22,8 |
FS = 11111 |
pi = 3.14 |
|
rootPath = "" |
|
# Needs Numeric or numarray or NumPy |
try: |
import numpy.oldnumeric as _Numeric |
51,12 → 53,13 |
class MeasureDialog(wx.Dialog): |
def __init__(self, *args, **kwds): |
# begin wxGlade: MeasureDialog.__init__ |
kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME |
kwds["style"] = wx.CAPTION|wx.RESIZE_BORDER|wx.THICK_FRAME |
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() |
|
63,10 → 66,11 |
self.Bind(wx.EVT_BUTTON, self.onButton, self.button) |
# end wxGlade |
|
self.button.SetFocus() |
|
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) |
77,7 → 81,7 |
self.voltageCtrl.SetTicksColour(wx.WHITE) |
self.voltageCtrl.SetHandColour(YELLOW) |
|
icon = wx.Icon("fuel.ico", wx.BITMAP_TYPE_ICO) |
icon = wx.Icon("%s/Resources/fuel.ico" % rootPath, wx.BITMAP_TYPE_ICO) |
icon.SetWidth(24) |
icon.SetHeight(24) |
|
88,7 → 92,6 |
|
|
# 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) |
290,8 → 293,11 |
wxglade_tmp_menu.Append(304, "Save", "", wx.ITEM_NORMAL) |
self.frame_1_menubar.Append(wxglade_tmp_menu, "TestSet") |
wxglade_tmp_menu = wx.Menu() |
wxglade_tmp_menu.Append(401, "Flash VibTest FC software", "", wx.ITEM_NORMAL) |
wxglade_tmp_menu.Append(402, "Restore original FC software", "", wx.ITEM_NORMAL) |
self.frame_1_menubar.Append(wxglade_tmp_menu, "MK") |
wxglade_tmp_menu = wx.Menu() |
wxglade_tmp_menu.Append(1099, "About", "", wx.ITEM_NORMAL) |
self.frame_1_menubar.Append(wxglade_tmp_menu, "Help") |
self.SetMenuBar(self.frame_1_menubar) |
# Menu Bar end |
302,13 → 308,13 |
self.label_35 = wx.StaticText(self, -1, "Motor(s)") |
self.tcMotors = wx.TextCtrl(self, -1, "1") |
self.label_38 = wx.StaticText(self, -1, "") |
self.text_ctrl_10 = wx.TextCtrl(self, -1, "") |
self.panel_2 = wx.Panel(self, -1) |
self.label_36 = wx.StaticText(self, -1, "Channel(s)") |
self.tcChannels = wx.TextCtrl(self, -1, "6") |
self.label_39 = wx.StaticText(self, -1, "") |
self.text_ctrl_11 = wx.TextCtrl(self, -1, "") |
self.button_4 = wx.Button(self, -1, "Start") |
self.GraphPanel = wx.Panel(self, -1) |
self.panel_3 = wx.Panel(self, -1) |
self.button_4 = wx.Button(self, -1, "Measure") |
self.graphCtrl = wx.lib.plot.PlotCanvas(self, size=(800,300)) |
self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
319,14 → 325,18 |
self.__do_layout() |
|
self.Bind(wx.EVT_MENU, self.OnSettings, id=101) |
self.Bind(wx.EVT_MENU, self.onExit, id=150) |
self.Bind(wx.EVT_MENU, self.onClear, id=301) |
self.Bind(wx.EVT_MENU, self.onClearSelected, id=302) |
self.Bind(wx.EVT_MENU, self.OnImport, id=303) |
self.Bind(wx.EVT_MENU, self.onExport, id=304) |
self.Bind(wx.EVT_MENU, self.onAbout, id=1099) |
self.Bind(wx.EVT_BUTTON, self.onStartMeasure, self.button_4) |
self.Bind(wx.EVT_CHOICE, self.onGraphTypeChange, self.graphTypeChoice) |
self.Bind(wx.EVT_CHOICE, self.onYAxisChange, self.yAxisChoice) |
# end wxGlade |
favicon = wx.Icon('%s/Resources/60px-Procman.ico' % rootPath, wx.BITMAP_TYPE_ICO, 32, 32) |
wx.Frame.SetIcon(self, favicon) |
|
def setApp(self, app): |
self.app = app |
337,7 → 347,7 |
self.SetSize((850, 700)) |
self.Description.SetMinSize((53, 13)) |
self.button_4.SetMinSize((80, 80)) |
self.GraphPanel.SetMinSize((800,300)) |
self.graphCtrl.SetMinSize((800,300)) |
self.graphTypeChoice.SetSelection(0) |
self.yAxisChoice.SetSelection(1) |
self.TestListCtrl.SetMinSize((800,300)) |
361,11 → 371,11 |
grid_sizer_1.Add(self.label_35, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
grid_sizer_1.Add(self.tcMotors, 0, 0, 0) |
grid_sizer_1.Add(self.label_38, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
grid_sizer_1.Add(self.text_ctrl_10, 0, 0, 0) |
grid_sizer_1.Add(self.panel_2, 1, wx.EXPAND, 0) |
grid_sizer_1.Add(self.label_36, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
grid_sizer_1.Add(self.tcChannels, 0, 0, 0) |
grid_sizer_1.Add(self.label_39, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) |
grid_sizer_1.Add(self.text_ctrl_11, 0, 0, 0) |
grid_sizer_1.Add(self.panel_3, 1, wx.EXPAND, 0) |
sizer_9.Add(grid_sizer_1, 0, 0, 0) |
sizer_10.Add((50, 20), 0, 0, 0) |
sizer_10.Add(self.button_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
372,7 → 382,7 |
sizer_9.Add(sizer_10, 1, wx.EXPAND, 0) |
sizer_8.Add(sizer_9, 0, 0, 0) |
sizer_8.Add((20, 30), 0, 0, 0) |
sizer_11.Add(self.GraphPanel, 1, wx.EXPAND, 0) |
sizer_11.Add(self.graphCtrl, 1, wx.EXPAND, 0) |
sizer_11.Add((20, 5), 0, 0, 0) |
sizer_12.Add(self.label_40, 0, wx.ALIGN_CENTER_VERTICAL, 0) |
sizer_12.Add(self.graphTypeChoice, 0, 0, 0) |
394,14 → 404,14 |
self.TestListCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnTestSelected, self.TestListCtrl) |
|
# Configure Graph |
self.client = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300)) |
#self.graphCtrl = wx.lib.plot.PlotCanvas(self.GraphPanel, size=(800,300)) |
|
self.client.SetPointLabelFunc(self.DrawPointLabel) |
self.graphCtrl.SetPointLabelFunc(self.DrawPointLabel) |
|
self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
self.client.SetFontSizeAxis(10) |
self.client.SetFontSizeLegend(7) |
self.client.setLogScale((False,False)) |
self.graphCtrl.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) |
self.graphCtrl.SetFontSizeAxis(10) |
self.graphCtrl.SetFontSizeLegend(7) |
self.graphCtrl.setLogScale((False,False)) |
|
|
# Configure TestListCtrl |
462,7 → 472,7 |
nbSelected = self.TestListCtrl.SelectedItemCount |
|
if nbSelected == 0: |
self.client.Clear() |
self.graphCtrl.Clear() |
|
elif nbSelected > 1: |
self.graphTypeChoice.Disable() |
476,8 → 486,8 |
line = wx.lib.plot.PolyLine(data, legend= 'Vibrations', colour='red', width=2) |
markers = wx.lib.plot.PolyMarker(data, legend= '', colour='red', marker='circle',size=2) |
title = "Comparing tests" |
self.client.Draw(wx.lib.plot.PlotGraphics([line, markers], title, "Test", "Vibration Value"), xAxis=(1,max(x,10)), yAxis=(0,y)) |
self.client.SetEnableGrid('Horizontal') |
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line, markers], title, "Test", "Vibration Value"), xAxis=(1,max(x,10)), yAxis=(0,y)) |
self.graphCtrl.SetEnableGrid('Horizontal') |
|
else: |
self.graphTypeChoice.Enable() |
491,8 → 501,8 |
line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
|
title = "Raw Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
self.client.SetEnableGrid('Horizontal') |
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
self.graphCtrl.SetEnableGrid('Horizontal') |
|
if self.graphTypeChoice.GetSelection() == 1: |
xydata = _Numeric.linspace(0,0.09*nb,2*nb) |
501,8 → 511,8 |
line = wx.lib.plot.PolyLine(xydata, legend= 'Raw Data', colour='red', width=2) |
|
title = "Filtered Signal: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
self.client.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
self.client.SetEnableGrid('Horizontal') |
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line], title, "Time (ms)", "Acc"), yAxis= (-y,y)) |
self.graphCtrl.SetEnableGrid('Horizontal') |
|
elif self.graphTypeChoice.GetSelection() == 2: |
xydata = _Numeric.linspace(0,FS/2,nb) |
519,8 → 529,8 |
filterLine2 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4) |
|
title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
self.client.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y)) |
self.client.SetEnableGrid(True) |
self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(0,200), yAxis= (-0,y)) |
self.graphCtrl.SetEnableGrid(True) |
|
|
def OnImport(self, event): # wxGlade: MainFrame.<event_handler> |
616,6 → 626,35 |
self._removeTest(idx) |
|
|
def onCopyData(self, event): # wxGlade: MainFrame.<event_handler> |
clipdata = wx.TextDataObject() |
txt = "" |
idx = self.TestListCtrl.GetFirstSelected() |
while idx != -1: |
txt += ("%d\n" % self.app.getTest(idx).getVibValue(self.app.settings["hpf"].value, self.app.settings["lpf"].value)) |
idx = self.TestListCtrl.GetNextSelected(idx) |
clipdata.SetText(txt) |
wx.TheClipboard.Open() |
wx.TheClipboard.SetData(clipdata) |
wx.TheClipboard.Close() |
|
def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
# First we create and fill the info object |
print "about" |
info = wx.AboutDialogInfo() |
info.Name = "MK Vibration Test" |
info.Version = "0.2" |
info.Copyright = "" |
info.Developers=["Frederic Goddeeris"] |
info.Description = "Please consult the WIKI page for a complete description of the tool:" |
info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
wx.AboutBox(info) |
|
|
def onExit(self, event): # wxGlade: MainFrame.<event_handler> |
self.Close(True) |
|
|
# end of class MainFrame |
|
class Setting: |
961,5 → 1000,10 |
# end of class App |
|
if __name__ == "__main__": |
|
rootPath = os.path.abspath(os.path.dirname(sys.argv[0])) |
|
print rootPath |
|
VibrationTestGui = App(0) |
VibrationTestGui.MainLoop() |