Anzeigeprogramm für PeakTech 4370 und andere
wxPython und pySerial erforderlich, Details siehe weiter unten
dvm.py — text/python-source, 2 kB (2475 bytes)
Dateiinhalt
# -*- coding: latin-1 -*-
#Boa:Frame:DVM
# $Id$ 2004/04/25 W. Strobl
"""Q&D DVM f�r PeakTech 4370
Ben�tigt Python24+ (www.python.org), wxPython 2.6+ (www.wxpython.org)
und pySerial (pyserial.sourceforge.net)
"""
PORT=0 # 0 == COM1 usw.
import serial
import wx
def create(parent):
return DVM(parent)
[wxID_DVM, wxID_DVMPANEL1, wxID_DVMSTATICTEXT1,
] = [wx.NewId() for _init_ctrls in range(3)]
[wxID_DVMTIMER1] = [wx.NewId() for _init_utils in range(1)]
class DVM(wx.Frame):
def _init_utils(self):
# generated method, don't edit
self.timer1 = wx.Timer(id=wxID_DVMTIMER1, owner=self)
self.Bind(wx.EVT_TIMER, self.OnTimer1Timer, id=wxID_DVMTIMER1)
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_DVM, name='DVM', parent=prnt,
pos=wx.Point(30, 90), size=wx.Size(776, 152),
style=wx.DEFAULT_FRAME_STYLE, title='DVM f�r PeakTech 4370')
self._init_utils()
self.SetClientSize(wx.Size(768, 118))
self.Bind(wx.EVT_CLOSE, self.OnDVMClose)
self.panel1 = wx.Panel(id=wxID_DVMPANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(768, 118),
style=wx.TAB_TRAVERSAL)
self.staticText1 = wx.StaticText(id=wxID_DVMSTATICTEXT1,
label='PeakTech 4370', name='staticText1', parent=self.panel1,
pos=wx.Point(8, 8), size=wx.Size(754, 103), style=0)
self.staticText1.SetFont(wx.Font(72, wx.SWISS, wx.NORMAL, wx.NORMAL,
False, 'Courier New'))
def __init__(self, parent):
self._init_ctrls(parent)
try:
ser=serial.Serial(port=PORT,baudrate=1200,bytesize=serial.SEVENBITS,
stopbits=serial.STOPBITS_TWO,timeout=3)
except serial.SerialException:
print "Port %d nicht verf�gbar"%(PORT,)
self.ser=None
return
self.ser=ser
ser.setDTR(1)
ser.setRTS(0)
ser.write("D\r")
line=ser.read(14)
# wegwerfen
self.timer1.Start(100)
def OnTimer1Timer(self, event):
self.ser.setRTS(0)
self.ser.write("D\r")
line=self.ser.read(14)
self.staticText1.SetLabel(line[1:])
def OnDVMClose(self, event):
self.timer1.Stop()
self.Destroy()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()
app.MainLoop()
