Skip to content

Commit 9bc6257

Browse files
committed
run_awg: cleanup
1 parent 849cedf commit 9bc6257

File tree

5 files changed

+55
-57
lines changed

5 files changed

+55
-57
lines changed

exopy_hqc_legacy/instruments/drivers/visa/tabor_awg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ def sampling_frequency(self, value):
249249
def running(self):
250250
"""Run state getter method
251251
"""
252-
return '2 : Intrument is running'
252+
return True
253253

254-
@running.setter
255254
@secure_communication()
256-
def running(self, value):
255+
def set_running(self, value, delay=0):
257256
"""Run state setter method
258257
"""
258+
pass
259259

260260

261261
@instrument_property

exopy_hqc_legacy/instruments/drivers/visa/tektro_awg.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# -----------------------------------------------------------------------------
3-
# Copyright 2015-2018 by ExopyHqcLegacy Authors, see AUTHORS for more details.
3+
# Copyright 2015-2020 by ExopyHqcLegacy Authors, see AUTHORS for more details.
44
#
55
# Distributed under the terms of the BSD license.
66
#
@@ -507,9 +507,10 @@ def to_send(self, name, waveform):
507507
self.write('*WAI')
508508

509509
@secure_communication()
510-
def send_load_awg_file(self, awg_file, filename='setup'):
510+
def send_load_awg_file(self, awg_data, filename='setup'):
511511
"""Command to send and load and .awg file into the AWG
512-
awg_file = bytearray
512+
513+
awg_data = bytearray
513514
514515
"""
515516
name_str = 'MMEMory:DATA "{}",'.format(filename+'.awg')
@@ -729,37 +730,21 @@ def sampling_frequency(self, value):
729730
raise InstrIOError(cleandoc('''Instrument did not set correctly
730731
the sampling frequency'''))
731732

732-
@instrument_property
733733
@secure_communication()
734-
def running(self):
735-
"""Run state getter method
736-
737-
"""
738-
self.clear_output_buffer()
739-
run = self.ask_for_values("AWGC:RST?")[0]
740-
if run == 0:
741-
return '0 : Instrument has stopped'
742-
elif run == 1:
743-
return '1 : Instrument is waiting for trigger'
744-
elif run == 2:
745-
return '2 : Intrument is running'
746-
else:
747-
raise InstrIOError
748-
749-
@running.setter
750-
@secure_communication()
751-
def running(self, value):
734+
def set_running(self, value, delay=0.0):
752735
"""Run state setter method
753736
754737
"""
755738
self.clear_output_buffer()
756-
if value in ('RUN', 1, 'True'):
739+
if value in ('RUN', 1, 'True', True):
757740
self.write('AWGC:RUN:IMM')
758-
values = self.query('AWGC:RST?', format=2, delay=self.delay)
741+
self.write('AWGC:RST?')
742+
time.sleep(delay)
743+
values = self.read_values(format=2)
759744
if values[0] not in (1, 2):
760745
raise InstrIOError(cleandoc('''Instrument did not set
761746
correctly the run state'''))
762-
elif value in ('STOP', 0, 'False'):
747+
elif value in ('STOP', 0, 'False', False):
763748
self.write('AWGC:STOP:IMM')
764749
if self.ask_for_values('AWGC:RST?')[0] != 0:
765750
raise InstrIOError(cleandoc('''Instrument did not set
@@ -769,6 +754,20 @@ def running(self, value):
769754
running method''').format(value), 80)
770755
raise VisaTypeError(mess)
771756

757+
@instrument_property
758+
@secure_communication()
759+
def running(self):
760+
"""Run state getter method
761+
762+
"""
763+
self.clear_output_buffer()
764+
run = self.ask_for_values("AWGC:RST?")[0]
765+
if run == 0:
766+
return False
767+
if run == 1 or run == 2:
768+
return True
769+
raise InstrIOError
770+
772771
@instrument_property
773772
@secure_communication()
774773
def run_mode(self):
@@ -819,6 +818,7 @@ def delete_all_waveforms(self):
819818
"""
820819
try:
821820
# Number of user defined waveforms
821+
# 25 is the number of default waveforms
822822
nb_waveforms = int(self.ask("WLIST:SIZE?")) - 25
823823
except Exception:
824824
nb_waveforms = 0
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# -----------------------------------------------------------------------------
3-
# Copyright 2015-2018 by ExopyHqcLegacy Authors, see AUTHORS for more details.
3+
# Copyright 2015-2020 by ExopyHqcLegacy Authors, see AUTHORS for more details.
44
#
55
# Distributed under the terms of the BSD license.
66
#
@@ -10,51 +10,51 @@
1010
1111
"""
1212
import logging
13-
import numbers
1413
import time
1514

