def __init__(self, name, parent_device, connection,
              BIAS_port=1027, serial_number=0x0, SDK='', effective_pixel_size=0.0,
              exposure_time=float('nan'), orientation='side', minimum_recovery_time=0,
              **kwargs):
                 
     # not a class attribute, so we don't have to have a subclass for each model of camera:
     self.minimum_recovery_time = minimum_recovery_time
     self.exposure_time = exposure_time
     self.orientation = orientation
     self.BLACS_connection = BIAS_port
     if isinstance(serial_number,str):
         serial_number = int(serial_number,16)
     self.sn = np.uint64(serial_number)
     self.sdk = str(SDK)
     self.effective_pixel_size = effective_pixel_size
     self.exposures = []
     
     # DEPRECATED: backward compatibility:
     if 'exposuretime' in kwargs:
         # We will call self.set_property later to overwrite the non-underscored kwarg's default value.
         self.exposure_time = kwargs.pop('exposuretime')
         import sys
         sys.stderr.write('WARNING: Camera\'s keyword argument \'exposuretime\' deprecated. Use \'exposure_time\' instead.\n')
     
     TriggerableDevice.__init__(self, name, parent_device, connection, **kwargs)
Ejemplo n.º 2
0
    def __init__(self, name, VISA_name, trigger_device, trigger_connection,
                 **kwargs):
        '''VISA_name can be full VISA connection string or NI-MAX alias.
        Trigger Device should be fast clocked device. '''
        self.VISA_name = VISA_name
        self.BLACS_connection = VISA_name
        TriggerableDevice.__init__(self, name, trigger_device,
                                   trigger_connection, **kwargs)

        # initialize start_time variable
        self.trigger_time = None
    def __init__(self,
                 name,
                 parent_device,
                 connection,
                 zmq_port=8675,
                 visa_resource='',
                 **kwargs):

        self.visa_resource = visa_resource
        self.BLACS_connection = zmq_port
        self.captures = []

        TriggerableDevice.__init__(self, name, parent_device, connection,
                                   **kwargs)
Ejemplo n.º 4
0
    def __init__(self,
                 name,
                 VISA_name,
                 trigger_device,
                 trigger_connection,
                 num_AI=4,
                 DI=True,
                 trigger_duration=1e-3,
                 compression=None,
                 compression_opts=None,
                 shuffle=False,
                 **kwargs):
        '''VISA_name can be full VISA connection string or NI-MAX alias.
        Trigger Device should be fast clocked device. 
        num_AI sets number of analog input channels, default 4
        DI sets if DI are present, default True
        trigger_duration set scope trigger duration, default 1ms
        Compression of traces in h5 file controlled by:
        compression: \'lzf\', \'gzip\', None 
        compression_opts: 0-9 for gzip
        shuffle: True/False '''
        self.VISA_name = VISA_name
        self.BLACS_connection = VISA_name
        TriggerableDevice.__init__(self, name, trigger_device,
                                   trigger_connection, **kwargs)

        self.compression = compression
        if (compression == 'gzip') and (compression_opts == None):
            # set default compression level if needed
            self.compression_opts = 4
        else:
            self.compression_opts = compression_opts
        self.shuffle = shuffle

        self.trigger_duration = trigger_duration
        self.allowed_analog_chan = [
            'Channel {0:d}'.format(i) for i in range(1, num_AI + 1)
        ]
        if DI:
            self.allowed_pod1_chan = [
                'Digital {0:d}'.format(i) for i in range(0, 8)
            ]
            self.allowed_pod2_chan = [
                'Digital {0:d}'.format(i) for i in range(8, 16)
            ]
Ejemplo n.º 5
0
 def __init__(self, name, parent_device, connection, com_port, **kwargs):
     self.BLACS_connection = com_port
     TriggerableDevice.__init__(self, name, parent_device, connection,
                                **kwargs)
