Blame view

instruments/PM100D.py 1.18 KB
90e45ebe9   mer0m   Add files via upload
1
2
3
4
5
6
7
8
9
10
11
12
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
  from abstract_instrument import abstract_instrument
  import os
  
  #==============================================================================
  
  ALL_VAL_TYPE = "PWR"
  
  #==============================================================================
  
  class PM100D(abstract_instrument):
      def __init__(self, adress="/dev/usbtmc0", vtype="PWR"):
          self.adress = adress
          self.vtype = vtype
  
      def model(self):
          self.send("*IDN?")
          return self.read()
  
      def connect(self):
          try:
              print('Connecting to device @%s...' %(self.adress))
              self.FILE = os.open(self.adress, os.O_RDWR)
              print('  --> Ok')
  
              print(self.model())
  
              if self.vtype == "PWR":
                  1
              else:
                  print("Wrong -v argument")
                  raise
  
          except Exception as er:
              print("Unexpected error during connection: " + str(er))
              raise
  
      def getValue(self):
          self.send("READ?")
          return self.read()
  
      def read(self):
          return os.read(self.FILE, 300)
  
      def disconnect(self):
          self.send('*RST')
  
      def send(self, command):
          os.write(self.FILE, command)