def init(self):
        exec 'import ctypes' in globals()
        exec 'from PyDAQmx import Task' in globals()
        exec 'from PyDAQmx.DAQmxConstants import *' in globals()
        exec 'from PyDAQmx.DAQmxTypes import *' in globals()
        global h5py
        import labscript_utils.h5_lock, h5py
        global numpy
        import numpy
        global threading
        import threading
        global zprocess
        import zprocess
        global logging
        import logging
        global time
        import time

        self.task_running = False
        self.daqlock = threading.Lock(
        )  # not sure if needed, access should be serialised already
        self.h5_file = None
        self.task = None
        self.abort = False
        self.all_waits_finished = zprocess.Event('all_waits_finished',
                                                 type='post')
        self.wait_durations_analysed = zprocess.Event(
            'wait_durations_analysed', type='post')
    def init(self):
        """Initialises the hardware communication.

        This function is automatically called by BLACS
        and configures hardware communication with the device.
        """

        # fmt: off
        global h5py
        import labscript_utils.h5_lock, h5py
        global serial
        import serial
        global time
        import time
        global re
        import re
        global numpy
        import numpy
        global zprocess
        import zprocess
        self.smart_cache = {}
        self.cached_pll_params = {}
        # fmt: on

        self.all_waits_finished = zprocess.Event("all_waits_finished",
                                                 type="post")
        self.wait_durations_analysed = zprocess.Event(
            "wait_durations_analysed", type="post")
        self.wait_completed = zprocess.Event("wait_completed", type="post")
        self.current_wait = 0
        self.wait_table = None
        self.measured_waits = None
        self.wait_timeout = None
        self.h5_file = None
        self.started = False

        self.prawnblaster = serial.Serial(self.com_port, 115200, timeout=1)
        self.check_status()

        # configure number of pseudoclocks
        self.prawnblaster.write(b"setnumpseudoclocks %d\r\n" %
                                self.num_pseudoclocks)
        assert self.prawnblaster.readline().decode() == "ok\r\n"

        # Configure pins
        for i, (out_pin, in_pin) in enumerate(zip(self.out_pins,
                                                  self.in_pins)):
            self.prawnblaster.write(b"setoutpin %d %d\r\n" % (i, out_pin))
            assert self.prawnblaster.readline().decode() == "ok\r\n"
            self.prawnblaster.write(b"setinpin %d %d\r\n" % (i, in_pin))
            assert self.prawnblaster.readline().decode() == "ok\r\n"
    def init(self):
        from labscript_utils import check_version
        check_version('spinapi', '3.1.1', '4')
        exec 'from spinapi import *' in globals()
        global h5py
        import labscript_utils.h5_lock, h5py
        global zprocess
        import zprocess

        self.pb_start = pb_start
        self.pb_stop = pb_stop
        self.pb_reset = pb_reset
        self.pb_close = pb_close
        self.pb_read_status = pb_read_status
        self.smart_cache = {
            'pulse_program': None,
            'ready_to_go': False,
            'initial_values': None
        }

        # An event for checking when all waits (if any) have completed, so that
        # we can tell the difference between a wait and the end of an experiment.
        # The wait monitor device is expected to post such events, which we'll wait on:
        self.all_waits_finished = zprocess.Event('all_waits_finished')
        self.waits_pending = False

        pb_select_board(self.board_number)
        pb_init()
        pb_core_clock(self.core_clock_freq)
    def init(self):
        from labscript_utils import check_version
        check_version('spinapi', '3.2.0', '4')
        exec('from spinapi import *', globals())
        global h5py
        import labscript_utils.h5_lock, h5py
        global zprocess
        import zprocess

        self.pb_start = pb_start
        self.pb_stop = pb_stop
        self.pb_reset = pb_reset
        self.pb_close = pb_close
        self.pb_read_status = pb_read_status
        self.smart_cache = {
            'pulse_program': None,
            'ready_to_go': False,
            'initial_values': None
        }

        # An event for checking when all waits (if any) have completed, so that
        # we can tell the difference between a wait and the end of an experiment.
        # The wait monitor device is expected to post such events, which we'll wait on:
        self.all_waits_finished = zprocess.Event('all_waits_finished')
        self.waits_pending = False

        pb_select_board(self.board_number)
        pb_init()
        pb_core_clock(self.core_clock_freq)

        # This is only set to True on a per-shot basis, so set it to False
        # for manual mode. Set associated attributes to None:
        self.time_based_stop_workaround = False
        self.time_based_shot_duration = None
        self.time_based_shot_end_time = None
