Commit 9cd3debc59b2feaeeaeebfa53939bf47f73c97b2

Authored by bmarechal
1 parent c8fbf474b1
Exists in master

add channels

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

instruments/AG34972A.py
from abstract_instrument import abstract_instrument 1 1 from abstract_instrument import abstract_instrument
import socket 2 2 import socket
3 3
#============================================================================== 4 4 #==============================================================================
5 5
ALL_VAL_TYPE = ['DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ'] 6 6 ALL_VAL_TYPE = ['DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ']
ALL_CHANNELS = ['101', '102', '103', '104', '105'] 7 7 ALL_CHANNELS = ['101', '102', '103', '104', '105', '106', '107']
8 8
ADDRESS = "192.168.0.72" 9 9 ADDRESS = "192.168.0.72"
CONF_VAL_TYPE = ['CONF:VOLT:DC', 'CONF:VOLT:AC', 'CONF:CURR:DC', 'CONF:CURR:AC', 'CONF:RES', 'CONF:FRES', 'CONF:FREQ'] 10 10 CONF_VAL_TYPE = ['CONF:VOLT:DC', 'CONF:VOLT:AC', 'CONF:CURR:DC', 'CONF:CURR:AC', 'CONF:RES', 'CONF:FRES', 'CONF:FREQ']
11 11
#============================================================================== 12 12 #==============================================================================
13 13
class AG34972A(abstract_instrument): 14 14 class AG34972A(abstract_instrument):
def __init__(self, channels, vtypes, address): 15 15 def __init__(self, channels, vtypes, address):
self.address = address 16 16 self.address = address
self.port = 5025 17 17 self.port = 5025
self.channels = channels 18 18 self.channels = channels
self.vtypes = vtypes 19 19 self.vtypes = vtypes
20 20
def model(self): 21 21 def model(self):
#self.send("*IDN?") 22 22 #self.send("*IDN?")
#return self.read() 23 23 #return self.read()
return "AG34972A" 24 24 return "AG34972A"
25 25
def connect(self): 26 26 def connect(self):
print('Connecting to device @%s:%s...' %(self.address, self.port)) 27 27 print('Connecting to device @%s:%s...' %(self.address, self.port))
self.sock = socket.socket(socket.AF_INET, 28 28 self.sock = socket.socket(socket.AF_INET,
socket.SOCK_STREAM, 29 29 socket.SOCK_STREAM,
socket.IPPROTO_TCP) 30 30 socket.IPPROTO_TCP)
self.sock.settimeout(2.0) # Don't hang around forever 31 31 self.sock.settimeout(2.0) # Don't hang around forever
self.sock.connect((self.address, self.port)) 32 32 self.sock.connect((self.address, self.port))
self.send("SYST:BEEP") 33 33 self.send("SYST:BEEP")
print(' --> Ok') 34 34 print(' --> Ok')
print(self.model()) 35 35 print(self.model())
self.configure() 36 36 self.configure()
37 37
def configure(self): 38 38 def configure(self):
self.strCh = '' 39 39 self.strCh = ''
for ch in self.channels: 40 40 for ch in self.channels:
self.send('%s (@%s)'%(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])], ch)) 41 41 self.send('%s (@%s)'%(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])], ch))
self.strCh = self.strCh + ch + ',' 42 42 self.strCh = self.strCh + ch + ','
self.strCh = self.strCh[0:-1] 43 43 self.strCh = self.strCh[0:-1]
self.send("ROUT:SCAN (@%s)"%self.strCh) 44 44 self.send("ROUT:SCAN (@%s)"%self.strCh)
self.send("TRIG:COUN 1") 45 45 self.send("TRIG:COUN 1")
46 46
def getValue(self): 47 47 def getValue(self):
self.send("INIT") 48 48 self.send("INIT")
self.send("FETC?") 49 49 self.send("FETC?")
return self.read() 50 50 return self.read()
51 51
def read(self): 52 52 def read(self):
ans = '' 53 53 ans = ''
nb_data_list = [] 54 54 nb_data_list = []
nb_data = '' 55 55 nb_data = ''
try: 56 56 try:
while ans != '\n': 57 57 while ans != '\n':
ans = self.sock.recv(1) 58 58 ans = self.sock.recv(1)
nb_data_list.append(ans) # Return the number of data 59 59 nb_data_list.append(ans) # Return the number of data
list_size = len(nb_data_list) 60 60 list_size = len(nb_data_list)
for j in range (0, list_size): 61 61 for j in range (0, list_size):
nb_data = nb_data+nb_data_list[j] 62 62 nb_data = nb_data+nb_data_list[j]