forked from jithinbp/Python-gpib-PCAR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi.py
58 lines (46 loc) · 1.22 KB
/
multi.py
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
49
50
51
52
53
54
55
56
57
#Commands for dealing with the KEITHLEY 6221,2182a
import Gpib, time, socket, threading
import os,string
import numpy as np
from console_out import *
class MULTI:
def __init__(self):
self.host = 'multi' #GPIB mnemonic for Lakeshore temp controller
self.timeout = 30
self.status=''
self.identity=''
self.connected=False
self.input_num = 'A'
self.curve_num = 21
self.selected_curve = ''
self.style='\033[7;95m'
self.val=''
self.text=Text()
self.communicationLock = threading.Lock()
def connect(self):
try:
self.device = Gpib.Gpib(self.host)
self.identity = self.go('*IDN?')
self.text.show(self.identity,'message')
self.status = 'connected'
self.connected = True
except socket.timeout:
self.status = "socket timeout"
self.identity = 'none'
self.connected = False
return self.identity
def go(self,command):
self.communicationLock.acquire()
try:
self.device.write(command)
received = self.device.read(100)#.split('\r\n')[0]
except:
received='0'
self.communicationLock.release()
return received.strip()
def clear(self):
self.go('*CLS')
def get_val(self):
#print self.input_num,len(self.input_num)
self.val = self.go(':DATA?')
return self.val