Blame view

instruments/testDevice.py 1.09 KB
d80362499   bmarechal   add test device
1
2
3
4
5
6
7
  from abstract_instrument import abstract_instrument
  import numpy, time
  
  #==============================================================================
  
  ALL_VAL_TYPE = ['vtype', 'DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ']
  ALL_CHANNELS = ['0', '1']
9058343c5   bmarechal   some minor fixes
8
  ADDRESS = "123.456.789.123"
d80362499   bmarechal   add test device
9
10
11
12
  
  #==============================================================================
  
  class testDevice(abstract_instrument):
348049517   bmarechal   replace 4 spaces ...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  	def __init__(self, channels,  vtype, address):
  		self.address = address
  		self.port = 9999
  		self.channels = channels
  		self.vtype = vtype
  
  	def model(self):
  		return 'test_device'
  
  	def connect(self):
  		print('Connecting to device @%s:%s...' %(self.address, self.port))
  		time.sleep(1)
  		print('  --> Ok')
  		self.configure()
  
  		print(self.model())
  
  	def getValue(self):
  		mes = ""
  		for ch in self.channels:
  			mes = mes + str(numpy.random.rand()) + '\t'
  		return mes + '
  '
  
  	def read(self):
  		print('reading')
  		return 1
  
  	def disconnect(self):
  		print('disconnect')
  
  	def send(self, command):
  		print('send %s'%command)
  
  	def configure(self):
  		print(self.channels)
  		print(self.vtype)
  		print('configured')