Commit 6d8a8497 authored by Martin Drechsler's avatar Martin Drechsler

some changes, more close to a final solution. I won't use the paramtree for...

some changes, more close to a final solution. I won't use the paramtree for now. Only to create a class which mixes the spinboxes (or checkpoints) with the corresponding D/A outuputs is pending.
parent 3644de2a
......@@ -41,7 +41,7 @@ class daq_DO(object):
self.out_num = out_num
def set_digital_out(self, bit_value):
def set_out(self, bit_value):
try:
# Output the value to the board
ul.d_bit_out(self.board_num, self.port.type, self.out_num, bit_value)
......@@ -62,8 +62,7 @@ class daq_AO(object):
self.ao_props = AnalogOutputProps(self.board_num)
self.out_num = out_num
def set_analog_out(self, value):
#ao_range = self.ao_props.available_ranges[0]
def set_out(self, value):
try:
ul.v_out(self.board_num, self.out_num, ao_range, value)
except ULError as e:
......
......@@ -5,7 +5,7 @@ Created on Thu May 31 14:22:48 2018
@author: Usuario
"""
#from ADoutputs import daq_AO, daq_DO
from ADoutputs import daq_AO, daq_DO
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
......@@ -23,16 +23,52 @@ win.setCentralWidget(cw)
win.show()
text = "Mi prueba fantastica"
spin = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1)
layout397 = QtGui.QGridLayout()
layout866 = QtGui.QGridLayout()
layoutPI = QtGui.QGridLayout()
label = QtGui.QLabel(text)
layout.addWidget(label)
layout.addWidget(spin)
layout.addLayout(layout397, 1, 1)
layout.addLayout(layout866, 2, 1)
layout.addLayout(layoutPI, 3, 1)
#analog0 = daq_AO(0)
#def whenChange(sb):
# analog0.set_analog_out(sb.value())
piezoA397 = {'sb': pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1, siPrefix = True, suffix = 'V'), 'daq': daq_AO(0)}
piezoB397 = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1, siPrefix = True, suffix = 'V')
shutter397 = QtGui.QCheckBox(win)
piezoA866 = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1, siPrefix = True, suffix = 'V')
piezoB866 = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1, siPrefix = True, suffix = 'V')
shutter866 = QtGui.QCheckBox(win)
piezoA423 = pg.SpinBox(value = 0.0, bounds=[-10, 10], step = .1, siPrefix = True, suffix = 'V')
shutter423 = QtGui.QCheckBox(win)
shutterLED = QtGui.QCheckBox(win)
######### 397 ###########
layout397.addWidget(QtGui.QLabel('397'), 0, 0)
layout397.addWidget(QtGui.QLabel('piezoA'), 1, 1), layout397.addWidget(piezoA397['sb'], 1, 2)
layout397.addWidget(QtGui.QLabel('piezoB'), 2, 1), layout397.addWidget(piezoB397, 2, 2)
layout397.addWidget(QtGui.QLabel('shutter'), 3, 1), layout397.addWidget(shutter397, 3, 2)
######### 866 ###########
layout866.addWidget(QtGui.QLabel('866'), 0, 0)
layout866.addWidget(QtGui.QLabel('piezoA'), 1, 1), layout866.addWidget(piezoA866, 1, 2)
layout866.addWidget(QtGui.QLabel('piezoB'), 2, 1), layout866.addWidget(piezoB866, 2, 2)
layout866.addWidget(QtGui.QLabel('shutter'), 3, 1), layout866.addWidget(shutter866, 3, 2)
######### PI ###########
layoutPI.addWidget(QtGui.QLabel('Photoion'), 0, 0)
layoutPI.addWidget(QtGui.QLabel('piezoA'), 1, 1), layoutPI.addWidget(piezoA423, 1, 2)
layoutPI.addWidget(QtGui.QLabel('shutter423'), 2, 1), layoutPI.addWidget(shutter423, 2, 2)
layoutPI.addWidget(QtGui.QLabel('shutterLED'), 3, 1), layoutPI.addWidget(shutterLED, 3, 2)
def whenChange(sb, daq):
daq.set_out(sb.value())
#spin.sigValueChanging.connect(whenChange)
\ No newline at end of file
piezoA397['sb'].sigValueChanging.connect(lambda: whenChange(piezoA397['daq']))
......@@ -15,12 +15,12 @@ from pyqtgraph.Qt import QtCore, QtGui
app = QtGui.QApplication([])
from pyqtgraph.parametertree import Parameter, ParameterTree, registerParameterType
from ADoutputs import daq_AO, daq_DO
params = [
{'name': '397 laser parameters', 'type': 'group', 'children': [
{'name': 'piezoA', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'laser_parameters_397', 'type': 'group', 'title': '397 laser parameters', 'children': [
{'name': 'piezoA', 'type': 'float', 'value': 0, 'step': 0.2, 'limits': (-10, 10), 'siPrefix': True, 'suffix': 'V'},
{'name': 'piezoB', 'type': 'float', 'value': 0, 'step': 0.05, 'limits': (-1, 1), 'siPrefix': True, 'suffix': 'V'},
{'name': 'shutter1', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
{'name': 'shutter2', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
......@@ -48,27 +48,55 @@ params = [
## Create tree of Parameter objects
p = Parameter.create(name='params', type='group', children=params)
"""
## If anything changes in the tree, print a message
def change(param, changes):
print("tree changes:")
for param, change, data in changes:
path = p.childPath(param)
if path is not None:
childName = '.'.join(path)
childName = '_'.join(path)
else:
childName = param.name()
print(' parameter: %s'% childName)
print(' change: %s'% change)
print(' data: %s'% str(data))
print(' ----------')
#print(' parameter: %s'% childName)
#print(' change: %s'% change)
#print(' data: %s'% str(data))
#print(path)
myDict[childName].set_analog_out(data)
#print(' ----------')
p.sigTreeStateChanged.connect(change)
def valueChanging(param, value):
print("Value changing (not finalized): %s %s" % (param, value))
"""
def valueChanging(box):
#print(box.name())
#print(box.value())
laser_parameters_397_piezoA.set_analog_out(box.value())
p.children()[0].children()[0].sigValueChanging.connect(valueChanging)
laser_parameters_397_piezoA = daq_AO(0)
myDict = {'laser_parameters_397_piezoA': laser_parameters_397_piezoA}
#def whenChange(sb):
# analog0.set_analog_out(sb.value())
#spin.sigValueChanging.connect(whenChange)
def save():
global state
......@@ -83,7 +111,7 @@ p.param('Save/Restore functionality', 'Save State').sigActivated.connect(save)
p.param('Save/Restore functionality', 'Restore State').sigActivated.connect(restore)
## Create two ParameterTree widgets, both accessing the same data
## Create ParameterTree widgets
t = ParameterTree()
t.setParameters(p, showTop=False)
t.setWindowTitle('pyqtgraph example: Parameter Tree')
......@@ -103,6 +131,7 @@ s = p.saveState()
p.restoreState(s)
## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
......
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