Beispiel #5
0
    def init(self):
        global h5py
        import labscript_utils.h5_lock, h5py
        # global serial; import serial
        global time
        import time
        global zprocess
        import zprocess
        global ok
        import ok  # OpalKelly library

        # check the import worked correctly
        # This handles the difference between v4 and v5 of front panel I think
        if not hasattr(ok, 'okCFrontPanel'):
            from ok import ok

        global numpy
        import numpy

        self.all_waits_finished = zprocess.Event('all_waits_finished',
                                                 type='post')
        self.wait_durations_analysed = zprocess.Event(
            'wait_durations_analysed', type='post')
        self.wait_completed = zprocess.Event('wait_completed', type='post')
        self.current_wait = 0
        self.wait_table = None
        self.measured_waits = None
        self.h5_file = None

        self.current_value = 0

        # Initialise connection to OPAL KELLY Board
        self.dev = ok.okCFrontPanel()
        if PY2:
            self.serial = bytes(self.serial)
        assert self.dev.OpenBySerial(self.serial) == self.dev.NoError

        try:
            assert self.dev.IsFrontPanelEnabled()
        except AssertionError:
            # Flash the FPGA bit file
            self.flash_FPGA()

        # ensure the FPGA's state machine is deactivated
        assert self.dev.ActivateTriggerIn(0x40, 1) == self.dev.NoError
    def init(self):
        #exec 'import traceback' in globals()
        exec 'from PyDAQmx import Task' in globals()
        exec 'from PyDAQmx.DAQmxConstants import *' in globals()
        exec 'from PyDAQmx.DAQmxTypes import *' in globals()
        global h5py
        import labscript_utils.h5_lock, h5py
        global numpy
        import numpy
        global threading
        import threading
        global zprocess
        import zprocess
        global logging
        import logging
        global time
        import time

        self.task_running = False
        self.daqlock = threading.Condition()
        # Channel details
        self.channels = []
        self.rate = 1000.
        self.samples_per_channel = 1000
        self.ai_start_delay = 25e-9
        self.h5_file = ""
        self.buffered_channels = []
        self.buffered_rate = 0
        self.buffered = False
        self.buffered_data = None
        self.buffered_data_list = []

        self.task = None
        self.abort = False

        # And event for knowing when the wait durations are known, so that we may use them
        # to chunk up acquisition data:
        self.wait_durations_analysed = zprocess.Event(
            'wait_durations_analysed')

        self.daqmx_read_thread = threading.Thread(target=self.daqmx_read)
        self.daqmx_read_thread.daemon = True
        self.daqmx_read_thread.start()
Beispiel #7
0
    def init(self):
        exec 'from spinapi import *' in globals()
        import spinapi
        version = [
            int(v) for v in spinapi.__version__.split('-')[0].split('.')
        ]
        requires_version = (3, 0, 4)
        try:
            assert version[0] == requires_version[0]
            assert version[1] >= requires_version[1]
            assert version[2] >= requires_version[2]
        except AssertionError:
            raise ImportError(
                'This PulseBlaster requires at least Python spinapi v%d.%d.%d'
                % requires_version)
        global h5py
        import labscript_utils.h5_lock, h5py
        global zprocess
        import zprocess

        self.pb_start = pb_start
        self.pb_stop = pb_stop
        self.pb_reset = pb_reset
        self.pb_close = pb_close
        self.pb_read_status = pb_read_status
        self.smart_cache = {
            'pulse_program': None,
            'ready_to_go': False,
            'initial_values': None
        }

        # An event for checking when all waits (if any) have completed, so that
        # we can tell the difference between a wait and the end of an experiment.
        # The wait monitor device is expected to post such events, which we'll wait on:
        self.all_waits_finished = zprocess.Event('all_waits_finished')
        self.waits_pending = False

        pb_select_board(self.board_number)
        pb_init()
        pb_core_clock(self.core_clock_freq)