%matplotlib nbagg
import matplotlib.pyplot as plt
import time
import numpy as np
import qcodes as qc
from qcodes.utils.validators import Enum, Strings
import qcodes.instrument_drivers.tektronix.Keithley_2600_channels as keith
import qcodes.instrument_drivers.agilent.Agilent_34400A as agi
from qcodes.loops import Loop
import time
class Timer(object):
def __init__(self, name=None):
self.name = name
def __enter__(self):
self.tstart = time.time()
def __exit__(self, type, value, traceback):
if self.name:
print('[%s]' % self.name,)
print('Elapsed: %s' % (time.time() - self.tstart))
# create Instruments
k1 = keith.Keithley_2600('Keithley1', 'GPIB0::15::INSTR')
a1 = agi.Agilent_34400A('Agilent1', 'GPIB0::11::INSTR')
a2 = agi.Agilent_34400A('Agilent2', 'GPIB0::6::INSTR')
# set integration time (number of line cycles)
a1.NPLC.set(10)
a2.NPLC.set(10)
station1 = qc.Station(a1,a2)
station1.set_measurement(a1.volt)
station2 = qc.Station(a1,a2)
station2.set_measurement(a1.volt, a2.volt)
# Time single readings
with Timer('Time s1'):
station1.measure()
with Timer('Time s2'):
station2.measure()
[Time s1] Elapsed: 2.0011143684387207
--------------------------------------------------------------------------- Empty Traceback (most recent call last) <ipython-input-5-a118e754f9ee> in <module>() 1 # Time single readings 2 with Timer('Time s1'): ----> 3 station1.measure() 4 with Timer('Time s2'): 5 station2.measure() E:\Git\Qcodes\qcodes\station.py in measure(self, *actions) 105 for action in actions: 106 if hasattr(action, 'get'): --> 107 out.append(action.get()) 108 elif callable(action): 109 action() E:\Git\Qcodes\qcodes\instrument\remote.py in get(self) 121 122 def get(self): --> 123 return self._instrument.connection.ask('get', self.name) 124 125 def set(self, value): E:\Git\Qcodes\qcodes\instrument\server.py in ask(self, func_name, *args, **kwargs) 134 Query the server copy of this instrument, expecting a response 135 ''' --> 136 return self.manager.ask('ask', self.id, func_name, args, kwargs) 137 138 def write(self, func_name, *args, **kwargs): E:\Git\Qcodes\qcodes\utils\multiprocessing.py in ask(self, timeout, *query) 332 if self._error_queue.empty(): 333 # only raise if we're not about to find a deeper error --> 334 raise e 335 self._check_for_errors(self._expect_error) 336 E:\Git\Qcodes\qcodes\utils\multiprocessing.py in ask(self, timeout, *query) 324 325 try: --> 326 res = self._check_response(timeout) 327 328 while not self._response_queue.empty(): E:\Git\Qcodes\qcodes\utils\multiprocessing.py in _check_response(self, timeout) 301 302 def _check_response(self, timeout): --> 303 res = self._response_queue.get(timeout=timeout) 304 if res == SERVER_ERR: 305 self._expect_error = True c:\users\qdev\anaconda3\lib\multiprocessing\queues.py in get(self, block, timeout) 103 timeout = deadline - time.time() 104 if timeout < 0 or not self._poll(timeout): --> 105 raise Empty 106 elif not self._poll(): 107 raise Empty Empty:
# Time single readings
with Timer('Time a1'):
a1.volt.get()
with Timer('Time a2'):
a2.volt.get()
with Timer('Time Loop 1'):
data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt).run(location='testsweep', overwrite=True,background=False)
with Timer('Time Loop 2'):
data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt, a2.volt).run(location='testsweep', overwrite=True,background=False)
with Timer('Time Loop 1'):
data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt).run(location='testsweep', overwrite=True)
while data.sync():
time.sleep(0.1)
with Timer('Time Loop 2'):
data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt, a2.volt).run(location='testsweep', overwrite=True)
while data.sync():
time.sleep(0.1)