Commit 8861f4dc authored by Martin Drechsler's avatar Martin Drechsler

Progress bar and label added to scan layouts.

parent e655a548
......@@ -10,11 +10,11 @@ import sys
from pyqtgraph.Qt import QtCore, QtGui
from myWidgets import anal_control_signal, digital_control_signal, activation_button
from myWidgets import anal_control_signal, digital_control_signal, activation_button, burleighWM
from pyqtgraph import dockarea
import pyqtgraph as pg
import telnetlib
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QLCDNumber
......@@ -125,7 +125,8 @@ layout397_scan.addWidget(QtGui.QLabel('start'), 1, 0), layout397_scan.addWidget(
layout397_scan.addWidget(QtGui.QLabel('stop'), 2, 0), layout397_scan.addWidget(piezoA397.scan_sb_stop, 2, 1)
layout397_scan.addWidget(QtGui.QLabel('period'), 3, 0), layout397_scan.addWidget(piezoA397.scan_sb_period, 3, 1)
layout397_scan.addWidget(QtGui.QLabel('Scanning'), 4, 0), layout397_scan.addWidget(piezoA397.scan_button, 4, 1)
layout397_scan.addWidget(piezoA397.scanLabelValue, 5, 0)
layout397_scan.addWidget(piezoA397.scanpBar, 5, 1)
#########################
......@@ -140,6 +141,8 @@ layout866_scan.addWidget(QtGui.QLabel('start'), 1, 0), layout866_scan.addWidget(
layout866_scan.addWidget(QtGui.QLabel('stop'), 2, 0), layout866_scan.addWidget(piezoB866.scan_sb_stop, 2, 1)
layout866_scan.addWidget(QtGui.QLabel('period'), 3, 0), layout866_scan.addWidget(piezoB866.scan_sb_period, 3, 1)
layout866_scan.addWidget(QtGui.QLabel('Scanning'), 4, 0), layout866_scan.addWidget(piezoB866.scan_button, 4, 1)
layout866_scan.addWidget(piezoB866.scanLabelValue, 5, 0)
layout866_scan.addWidget(piezoB866.scanpBar, 5, 1)
#########################
######### PI ###########
......@@ -153,6 +156,9 @@ layout423_scan.addWidget(QtGui.QLabel('start'), 1, 0), layout423_scan.addWidget(
layout423_scan.addWidget(QtGui.QLabel('stop'), 2, 0), layout423_scan.addWidget(piezoA423.scan_sb_stop, 2, 1)
layout423_scan.addWidget(QtGui.QLabel('period'), 3, 0), layout423_scan.addWidget(piezoA423.scan_sb_period, 3, 1)
layout423_scan.addWidget(QtGui.QLabel('Scanning'), 4, 0), layout423_scan.addWidget(piezoA423.scan_button, 4, 1)
layout423_scan.addWidget(piezoA423.scanLabelValue, 5, 0)
layout423_scan.addWidget(piezoA423.scanpBar, 5, 1)
#########################
######### trap electrodes ###########
......@@ -162,15 +168,9 @@ layout_trap_electrodes.addWidget(QtGui.QLabel(trapDCB.name), 2, 1), layout_trap_
layout_trap_electrodes.addWidget(QtGui.QLabel(trapCompC.name), 1, 3), layout_trap_electrodes.addWidget(trapCompC.sb, 1, 4)
layout_trap_electrodes.addWidget(QtGui.QLabel(trapCompD.name), 2, 3), layout_trap_electrodes.addWidget(trapCompD.sb, 2, 4)
#########################
###########################################################
#all shutter start in False:
shutters = [shutter397, shutter866, shutter423, shutterLED]
try:
......@@ -178,45 +178,11 @@ try:
sh.DO.set_out(True)
except:
pass
###########################################################
###########################################################
#read wavemeter
wavemeter_ok = False
try:
tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1)
wavemeter_ok = True
except:
print('wannanosaurus not connected')
if wavemeter_ok:
tn.write(b'++eos 1\n')
lcd = QLCDNumber()
lcd.setDigitCount(9)
lcd.display("000000 00")
def update_label():
tn.sock_avail()
tn.write(b'++read <cr>\n')
a = tn.read_very_eager().decode("utf-8")
#print(a)
try:
lcd.display(a[3:12])
except:
lcd.display("000000 00")
layoutWM.setGeometry(300, 300, 250, 150)
layoutWM.show()
layoutWM.timer = QTimer()
layoutWM.timer.timeout.connect(update_label)
layoutWM.timer.start(1000) # every 10,000 milliseconds
layoutWM.addWidget(lcd)
dWM.addWidget(layoutWM)
wavemeter = burleighWM(layoutWM, dWM)
###############################################################################
myToolbar.incorporate_toolbar(win, anal_control_signal._registry)
###############################################################################
......
......@@ -8,8 +8,9 @@ This is a temporary script file.
import pyqtgraph as pg
from ADoutputs import daq_AO, daq_DO
from pyqtgraph.Qt import QtGui, QtCore
from PyQt5.QtCore import QBasicTimer
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout)
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel)
import telnetlib
import os
#An example of a class
......@@ -38,10 +39,15 @@ class anal_control_signal(QWidget):
print('Analog output %i not found. Daq might not be connected' % self.ch)
self.sb.sigValueChanging.connect(self.sb_analog_change)
self.scan_button = QPushButton('Start scan')
self.timer = QBasicTimer()
self.timer = QTimer()
self.scan_step = 0
self.scanpBar = QProgressBar(self)
#self.scanpBar.setTextVisible(False)
self.scanLabelValue = QLabel(self)
self.scan_sb_start = pg.SpinBox(value = 0, bounds=[self.min, self.max], step = self.step, siPrefix = self.siPrefix, suffix = self.suffix)
self.scan_sb_stop = pg.SpinBox(value = 0, bounds=[self.min, self.max], step = self.step, siPrefix = self.siPrefix, suffix = self.suffix)
......@@ -74,7 +80,7 @@ class anal_control_signal(QWidget):
def timerEvent(self, e):
def scanEvent(self):
if abs(abs(self.scan_step)-abs(float(self.scan_sb_start.val)))<1e-6 or abs(abs(self.scan_step)-abs(float(self.scan_sb_stop.val)))<1e-6:
self.scan_direction = (-1) * self.scan_direction
......@@ -82,12 +88,17 @@ class anal_control_signal(QWidget):
self.scan_step = self.scan_step + self.scan_direction
self.AO.set_out(self.scan_step)
self.scanpBar.setValue( 100 * float(self.scan_step-float(self.scan_sb_start.val))/float(self.scan_sb_stop.val-self.scan_sb_start.val) )
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
#print(self.scan_step)
def doAction(self):
self.scan_direction = -float( (self.scan_sb_stop.val-self.scan_sb_start.val)/self.scan_sb_period.val ) * float(2 * 1e-3)
self.scan_step = float(self.scan_sb_start.val)
if self.timer.isActive():
self.timer.stop()
self.scan_button.setText('Start scan')
......@@ -97,7 +108,8 @@ class anal_control_signal(QWidget):
self.AO.set_out(self.sb.val)
else:
self.scan_button.setStyleSheet("background-color: green")
self.timer.start(1, self)
self.timer.start(1)
self.timer.timeout.connect(self.scanEvent)
self.scan_button.setText('Scanning')
......@@ -146,4 +158,48 @@ class activation_button(QWidget):
def handleButton(self):
self.button.setIcon(QtGui.QIcon(os.path.dirname(os.path.realpath(__file__))+ "\\snuffles.png"))
\ No newline at end of file
class burleighWM(QWidget):
def __init__(self, layout, dock):
super().__init__()
self.dockWM = dock
self.layoutWM = layout
wavemeter_ok = False
try:
tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1)
wavemeter_ok = True
except:
print('wannanosaurus not connected')
if wavemeter_ok:
tn.write(b'++eos 1\n')
lcd = QLCDNumber()
lcd.setDigitCount(9)
lcd.display("000000 00")
def update_label():
tn.sock_avail()
tn.write(b'++read <cr>\n')
a = tn.read_very_eager().decode("utf-8")
#print(a)
try:
lcd.display(a[3:12])
except:
lcd.display("000000 00")
self.layoutWM.setGeometry(300, 300, 250, 150)
self.layoutWM.timer = QTimer()
self.layoutWM.timer.timeout.connect(update_label)
self.layoutWM.timer.start(1000) # every 10,000 milliseconds
self.layoutWM.addWidget(lcd)
self.dockWM.addWidget(self.layoutWM)
\ No newline at end of file
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