Skip to content

Commit

Permalink
MCC DAQ -> Handle import error in connect and find_ports to allow loa…
Browse files Browse the repository at this point in the history
…ding driver in GUI
  • Loading branch information
franz-sweepMe committed May 22, 2024
1 parent 55c966b commit 57685d0
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/Logger-MCC_DAQ/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from mcculw import ul
from mcculw.device_info import DaqDeviceInfo
from mcculw.enums import AnalogInputMode, InterfaceType, ULRange
except FileNotFoundError:
except:
mcculw_library_missing = True


Expand All @@ -61,9 +61,6 @@ class Device(EmptyDevice):
def __init__(self) -> None:
"""Initialize driver parameters."""
EmptyDevice.__init__(self)
if mcculw_library_missing:
msg = "MCC DAQ Software missing. Install Universal Library (UL)."
raise ImportError(msg)

self.shortname = "MCC-DAQ" # short name will be shown in the sequencer
self.variables = []
Expand All @@ -84,12 +81,15 @@ def __init__(self) -> None:
self.daq_info = None

# AI Range
self.available_ai_ranges = {
"10 V": ULRange.BIP10VOLTS,
"5 V": ULRange.BIP5VOLTS,
"2 V": ULRange.BIP2VOLTS,
"1 V": ULRange.BIP1VOLTS,
}
if mcculw_library_missing:
self.available_ai_ranges = {}
else:
self.available_ai_ranges = {
"10 V": ULRange.BIP10VOLTS,
"5 V": ULRange.BIP5VOLTS,
"2 V": ULRange.BIP2VOLTS,
"1 V": ULRange.BIP1VOLTS,
}
self.ai_range = None

def set_GUIparameter(self) -> dict: # noqa: N802
Expand All @@ -115,6 +115,7 @@ def get_GUIparameter(self, parameter: dict) -> None: # noqa: N802

def find_ports(self) -> list:
"""Find ports of available DAQ devices."""
self.check_mcculw()
ul.ignore_instacal()
ul.release_daq_device(self.board_num)

Expand All @@ -127,6 +128,7 @@ def find_ports(self) -> list:

def connect(self) -> None:
"""Connect to the selected port."""
self.check_mcculw()
ul.ignore_instacal()

inventory = ul.get_daq_device_inventory(InterfaceType.ANY)
Expand Down Expand Up @@ -200,3 +202,10 @@ def create_device_list() -> list:
device_list.append(str(device) + "_" + device.unique_id)

return device_list

@staticmethod
def check_mcculw() -> None:
"""Check if the mcculw library is installed."""
if mcculw_library_missing:
msg = "MCC DAQ Software missing. Install Universal Library (UL)."
raise ImportError(msg)

0 comments on commit 57685d0

Please sign in to comment.