Skip to content

Commit 7d79dee

Browse files
committed
tektro-awg: add send_load_awg_file
1 parent a5d6b21 commit 7d79dee

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

exopy_hqc_legacy/instruments/drivers/visa/tektro_awg.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212
import re
1313
import time
14+
import random
1415
import logging
1516
from textwrap import fill
1617
from inspect import cleandoc
@@ -506,6 +507,38 @@ def to_send(self, name, waveform):
506507
self._driver.write_binary_values(header, waveform, datatype='B')
507508
self.write('*WAI')
508509

510+
@secure_communication()
511+
def send_load_awg_file(self, awg_file, filename='setup', timeout=100):
512+
"""Command to send and load and .awg file into the AWG
513+
awg_file = bytearray
514+
filename = str
515+
timeout = float
516+
"""
517+
# Add a random int at the the end of the file to make it unique
518+
filename += str(random.randint(0, 10000))
519+
name_str = 'MMEMory:DATA "{}",'.format(filename+'.awg').encode('ASCII')
520+
size_str = ('#' + str(len(str(len(awg_file))))
521+
+ str(len(awg_file))).encode('ASCII')
522+
mes = name_str + size_str + awg_file
523+
self.write('MMEMory:CDIRectory "/Users/OEM/Documents"')
524+
# mes = self._driver.read_raw()
525+
self._driver.write_raw(mes)
526+
self.write('AWGCONTROL:SRESTORE "{}"'.format(filename+'.awg'))
527+
528+
# Wait for the AWG to finish loading the file
529+
start_time = time.clock()
530+
current_file = ''
531+
while time.clock() - start_time <= timeout and\
532+
filename not in current_file:
533+
time.sleep(0.5)
534+
try:
535+
current_file = self.ask('AWGCONTROL:SNAMe?')
536+
except VisaIOError:
537+
continue
538+
if filename not in current_file:
539+
raise InstrIOError(cleandoc('''Timeout during AWG file loading'''))
540+
541+
509542
@secure_communication()
510543
def clear_sequence(self):
511544
"""Command to delete the sequence

0 commit comments

Comments
 (0)