Skip to content

Commit c757fea

Browse files
committed
Clean up
1 parent c9236d2 commit c757fea

File tree

2 files changed

+14
-127
lines changed

2 files changed

+14
-127
lines changed

exopy_hqc_legacy/instruments/drivers/visa/tektro_awg.py

Lines changed: 13 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -451,90 +451,6 @@ def __init__(self, connection_info, caching_allowed=True,
451451
caching_permissions, auto_open)
452452
self.channels = {}
453453
self.lock = Lock()
454-
self.AWG_FILE_FORMAT_HEAD = {
455-
'SAMPLING_RATE': 'd', # d
456-
'REPETITION_RATE': 'd', # # NAME?
457-
'HOLD_REPETITION_RATE': 'h', # True | False
458-
'CLOCK_SOURCE': 'h', # Internal | External
459-
'REFERENCE_SOURCE': 'h', # Internal | External
460-
'EXTERNAL_REFERENCE_TYPE': 'h', # Fixed | Variable
461-
'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h',
462-
'REFERENCE_MULTIPLIER_RATE': 'h', #
463-
'DIVIDER_RATE': 'h', # 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256
464-
'TRIGGER_SOURCE': 'h', # Internal | External
465-
'INTERNAL_TRIGGER_RATE': 'd', #
466-
'TRIGGER_INPUT_IMPEDANCE': 'h', # 50 ohm | 1 kohm
467-
'TRIGGER_INPUT_SLOPE': 'h', # Positive | Negative
468-
'TRIGGER_INPUT_POLARITY': 'h', # Positive | Negative
469-
'TRIGGER_INPUT_THRESHOLD': 'd', #
470-
'EVENT_INPUT_IMPEDANCE': 'h', # 50 ohm | 1 kohm
471-
'EVENT_INPUT_POLARITY': 'h', # Positive | Negative
472-
'EVENT_INPUT_THRESHOLD': 'd',
473-
'JUMP_TIMING': 'h', # Sync | Async
474-
'INTERLEAVE': 'h', # On | This setting is stronger than .
475-
'ZEROING': 'h', # On | Off
476-
'COUPLING': 'h', # The Off | Pair | All setting is weaker than .
477-
'RUN_MODE': 'h', # Continuous | Triggered | Gated | Sequence
478-
'WAIT_VALUE': 'h', # First | Last
479-
'RUN_STATE': 'h', # On | Off
480-
'INTERLEAVE_ADJ_PHASE': 'd',
481-
'INTERLEAVE_ADJ_AMPLITUDE': 'd',
482-
}
483-
484-
self.AWG_FILE_FORMAT_CHANNEL = {
485-
# Include NULL.(Output Waveform Name for Non-Sequence mode)
486-
'OUTPUT_WAVEFORM_NAME_N': 's',
487-
'CHANNEL_STATE_N': 'h', # On | Off
488-
'ANALOG_DIRECT_OUTPUT_N': 'h', # On | Off
489-
'ANALOG_FILTER_N': 'h', # Enum type.
490-
'ANALOG_METHOD_N': 'h', # Amplitude/Offset, High/Low
491-
# When the Input Method is High/Low, it is skipped.
492-
'ANALOG_AMPLITUDE_N': 'd',
493-
# When the Input Method is High/Low, it is skipped.
494-
'ANALOG_OFFSET_N': 'd',
495-
# When the Input Method is Amplitude/Offset, it is skipped.
496-
'ANALOG_HIGH_N': 'd',
497-
# When the Input Method is Amplitude/Offset, it is skipped.
498-
'ANALOG_LOW_N': 'd',
499-
'MARKER1_SKEW_N': 'd',
500-
'MARKER1_METHOD_N': 'h', # Amplitude/Offset, High/Low
501-
# When the Input Method is High/Low, it is skipped.
502-
'MARKER1_AMPLITUDE_N': 'd',
503-
# When the Input Method is High/Low, it is skipped.
504-
'MARKER1_OFFSET_N': 'd',
505-
# When the Input Method is Amplitude/Offset, it is skipped.
506-
'MARKER1_HIGH_N': 'd',
507-
# When the Input Method is Amplitude/Offset, it is skipped.
508-
'MARKER1_LOW_N': 'd',
509-
'MARKER2_SKEW_N': 'd',
510-
'MARKER2_METHOD_N': 'h', # Amplitude/Offset, High/Low
511-
# When the Input Method is High/Low, it is skipped.
512-
'MARKER2_AMPLITUDE_N': 'd',
513-
# When the Input Method is High/Low, it is skipped.
514-
'MARKER2_OFFSET_N': 'd',
515-
# When the Input Method is Amplitude/Offset, it is skipped.
516-
'MARKER2_HIGH_N': 'd',
517-
# When the Input Method is Amplitude/Offset, it is skipped.
518-
'MARKER2_LOW_N': 'd',
519-
'DIGITAL_METHOD_N': 'h', # Amplitude/Offset, High/Low
520-
# When the Input Method is High/Low, it is skipped.
521-
'DIGITAL_AMPLITUDE_N': 'd',
522-
# When the Input Method is High/Low, it is skipped.
523-
'DIGITAL_OFFSET_N': 'd',
524-
# When the Input Method is Amplitude/Offset, it is skipped.
525-
'DIGITAL_HIGH_N': 'd',
526-
# When the Input Method is Amplitude/Offset, it is skipped.
527-
'DIGITAL_LOW_N': 'd',
528-
'EXTERNAL_ADD_N': 'h', # AWG5000 only
529-
'PHASE_DELAY_INPUT_METHOD_N': 'h', # Phase/DelayInme/DelayInints
530-
'PHASE_N': 'd', # When the Input Method is not Phase, it is skipped.
531-
# When the Input Method is not DelayInTime, it is skipped.
532-
'DELAY_IN_TIME_N': 'd',
533-
# When the Input Method is not DelayInPoint, it is skipped.
534-
'DELAY_IN_POINTS_N': 'd',
535-
'CHANNEL_SKEW_N': 'd',
536-
'DC_OUTPUT_LEVEL_N': 'd', # V
537-
}
538454

