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
#from __future__ import absolute_import, division, print_function
import warnings
from messages import show_warning
daqfound = True
try:
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.ao import AnalogOutputProps
......@@ -20,15 +22,28 @@ try:
ao_range = ULRange.BIP10VOLTS
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
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):
def __init__(self, out_num):
global daqfound
#ul.ignore_instacal()
self.board_num = 0
self.out_num = out_num
if daqfound:
......@@ -47,6 +62,8 @@ class daq_DO(object):
self.board_num, self.port.type, DigitalIODirection.OUT)
except ULError as e:
self.show_ul_error(e)
print('puerto: ', self.port)
print(self.port.type)
if daqfound:
def set_out(self, bit_value):
......@@ -64,6 +81,8 @@ class daq_DO(object):
class daq_AO(object):
def __init__(self, out_num):
global daqfound
#ul.ignore_instacal()
self.board_num = 0
self.out_num = out_num
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
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel)
import telnetlib
import os
from messages import show_warning
#An example of a class
class anal_control_signal(QWidget):
......@@ -38,7 +38,7 @@ class anal_control_signal(QWidget):
try:
self.AO = daq_AO(self.ch)
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)
......@@ -109,7 +109,8 @@ class anal_control_signal(QWidget):
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
except ZeroDivisionError:
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):
......@@ -142,17 +143,19 @@ class anal_control_signal(QWidget):
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:
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
else:
self.sb.setEnabled(False)
self.scan_button.setStyleSheet("background-color: green")
self.PbarTimer.start(dt*1e3)
self.ScanTimer.start(dt*1e3)
self.scan_button.setText('Scanning')
self.PbarTimer.start(dt*1e3)
......@@ -171,7 +174,7 @@ class digital_control_signal(QWidget):
try:
self.DO = daq_DO(self.ch)
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.stateChanged.connect(self.whenChangeDigital)
......@@ -210,9 +213,15 @@ class burleighWM(QWidget):
wavemeter_ok = False
try:
tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1)
wavemeter_ok = True
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:
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