Commit 6d0bdd38 authored by Lucas Giardino's avatar Lucas Giardino

debug c/artiq + agrego la carga de JSON preexistente

parent c55d7e6a
...@@ -17,8 +17,9 @@ from artiq.experiment import * ...@@ -17,8 +17,9 @@ from artiq.experiment import *
# TODO: # TODO:
# [ ] Check why amplitude fails to update # [ ] Check why amplitude fails to update
# [~] Set initial values of inputs to correct ones based on dict # [✓] Set initial values of inputs to correct ones based on dict
# [~] └ Look for a saved json at start to get initial values # [✓] └ Look for a saved json at start to get initial values
# [ ] └ Make use of the initial 'state' variable
# [ ] Check inputs # [ ] Check inputs
# [ ] Add options to specify datafiles # [ ] Add options to specify datafiles
# [ ] Catch errors and send according popups # [ ] Catch errors and send according popups
...@@ -48,6 +49,7 @@ class SingleChannel(QWidget): #{{{ ...@@ -48,6 +49,7 @@ class SingleChannel(QWidget): #{{{
else: else:
self.state_params = initial_pars self.state_params = initial_pars
print(self.state_params)
# Each DDS will have each own enablable group # Each DDS will have each own enablable group
self.groupbox = QGroupBox(name) self.groupbox = QGroupBox(name)
self.groupbox.setCheckable(True) self.groupbox.setCheckable(True)
...@@ -70,8 +72,9 @@ class SingleChannel(QWidget): #{{{ ...@@ -70,8 +72,9 @@ class SingleChannel(QWidget): #{{{
# Frecuency input {{{ # Frecuency input {{{
self.freq_input = QDoubleSpinBox() self.freq_input = QDoubleSpinBox()
self.freq_input.setPrefix("Frequency: ") self.freq_input.setPrefix("Frequency: ")
self.freq_input.setRange(1., 400., 0.1) self.freq_input.setRange(1., 400.)
self.freq_input.setValue(self.state_params['freq']) self.freq_input.setSingleStep(0.1)
self.freq_input.setValue(self.state_params['freq']/MHz)
self.freq_input.setSuffix(" MHz") self.freq_input.setSuffix(" MHz")
self.freq_input.valueChanged.connect(self.freq_change) self.freq_input.valueChanged.connect(self.freq_change)
vbox.addWidget(self.freq_input) vbox.addWidget(self.freq_input)
...@@ -80,8 +83,9 @@ class SingleChannel(QWidget): #{{{ ...@@ -80,8 +83,9 @@ class SingleChannel(QWidget): #{{{
# Amplitude input {{{ # Amplitude input {{{
self.amp_input = QDoubleSpinBox() self.amp_input = QDoubleSpinBox()
self.amp_input.setPrefix("Amplitude: ") self.amp_input.setPrefix("Amplitude: ")
self.amp_input.setRange(0., 1., 0.1) self.amp_input.setRange(0., 1.)
self.amp_input.setValue(self.state_params['att']) self.amp_input.setSingleStep(0.1)
self.amp_input.setValue(self.state_params['amp'])
self.amp_input.valueChanged.connect(self.amp_change) self.amp_input.valueChanged.connect(self.amp_change)
vbox.addWidget(self.amp_input) vbox.addWidget(self.amp_input)
# }}} # }}}
...@@ -89,7 +93,8 @@ class SingleChannel(QWidget): #{{{ ...@@ -89,7 +93,8 @@ class SingleChannel(QWidget): #{{{
# Attenuation input {{{ # Attenuation input {{{
self.att_input = QDoubleSpinBox() self.att_input = QDoubleSpinBox()
self.att_input.setPrefix("Attenuation: ") self.att_input.setPrefix("Attenuation: ")
self.att_input.setRange(0., 31., 0.1) self.att_input.setRange(0., 31.)
self.att_input.setSingleStep(0.1)
self.att_input.setValue(self.state_params['att']) self.att_input.setValue(self.state_params['att'])
self.att_input.setSuffix(" dB") self.att_input.setSuffix(" dB")
self.att_input.valueChanged.connect(self.att_change) self.att_input.valueChanged.connect(self.att_change)
...@@ -185,7 +190,7 @@ class DDSManager(QWidget): #{{{ ...@@ -185,7 +190,7 @@ class DDSManager(QWidget): #{{{
# Make a default initial parameter dictionary to pass to the channels # Make a default initial parameter dictionary to pass to the channels
# in case a real one is found, this gets stepped on with the real values # in case a real one is found, this gets stepped on with the real values
initial_params = {'ch0': None, 'ch1': None} initial_params = {'ch0': None, 'ch1': None}
loaded_params.update(self.load_state()) initial_params.update(self.load_state())
self.setWindowTitle("DDS Manager GUI") self.setWindowTitle("DDS Manager GUI")
layout = QGridLayout() layout = QGridLayout()
...@@ -201,7 +206,7 @@ class DDSManager(QWidget): #{{{ ...@@ -201,7 +206,7 @@ class DDSManager(QWidget): #{{{
layout.addWidget(self.laser_2.get_widget(), 0, 1) layout.addWidget(self.laser_2.get_widget(), 0, 1)
save_btn = QPushButton("Save state") save_btn = QPushButton("Save state")
save_btn.clicked.connect(self.save) save_btn.clicked.connect(self.save_state)
layout.addWidget(save_btn, 1, 0) layout.addWidget(save_btn, 1, 0)
start_btn = QPushButton("Start") start_btn = QPushButton("Start")
...@@ -210,7 +215,7 @@ class DDSManager(QWidget): #{{{ ...@@ -210,7 +215,7 @@ class DDSManager(QWidget): #{{{
def load_state(self): def load_state(self):
"""Load the JSON parameter dictionary if existent""" """Load the JSON parameter dictionary if existent"""
if !os.path.isfile(JSON_DATAFILE): if not os.path.isfile(JSON_DATAFILE):
return False return False
with open(JSON_DATAFILE, "r") as in_json: with open(JSON_DATAFILE, "r") as in_json:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment