Commit 2f4ced78 authored by Martin Drechsler's avatar Martin Drechsler

Merge branch 'tidyngUp' into 'master'

add a branch for tidynig up, and for now if daq not found it prints outputs

See merge request martindrech/control_app!1
parents aa030d56 ab3b000d
......@@ -7,6 +7,7 @@ Created on Wed May 30 15:27:17 2018
from __future__ import absolute_import, division, print_function
daqfound = True
try:
from mcculw import ul
......@@ -20,65 +21,67 @@ try:
except:
print('import error: mcculw not installed. In linux this might not be available. ')
daqfound = False
#%%
class daq_DO(object):
def __init__(self, out_num):
global daqfound
self.board_num = 0
self.digital_props = DigitalProps(self.board_num)
# Find the first port that supports output, defaulting to None
# if one is not found.
self.port = next(
(port for port in self.digital_props.port_info
if port.supports_output), None)
# If the port is configurable, configure it for output
if self.port != None and self.port.is_port_configurable:
self.out_num = out_num
if daqfound:
self.digital_props = DigitalProps(self.board_num)
# Find the first port that supports output, defaulting to None
# if one is not found.
self.port = next(
(port for port in self.digital_props.port_info
if port.supports_output), None)
# If the port is configurable, configure it for output
if self.port != None and self.port.is_port_configurable:
try:
ul.d_config_port(
self.board_num, self.port.type, DigitalIODirection.OUT)
except ULError as e:
self.show_ul_error(e)
if daqfound:
def set_out(self, bit_value):
try:
ul.d_config_port(
self.board_num, self.port.type, DigitalIODirection.OUT)
# Output the value to the board
ul.d_bit_out(self.board_num, self.port.type, self.out_num, bit_value)
except ULError as e:
self.show_ul_error(e)
self.out_num = out_num
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)
except ULError as e:
self.show_ul_error(e)
def get_digital_out(self):
try:
state = ul.d_bit_in(self.board_num, self.port.type, self.out_num)
print(state)
except ValueError:
return 0
else:
def set_out(self, bit_value):
return bit_value, self.out_num
class daq_AO(object):
def __init__(self, out_num):
global daqfound
self.board_num = 0
self.ao_props = AnalogOutputProps(self.board_num)
self.out_num = out_num
def set_out(self, value):
try:
ul.v_out(self.board_num, self.out_num, ao_range, value)
except ULError as e:
self.show_ul_error(e)
def get_analog_out(self):
#ao_range = self.ao_props.available_ranges[0]
try:
state = ul.a_in(self.board_num, self.out_num, ao_range)
print(state)
except ValueError:
return 0
if daqfound:
self.ao_props = AnalogOutputProps(self.board_num)
if daqfound:
def set_out(self, value):
try:
ul.v_out(self.board_num, self.out_num, ao_range, value)
except ULError as e:
self.show_ul_error(e)
def get_analog_out(self):
#ao_range = self.ao_props.available_ranges[0]
try:
state = ul.a_in(self.board_num, self.out_num, ao_range)
print(state)
except ValueError:
return 0
else:
def set_out(self, value):
return value, self.out_num
######################################################################################
......@@ -92,11 +92,11 @@ class myToolbarMenu(QWidget):
settings.endGroup()
def first_load(self, aos):
try:
settings = QSettings('C:\\Users\\Usuario\\Documents\\control_app\\config.ini', QSettings.IniFormat)
except:
settings = QSettings('C:\\Users\\Usuario\\Documents\\control_app\\config.ini', QSettings.IniFormat)
if not settings:
print('Warning: no config.ini file in control_app folder. Pleace, be kindful and create one')
return
return 0
settings.beginGroup('Ventana')
for ao in aos:
......
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