Commit 5901d2c5 authored by Martin Drechsler's avatar Martin Drechsler

Merge branch 'test_branch'

parents 9f6b2aff 3a14aa59
...@@ -7,12 +7,14 @@ Created on Wed May 30 15:27:17 2018 ...@@ -7,12 +7,14 @@ Created on Wed May 30 15:27:17 2018
#from __future__ import absolute_import, division, print_function #from __future__ import absolute_import, division, print_function
import warnings import warnings
from messages import show_warning
daqfound = True daqfound = True
try: try:
from mcculw import ul from mcculw import ul
from mcculw.enums import DigitalIODirection, ULRange from mcculw.enums import DigitalIODirection, ULRange, InterfaceType
from examples.props.digital import DigitalProps from examples.props.digital import DigitalProps
from examples.props.ao import AnalogOutputProps from examples.props.ao import AnalogOutputProps
...@@ -20,15 +22,28 @@ try: ...@@ -20,15 +22,28 @@ try:
ao_range = ULRange.BIP10VOLTS ao_range = ULRange.BIP10VOLTS
except: except:
warnings.warn('Warning: either the daq was not found, or there was some error with the mcculw drivers. ') warnings.warn('There was some error with the mcculw drivers. ')
devices = ul.get_daq_device_inventory(interface_type=InterfaceType.USB)
if len(devices)==0:
daqfound = False daqfound = False
warnings.warn('daq not found')
else:
device = devices[0]
print('The daq %s was found succesfully :)' % device.product_name)
daqfound = True
#%% #%%
class daq_DO(object): class daq_DO(object):
def __init__(self, out_num): def __init__(self, out_num):
global daqfound global daqfound
#ul.ignore_instacal()
self.board_num = 0 self.board_num = 0
self.out_num = out_num self.out_num = out_num
if daqfound: if daqfound:
...@@ -47,6 +62,8 @@ class daq_DO(object): ...@@ -47,6 +62,8 @@ class daq_DO(object):
self.board_num, self.port.type, DigitalIODirection.OUT) self.board_num, self.port.type, DigitalIODirection.OUT)
except ULError as e: except ULError as e:
self.show_ul_error(e) self.show_ul_error(e)
print('puerto: ', self.port)
print(self.port.type)
if daqfound: if daqfound:
def set_out(self, bit_value): def set_out(self, bit_value):
...@@ -64,6 +81,8 @@ class daq_DO(object): ...@@ -64,6 +81,8 @@ class daq_DO(object):
class daq_AO(object): class daq_AO(object):
def __init__(self, out_num): def __init__(self, out_num):
global daqfound global daqfound
#ul.ignore_instacal()
self.board_num = 0 self.board_num = 0
self.out_num = out_num self.out_num = out_num
if daqfound: if daqfound:
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 22 11:46:00 2018
@author: martindrech
"""
from PyQt5.QtWidgets import QMessageBox
def show_warning(text, details_text = ''):
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText(text)
msg.setWindowTitle("Oh dear")
if details_text:
msg.setDetailedText(details_text)
msg.setStandardButtons(QMessageBox.Ok)
msg.buttonClicked.connect(msgbtn)
retval = msg.exec_()
#print("value of pressed message box button:", retval)
def msgbtn(i):
print("Button pressed is:",i.text())
\ No newline at end of file
...@@ -12,7 +12,7 @@ from PyQt5.QtCore import QTimer ...@@ -12,7 +12,7 @@ from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel) from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel)
import telnetlib import telnetlib
import os import os
from messages import show_warning
#An example of a class #An example of a class
class anal_control_signal(QWidget): class anal_control_signal(QWidget):
...@@ -38,7 +38,7 @@ class anal_control_signal(QWidget): ...@@ -38,7 +38,7 @@ class anal_control_signal(QWidget):
try: try:
self.AO = daq_AO(self.ch) self.AO = daq_AO(self.ch)
except: except:
print('Analog output %i not found. Daq might not be connected' % self.ch) show_warning('Analog output %i not found. Daq might not be connected' % self.ch)
...@@ -96,7 +96,7 @@ class anal_control_signal(QWidget): ...@@ -96,7 +96,7 @@ class anal_control_signal(QWidget):
def scanEvent(self): def scanEvent(self):
if float(self.scan_step) < float(self.scan_sb_start.val) or float(self.scan_step) > float(self.scan_sb_stop.val): if float(self.scan_step) < float(self.scan_sb_start.val) or float(self.scan_step) > float(self.scan_sb_stop.val):
self.scan_direction = (-1) * self.scan_direction self.scan_direction = (-1) * self.scan_direction
self.scan_step = self.scan_step + self.scan_direction self.scan_step = self.scan_step + self.scan_direction
self.AO.set_out(self.scan_step) self.AO.set_out(self.scan_step)
...@@ -109,7 +109,8 @@ class anal_control_signal(QWidget): ...@@ -109,7 +109,8 @@ class anal_control_signal(QWidget):
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V') self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
except ZeroDivisionError: except ZeroDivisionError:
self.doScanAction() self.doScanAction()
print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ') #print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
show_warning('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.')
def doScanAction(self): def doScanAction(self):
...@@ -142,17 +143,19 @@ class anal_control_signal(QWidget): ...@@ -142,17 +143,19 @@ class anal_control_signal(QWidget):
if self.scan_step > b or self.scan_step < a: if self.scan_step > b or self.scan_step < a:
print('scan can not start outside scan range and scan start should be lower than scan stop') details = 'Remember remember the fifth of November.' + '\n' + 'Also remember that scan starts from the value of the corresponding spin box'
show_warning('Scan can not start outside scan range and scan start should be lower than scan stop', details_text= details)
elif n < 5: elif n < 5:
print('%i steps are too few, you need at least 5 steps' % (n) ) show_warning('%i steps are too few, you need at least 5 steps' % (n) )
pass pass
else: else:
self.sb.setEnabled(False) self.sb.setEnabled(False)
self.scan_button.setStyleSheet("background-color: green") self.scan_button.setStyleSheet("background-color: green")
self.PbarTimer.start(dt*1e3)
self.ScanTimer.start(dt*1e3) self.ScanTimer.start(dt*1e3)
self.scan_button.setText('Scanning') self.scan_button.setText('Scanning')
self.PbarTimer.start(dt*1e3)
...@@ -171,7 +174,7 @@ class digital_control_signal(QWidget): ...@@ -171,7 +174,7 @@ class digital_control_signal(QWidget):
try: try:
self.DO = daq_DO(self.ch) self.DO = daq_DO(self.ch)
except: except:
print('Digital output %i not found. Daq might not be connected' % self.ch) show_warning('Digital output %i not found. Daq might not be connected' % self.ch)
self.cb = QtGui.QCheckBox() self.cb = QtGui.QCheckBox()
self.cb.stateChanged.connect(self.whenChangeDigital) self.cb.stateChanged.connect(self.whenChangeDigital)
...@@ -210,9 +213,15 @@ class burleighWM(QWidget): ...@@ -210,9 +213,15 @@ class burleighWM(QWidget):
wavemeter_ok = False wavemeter_ok = False
try: try:
tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1) tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1)
wavemeter_ok = True
except: except:
print('wannanosaurus not connected') show_warning('Wannanosaurus not connected')
if tn.sock_avail():
wavemeter_ok = True
else:
show_warning('Wannanosaurus seems connected but WM might be off.')
if wavemeter_ok: if wavemeter_ok:
tn.write(b'++eos 1\n') tn.write(b'++eos 1\n')
......
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