Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions ldk/drivers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def reset(self):
def reset_laser(self):
@command('Laser')
def reset(self): pass

reset(self)

@command(classname='Laser')
Expand All @@ -46,33 +45,32 @@ def start_laser(self): pass
@command(classname='Laser')
def stop_laser(self): pass

@command(classname='Laser')
def get_laser_current(self):
return (0.0001/21.) * self.client.recv_uint32()
@property
@command(classname='Laser', funcname='get_laser_current')
def laser_current(self):
self.__laser_current = (0.0001/21.) * self.client.recv_uint32()
return self.__laser_current

@command(classname='Laser')
def get_laser_power(self):
return self.client.recv_uint32()
@property
@command(classname='Laser', funcname='get_laser_power')
def laser_power(self):
self.__laser_power = self.client.recv_uint32()
return self.__laser_power

@command(classname='Laser')
def get_monitoring(self):
return self.client.recv_tuple()

@command(classname='Laser')
def set_laser_current(self, current):
@laser_current.setter
@command(classname='Laser', funcname='set_laser_current')
def laser_current(self, current):
""" current: The bias in mA """
pass

@command(classname='Common')
def get_bitstream_id(self): pass

@command(classname='Common')
def set_led(self, value): pass

@command(classname='Common')
def init(self): pass

def twoint14_to_uint32(self, data):
data1 = np.mod(np.floor(8192 * data[0, :]) + 8192,16384) + 8192
data2 = np.mod(np.floor(8192 * data[1, :]) + 8192,16384) + 8192
return data1 + 65536 * data2
return data1 + 65536 * data2
92 changes: 0 additions & 92 deletions ldk/drivers/base_simu.py

This file was deleted.

76 changes: 51 additions & 25 deletions ldk/drivers/oscillo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,66 @@ def __init__(self, client, verbose=False):
self.wfm_size = 8192
super(Oscillo, self).__init__(self.wfm_size, client)

self.avg_on = False
self.__period = self.wfm_size
self.__averaging = False

self.period = self.wfm_size
self.adc = np.zeros((2, self.wfm_size))
self.spectrum = np.zeros((2, self.wfm_size / 2))
self.avg_spectrum = np.zeros((2, self.wfm_size / 2))

@command()
def set_dac_periods(self, period0, period1):
""" Select the periods played on each address generator
ex: self.set_dac_periods(8192, 4096)
"""
@property
def period(self):
return self.__period

@period.setter
@command(classname='Oscillo', funcname='set_avg_period')
def period(self, avg_period):
""" Set the period of the averaging module and reset the module. """
self.__period = avg_period
pass

@command()
def set_n_avg_min(self, n_avg_min):
@property
def dac_periods(self):
return self.__dac_periods

@dac_periods.setter
@command(classname='Oscillo', funcname='set_dac_periods')
def dac_periods(self, dac_periods):
""" Select the periods played on each address generator """
self.__dac_periods = dac_periods
pass

@property
def n_avg(self, channel):
""" Get the number of averages corresponding to the last acquisition """
@command(classname='Oscillo')
def get_num_average(self, channel):
return self.client.recv_uint32()
self.__n_avg = get_num_average(self, 0)
return self.__n_avg

@n_avg.setter
@command(classname='Oscillo', funcname='set_n_avg_min')
def n_avg(self, n_avg_min):
""" Set the minimum of averages that will be computed on the FPGA
The effective number of averages is >= n_avg_min.
"""
pass

@property
def averaging(self):
return self.__averaging

@averaging.setter
@command(classname='Oscillo', funcname='set_averaging')
def averaging(self, avg_status):
""" True enables averaging """
self.__averaging = avg_status


@command()
def set_avg_period(self, avg_period):
""" Set the period of the averaging module and reset the module.
"""
""" Set the period of the averaging module and reset the module. """
self.period = avg_period
pass

Expand All @@ -56,17 +91,6 @@ def set_dac_buffer(self, channel, arr):
data = np.uint32(np.mod(np.floor(8192 * self.dac[channel,:]) + 8192, 16384) + 8192)
set_dac_buffer(self, channel, data[::2] + data[1::2] * 65536)

@command()
def set_averaging(self, avg_status):
""" self.set_averaging(True) enables averaging. """
pass