539455
def reopen_connection(self):
540456
"""Clear buffer on connection reseting.
@@ -590,19 +506,17 @@ def to_send(self, name, waveform):
590506
self._driver.write_binary_values(header, waveform, datatype='B')
591507
self.write('*WAI')
592508

593-
594509
@secure_communication()
595-
def send_load_awg_file(self, awg_file, filename = 'setup'):
510+
def send_load_awg_file(self, awg_file, filename='setup'):
596511
"""Command to send and load and .awg file into the AWG
597512
awg_file = bytearray
598513
599514
"""
600-
name_str = 'MMEMory:DATA "{}",'.format(filename+'.awg').encode('ASCII')
601-
size_str = ('#' + str(len(str(len(awg_file)))) + str(len(awg_file))).encode('ASCII')
515+
name_str = 'MMEMory:DATA "{}",'.format(filename+'.awg')
516+
size_str = ('#' + str(len(str(len(awg_file)))) + str(len(awg_file)))
602517
mes = name_str + size_str + awg_file
603518
self.write('MMEMory:CDIRectory "/Users/OEM/Documents"')
604-
# mes = self._driver.read_raw()
605-
self._driver.write_raw(mes)
519+
self._driver.write_ascii_values(mes)
606520
self.write('AWGCONTROL:SRESTORE "{}"'.format(filename+'.awg'))
607521

608522
@secure_communication()
@@ -626,9 +540,8 @@ def set_jump_pos(self, position, jump):
626540
"""Sets the jump value at position to jump
627541
628542
"""
629-
self.write('SEQuence:ELEMent' + str(position) + ':JTARget:TYPE INDex')
630-
self.write('SEQuence:ELEMent' + str(position) + ':JTARget:INDex ' +
631-
str(jump))
543+
self.write('SEQuence:ELEMent{}:JTARget:TYPE INDex'.format(position))
544+
self.write('SEQuence:ELEMent{}:JTARget:INDex {}'.format(position, jump))
632545

633546
@secure_communication()
634547
def send_event(self):
@@ -642,15 +555,14 @@ def ask_sequencer_pos(self):
642555
"""Ask the current position index of the sequencer
643556
644557
"""
645-
pos = self.ask('AWGC:SEQ:POS?')
646-
return(pos)
558+
return self.ask('AWGC:SEQ:POS?')
647559

648560
@secure_communication()
649561
def force_jump_to(self, pos):
650562
"""Make the sequencer jump to position pos
651563
652564
"""
653-
self.ask('SEQUENCE:JUMP:IMMEDIATE %d'%pos)
565+
self.ask('SEQUENCE:JUMP:IMMEDIATE {}'.format(pos))
654566

655567
@secure_communication()
656568
def set_repeat(self, position, repeat):
@@ -843,9 +755,7 @@ def running(self, value):
843755
self.clear_output_buffer()
844756
if value in ('RUN', 1, 'True'):
845757
self.write('AWGC:RUN:IMM')
846-
self.write('AWGC:RST?')
847-
time.sleep(delay)
848-
values = self.read_values(format=2)
758+
values = self.query('AWGC:RST?', format=2, delay=self.delay)
849759
if values[0] not in (1, 2):
850760
raise InstrIOError(cleandoc('''Instrument did not set
851761
correctly the run state'''))
@@ -908,31 +818,17 @@ def delete_all_waveforms(self):
908818
909819
"""
910820
try:
911-
nb_waveforms = int(self.ask("WLIST:SIZE?")) - 25 #nb of user defined wf
821+
# Number of user defined waveforms
822+
nb_waveforms = int(self.ask("WLIST:SIZE?")) - 25
912823
except Exception:
913824
nb_waveforms = 0
914825
wait_time = 1+int(nb_waveforms/120)
915826
self.write('WLIST:WAVEFORM:DELETE ALL')
916827

