Commit e2893ce0 authored by Martin Drechsler's avatar Martin Drechsler
Browse files
parents 70355361 eacef26f
Loading
Loading
Loading
Loading
+2 −1
Changes for cameraGui.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -234,7 +234,8 @@ class CameraGuiMainWindow(QMainWindow):
                % (self.frame_index, acq_index)
            )
            
        self.img.setImage(image, autoDownsample=True)
        self.img.setImage(image, autoDownsample=True, autoHistogramRange=False, autoLevels=False,
                 autoRange=False)
        self.updatePlots()
        self.frame_index = self.frame_index + 1

+124
Changes for drivers/ADoutputs_linux.py: 124 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 22 16:29:22 2019

@author: liaf-ankylosaurus-admin
"""

from uldaq import (get_daq_device_inventory, DaqDevice, InterfaceType,
                   DigitalDirection, DigitalPortIoType, AOutFlag, Range)

#empty some variables and defining interface type
daq_device = None
dio_device = None
port_to_write = None
port_info = None
interface_type = InterfaceType.USB
descriptor_index = 0
port_types_index = 0

# Get descriptors for all of the available DAQ devices.
devices = get_daq_device_inventory(interface_type)
number_of_devices = len(devices)
if number_of_devices == 0:
    raise Exception('Error: No DAQ devices found')

print('Found', number_of_devices, 'DAQ device(s):')
for i in range(number_of_devices):
    print('  ', devices[i].product_name, ' (', devices[i].unique_id, ')', sep='')

# Create the DAQ device object associated with the specified descriptor index.
daq_device = DaqDevice(devices[descriptor_index])

# Get the DioDevice object and verify that it is valid.
dio_device = daq_device.get_dio_device()
if dio_device is None:
    raise Exception('Error: The device does not support digital output')
    
# Create a aoDevice object from the first descriptor.
ao_device = daq_device.get_ao_device() 

# Verify the specified DAQ device supports analog output.
if ao_device is None:
    raise Exception('Error: The DAQ device does not support analog output')
ao_info = ao_device.get_info()

    
# Establish a connection to the DAQ device.
descriptor = daq_device.get_descriptor()
if not daq_device.is_connected():
    print('\nConnecting to', descriptor.dev_string, '- please wait...')
    daq_device.connect()
    print('\n', descriptor.dev_string, 'ready')

def _configure_digital_outs():
        global port_types_index
        # Get the port types for the device(AUXPORT, FIRSTPORTA, ...)
        dio_info = dio_device.get_info()
        port_types = dio_info.get_port_types()

        if port_types_index >= len(port_types):
            port_types_index = len(port_types) - 1

        port_to_write = port_types[port_types_index]

        # Get the port I/O type and the number of bits for the first port.
        port_info = dio_info.get_port_info(port_to_write)

        # If the port is bit configurable, then configure the individual bits
        # for output; otherwise, configure the entire port for output.
        if port_info.port_io_type == DigitalPortIoType.BITIO:
            # Configure all of the bits for output for the first port.
            for bit_number in range(port_info.number_of_bits):
                dio_device.d_config_bit(port_to_write, bit_number,
                                        DigitalDirection.OUTPUT)
        elif port_info.port_io_type == DigitalPortIoType.IO:
            # Configure the entire port for output.
            dio_device.d_config_port(port_to_write, DigitalDirection.OUTPUT)
            
_configure_digital_outs() 
            
class daq_AO(object):
    def __init__(self, out_num, min_value = -10, max_value = 10, output_range = Range.BIP10VOLTS):
        self.out_num = out_num
        self.output_range = output_range
        self.max = max_value
        self.min = min_value
        self.current_value = 0
        
    #methods  
    def set_out(self, value):
        try:
            ao_device.a_out(self.out_num, self.output_range, AOutFlag.DEFAULT, float(value))
            self.current_value = value
        except:
            raise("Failing to set analog output %i", self.out_num)
    
#    def set_out(self, value):
#        print('Analog out %i set to %f' % (self.out_num, value) )
#        return value, self.out_num
       

        
class daq_DO(object):
    global port_types_index, dio_device
    def __init__(self, out_num):
        self.out_num = out_num
           
        self.dio_info = dio_device.get_info()
        self.port_types = self.dio_info.get_port_types()
        self.port_to_write = self.port_types[port_types_index]

    def set_out(self, bit_value):
        try:
            # Output the value to the board
            dio_device.d_bit_out(self.port_to_write, self.out_num, bit_value)
        except:
            raise("Failing to set digital output %i", self.out_num)
            
#    def set_out(self, bit_value):
#        print('Digital out %i set to %s' % (self.out_num, bit_value) )
#        return bit_value, self.out_num
#                       
        
+3 −3
Changes for drivers/dummyAndor.py: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -93,10 +93,10 @@ class AndorZyla:
    def _twoD_gaussian(self, lim=10, sigma=1, x0=0, y0=0):
        N = self.ImageArea.getValue()
        x, y = np.meshgrid(np.linspace(-lim, lim, N), np.linspace(-lim, lim, N))
        d = np.sqrt((x - x0) ** 2 + (y - y0) ** 2)
        d = np.sqrt(5*(x - x0) ** 2 + (y - y0) ** 2)
        g = np.exp(-((d) ** 2 / (2.0 * sigma ** 2)))
        noise = np.random.rand(N, N)
        return np.int8(g + noise) 
        noise = np.random.normal(size = (N, N))
        return g + noise 

    def trigger(self):
         self.current_image = self.images_array[self.acq_index_i%10]
+3 −2
Changes for examples/imageview_example.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import pyqtgraph.ptime as ptime
def _twoD_gaussian(lim=10, sigma=1, x0=0, y0=0):
    N = 600
    x, y = np.meshgrid(np.linspace(-lim, lim, N), np.linspace(-lim, lim, N))
    d = np.sqrt((x - x0) ** 2 + (y - y0) ** 2)
    d = np.sqrt(5*(x - x0) ** 2 + (y - y0) ** 2)
    g = np.exp(-((d) ** 2 / (2.0 * sigma ** 2)))
    noise = np.random.normal(size=(N, N))/10
    return g + noise 
@@ -32,6 +32,7 @@ app = QtGui.QApplication([])
win = QtGui.QMainWindow()
win.resize(800,800)
imv = pg.ImageView()

win.setCentralWidget(imv)
win.show()
win.setWindowTitle('pyqtgraph example: ImageView')
@@ -50,7 +51,7 @@ def updateData():

    ## Display the data
    imv.setImage(data[i], autoHistogramRange=False, autoLevels=False,
                 autoRange=False 
                 autoRange=False, rot
                 )
    i = (i+1) % data.shape[0]

+2 −2
Changes for main.py: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
    
from PyQt5 import QtGui, QtCore
#from drivers.andorzyla import AndorZyla
from drivers.dummyAndor import AndorZyla
from drivers.andorzyla import AndorZyla
#from drivers.dummyAndor import AndorZyla

from cameraGui import CameraGuiMainWindow
from zylaCameraWorker import CameraWorker