gpib_plotter_mockup.py

changeset 32
59da528bc470
parent 31
c869766e25ff
child 33
61809bb871bf
equal deleted inserted replaced
31:c869766e25ff 32:59da528bc470
1 import glob
2 import os
3 import time
4 import random
5
6 class GPIBplotter:#(GPIB):
7 """
8 A mockup thet will find in a directory some HPGL files and feed them randomly
9 """
10 def __init__(self, device="/dev/ttyUSB0", baudrate=115200, timeout=0.1,
11 address=5):
12 self._timeout = timeout
13 self.filenames = glob.glob('examples/*.plt')
14 self._next = random.randint(10,50)
15 self._num = 0
16
17 def plotStarted(self):
18 pass
19
20 def load_plot(self, wait_timeout=0):
21 if wait_timeout:
22 time.sleep(wait_timeout)
23 self._num += 1
24 if self._num > self._next:
25 ret = open(random.choice(self.filenames)).read()
26 if len(ret)>0:
27 self.plotStarted()
28 self._num = 0
29 self._next = random.randint(10,100)
30 time.sleep(random.randint(1,3))
31 return ret
32 return None
33 return None
34
35

mercurial