Blame view

instruments/PM100D.py 1015 Bytes
6cdd466f1   bma   Add files via upload
1
2
3
4
5
6
7
8
9
10
  from abstract_instrument import abstract_instrument
  import os
  
  #==============================================================================
  
  ALL_VAL_TYPE = "PWR"
  
  #==============================================================================
  
  class PM100D(abstract_instrument):
10016888c   bmarechal   replace 4 spaces ...
11
12
13
  	def __init__(self, adress="/dev/usbtmc0", vtype="PWR"):
  		self.adress = adress
  		self.vtype = vtype
6cdd466f1   bma   Add files via upload
14

10016888c   bmarechal   replace 4 spaces ...
15
16
17
  	def model(self):
  		self.send("*IDN?")
  		return self.read()
6cdd466f1   bma   Add files via upload
18

10016888c   bmarechal   replace 4 spaces ...
19
20
21
22
23
  	def connect(self):
  		try:
  			print('Connecting to device @%s...' %(self.adress))
  			self.FILE = os.open(self.adress, os.O_RDWR)
  			print('  --> Ok')
6cdd466f1   bma   Add files via upload
24

10016888c   bmarechal   replace 4 spaces ...
25
  			print(self.model())
6cdd466f1   bma   Add files via upload
26

10016888c   bmarechal   replace 4 spaces ...
27
28
29
30
31
  			if self.vtype == "PWR":
  				1
  			else:
  				print("Wrong -v argument")
  				raise
6cdd466f1   bma   Add files via upload
32

10016888c   bmarechal   replace 4 spaces ...
33
34
35
  		except Exception as er:
  			print("Unexpected error during connection: " + str(er))
  			raise
6cdd466f1   bma   Add files via upload
36

10016888c   bmarechal   replace 4 spaces ...
37
38
39
  	def getValue(self):
  		self.send("READ?")
  		return self.read()
6cdd466f1   bma   Add files via upload
40

10016888c   bmarechal   replace 4 spaces ...
41
42
  	def read(self):
  		return os.read(self.FILE, 300)
6cdd466f1   bma   Add files via upload
43

10016888c   bmarechal   replace 4 spaces ...
44
45
  	def disconnect(self):
  		self.send('*RST')
6cdd466f1   bma   Add files via upload
46

10016888c   bmarechal   replace 4 spaces ...
47
48
  	def send(self, command):
  		os.write(self.FILE, command)