Commit 149c417c authored by Martin Drechsler's avatar Martin Drechsler

added the coherent wavemeter dock

parent 265ebad7
......@@ -10,7 +10,7 @@ import sys
from pyqtgraph.Qt import QtGui
from myWidgets import anal_control_signal, digital_control_signal, activation_button, burleighWM
from myWidgets import anal_control_signal, digital_control_signal, activation_button, burleighWM, coherentWM
from PyQt5.QtWidgets import QMainWindow
from pyqtgraph import dockarea
import pyqtgraph as pg
......@@ -49,6 +49,8 @@ class GuiMainWindow(QMainWindow):
self.layoutPI = pg.LayoutWidget()
self.layoutIMG = pg.LayoutWidget()
self.layoutWM = pg.LayoutWidget()
self.layoutWM_coherent = pg.LayoutWidget()
self.layout397_scan = pg.LayoutWidget()
self.layout866_scan = pg.LayoutWidget()
self.layout423_scan = pg.LayoutWidget()
......@@ -62,6 +64,8 @@ class GuiMainWindow(QMainWindow):
self.d866 = dockarea.Dock("Dock866", size=(self.s1, self.s2))
self.dPI = dockarea.Dock("DockPI", size=(self.s1, self.s2))
self.dWM = dockarea.Dock("DockWM", size=(self.s1, self.s2))
self.dWM_coherent = dockarea.Dock("DockWM_coherent", size=(self.s1, self.s2))
self.d397_scan = dockarea.Dock("Dock 397 scan", size=(self.s1, self.s2))
self.d866_scan = dockarea.Dock("Dock 866 scan", size=(self.s1, self.s2))
self.d423_scan = dockarea.Dock("Dock 423 scan", size=(self.s1, self.s2))
......@@ -70,28 +74,34 @@ class GuiMainWindow(QMainWindow):
self.dactivate.hideTitleBar()
# Here I add the docks
#self.area.addDock( self.dtrap_electrodes)
#self.area.addDock(self.d397, 'bottom', self.dtrap_electrodes)
#self.area.addDock(self.d866, 'bottom', self.d397)
self.area.addDock( self.dtrap_electrodes)
self.area.addDock(self.d397, 'bottom', self.dtrap_electrodes)
self.area.addDock(self.d866, 'bottom', self.d397)
self.area.addDock(self.dWM)
self.area.addDock(self.dWM_coherent)
self.area.addDock(self.dPI, 'bottom', self.dWM)
#self.area.addDock(self.d397_scan, 'right', self.d397)
self.area.addDock(self.d397_scan, 'right', self.d397)
self.area.addDock(self.d423_scan, 'right', self.dPI)
#self.area.addDock(self.d866_scan, 'right', self.d866)
self.area.addDock(self.d866_scan, 'right', self.d866)
#self.area.addDock(self.dactivate, 'right', self.dtrap_electrodes)
#self.area.moveDock(self.dWM, 'above', self.dtrap_electrodes)
self.area.moveDock(self.dWM, 'above', self.dtrap_electrodes)
self.area.moveDock(self.dWM_coherent, 'above', self.dWM)
self.area.moveDock(self.dPI, 'above', self.d423_scan)
# Here I add the layouts to the corresponding dock
#self.d397.addWidget(self.layout397)
#self.d866.addWidget(self.layout866)
self.d397.addWidget(self.layout397)
self.d866.addWidget(self.layout866)
self.dPI.addWidget(self.layoutPI)
self.dWM.addWidget(self.layoutWM)
#self.d397_scan.addWidget(self.layout397_scan)
#self.d866_scan.addWidget(self.layout866_scan)
self.dWM_coherent.addWidget(self.layoutWM_coherent)
self.d397_scan.addWidget(self.layout397_scan)
self.d866_scan.addWidget(self.layout866_scan)
self.d423_scan.addWidget(self.layout423_scan)
#self.dtrap_electrodes.addWidget(self.layout_trap_electrodes)
self.dtrap_electrodes.addWidget(self.layout_trap_electrodes)
#self.dactivate.addWidget(self.layout_activate)
......@@ -208,7 +218,7 @@ class GuiMainWindow(QMainWindow):
# read wavemeter
self.wavemeter = burleighWM(self.layoutWM, self.dWM)
self.wm_coherent = coherentWM(self.layoutWM_coherent, self.dWM_coherent)
###############################################################################
......
......@@ -9,12 +9,13 @@ import pyqtgraph as pg
from ADoutputs import daq_AO, daq_DO
from pyqtgraph.Qt import QtGui, QtCore
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel, QCheckBox)
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel, QCheckBox, QComboBox)
import telnetlib
import os
import os, serial
from messages import show_warning
import scanFunctions
import wav_coherent
#An example of a class
class anal_control_signal(QWidget):
......@@ -260,8 +261,78 @@ class burleighWM(QWidget):
self.layoutWM.addWidget(lcd)
self.dockWM.addWidget(self.layoutWM)
class coherentWM(QWidget):
def __init__(self, layout, dock):
super().__init__()
self.dockWM = dock
self.layoutWM = layout
wavemeter_ok = False
try:
wavCoh= serial.Serial('COM11', timeout=1, rtscts=True)
wavCoh.close()
wavemeter_ok = True
except:
show_warning('Coherent wavemeter not connected')
if wavemeter_ok:
lcd = QLCDNumber()
lcd.setDigitCount(10)
lcd.display("00000000 0")
wav_coherent.set_unit(wavCoh, b'F')
def update_label():
value = wav_coherent.read_measurement(wavCoh)
unit = wav_coherent.check_unit(wavCoh)
try:
lcd.display(value + ' ' + unit)
except:
lcd.display("error000 0")
self.layoutWM.timer = QTimer()
self.layoutWM.timer.timeout.connect(update_label)
self.layoutWM.timer.start(500) # every 10,000 milliseconds
self.layoutWM.setGeometry(300, 300, 250, 150)
combo = QComboBox()
combo.addItem("Frequency")
combo.addItem("Wavelength Vac")
combo.addItem("Wavelength Air")
def comboActivated(text):
if text == "Frequency":
unit = b'F'
if text == "Wavelength Vac":
unit = b'V'
if text == "Wavelength Air":
unit = b'A'
with wavCoh as w:
wav_coherent.set_unit(w, unit)
combo.activated[str].connect(comboActivated)
self.layoutWM.addWidget(lcd, 0, 0)
self.layoutWM.addWidget(combo, 1, 0)
self.dockWM.addWidget(self.layoutWM)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 6 13:07:39 2019
@author: Usuario
"""
#import serial
#import time
#
#wavCoh=serial.Serial('COM10', timeout=1, rtscts=True)
#wavCoh.close()
#%%
def read_measurement(wm):
with wm as w:
w.write(b'VAL?\n')
#time.sleep(0.2)
a = w.readline().decode("utf-8")
return a[12:20]
def set_unit(wm, unit):
"""
unit can be:
A: wl in air
V: wl in vacuum
F: frequency
W: wavenumber
"""
with wm as w:
string_to_write = b'UNI ' + unit + b'\n'
w.write(string_to_write)
def check_unit(wm):
with wm as w:
w.write(b'UNI? \n')
#time.sleep(0.2)
unit = w.readline().decode("utf-8")
if unit[5:6] == 'V':
return 'U'
return unit[5:6]
#%%
if __name__ == '__main__':
import serial
import time
wavCoh=serial.Serial('COM11', timeout=1, rtscts=True)
wavCoh.close()
set_unit(wavCoh, b'V')
print(read_measurement(wavCoh))
read_measurement(wavCoh)
print(a[12:20])
check_unit(wavCoh)
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