@command()
def get_num_average(self, channel):
""" Get the number of averages corresponding to the last acquisition. """
n_avg = self.client.recv_uint32()
return n_avg

@command()
def read_all_channels(self):
return self.client.recv_array(2 * self.wfm_size, dtype='float32')
Expand Down Expand Up @@ -105,13 +129,15 @@ def always_update(self):
"""
pass

@command()
def get_counter(self):
@property
@command(classname='Oscillo', funcname='get_counter')
def counter(self):
""" Return a 64 bits integer that counts the number of clock
cycles (8 ns) between the startup of the FPGA and the last trigger
(beginning of the last acquisition).
"""
return self.client.recv_int(8, fmt='Q')
self.__counter = self.client.recv(fmt='Q')
return self.__counter

@command()
def reset_acquisition(self):
Expand Down
2 changes: 1 addition & 1 deletion ldk/drivers/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def store_peak_fifo_data(self):

@command(classname='Spectrum')
def get_peak_fifo_data(self):
return self.client.recv_buffer(self.peak_stream_length, data_type='uint32')
return self.client.recv_array(self.peak_stream_length, dtype='uint32')

return get_peak_fifo_data(self)

Expand Down
2 changes: 1 addition & 1 deletion ldk/gui/base_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, driver, parent):

# Initialize driver
self.driver.set_dac()
self.power_offset = self.driver.get_laser_power()
self.power_offset = self.driver.laser_power

# Layout
self.init_layout()
Expand Down
8 changes: 4 additions & 4 deletions ldk/gui/connect_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import json
import os
import requests
from koheron import KoheronClient, load_instrument
from koheron import KoheronClient, connect

class ConnectWidget(QtGui.QWidget):
def __init__(self, parent, ip_path=None):
Expand Down Expand Up @@ -99,8 +99,8 @@ def ip_changed(self, index):
self.lines[index+1].setFocus()
self.lines[index+1].selectAll()

def load_instrument(self, instrument_name):
self.client = load_instrument(self.host, instrument_name)
def koheron_connect(self, instrument_name):
self.client = connect(self.host, instrument_name)

def disconnect(self):
self.is_connected = False
Expand All @@ -124,7 +124,7 @@ def connect(self):

# Load the first instrument available by default
instrument_name = (next(instr for instr in self.parent.instrument_list if instr))
self.load_instrument(instrument_name)
self.koheron_connect(instrument_name)

self.connection_info.setText('Connected to ' + self.host)
self.is_connected = True
Expand Down
6 changes: 3 additions & 3 deletions ldk/gui/laser_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def __init__(self, driver, laser_on=False, laser_current=0):
self.laser_on = laser_on
self.laser_current = laser_current

self.driver.set_laser_current(self.laser_current *
self.laser_on)
self.driver.laser_current = self.laser_current * self.laser_on

# Layout
self.layout = QtGui.QHBoxLayout()
# Laser ON/OFF button
Expand Down Expand Up @@ -49,7 +49,7 @@ def stop_laser(self):

def change_current(self, value):
self.laser_current = value
self.driver.set_laser_current(self.laser_current)
self.driver.laser_current = self.laser_current

def save_as_h5(self, f):
laser_grp = f.create_group('laser')
Expand Down
7 changes: 3 additions & 4 deletions ldk/gui/math_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ def __init__(self, driver, plot_widget):
self.connect(self.n_avg_min_slider, SIGNAL("value(float)"), self.change_n_avg_min)

def change_averaging(self):
self.driver.avg_on = not self.driver.avg_on
if self.driver.avg_on:
self.driver.averaging = not self.driver.averaging
if self.driver.averaging:
self.avg_on_button.setStyleSheet('QPushButton {color: red;}')
self.avg_on_button.setText('Stop averaging')
else:
self.avg_on_button.setStyleSheet('QPushButton {color: green;}')
self.avg_on_button.setText('Start averaging')
self.driver.set_averaging(self.driver.avg_on)

def fourier_connect(self, state):
if state == QtCore.Qt.Checked:
Expand All @@ -111,7 +110,7 @@ def avg_connect(self):
self.n_avg_spectrum = self.avg_spin.value()

def change_n_avg_min(self, value):
self.driver.set_n_avg_min(int(value))
self.driver.n_avg = int(value)

def save_as_h5(self, f):
math_grp = f.create_group('math')
Expand Down
Loading