|
16 | 16 | str = unicode |
17 | 17 |
|
18 | 18 | from labscript_devices import BLACS_tab, runviewer_parser |
| 19 | +from labscript_utils import dedent |
19 | 20 |
|
20 | | -from labscript import Device, PseudoclockDevice, Pseudoclock, ClockLine, IntermediateDevice, DigitalQuantity, DigitalOut, DDS, DDSQuantity, config, LabscriptError, set_passed_properties |
| 21 | +from labscript import ( |
| 22 | + Device, |
| 23 | + PseudoclockDevice, |
| 24 | + Pseudoclock, |
| 25 | + ClockLine, |
| 26 | + IntermediateDevice, |
| 27 | + DigitalQuantity, |
| 28 | + DigitalOut, |
| 29 | + DDS, |
| 30 | + DDSQuantity, |
| 31 | + config, |
| 32 | + LabscriptError, |
| 33 | + set_passed_properties, |
| 34 | + compiler, |
| 35 | +) |
21 | 36 |
|
22 | 37 | import numpy as np |
23 | 38 |
|
@@ -603,14 +618,30 @@ def write_pb_inst_to_h5(self, pb_inst, hdf5_file): |
603 | 618 | group.create_dataset('PULSE_PROGRAM', compression=config.compression,data = pb_inst_table) |
604 | 619 | self.set_property('stop_time', self.stop_time, location='device_properties') |
605 | 620 |
|
606 | | - |
| 621 | + |
| 622 | + def _check_wait_monitor_ok(self): |
| 623 | + if ( |
| 624 | + compiler.master_pseudoclock is self |
| 625 | + and compiler.wait_table |
| 626 | + and compiler.wait_monitor is None |
| 627 | + and self.programming_scheme != 'pb_stop_programming/STOP' |
| 628 | + ): |
| 629 | + msg = """If using waits without a wait monitor, the PulseBlaster used as a |
| 630 | + master pseudoclock must have |
| 631 | + programming_scheme='pb_stop_programming/STOP'. Otherwise there is no way |
| 632 | + for BLACS to distinguish between a wait, and the end of a shot. Either |
| 633 | + use a wait monitor (see labscript.WaitMonitor for details) or set |
| 634 | + programming_scheme='pb_stop_programming/STOP for %s.""" |
| 635 | + raise LabscriptError(dedent(msg) % self.name) |
| 636 | + |
607 | 637 | def generate_code(self, hdf5_file): |
608 | 638 | # Generate the hardware instructions |
609 | | - hdf5_file.create_group('/devices/'+self.name) |
| 639 | + hdf5_file.create_group('/devices/' + self.name) |
610 | 640 | PseudoclockDevice.generate_code(self, hdf5_file) |
611 | 641 | dig_outputs, dds_outputs = self.get_direct_outputs() |
612 | 642 | freqs, amps, phases = self.generate_registers(hdf5_file, dds_outputs) |
613 | 643 | pb_inst = self.convert_to_pb_inst(dig_outputs, dds_outputs, freqs, amps, phases) |
| 644 | + self._check_wait_monitor_ok() |
614 | 645 | self.write_pb_inst_to_h5(pb_inst, hdf5_file) |
615 | 646 |
|
616 | 647 |
|
@@ -1042,10 +1073,17 @@ def transition_to_buffered(self,device_name,h5file,initial_values,fresh): |
1042 | 1073 | else: |
1043 | 1074 | raise ValueError('invalid programming_scheme %s'%str(self.programming_scheme)) |
1044 | 1075 |
|
1045 | | - # Are there waits in use in this experiment? The monitor waiting for the end of |
1046 | | - # the experiment will need to know: |
1047 | | - self.waits_pending = bool(len(hdf5_file['waits'])) |
1048 | | - |
| 1076 | + # Are there waits in use in this experiment? The monitor waiting for the end |
| 1077 | + # of the experiment will need to know: |
| 1078 | + wait_monitor_exists = bool(hdf5_file['waits'].attrs['wait_monitor_acquisition_device']) |
| 1079 | + waits_in_use = bool(len(hdf5_file['waits'])) |
| 1080 | + self.waits_pending = wait_monitor_exists and waits_in_use |
| 1081 | + if waits_in_use and not wait_monitor_exists: |
| 1082 | + # This should be caught during labscript compilation, but just in case. |
| 1083 | + # Having waits but not a wait monitor means we can't tell when the shot |
| 1084 | + # is over unless the shot ends in a STOP instruction: |
| 1085 | + assert self.programming_scheme == 'pb_stop_programming/STOP' |
| 1086 | + |
1049 | 1087 | # Now we build a dictionary of the final state to send back to the GUI: |
1050 | 1088 | return_values = {'dds 0':{'freq':finalfreq0, 'amp':finalamp0, 'phase':finalphase0, 'gate':en0}, |
1051 | 1089 | 'dds 1':{'freq':finalfreq1, 'amp':finalamp1, 'phase':finalphase1, 'gate':en1}, |
@@ -1077,7 +1115,7 @@ def transition_to_manual(self): |
1077 | 1115 | if self.programming_scheme == 'pb_start/BRANCH': |
1078 | 1116 | done_condition = status['waiting'] |
1079 | 1117 | elif self.programming_scheme == 'pb_stop_programming/STOP': |
1080 | | - done_condition = True # status['stopped'] |
| 1118 | + done_condition = status['stopped'] |
1081 | 1119 |
|
1082 | 1120 | if time_based_shot_over is not None: |
1083 | 1121 | done_condition = time_based_shot_over |
|
0 commit comments