Blame view

instruments/LS350.py 2.1 KB
cb568e88d   bmarechal   Add Lakeshore LS3...
1
2
3
4
5
6
7
  from abstract_instrument import abstract_instrument
  import socket
  
  #==============================================================================
  
  ALL_VAL_TYPE = ['TEMP', 'RES']
  ALL_CHANNELS = ['a', 'b', 'c', 'd']
9058343c5   bmarechal   some minor fixes
8
  ADDRESS = "192.168.0.12"
cb568e88d   bmarechal   Add Lakeshore LS3...
9
10
11
12
13
  CONF_VAL_TYPE = ['krdg?', 'srdg?']
  
  #==============================================================================
  
  class LS350(abstract_instrument):
9058343c5   bmarechal   some minor fixes
14
15
      def __init__(self, channels, vtypes, address):
          self.address = address
cb568e88d   bmarechal   Add Lakeshore LS3...
16
          self.port = 7777
05ab07cc3   bmarechal   -
17
          self.channels = channels
cb568e88d   bmarechal   Add Lakeshore LS3...
18
19
20
21
22
          self.vtypes = vtypes
  
      def model(self):
          #self.send("*IDN?")
          #return self.read()
05ab07cc3   bmarechal   -
23
          return "LS350"
cb568e88d   bmarechal   Add Lakeshore LS3...
24
25
  
      def connect(self):
9058343c5   bmarechal   some minor fixes
26
          print('Connecting to device @%s:%s...' %(self.address, self.port))
cb568e88d   bmarechal   Add Lakeshore LS3...
27
28
29
30
          self.sock = socket.socket(socket.AF_INET,
                               socket.SOCK_STREAM,
                               socket.IPPROTO_TCP)
          self.sock.settimeout(10.0)    # Don't hang around forever
9058343c5   bmarechal   some minor fixes
31
          self.sock.connect((self.address, self.port))
cb568e88d   bmarechal   Add Lakeshore LS3...
32
33
          print('  --> Ok')
          print(self.model())
05ab07cc3   bmarechal   -
34
          self.configure()
cb568e88d   bmarechal   Add Lakeshore LS3...
35
36
  
      def configure(self):
05ab07cc3   bmarechal   -
37
38
39
40
41
          self.strCh = ''
          for ch in self.channels:
              self.strCh = self.strCh + '%s %s;'%(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])], ch)
          self.strCh = self.strCh[0:-1]
          print(self.strCh)
cb568e88d   bmarechal   Add Lakeshore LS3...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  
      def getValue(self):
          self.send(self.strCh)
          return self.read()
  
      def read(self):
          self.send("++read eoi")
          ans = ''
          nb_data_list = []
          nb_data = ''
          try:
              while ans != '
  ':
                  ans = self.sock.recv(1)
                  nb_data_list.append(ans) # Return the number of data
              list_size = len(nb_data_list)
              for j in range (0, list_size):
                  nb_data = nb_data+nb_data_list[j]
              return nb_data
          except socket.timeout:
              print "Socket timeout error when reading."
              raise
  
      def disconnect(self):
          self.send('MODE0')
          self.sock.close()
  
      def send(self, command):
          self.sock.send("%s
  "%command)