Mon, 04 Feb 2008 19:49:48 +0100
refactoring in progress
import glob import os import time import random class GPIBplotter:#(GPIB): """ A mockup thet will find in a directory some HPGL files and feed them randomly """ def __init__(self, device="/dev/ttyUSB0", baudrate=115200, timeout=0.1, address=5): self._timeout = timeout self.filenames = glob.glob('examples/*.plt') self._next = random.randint(10,50) self._num = 0 def plotStarted(self): pass def load_plot(self, wait_timeout=0): if wait_timeout: time.sleep(wait_timeout) self._num += 1 if self._num > self._next: ret = open(random.choice(self.filenames)).read() if len(ret)>0: self.plotStarted() self._num = 0 self._next = random.randint(10,100) time.sleep(random.randint(1,3)) return ret return None return None