--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpib_plotter_mockup.py Fri Jan 25 20:25:39 2008 +0100 @@ -0,0 +1,35 @@ +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 + +