917-
print('Waiting {}s for {} waveforms to be deleted'.format(wait_time,
918-
nb_waveforms))
828+
logging.info('Waiting {}s for {} waveforms to be deleted'.format(wait_time,
829+
nb_waveforms))
919830
time.sleep(wait_time)
920831

921-
def get_waveform_name(self, index):
922-
"""Get the name of waveform at given index
923-
924-
"""
925-
waveform_name = self.ask("WLIST:NAME? %d"%index)
926-
927-
return waveform_name[1:-2]
928-
929-
def get_waveform_number(self):
930-
"""Get the current number of waveforms in the waveform list
931-
932-
"""
933-
nb_waveforms = int(self.ask("WLIST:SIZE?"))
934-
return nb_waveforms
935-
936832
def clear_all_sequences(self):
937833
"""Clear the all sequences played by the AWG.
938834

exopy_hqc_legacy/tasks/tasks/instr/run_awg.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,21 @@ class RunAWGTask(InstrumentTask):
2424
"""
2525
#: Switch to choose the AWG run mode: on or off
2626
switch = Unicode('Off').tag(pref=True, feval=validators.SkipLoop())
27-
delay = Float(0).tag(pref=True,
28-
feval=validators.SkipLoop(types=numbers.Real))
29-
27+
delay = Float(0).tag(pref=True)
3028
database_entries = set_default({'output': 0})
3129

3230
def perform(self, switch=None):
3331
"""Default interface behavior.
3432
3533
"""
36-
delay = self.format_and_eval_string(self.delay)
3734
if switch is None:
3835
switch = self.format_and_eval_string(self.switch)
39-
4036
if switch == 'On' or switch == 1:
41-
print('On')
4237
self.driver.send_event()
4338
# The delay is required when loading large sequences
4439
self.driver.run_awg(1, delay=delay)
4540
self.write_in_database('output', 1)
4641
elif switch == 'Event':
47-
print('Event')
4842
time.sleep(delay)
4943
self.driver.send_event()
5044
elif switch == 'Rearm':
@@ -54,13 +48,10 @@ def perform(self, switch=None):
5448
while not success:
5549
self.driver.send_event()
5650
pos = int(self.driver.ask_sequencer_pos())
57-
print(pos)
5851
if pos == 1:
5952
success = True
60-
print(success)
6153
time.sleep(delay)
6254
else:
63-
print('Off')
6455
time.sleep(delay)
6556
self.driver.run_awg(0)
6657
self.write_in_database('output', 0)

0 commit comments

Comments
 (0)