Skip to content

Commit

Permalink
Added notice for when the nidaqmx drivers are not detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahsoka committed Jul 16, 2021
1 parent 39ed6c5 commit 81f10d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
18 changes: 15 additions & 3 deletions beskar/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ def __init__(self, main_window):
self.label = QtWidgets.QLabel(
"SEAL kit not detected, please make sure it's plugged in"
)
self.label.setObjectName('label')

self.no_drivers = QtWidgets.QLabel(
'<b>WARNING:</b> Drivers are not detected on this computer. '
'In order to connect with the SEAL kit you must install the drivers from '
'<a href="https://www.ni.com/en-us/support/downloads/drivers/download.ni-daqmx.html#348669">here</a>.'
)
self.no_drivers.setOpenExternalLinks(True)
self.no_drivers.setWordWrap(True)
self.no_drivers.hide()

self.combo_box = QtWidgets.QComboBox()
self.combo_box.setObjectName('combo_box')
Expand All @@ -96,11 +104,12 @@ def __init__(self, main_window):

self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addWidget(self.label)
self.main_layout.addWidget(self.no_drivers)
self.main_layout.addLayout(self.buttons_layout)

self.setWindowFlag(QtCore.Qt.WindowType.WindowCloseButtonHint, on=False)

self.setFixedSize(311, 68)
self.setFixedSize(315, 68)

@QtCore.pyqtSlot()
def on_refresh_push_button_clicked(self):
Expand All @@ -109,7 +118,10 @@ def on_refresh_push_button_clicked(self):
for _ in range(5):
QtTest.QTest.qWait(100)
self.label.setText(f"{self.label.text()}.")
system, num_of_devices = get_number_of_devices()
system, num_of_devices, has_drivers = get_number_of_devices(drivers=True)
if not has_drivers and self.no_drivers.isHidden():
self.setFixedHeight(130)
self.no_drivers.show()
if num_of_devices == 0:
self.label.setText('SEAL kit not detected, please try refreshing again.')
else:
Expand Down
10 changes: 8 additions & 2 deletions beskar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ def interact_with_LEDs(device_name: str, interaction: Literal['on', 'off', 'on&o
task.write(False)
task.write(True)

def get_number_of_devices(system=True):
def get_number_of_devices(system=True, drivers=False):
errors = (FileNotFoundError, DaqNotFoundError)
has_drivers = True
try:
from __main__ import PyInstallerImportError
errors += (PyInstallerImportError,)
Expand All @@ -61,8 +62,13 @@ def get_number_of_devices(system=True):
num_of_devices = len(the_system.devices)
except errors:
num_of_devices = 0
if system:
has_drivers = False
if system and drivers:
return the_system, num_of_devices, has_drivers
elif system:
return the_system, num_of_devices
elif drivers:
return the_system, has_drivers
else:
return num_of_devices

Expand Down

0 comments on commit 81f10d2

Please sign in to comment.