Ejemplo n.º 6
0
    def __init__(
        self,
        name,
        parent_device,
        connection,
        serial_number,
        orientation=None,
        trigger_edge_type='rising',
        trigger_duration=None,
        minimum_recovery_time=0.0,
        camera_attributes=None,
        manual_mode_camera_attributes=None,
        stop_acquisition_timeout=5.0,
        exception_on_failed_shot=True,
        saved_attribute_visibility_level='intermediate',
        mock=False,
        **kwargs
    ):
        """A camera to be controlled using NI IMAQdx and triggered with a digital edge.

        Args:
            name (str)
                device name

            parent_device (IntermediateDevice)
                Device with digital outputs to be used to trigger acquisition

            connection (str)
                Name of digital output port on parent device.

            serial_number (str or int)
                string or integer (integer allows entering a hex literal) of the
                camera's serial number. This will be used to idenitfy the camera.

            orientation (str, optional), default: `<name>`
                Description of the camera's location or orientation. This will be used
                to determine the location in the shot file where the images will be
                saved. If not given, the device name will be used instead.

            trigger_edge_type (str), default: `'rising'`
                The direction of the desired edges to be generated on the parent
                devices's digital output used for triggering. Must be 'rising' or
                'falling'. Note that this only determines the edges created on the
                parent device, it does not program the camera to expect this type of
                edge. If required, one must configure the camera separately via
                `camera_attributes` to ensure it expects the type of edge being
                generated. Default: `'rising'`

            trigger_duration (float or None), default: `None`
                Duration of digital pulses to be generated by the parent device. This
                can also be specified as an argument to `expose()` - the value given
                here will be used only if nothing is passed to `expose()`.

            minimum_recovery_time (float), default: `0`
                Minimum time between frames. This will be used for error checking during
                compilation.

            camera_attributes (dict, optional):
                Dictionary of camera attribute names and values to be programmed into
                the camera. The meaning of these attributes is model-specific.
                Attributes will be programmed in the order they appear in this
                dictionary. This can be important as some attributes may not be settable
                unless another attrbiute has been set first. After adding this device to
                your connection table, a dictionary of the camera's default attributes
                can be obtained from the BLACS tab, appropriate for copying and pasting
                into your connection table to customise the ones you are interested in.

            manual_mode_camera_attributes (dict, optional):
                Dictionary of attributes that will be programmed into the camera during
                manual mode, that differ from their values in `camera_attributes`. This
                can be useful for example, to have software triggering during manual
                mode (allowing the acquisition of frames from the BLACS manual mode
                interface) but hardware triggering during buffered runs. Any attributes
                in this dictionary must also be present in `camera_attributes`.

            stop_acquisition_timeout (float), default: `5.0`
                How long, in seconds, to wait during `transition_to_buffered` for the
                acquisition of images to complete before giving up. Whilst all triggers
                should have been received, this can be used to allow for slow image
                download time.

            exception_on_failed_shot (bool), default: `True`.
                If acquisition does not complete within the given timeout after the end
                of a shot, whether to raise an exception. If False, instead prints a
                warning to stderr (visible in the terminal output pane in the BLACS
                tab), saves the images acquired so far, and continues. In the case of
                such a 'failed shot', the HDF5 attribute
                f['images'][orientation/name].attrs['failed_shot'] will be set to `True`
                (otherwise it is set to `False`). This attribute is acessible in the
                lyse dataframe as `df[orientation/name, 'failed_shot']`.

            saved_attribute_visibility_level (str or None), default: 'intermediate'
                The detail level of the camera attributes saved to the HDF5 file at the
                end of each shot. If None, no attributes will be saved. Must be one of
                `'simple'`, `'intermediate'`, `'advanced'`, or `None`. If `None`, no
                attributes will be saved.

            mock (bool, optional), default: False
                For testing purpses, simulate a camera with fake data instead of
                communicating with actual hardware.

            **kwargs: Further keyword arguments to be passed to the `__init__` method of
                the parent class (TriggerableDevice).
        """
        self.trigger_edge_type = trigger_edge_type
        self.minimum_recovery_time = minimum_recovery_time
        self.trigger_duration = trigger_duration
        self.orientation = orientation
        if isinstance(serial_number, (str, bytes)):
            serial_number = int(serial_number, 16)
        self.serial_number = serial_number
        self.BLACS_connection = hex(self.serial_number)[2:].upper()
        if camera_attributes is None:
            camera_attributes = {}
        if manual_mode_camera_attributes is None:
            print(manual_mode_camera_attributes)
            manual_mode_camera_attributes = {}
        for attr_name in manual_mode_camera_attributes:
            if attr_name not in camera_attributes:
                msg = f"""attribute '{attr_name}' is present in
                    manual_mode_camera_attributes but not in camera_attributes.
                    Attributes that are to differ between manual mode and buffered
                    mode must be present in both dictionaries."""
                raise ValueError(dedent(msg))
        valid_attr_levels = ('simple', 'intermediate', 'advanced', None)
        if saved_attribute_visibility_level not in valid_attr_levels:
            msg = "saved_attribute_visibility_level must be one of %s"
            raise ValueError(msg % valid_attr_levels)
        self.camera_attributes = camera_attributes
        self.manual_mode_camera_attributes = manual_mode_camera_attributes
        self.exposures = []
        TriggerableDevice.__init__(self, name, parent_device, connection, **kwargs)