1615
from atom.api import (Float, Unicode, set_default)
1716

18-
from exopy.tasks.api import (InstrumentTask, validators)
17+
from exopy.tasks.api import InstrumentTask
1918

2019

2120
class RunAWGTask(InstrumentTask):
2221
""" Task to set AWG run mode
2322
2423
"""
25-
#: Switch to choose the AWG run mode: on or off
26-
switch = Unicode('Off').tag(pref=True, feval=validators.SkipLoop())
24+
#: Switch to choose the AWG run mode
25+
switch = Unicode('Off').tag(pref=True)
26+
27+
#: Delay required to load the sequence
2728
delay = Float(0).tag(pref=True)
29+
2830
database_entries = set_default({'output': 0})
2931

30-
def perform(self, switch=None):
32+
def perform(self):
3133
"""Default interface behavior.
3234
3335
"""
34-
if switch is None:
35-
switch = self.format_and_eval_string(self.switch)
36-
if switch == 'On' or switch == 1:
36+
if self.switch.lower() == 'on' or self.switch == '1':
3737
self.driver.send_event()
3838
# The delay is required when loading large sequences
39-
self.driver.run_awg(1, delay=delay)
39+
self.driver.set_running(True, delay=self.delay)
4040
self.write_in_database('output', 1)
41-
elif switch == 'Event':
42-
time.sleep(delay)
41+
elif self.switch.lower() == 'event':
42+
time.sleep(self.delay)
4343
self.driver.send_event()
44-
elif switch == 'Rearm':
45-
print('Rearm')
46-
time.sleep(delay)
44+
elif self.switch.lower() == 'rearm':
45+
time.sleep(self.delay)
4746
success = False
4847
while not success:
4948
self.driver.send_event()
5049
pos = int(self.driver.ask_sequencer_pos())
5150
if pos == 1:
5251
success = True
53-
time.sleep(delay)
54-
else:
55-
time.sleep(delay)
56-
self.driver.run_awg(0)
52+
time.sleep(self.delay)
53+
elif self.switch.lower() == 'off' or self.switch == '0':
54+
time.sleep(self.delay)
55+
self.driver.set_running(False)
5756
self.write_in_database('output', 0)
58-
log = logging.getLogger(__name__)
59-
msg = 'AWG running state OK'
60-
log.debug(msg)
57+
else:
58+
logger = logging.getLogger(__name__)
59+
msg = "Unable to recognize {} running mode"
60+
logger.warning(msg.format(switch))

exopy_hqc_legacy/tasks/tasks/instr/views/run_awg_views.enaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
"""
1212
from enaml.stdlib.fields import FloatField
1313
from enaml.core.api import Conditional
14-
from enaml.widgets.api import (GroupBox, Label, Field, ObjectCombo, CheckBox)
14+
from enaml.widgets.api import (Label, Field)
1515
from enaml.layout.api import factory
1616

1717
from textwrap import fill
1818

19-
from exopy.tasks.api import InstrTaskView, EVALUATER_TOOLTIP
20-
from exopy.utils.widgets.qt_completers import QtLineCompleter
19+
from exopy.tasks.api import InstrTaskView
2120
from exopy_hqc_legacy.utils.layouts import auto_grid_layout
2221
from ...base_instr_view import InstrView
2322

@@ -36,11 +35,10 @@ enamldef RunAWGView(InstrView): view:
3635
condition << not in_loop
3736
Label:
3837
text = 'Output'
39-
QtLineCompleter:
38+
Field:
4039
hug_width = 'ignore'
4140
text := task.switch
42-
entries_updater << task.list_accessible_database_entries
43-
tool_tip = 'Should be On, Off or Event'
41+
tool_tip = 'Should be On, Off, Event or Rearm'
4442

4543
Label: delay:
4644
text = 'Delay (s)'

tests/pulses/contexts/test_awg_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self):
5454
self.sequences = {}
5555
self.defined_channels = [1, 2, 3, 4]
5656
self.channels = {i: DummyChannel(self, i) for i in range(1, 5)}
57-
self.running = False
57+
self.set_running(False)
5858

5959
def to_send(self, name, array):
6060
self.sequences[name] = array

0 commit comments

Comments
 (0)