-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathlakeshore218.py
85 lines (69 loc) · 2.29 KB
/
lakeshore218.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright (C) 2007 Matthew Neeley
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
### BEGIN NODE INFO
[info]
name = Lakeshore Diodes
version = 2.2
description =
[startup]
cmdline = %PYTHON% %FILE%
timeout = 20
[shutdown]
message = 987654321
timeout = 20
### END NODE INFO
"""
from labrad.units import K, V
from labrad.server import setting
from labrad.gpib import GPIBManagedServer, GPIBDeviceWrapper
from twisted.internet.defer import returnValue
def parse(val):
"""
Parse function to account for the occasional GPIB glitches where we get extra characters in front of the numbers.
"""
if len(val):
try:
return float(val)
except ValueError:
return parse(val[1:])
else:
return 0.0
class LakeshoreDiodeServer(GPIBManagedServer):
name = 'Lakeshore Diodes'
deviceName = 'LSCI MODEL218S'
deviceWrapper = GPIBDeviceWrapper
@setting(10, 'Temperatures', returns=['*v[K]'])
def temperatures(self, c):
"""Read channel temperatures.
Returns a ValueList of the channel temperatures in Kelvin.
"""
dev = self.selectedDevice(c)
resp = yield dev.query('KRDG? 0')
vals = [parse(val) * K for val in resp.split(',')]
returnValue(vals)
@setting(11, 'Voltages', returns=['*v[V]'])
def voltages(self, c):
"""Read channel voltages.
Returns a ValueList of the channel voltages in Volts.
"""
dev = self.selectedDevice(c)
resp = yield dev.query('SRDG? 0')
vals = [parse(val) * V for val in resp.split(',')]
returnValue(vals)
__server__ = LakeshoreDiodeServer()
if __name__ == '__main__':
from labrad import util
util.runServer(__server__)