Commit e5a64c5124221a98ad8022e613252f330e643ba6

Authored by bmarechal
1 parent 10d2e8222f
Exists in master

FPC1000: measure MKR_PWR instead PK_SRC_PWR

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

instruments/FPC1000.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 = ['PWR_MKR1'] 6 6 ALL_VAL_TYPE = ['PWR_MKR']
ALL_CHANNELS = ['1'] 7 7 ALL_CHANNELS = ['1', '2', '3', '4']
8 8
ADDRESS = "192.168.0.17" 9 9 ADDRESS = "192.168.0.17"
CONF_VAL_TYPE = ['CALC:MARK1:MAX:PEAK'] 10 10 CONF_VAL_TYPE = ['CALC:MARK1:Y?', 'CALC:MARK2:Y?', 'CALC:MARK3:Y?', 'CALC:MARK4:Y?']
11 11
#============================================================================== 12 12 #==============================================================================
13 13
class FPC1000(abstract_instrument): 14 14 class FPC1000(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 = 5555 17 17 self.port = 5555
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 "FPC1000" 24 24 return "FPC1000"
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(10.0) # Don't hang around forever 31 31 self.sock.settimeout(10.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):
for ch in self.channels: 39 39 #for ch in self.channels:
self.send(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])]) 40 40 # self.send(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])])
41 pass
41 42
def getValue(self): 42 43 def getValue(self):
mes = '' 43 44 mes = ''
for ch in self.channels: 44 45 for ch in self.channels:
self.send('CALC:MARK1:MAX:PEAK') 45 46 #self.send('CALC:MARK1:MAX:PEAK')
self.send("CALC:MARK1:Y?") 46 47 self.send(CONF_VAL_TYPE[int(ch)-1])
mesTemp = self.read() 47 48 mesTemp = self.read()
mes = mes + '\t' + mesTemp 48 49 mes = mes + '\t' + mesTemp.replace('\n', '')
return mes 49 50 return mes
50 51
def read(self): 51 52 def read(self):
ans = '' 52 53 ans = ''
nb_data_list = [] 53 54 nb_data_list = []
nb_data = '' 54 55 nb_data = ''
try: 55 56 try:
while ans != '\n': 56 57 while ans != '\n':
ans = self.sock.recv(1) 57 58 ans = self.sock.recv(1)
nb_data_list.append(ans) # Return the number of data 58 59 nb_data_list.append(ans) # Return the number of data
list_size = len(nb_data_list) 59 60 list_size = len(nb_data_list)
for j in range (0, list_size): 60 61 for j in range (0, list_size):
nb_data = nb_data+nb_data_list[j] 61 62 nb_data = nb_data+nb_data_list[j]
return nb_data 62 63 return nb_data
except socket.timeout: 63 64 except socket.timeout:
print "Socket timeout error when reading." 64 65 print "Socket timeout error when reading."
raise 65 66 raise
66 67
def disconnect(self): 67 68 def disconnect(self):
#self.send('*RST') 68 69 #self.send('*RST')
#self.send("SYST:BEEP") 69 70 #self.send("SYST:BEEP")